diff --git a/.auroraversion b/.auroraversion index d183d4a..ca222b7 100644 --- a/.auroraversion +++ b/.auroraversion @@ -1 +1 @@ -0.16.0 \ No newline at end of file +0.23.0 diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c2f77d7 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +gen-go/ linguist-generated=true +vendor/ linguist-generated=true +Gopkg.lock linguist-generated=true diff --git a/.github/main.yml b/.github/main.yml new file mode 100644 index 0000000..0445266 --- /dev/null +++ b/.github/main.yml @@ -0,0 +1,25 @@ +name: CI + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup Go for use with actions + uses: actions/setup-go@v2 + with: + go-version: 1.16 + - name: Install goimports + run: go get golang.org/x/tools/cmd/goimports + - name: Set env with list of directories in repo containin go code + run: echo GO_USR_DIRS=$(go list -f {{.Dir}} ./... | grep -E -v "/gen-go/|/vendor/") >> $GITHUB_ENV + - name: Run goimports check + run: test -z "`for d in $GO_USR_DIRS; do goimports -d $d/*.go | tee /dev/stderr; done`" + - name: Create aurora/mesos docker cluster + run: docker-compose up -d + - name: Run tests + run: go test -timeout 35m -race -coverprofile=coverage.txt -covermode=atomic -v github.com/paypal/gorealis diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml new file mode 100644 index 0000000..6c1890f --- /dev/null +++ b/.github/workflows/codeql-analysis.yml @@ -0,0 +1,57 @@ +# For most projects, this workflow file will not need changing; you simply need +# to commit it to your repository. +# +# You may wish to alter this file to override the set of languages analyzed, +# or to provide custom queries or build logic. +# +# ******** NOTE ******** +# We have attempted to detect the languages in your repository. Please check +# the `language` matrix defined below to confirm you have the correct set of +# supported CodeQL languages. +# +name: "CodeQL" + +on: + push: + branches: [ main ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ main ] + schedule: + - cron: '34 4 * * 3' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'go' ] + # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ] + # Learn more: + # https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed + + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@v1 + with: + languages: ${{ matrix.language }} + # If you wish to specify custom queries, you can do so here or in a config file. + # By default, queries listed here will override any specified in a config file. + # Prefix the list here with "+" to use these queries and those in the config file. + # queries: ./path/to/local/query, your-org/your-repo/queries@main + + - run: go build examples/client.go + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v1 diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..7edfc51 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,30 @@ +name: CI + +on: + push: + branches: + - main + pull_request: + branches: + - main +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + - name: Setup Go for use with actions + uses: actions/setup-go@v2 + with: + go-version: 1.16 + - name: Install goimports + run: go get golang.org/x/tools/cmd/goimports + - name: Set env with list of directories in repo containin go code + run: echo GO_USR_DIRS=$(go list -f {{.Dir}} ./... | grep -E -v "/gen-go/|/vendor/") >> $GITHUB_ENV + - name: Run goimports check + run: test -z "`for d in $GO_USR_DIRS; do goimports -d $d/*.go | tee /dev/stderr; done`" + - name: Create aurora/mesos docker cluster + run: docker-compose up -d + - name: Run tests + run: go test -timeout 35m -race -coverprofile=coverage.txt -covermode=atomic -v github.com/paypal/gorealis diff --git a/.gitignore b/.gitignore index cd0d5d1..ecf2cf1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,18 @@ # Folders _obj _test +.idea + +# Thrift library comes with a lot of other files we don't need. +# Ignore everything but the files we do need +vendor/github.com/apache/thrift/* +!vendor/github.com/apache/thrift/lib/ + +vendor/github.com/apache/thrift/lib/* +!vendor/github.com/apache/thrift/lib/go/ + +vendor/github.com/apache/thrift/lib/go/* +!vendor/github.com/apache/thrift/lib/go/thrift/ # Architecture specific extensions/prefixes *.[568vq] diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..dd37918 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,71 @@ +# This file contains all available configuration options +# with their default values. + +# options for analysis running +run: + # default concurrency is a available CPU number + concurrency: 4 + + # timeout for analysis, e.g. 30s, 5m, default is 1m + deadline: 1m + + # exit code when at least one issue was found, default is 1 + issues-exit-code: 1 + + # include test files or not, default is true + tests: true + + skip-dirs: + - gen-go/ + +# output configuration options +output: + # colored-line-number|line-number|json|tab|checkstyle|code-climate, default is "colored-line-number" + format: colored-line-number + + # print lines of code with issue, default is true + print-issued-lines: true + + # print linter name in the end of issue text, default is true + print-linter-name: true + + +# all available settings of specific linters +linters-settings: + errcheck: + # report about not checking of errors in type assetions: `a := b.(MyStruct)`; + # default is false: such cases aren't reported by default. + check-type-assertions: true + + # report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`; + # default is false: such cases aren't reported by default. + check-blank: true + govet: + # report about shadowed variables + check-shadowing: true + goconst: + # minimal length of string constant, 3 by default + min-len: 3 + # minimal occurrences count to trigger, 3 by default + min-occurrences: 2 + misspell: + # Correct spellings using locale preferences for US or UK. + # Default is to use a neutral variety of English. + # Setting locale to US will correct the British spelling of 'colour' to 'color'. + locale: US + lll: + # max line length, lines longer will be reported. Default is 120. + # '\t' is counted as 1 character by default, and can be changed with the tab-width option + line-length: 120 + # tab width in spaces. Default to 1. + tab-width: 4 + +linters: + enable: + - govet + - goimports + - golint + - lll + - goconst + enable-all: false + fast: false diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..9cfbaef --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,62 @@ +1.25.1 (unreleased) + +1.25.0 + +* Add priority api + +1.24.0 + +* enable default sla for slaDrain +* Changes Travis CI badge to Github Actions badge +* Bug fix for auto paused update monitor +* Adds support for running CI on github actions + +1.23.0 + +* First release tested against Aurora Scheduler 0.23.0 + +1.22.5 + +* Upgrading to thrift 0.14.0 + +1.22.4 + +* Updates which result in a no-op now return a response value so that the caller may analyze it to determine what happened + +1.22.3 + +* Contains a monitor timeout fix. Previously an error was being left unchecked which made a specific monitor timining out not be handled properly. + +1.22.2 + +* Bug fix: Change in retry mechanism created a deadlock. This release reverts that particular change. + +1.22.1 + +* Adding safeguards against setting multiple constraints with the same name for a single task. + +1.22.0 + +* CreateService and StartJobUpdate do not continue retrying if a timeout has been encountered +by the HTTP client. Instead they now return an error that conforms to the Timedout interface. +Users can check for a Timedout error by using `realis.IsTimeout(err)`. +* New API function VariableBatchStep has been added which returns the current batch at which +a Variable Batch Update configured Update is currently in. +* Added new PauseUpdateMonitor which monitors an update until it is an `ROLL_FORWARD_PAUSED` state. +* Added variableBatchStep command to sample client to be used for testing new VariableBatchStep api. +* JobUpdateStatus has changed function signature from: +`JobUpdateStatus(updateKey aurora.JobUpdateKey, desiredStatuses map[aurora.JobUpdateStatus]bool, interval, timeout time.Duration) (aurora.JobUpdateStatus, error)` +to +`JobUpdateStatus(updateKey aurora.JobUpdateKey, desiredStatuses []aurora.JobUpdateStatus, interval, timeout time.Duration) (aurora.JobUpdateStatus, error)` +* Added TerminalUpdateStates function which returns an slice containing all UpdateStates which are considered terminal states. + +1.21.0 + +* Version numbering change. Future versions will be labled X.Y.Z where X is the major version, Y is the Aurora version the library has been tested against (e.g. 21 -> 0.21.0), and X is the minor revision. +* Moved to Thrift 0.12.0 code generator and go library. +* `aurora.ACTIVE_STATES`, `aurora.SLAVE_ASSIGNED_STATES`, `aurora.LIVE_STATES`, `aurora.TERMINAL_STATES`, `aurora.ACTIVE_JOB_UPDATE_STATES`, `aurora.AWAITNG_PULSE_JOB_UPDATE_STATES` are all now generated as a slices. +* Please use `realis.ActiveStates`, `realis.SlaveAssignedStates`,`realis.LiveStates`, `realis.TerminalStates`, `realis.ActiveJobUpdateStates`, `realis.AwaitingPulseJobUpdateStates` in their places when map representations are needed. +* `GetInstanceIds(key *aurora.JobKey, states map[aurora.ScheduleStatus]bool) (map[int32]bool, error)` has changed signature to ` GetInstanceIds(key *aurora.JobKey, states []aurora.ScheduleStatus) ([]int32, error)` +* Adding support for GPU as resource. +* Changing compose environment to Aurora snapshot in order to support staggered update. +* Adding staggered updates API. diff --git a/README.md b/README.md index cd6af0f..0ce8bc1 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,12 @@ -# gorealis [![GoDoc](https://godoc.org/github.com/rdelval/gorealis?status.svg)](https://godoc.org/github.com/rdelval/gorealis) +# gorealis [![GoDoc](https://godoc.org/github.com/paypal/gorealis?status.svg)](https://godoc.org/github.com/paypal/gorealis) ![CI Build Status](https://github.com/paypal/gorealis/actions/workflows/main.yml/badge.svg) [![codecov](https://codecov.io/gh/paypal/gorealis/branch/main/graph/badge.svg)](https://codecov.io/gh/paypal/gorealis) -Go library for communicating with [Apache Aurora](https://github.com/apache/aurora). -Named after the northern lights (Aurora Borealis). +Version 1 of Go library for interacting with [Aurora Scheduler](https://github.com/aurora-scheduler/aurora). + +Version 2 of this library can be found [here](https://github.com/aurora-scheduler/gorealis). ### Aurora version compatibility Please see [.auroraversion](./.auroraversion) to see the latest Aurora version against which this -library has been tested. Vendoring a working version of this library is highly recommended. +library has been tested. ## Usage @@ -13,13 +14,10 @@ library has been tested. Vendoring a working version of this library is highly r * [Using the sample client](docs/using-the-sample-client.md) * [Leveraging the library](docs/leveraging-the-library.md) -## To Do -* Create or import a custom transport that uses https://github.com/jmcvetta/napping to improve efficiency -* End to end testing with Vagrant setup +## Projects using gorealis -## Importing -* We suggest using a vendoring tool such as [govendor](https://github.com/kardianos/govendor) and -fetching by version, for example: `govendor fetch github.com/rdelval/gorealis@v1` +* [australis](https://github.com/aurora-scheduler/australis) ## Contributions -Contributions are very much welcome. Please raise an issue so that the contribution may be discussed before it's made. \ No newline at end of file +Contributions are always welcome. Please raise an issue to discuss a contribution before it is made. + diff --git a/auroraAPI.thrift b/auroraAPI.thrift index a777e78..3e43f6f 100644 --- a/auroraAPI.thrift +++ b/auroraAPI.thrift @@ -27,8 +27,8 @@ enum ResponseCode { ERROR = 2, WARNING = 3, AUTH_FAILED = 4, - /** Raised when a Lock-protected operation failed due to lock validation. */ - LOCK_ERROR = 5, + /** Raised when an operation was unable to proceed due to an in-progress job update. */ + JOB_UPDATING_ERROR = 5, /** Raised when a scheduler is transiently unavailable and later retry is recommended. */ ERROR_TRANSIENT = 6 } @@ -115,11 +115,13 @@ struct JobKey { 3: string name } +// TODO(jly): Deprecated, remove in 0.21. See AURORA-1959. /** A unique lock key. */ union LockKey { 1: JobKey job } +// TODO(jly): Deprecated, remove in 0.21. See AURORA-1959. /** A generic lock struct to facilitate context specific resource/operation serialization. */ struct Lock { /** ID of the lock - unique per storage */ @@ -203,6 +205,8 @@ union Image { struct MesosContainer { /** the optional filesystem image to use when launching this task. */ 1: optional Image image + /** the optional list of volumes to mount into the task. */ + 2: optional list volumes } /** Describes a parameter passed to docker cli */ @@ -236,6 +240,42 @@ union Resource { 5: i64 numGpus } +struct PartitionPolicy { + 1: bool reschedule + 2: optional i64 delaySecs +} + +/** SLA requirements expressed as the percentage of instances to be RUNNING every durationSecs */ +struct PercentageSlaPolicy { + /* The percentage of active instances required every `durationSecs`. */ + 1: double percentage + /** Minimum time duration a task needs to be `RUNNING` to be treated as active */ + 2: i64 durationSecs +} + +/** SLA requirements expressed as the number of instances to be RUNNING every durationSecs */ +struct CountSlaPolicy { + /** The number of active instances required every `durationSecs` */ + 1: i64 count + /** Minimum time duration a task needs to be `RUNNING` to be treated as active */ + 2: i64 durationSecs +} + +/** SLA requirements to be delegated to an external coordinator */ +struct CoordinatorSlaPolicy { + /** URL for the coordinator service that needs to be contacted for SLA checks */ + 1: string coordinatorUrl + /** Field in the Coordinator response json indicating if the action is allowed or not */ + 2: string statusKey +} + +/** SLA requirements expressed in one of the many types */ +union SlaPolicy { + 1: PercentageSlaPolicy percentageSlaPolicy + 2: CountSlaPolicy countSlaPolicy + 3: CoordinatorSlaPolicy coordinatorSlaPolicy +} + /** Description of the tasks contained within a job. */ struct TaskConfig { /** Job task belongs to. */ @@ -244,12 +284,6 @@ struct TaskConfig { /** contains the role component of JobKey */ 17: Identity owner 7: bool isService - // TODO(maxim): Deprecated. See AURORA-1707. - 8: double numCpus - // TODO(maxim): Deprecated. See AURORA-1707. - 9: i64 ramMb - // TODO(maxim): Deprecated. See AURORA-1707. - 10: i64 diskMb 11: i32 priority 13: i32 maxTaskFailures // TODO(mnurolahzade): Deprecated. See AURORA-1708. @@ -261,8 +295,6 @@ struct TaskConfig { 32: set resources 20: set constraints - /** a list of named ports this task requests */ - 21: set requestedPorts /** Resources to retrieve with Mesos Fetcher */ 33: optional set mesosFetcherUris /** @@ -276,6 +308,10 @@ struct TaskConfig { 25: optional ExecutorConfig executorConfig /** Used to display additional details in the UI. */ 27: optional set metadata + /** Policy for how to deal with task partitions */ + 34: optional PartitionPolicy partitionPolicy + /** SLA requirements to be met during maintenance */ + 35: optional SlaPolicy slaPolicy // This field is deliberately placed at the end to work around a bug in the immutable wrapper // code generator. See AURORA-1185 for details. @@ -284,15 +320,6 @@ struct TaskConfig { } struct ResourceAggregate { - // TODO(maxim): Deprecated. See AURORA-1707. - /** Number of CPU cores allotted. */ - 1: double numCpus - // TODO(maxim): Deprecated. See AURORA-1707. - /** Megabytes of RAM allotted. */ - 2: i64 ramMb - // TODO(maxim): Deprecated. See AURORA-1707. - /** Megabytes of disk space allotted. */ - 3: i64 diskMb /** Aggregated resource values. */ 4: set resources } @@ -420,7 +447,11 @@ enum ScheduleStatus { /** A fault in the task environment has caused the system to believe the task no longer exists. * This can happen, for example, when a slave process disappears. */ - LOST = 7 + LOST = 7, + /** + * The task is currently partitioned and in an unknown state. + **/ + PARTITIONED = 18 } // States that a task may be in while still considered active. @@ -432,6 +463,7 @@ const set ACTIVE_STATES = [ScheduleStatus.ASSIGNED, ScheduleStatus.RESTARTING ScheduleStatus.RUNNING, ScheduleStatus.STARTING, + ScheduleStatus.PARTITIONED, ScheduleStatus.THROTTLED] // States that a task may be in while associated with a slave machine and non-terminal. @@ -441,6 +473,7 @@ const set SLAVE_ASSIGNED_STATES = [ScheduleStatus.ASSIGNED, ScheduleStatus.PREEMPTING, ScheduleStatus.RESTARTING, ScheduleStatus.RUNNING, + ScheduleStatus.PARTITIONED, ScheduleStatus.STARTING] // States that a task may be in while in an active sandbox. @@ -448,6 +481,7 @@ const set LIVE_STATES = [ScheduleStatus.KILLING, ScheduleStatus.PREEMPTING, ScheduleStatus.RESTARTING, ScheduleStatus.DRAINING, + ScheduleStatus.PARTITIONED, ScheduleStatus.RUNNING] // States a completed task may be in. @@ -516,6 +550,11 @@ struct ScheduledTask { * this task. */ 3: i32 failureCount + /** + * The number of partitions this task has accumulated over its lifetime. + */ + 6: i32 timesPartitioned + /** State change history for this task. */ 4: list taskEvents /** @@ -538,16 +577,16 @@ struct GetJobsResult { * (terms are AND'ed together). */ struct TaskQuery { - 14: string role - 9: string environment - 2: string jobName - 4: set taskIds - 5: set statuses - 7: set instanceIds - 10: set slaveHosts - 11: set jobKeys - 12: i32 offset - 13: i32 limit + 14: optional string role + 9: optional string environment + 2: optional string jobName + 4: optional set taskIds + 5: optional set statuses + 7: optional set instanceIds + 10: optional set slaveHosts + 11: optional set jobKeys + 12: optional i32 offset + 13: optional i32 limit } struct HostStatus { @@ -617,6 +656,9 @@ const set ACTIVE_JOB_UPDATE_STATES = [JobUpdateStatus.ROLLING_F JobUpdateStatus.ROLL_BACK_PAUSED, JobUpdateStatus.ROLL_FORWARD_AWAITING_PULSE, JobUpdateStatus.ROLL_BACK_AWAITING_PULSE] +/** States the job update can be in while waiting for a pulse. */ +const set AWAITNG_PULSE_JOB_UPDATE_STATES = [JobUpdateStatus.ROLL_FORWARD_AWAITING_PULSE, + JobUpdateStatus.ROLL_BACK_AWAITING_PULSE] /** Job update actions that can be applied to job instances. */ enum JobUpdateAction { @@ -674,9 +716,40 @@ struct JobUpdateKey { 2: string id } +/** Limits the amount of active changes being made to instances to groupSize. */ +struct QueueJobUpdateStrategy { + 1: i32 groupSize +} + +/** Similar to Queue strategy but will not start a new group until all instances in an active + * group have finished updating. + */ +struct BatchJobUpdateStrategy { + 1: i32 groupSize + /* Update will pause automatically after each batch completes */ + 2: bool autopauseAfterBatch +} + +/** Same as Batch strategy but each time an active group completes, the size of the next active + * group may change. + */ +struct VariableBatchJobUpdateStrategy { + 1: list groupSizes + /* Update will pause automatically after each batch completes */ + 2: bool autopauseAfterBatch +} + +union JobUpdateStrategy { + 1: QueueJobUpdateStrategy queueStrategy + 2: BatchJobUpdateStrategy batchStrategy + 3: VariableBatchJobUpdateStrategy varBatchStrategy +} + /** Job update thresholds and limits. */ struct JobUpdateSettings { - /** Max number of instances being updated at any given moment. */ + /** Deprecated, please set value inside of desired update strategy instead. + * Max number of instances being updated at any given moment. + */ 1: i32 updateGroupSize /** Max number of instance failures to tolerate before marking instance as FAILED. */ @@ -694,19 +767,28 @@ struct JobUpdateSettings { /** Instance IDs to act on. All instances will be affected if this is not set. */ 7: set updateOnlyTheseInstances - /** + /** Deprecated, please set updateStrategy to the Batch strategy instead. * If true, use updateGroupSize as strict batching boundaries, and avoid proceeding to another * batch until the preceding batch finishes updating. */ 8: bool waitForBatchCompletion - /** - * If set, requires external calls to pulseJobUpdate RPC within the specified rate for the - * update to make progress. If no pulses received within specified interval the update will - * block. A blocked update is unable to continue but retains its current status. It may only get - * unblocked by a fresh pulseJobUpdate call. - */ + /** + * If set, requires external calls to pulseJobUpdate RPC within the specified rate for the + * update to make progress. If no pulses received within specified interval the update will + * block. A blocked update is unable to continue but retains its current status. It may only get + * unblocked by a fresh pulseJobUpdate call. + */ 9: optional i32 blockIfNoPulsesAfterMs + + /** + * If true, updates will obey the SLA requirements of the tasks being updated. If the SLA policy + * differs between the old and new task configurations, updates will use the newest configuration. + */ + 10: optional bool slaAware + + /** Update strategy to be used for the update. See JobUpdateStrategy for choices. */ + 11: optional JobUpdateStrategy updateStrategy } /** Event marking a state transition in job update lifecycle. */ @@ -737,6 +819,9 @@ struct JobInstanceUpdateEvent { /** Job update action taken on the instance. */ 3: JobUpdateAction action + + /** Optional message explaining the instance update event. */ + 4: optional string message } /** Maps instance IDs to TaskConfigs it. */ @@ -849,6 +934,13 @@ struct JobUpdateQuery { 7: i32 limit } +struct HostMaintenanceRequest { + 1: string host + 2: SlaPolicy defaultSlaPolicy + 3: i64 timeoutSecs + 4: i64 createdTimestampMs +} + struct ListBackupsResult { 1: set backups } @@ -1033,7 +1125,6 @@ service ReadOnlyScheduler { Response getJobUpdateSummaries(1: JobUpdateQuery jobUpdateQuery) /** Gets job update details. */ - // TODO(zmanji): `key` is deprecated, remove this with AURORA-1765 Response getJobUpdateDetails(2: JobUpdateQuery query) /** Gets the diff between client (desired) and server (current) job states. */ @@ -1073,7 +1164,7 @@ service AuroraSchedulerManager extends ReadOnlyScheduler { Response restartShards(5: JobKey job, 3: set shardIds) /** Initiates a kill on tasks. */ - Response killTasks(4: JobKey job, 5: set instances) + Response killTasks(4: JobKey job, 5: set instances, 6: string message) /** * Adds new instances with the TaskConfig of the existing instance pointed by the key. @@ -1134,31 +1225,6 @@ service AuroraSchedulerManager extends ReadOnlyScheduler { Response pulseJobUpdate(1: JobUpdateKey key) } -struct InstanceConfigRewrite { - /** Key for the task to rewrite. */ - 1: InstanceKey instanceKey - /** The original configuration. */ - 2: TaskConfig oldTask - /** The rewritten configuration. */ - 3: TaskConfig rewrittenTask -} - -struct JobConfigRewrite { - /** The original job configuration. */ - 1: JobConfiguration oldJob - /** The rewritten job configuration. */ - 2: JobConfiguration rewrittenJob -} - -union ConfigRewrite { - 1: JobConfigRewrite jobRewrite - 2: InstanceConfigRewrite instanceRewrite -} - -struct RewriteConfigsRequest { - 1: list rewriteCommands -} - struct ExplicitReconciliationSettings { 1: optional i32 batchSize } @@ -1211,23 +1277,27 @@ service AuroraAdmin extends AuroraSchedulerManager { /** Set the given hosts back into serving mode. */ Response endMaintenance(1: Hosts hosts) + /** + * Ask scheduler to put hosts into DRAINING mode and move scheduled tasks off of the hosts + * such that its SLA requirements are satisfied. Use defaultSlaPolicy if it is not set for a task. + **/ + Response slaDrainHosts(1: Hosts hosts, 2: SlaPolicy defaultSlaPolicy, 3: i64 timeoutSecs) + /** Start a storage snapshot and block until it completes. */ Response snapshot() - /** - * Forcibly rewrites the stored definition of user configurations. This is intended to be used - * in a controlled setting, primarily to migrate pieces of configurations that are opaque to the - * scheduler (e.g. executorConfig). - * The scheduler may do some validation of the rewritten configurations, but it is important - * that the caller take care to provide valid input and alter only necessary fields. - */ - Response rewriteConfigs(1: RewriteConfigsRequest request) - /** Tell scheduler to trigger an explicit task reconciliation with the given settings. */ Response triggerExplicitTaskReconciliation(1: ExplicitReconciliationSettings settings) /** Tell scheduler to trigger an implicit task reconciliation. */ Response triggerImplicitTaskReconciliation() + + /** + * Force prune any (terminal) tasks that match the query. If no statuses are supplied with the + * query, it will default to all terminal task states. If statuses are supplied, they must be + * terminal states. + */ + Response pruneTasks(1: TaskQuery query) } // The name of the header that should be sent to bypass leader redirection in the Scheduler. @@ -1235,4 +1305,4 @@ const string BYPASS_LEADER_REDIRECT_HEADER_NAME = 'Bypass-Leader-Redirect' // The path under which a task's filesystem should be mounted when using images and the Mesos // unified containerizer. -const string TASK_FILESYSTEM_MOUNT_POINT = 'taskfs' \ No newline at end of file +const string TASK_FILESYSTEM_MOUNT_POINT = 'taskfs' diff --git a/clusters.go b/clusters.go index 66d719b..339dc38 100644 --- a/clusters.go +++ b/clusters.go @@ -16,10 +16,13 @@ package realis import ( "encoding/json" - "github.com/pkg/errors" "os" + + "github.com/pkg/errors" ) +// Cluster contains the definition of the clusters.json file used by the default Aurora +// client for configuration type Cluster struct { Name string `json:"name"` AgentRoot string `json:"slave_root"` @@ -32,7 +35,8 @@ type Cluster struct { AuthMechanism string `json:"auth_mechanism"` } -// Loads clusters.json file traditionally located at /etc/aurora/clusters.json +// LoadClusters loads clusters.json file traditionally located at /etc/aurora/clusters.json +// for use with a gorealis client func LoadClusters(config string) (map[string]Cluster, error) { file, err := os.Open(config) diff --git a/clusters_test.go b/clusters_test.go index 2e7118b..0663cdc 100644 --- a/clusters_test.go +++ b/clusters_test.go @@ -12,17 +12,19 @@ * limitations under the License. */ -package realis +package realis_test import ( "fmt" - "github.com/stretchr/testify/assert" "testing" + + realis "github.com/paypal/gorealis" + "github.com/stretchr/testify/assert" ) func TestLoadClusters(t *testing.T) { - clusters, err := LoadClusters("examples/clusters.json") + clusters, err := realis.LoadClusters("examples/clusters.json") if err != nil { fmt.Print(err) } diff --git a/container.go b/container.go index 6216708..7c51d2f 100644 --- a/container.go +++ b/container.go @@ -15,36 +15,77 @@ package realis import ( - "github.com/rdelval/gorealis/gen-go/apache/aurora" + "github.com/paypal/gorealis/gen-go/apache/aurora" ) +// Container is an interface that defines a single function needed to create +// an Aurora container type. It exists because the code must support both Mesos +// and Docker containers. type Container interface { Build() *aurora.Container } -// TODO(rdelvalle): Implement Mesos container builder +// MesosContainer is a Mesos style container that can be used by Aurora Jobs. type MesosContainer struct { container *aurora.MesosContainer } +// DockerContainer is a vanilla Docker style container that can be used by Aurora Jobs. type DockerContainer struct { container *aurora.DockerContainer } +// NewDockerContainer creates a new Aurora compatible Docker container configuration. func NewDockerContainer() DockerContainer { return DockerContainer{container: aurora.NewDockerContainer()} } +// Build creates an Aurora container based upon the configuration provided. func (c DockerContainer) Build() *aurora.Container { return &aurora.Container{Docker: c.container} } +// Image adds the name of a Docker image to be used by the Job when running. func (c DockerContainer) Image(image string) DockerContainer { c.container.Image = image return c } +// AddParameter adds a parameter to be passed to Docker when the container is run. func (c DockerContainer) AddParameter(name, value string) DockerContainer { - c.container.Parameters = append(c.container.Parameters, &aurora.DockerParameter{name, value}) + c.container.Parameters = append(c.container.Parameters, &aurora.DockerParameter{ + Name: name, + Value: value, + }) + return c +} + +// NewMesosContainer creates a Mesos style container to be configured and built for use by an Aurora Job. +func NewMesosContainer() MesosContainer { + return MesosContainer{container: aurora.NewMesosContainer()} +} + +// Build creates a Mesos style Aurora container configuration to be passed on to the Aurora Job. +func (c MesosContainer) Build() *aurora.Container { + return &aurora.Container{Mesos: c.container} +} + +// DockerImage configures the Mesos container to use a specific Docker image when being run. +func (c MesosContainer) DockerImage(name, tag string) MesosContainer { + if c.container.Image == nil { + c.container.Image = aurora.NewImage() + } + + c.container.Image.Docker = &aurora.DockerImage{Name: name, Tag: tag} + return c +} + +// AppcImage configures the Mesos container to use an image in the Appc format to run the container. +func (c MesosContainer) AppcImage(name, imageID string) MesosContainer { + if c.container.Image == nil { + c.container.Image = aurora.NewImage() + } + + c.container.Image.Appc = &aurora.AppcImage{Name: name, ImageId: imageID} return c } diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..9c6169f --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,109 @@ +version: "2" + +services: + zk: + image: rdelvalle/zookeeper + restart: on-failure + ports: + - "2181:2181" + environment: + ZK_CONFIG: tickTime=2000,initLimit=10,syncLimit=5,maxClientCnxns=128,forceSync=no,clientPort=2181 + ZK_ID: 1 + networks: + aurora_cluster: + ipv4_address: 192.168.33.2 + + master: + image: aurorascheduler/mesos-master:1.7.2 + restart: on-failure + ports: + - "5050:5050" + environment: + MESOS_ZK: zk://192.168.33.2:2181/mesos + MESOS_QUORUM: 1 + MESOS_HOSTNAME: localhost + MESOS_CLUSTER: test-cluster + MESOS_REGISTRY: replicated_log + MESOS_WORK_DIR: /tmp/mesos + networks: + aurora_cluster: + ipv4_address: 192.168.33.3 + depends_on: + - zk + + agent-one: + image: aurorascheduler/mesos-agent:1.7.2 + pid: host + restart: on-failure + ports: + - "5051:5051" + environment: + MESOS_ATTRIBUTES: 'zone:west' + MESOS_MASTER: zk://192.168.33.2:2181/mesos + MESOS_CONTAINERIZERS: docker,mesos + MESOS_PORT: 5051 + MESOS_HOSTNAME: localhost + MESOS_RESOURCES: ports(*):[11000-11999] + MESOS_SYSTEMD_ENABLE_SUPPORT: 'false' + MESOS_WORK_DIR: /tmp/mesos + networks: + aurora_cluster: + ipv4_address: 192.168.33.4 + + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup + - /var/run/docker.sock:/var/run/docker.sock + depends_on: + - zk + + agent-two: + image: aurorascheduler/mesos-agent:1.7.2 + pid: host + restart: on-failure + ports: + - "5061:5061" + environment: + MESOS_ATTRIBUTES: 'zone:east' + MESOS_MASTER: zk://192.168.33.2:2181/mesos + MESOS_CONTAINERIZERS: docker,mesos + MESOS_HOSTNAME: localhost + MESOS_PORT: 5061 + MESOS_RESOURCES: ports(*):[11000-11999] + MESOS_SYSTEMD_ENABLE_SUPPORT: 'false' + MESOS_WORK_DIR: /tmp/mesos + networks: + aurora_cluster: + ipv4_address: 192.168.33.5 + + volumes: + - /sys/fs/cgroup:/sys/fs/cgroup + - /var/run/docker.sock:/var/run/docker.sock + depends_on: + - zk + + aurora-one: + image: aurorascheduler/scheduler:0.23.0 + pid: host + ports: + - "8081:8081" + restart: on-failure + environment: + CLUSTER_NAME: test-cluster + ZK_ENDPOINTS: "192.168.33.2:2181" + MESOS_MASTER: "zk://192.168.33.2:2181/mesos" + EXTRA_SCHEDULER_ARGS: "-min_required_instances_for_sla_check=1" + networks: + aurora_cluster: + ipv4_address: 192.168.33.7 + depends_on: + - zk + - master + - agent-one + +networks: + aurora_cluster: + driver: bridge + ipam: + config: + - subnet: 192.168.33.0/16 + gateway: 192.168.33.1 diff --git a/docs/developing.md b/docs/developing.md new file mode 100644 index 0000000..895ad1e --- /dev/null +++ b/docs/developing.md @@ -0,0 +1,90 @@ + +# Developing gorealis + + +### Installing Docker + +For our developer environment we leverage of Docker containers. + +First you must have Docker installed. Instructions on how to install Docker +vary from platform to platform and can be found [here](https://docs.docker.com/install/). + +### Installing docker-compose + +To make the creation of our developer environment as simple as possible, we leverage +docker-compose to bring up all independent components up separately. + +This also allows us to delete and recreate our development cluster very quickly. + +To install docker-compose please follow the instructions for your platform +[here](https://docs.docker.com/compose/install/). + + +### Getting the source code + +As of go 1.10.x, GOPATH is still relevant. This may change in the future but +for the sake of making development less error prone, it is suggested that the following +directories be created: + +`$ mkdir -p $GOPATH/src/github.com/paypal` + +And then clone the master branch into the newly created folder: + +`$ cd $GOPATH/src/github.com/paypal; git clone git@github.com:paypal/gorealis.git` + +Since we check in our vendor folder, gorealis no further set up is needed. + +### Bringing up the cluster + +To develop gorealis, you will need a fully functioning Mesos cluster along with +Apache Aurora. + +In order to bring up our docker-compose set up execute the following command from the root +of the git repository: + +`$ docker-compose up -d` + +### Testing code + +Since Docker does not work well using host mode under MacOS, a workaround has been employed: +docker-compose brings up a bridged network. + +* The ports 8081 is exposed for Aurora. http://localhost:8081 will load the Aurora Web UI. +* The port 5050 is exposed for Mesos. http://localhost:5050 will load the Mesos Web UI. + +#### Note for developers on MacOS: +Running the cluster using a bridged network on MacOS has some side effects. +Since Aurora exposes it's internal IP location through Zookeeper, gorealis will determine +the address to be 192.168.33.7. The address 192.168.33.7 is valid when running in a Linux +environment but not when running under MacOS. To run code involving the ZK leader fetcher +(such as the tests), a container connected to the network needs to be launched. + +For example, running the tests in a container can be done through the following command from +the root of the git repository: + +`$ docker run -t -v $(pwd):/go/src/github.com/paypal/gorealis --network gorealis_aurora_cluster golang:1.10.3-alpine go test github.com/paypal/gorealis` + +Or + +`$ ./runTestsMac.sh` + +Alternatively, if an interactive shell is necessary, the following command may be used: +`$ docker run -it -v $(pwd):/go/src/github.com/paypal/gorealis --network gorealis_aurora_cluster golang:1.10.3-alpine /bin/sh` + +### Cleaning up the cluster + +If something went wrong while developing and a clean environment is desired, perform the +following command from the root of the git directory: + +`$ docker-compose down && docker-compose up -d` + + +### Tearing down the cluster + +Once development is done, the environment may be torn down by executing (from the root of the +git directory): + +`$ docker-compose down` + + + diff --git a/docs/getting-started.md b/docs/getting-started.md index cd6357c..d45477c 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -1,27 +1,11 @@ # Running custom executors on Aurora -In this document, we will be using the docker-compose executor to demonstrate +In this document we will be using the docker-compose executor to demonstrate how Aurora can use multiple executors on a single Scheduler. For this guide, we will be using a vagrant instance to demonstrate the setup process. Many of the same steps also apply to an Aurora installation made via a package manager. Differences in how to configure the cluster between the vagrant image and the package manager will be clarified when necessary. -## Pre-configured Aurora Vagrant box -Alternatively, if Vagrant and VirtualBox are already configured your machine, -you may use a pre-configured vagrant image and skip to the [Creating Aurora Jobs](#creating-aurora-jobs). - -To take this path, start by cloning the following repository and checking out the DockerComposeExecutor branch: -``` -$ git clone -b 0.16.0-DCE git@github.com:rdelval/aurora.git -``` - -And bringing the vagrant box -``` -$ cd aurora -$ vagrant up -``` -**The pre-configured Vagrant box will most likely run on a stale version of Aurora (compared to the master)** - ## Configuring Aurora manually ### Spinning up an Aurora instance with Vagrant Follow the guide at http://aurora.apache.org/documentation/latest/getting-started/vagrant/ @@ -31,7 +15,7 @@ until the end of step 4 (Start the local cluster) and skip to configuring Docker Follow the guide at http://aurora.apache.org/documentation/latest/operations/installation/ ### Configuring Scheduler to use Docker-Compose executor -In order use the docker compose executor with Aurora, we must first give the scheduler +In order to use the docker compose executor with Aurora, we must first give the scheduler a configuration file that contains information on how to run the executor. #### Configuration file @@ -42,14 +26,14 @@ under the custom executors section. A sample config file for the docker-compose executor looks like this: ``` -[ - { - "executor":{ - "command":{ +[ + { + "executor":{ + "command":{ "value":"java -jar docker-compose-executor_0.1.0.jar", "shell":"true", - "uris":[ - { + "uris":[ + { "cache":false, "executable":true, "extract":false, @@ -63,10 +47,8 @@ A sample config file for the docker-compose executor looks like this: "task_prefix":"compose-" } ] - ``` - #### Configuring the Scheduler to run a custom executor ##### Setting the proper flags Some flags need to be set on the Aurora scheduler in order for custom executors to work properly. @@ -106,102 +88,37 @@ On Ubuntu, restarting the aurora-scheduler can be achieved by running the follow $ sudo service aurora-scheduler restart ``` -### Using a custom client -Pystachio does yet support launching tasks using custom executors. Therefore, a custom -client must be used in order to launch tasks using a custom executor. In this case, -we will be using [gorealis](https://github.com/rdelval/gorealis) to launch a task with -the compose executor on Aurora. +## Using [dce-go](https://github.com/paypal/dce-go) +Instead of manually configuring Aurora to run the docker-compose executor, one can follow the instructions provided [here](https://github.com/paypal/dce-go/blob/develop/docs/environment.md) to quickly create a DCE environment that would include mesos, aurora, golang1.7, docker, docker-compose and DCE installed. + +Please note that when using dce-go, the endpoints are going to be as shown below, +``` +Aurora endpoint --> http://192.168.33.8:8081 +Mesos endpoint --> http://192.168.33.8:5050 +``` ## Configuring the system to run a custom client and docker-compose executor ### Installing Go -#### Linux +Follow the instructions at the official golang website: [golang.org/doc/install](https://golang.org/doc/install) -##### Ubuntu +### Installing docker-compose -###### Adding a PPA and install via apt-get -``` -$ sudo add-apt-repository ppa:ubuntu-lxc/lxd-stable -$ sudo apt-get update -$ sudo apt-get install golang -``` - -###### Configuring the GOPATH - -Configure the environment to be able to compile and run Go code. -``` -$ mkdir $HOME/go -$ echo export GOPATH=$HOME/go >> $HOME/.bashrc -$ echo export GOROOT=/usr/lib/go >> $HOME/.bashrc -$ echo export PATH=$PATH:$GOPATH/bin >> $HOME/.bashrc -$ echo export PATH=$PATH:$GOROOT/bin >> $HOME/.bashrc -``` - -Finally we must reload the .bashrc configuration: -``` -$ source $HOME/.bashrc -``` - -#### OS X - -One way to install go on OS X is by using [Homebrew](http://brew.sh/) - -##### Installing Homebrew -Run the following command from the terminal to install Hombrew: -``` -$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" -``` - -##### Installing Go using Hombrew - -Run the following command from the terminal to install Go: -``` -$ brew install go -``` - -##### Configuring the GOPATH - -Configure the environment to be able to compile and run Go code. -``` -$ mkdir $HOME/go -$ echo export GOPATH=$HOME/go >> $HOME/.profile -$ echo export GOROOT=/usr/local/opt/go/libexec >> $HOME/.profile -$ echo export PATH=$PATH:$GOPATH/bin >> $HOME/.profile -$ echo export PATH=$PATH:$GOROOT/bin >> $HOME/.profile -``` - -Finally we must reload the .profile configuration: -``` -$ source $HOME/.profile -``` - -#### Windows - -Download and run the msi installer from https://golang.org/dl/ - -## Installing Docker Compose -To show Aurora's new multi executor feature, we need to use at least one custom executor. -In this case we will be using the [docker-compose-executor](https://github.com/mesos/docker-compose-executor). - -In order to run the docker-compose executor, each agent must have docker-compose installed on it. - -This can be done using pip: -``` -$ sudo pip install docker-compose -``` +Agents which will run dce-go will need docker-compose in order to sucessfully run the executor. +Instructions for installing docker-compose on various platforms may be found on Docker's webiste: [docs.docker.com/compose/install/](https://docs.docker.com/compose/install/) ## Downloading gorealis Finally, we must get `gorealis` using the `go get` command: ``` -go get github.com/rdelval/gorealis +go get github.com/paypal/gorealis ``` # Creating Aurora Jobs ## Creating a thermos job -To demonstrate that we are able to run jobs using different executors on the +To demonstrate that we are able to run jobs using different executors on the same scheduler, we'll first launch a thermos job using the default Aurora Client. We can use a sample job for this: @@ -264,12 +181,12 @@ job = realis.NewJob(). Using a vagrant setup as an example, we can run the following command to create a compose job: ``` -go run $GOPATH/src/github.com/rdelval/gorealis/examples/client.go -executor=compose -url=http://192.168.33.7:8081 -cmd=create +go run $GOPATH/src/github.com/paypal/gorealis/examples/client.go -executor=compose -url=http://192.168.33.7:8081 -cmd=create ``` If everything went according to plan, a new job will be shown in the Aurora UI. -We can further investigate inside the Mesos task sandbox. Inside the sandbox, under -the sample-app folder, we can find a docker-compose.yml-generated.yml. If we inspect this file, +We can further investigate inside the Mesos task sandbox. Inside the sandbox, under +the sample-app folder, we can find a docker-compose.yml-generated.yml. If we inspect this file, we can find the port at which we can find the web server we launched. Under Web->Ports, we find the port Mesos allocated. We can then navigate to: @@ -278,10 +195,10 @@ Under Web->Ports, we find the port Mesos allocated. We can then navigate to: A message from the executor should greet us. ## Creating a Thermos job using gorealis -It is also possible to create a thermos job using gorealis. To do this, however, +It is also possible to create a thermos job using gorealis. To do this, however, a thermos payload is required. A thermos payload consists of a JSON blob that details the entire task as it exists inside the Aurora Scheduler. *Creating the blob is unfortunately -out of the scope of was gorealis does*, so a thermos payload must be generated beforehand or +out of the scope of what gorealis does*, so a thermos payload must be generated beforehand or retrieved from the structdump of an existing task for testing purposes. A sample thermos JSON payload may be found [here](../examples/thermos_payload.json) in the examples folder. @@ -306,17 +223,36 @@ job = realis.NewJob(). Using a vagrant setup as an example, we can run the following command to create a Thermos job: ``` -$ cd $GOPATH/src/github.com/rdelval/gorealis +$ cd $GOPATH/src/github.com/paypal/gorealis $ go run examples/client.go -executor=thermos -url=http://192.168.33.7:8081 -cmd=create -executor=thermos ``` +## Creating jobs using gorealis JSON client +We can also use the [JSON client](../examples/jsonClient.go) to create Aurora jobs using gorealis. + +If using _dce-go_, then use `http://192.168.33.8:8081` as the scheduler URL. + +``` +$ cd $GOPATH/src/github.com/paypal/gorealis/examples +``` + +To launch a job using the Thermos executor, +``` +$ go run jsonClient.go -job=job_thermos.json -config=config.json +``` + +To launch a job using docker-compose executor, +``` +$ go run jsonClient.go -job=job_dce.json -config=config.json +``` + # Cleaning up To stop the jobs we've launched, we need to send a job kill request to Aurora. It should be noted that although we can't create jobs using a custom executor using the default Aurora client, we ~can~ use the default Aurora client to kill them. Additionally, we can use gorealis perform the clean up as well. -## Using the Default Client +## Using the Default Client (if manually configured Aurora) ``` $ aurora job killall devcluster/www-data/prod/hello @@ -326,6 +262,6 @@ $ aurora job killall devcluster/vagrant/prod/docker-compose ## Using gorealis ``` -$ go run $GOPATH/src/github.com/rdelval/gorealis/examples/client.go -executor=compose -url=http://192.168.33.7:8081 -cmd=kill -$ go run $GOPATH/src/github.com/rdelval/gorealis/examples/client.go -executor=thermos -url=http://192.168.33.7:8081 -cmd=kill +$ go run $GOPATH/src/github.com/paypal/gorealis/examples/client.go -executor=compose -url=http://192.168.33.7:8081 -cmd=kill +$ go run $GOPATH/src/github.com/paypal/gorealis/examples/client.go -executor=thermos -url=http://192.168.33.7:8081 -cmd=kill ``` diff --git a/docs/leveraging-the-library.md b/docs/leveraging-the-library.md index ea47629..e13ca2c 100644 --- a/docs/leveraging-the-library.md +++ b/docs/leveraging-the-library.md @@ -1,6 +1,6 @@ # How to leverage the library (based on the [sample client](../examples/client.go)) -For a more complete look at the API, please visit https://godoc.org/github.com/rdelval/gorealis +For a more complete look at the API, please visit https://godoc.org/github.com/paypal/gorealis * Create a default configuration file (alternatively, manually create your own Config): ``` @@ -57,4 +57,19 @@ updateJob := realis.NewUpdateJob(job) updateJob.InstanceCount(1) updateJob.Ram(128) msg, err := r.UpdateJob(updateJob, "") -``` \ No newline at end of file +``` + + +* Handling a timeout scenario: + +When sending an API call to Aurora, the call may timeout at the client side. +This means that the time limit has been reached while waiting for the scheduler +to reply. In such a case it is recommended that the timeout is increased through +the use of the `realis.TimeoutMS()` option. + +As these timeouts cannot be totally avoided, there exists a mechanism to mitigate such +scenarios. The `StartJobUpdate` and `CreateService` API will return an error that +implements the Timeout interface. + +An error can be checked to see if it is a Timeout error by using the `realis.IsTimeout()` +function. \ No newline at end of file diff --git a/docs/using-the-sample-client.md b/docs/using-the-sample-client.md index 2e57696..7e20455 100644 --- a/docs/using-the-sample-client.md +++ b/docs/using-the-sample-client.md @@ -1,6 +1,6 @@ # Using the Sample client -## Usage: +## Usage: ``` Usage of ./client: -cluster string @@ -29,21 +29,21 @@ executor examples, the vagrant box must be configured properly to use the docker #### Creating a Thermos job ``` -$ cd $GOPATH/src/github.com/rdelval/gorealis/examples +$ cd $GOPATH/src/github.com/paypal/gorealis/examples $ go run client.go -executor=thermos -url=http://192.168.33.7:8081 -cmd=create ``` #### Kill a Thermos job ``` -$ go run $GOPATH/src/github.com/rdelval/gorealis.git/examples/client.go -executor=thermos -url=http://192.168.33.7:8081 -cmd=kill +$ go run $GOPATH/src/github.com/paypal/gorealis/examples/client.go -executor=thermos -url=http://192.168.33.7:8081 -cmd=kill ``` ### Docker Compose executor (custom executor) #### Creating Docker Compose executor job ``` -$ go run $GOPATH/src/github.com/rdelval/gorealis/examples/client.go -executor=compose -url=http://192.168.33.7:8081 -cmd=create +$ go run $GOPATH/src/github.com/paypal/gorealis/examples/client.go -executor=compose -url=http://192.168.33.7:8081 -cmd=create ``` #### Kill a Docker Compose executor job ``` -$ go run $GOPATH/src/github.com/rdelval/gorealis/examples/client.go -executor=compose -url=http://192.168.33.7:8081 -cmd=kill +$ go run $GOPATH/src/github.com/paypal/gorealis/examples/client.go -executor=compose -url=http://192.168.33.7:8081 -cmd=kill ``` diff --git a/errors.go b/errors.go new file mode 100644 index 0000000..d865aea --- /dev/null +++ b/errors.go @@ -0,0 +1,104 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package realis + +// Using a pattern described by Dave Cheney to differentiate errors +// https://dave.cheney.net/2016/04/27/dont-just-check-errors-handle-them-gracefully + +// Timeout errors are returned when a function is unable to continue executing due +// to a time constraint or meeting a set number of retries. +type timeout interface { + Timedout() bool +} + +// IsTimeout returns true if the error being passed as an argument implements the Timeout interface +// and the Timedout function returns true. +func IsTimeout(err error) bool { + temp, ok := err.(timeout) + return ok && temp.Timedout() +} + +type timeoutErr struct { + error + timedout bool +} + +func (r *timeoutErr) Timedout() bool { + return r.timedout +} + +func newTimedoutError(err error) *timeoutErr { + return &timeoutErr{error: err, timedout: true} +} + +// retryErr is a superset of timeout which includes extra context +// with regards to our retry mechanism. This is done in order to make sure +// that our retry mechanism works as expected through our tests and should +// never be relied on or used directly. It is not made part of the public API +// on purpose. +type retryErr struct { + error + timedout bool + retryCount int // How many times did the mechanism retry the command +} + +// Retry error is a timeout type error with added context. +func (r *retryErr) Timedout() bool { + return r.timedout +} + +func (r *retryErr) RetryCount() int { + return r.retryCount +} + +// ToRetryCount is a helper function for testing verification to avoid whitebox testing +// as well as keeping retryErr as a private. +// Should NOT be used under any other context. +func ToRetryCount(err error) *retryErr { + if retryErr, ok := err.(*retryErr); ok { + return retryErr + } + return nil +} + +func newRetryError(err error, retryCount int) *retryErr { + return &retryErr{error: err, timedout: true, retryCount: retryCount} +} + +// Temporary errors indicate that the action may or should be retried. +type temporary interface { + Temporary() bool +} + +// IsTemporary indicates whether the error passed in as an argument implements the temporary interface +// and if the Temporary function returns true. +func IsTemporary(err error) bool { + temp, ok := err.(temporary) + return ok && temp.Temporary() +} + +type temporaryErr struct { + error + temporary bool +} + +func (t *temporaryErr) Temporary() bool { + return t.temporary +} + +// NewTemporaryError creates a new error which satisfies the Temporary interface. +func NewTemporaryError(err error) *temporaryErr { + return &temporaryErr{error: err, temporary: true} +} diff --git a/examples/certs/client.cert b/examples/certs/client.cert new file mode 100644 index 0000000..67d2b91 --- /dev/null +++ b/examples/certs/client.cert @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDrTCCApWgAwIBAgIJAM+bKx50CY9JMA0GCSqGSIb3DQEBCwUAMG0xCzAJBgNV +BAYTAkdCMQ8wDQYDVQQIDAZMb25kb24xDzANBgNVBAcMBkxvbmRvbjEYMBYGA1UE +CgwPR2xvYmFsIFNlY3VyaXR5MRYwFAYDVQQLDA1JVCBEZXBhcnRtZW50MQowCAYD +VQQDDAEqMB4XDTE3MTIwODIwNTMwMVoXDTI3MTIwNjIwNTMwMVowbTELMAkGA1UE +BhMCR0IxDzANBgNVBAgMBkxvbmRvbjEPMA0GA1UEBwwGTG9uZG9uMRgwFgYDVQQK +DA9HbG9iYWwgU2VjdXJpdHkxFjAUBgNVBAsMDUlUIERlcGFydG1lbnQxCjAIBgNV +BAMMASowggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQDhdN0KH80BF3Dk +RQqAARcf7F87uNhQM05HXK8ffpESvKhzrO9BHuDZ0yS3il0BK9XpTyTtHSLIbphk +rO3BOsmPj0zhaM20LsPtwy8GmMCym3hVNSYYyP5XCdjA3uZIYq2R8ruk+vZTe4Zr +F8GHV/xGYU4zKPMGzsQbICjZhj0yiYF9UQ2J+xw79nsqPTmo8+EdVuunLz39dt2o +SbDA01g/kPTIg9K2CAUH0mm4zegiqytwpn2JKVoemmgrDYECWnhLprWlvN9t/fX9 +IgprDAHN1BsMrzfmfQXZpVmbIlTriVSdYVeTwG8rT7Tg8soIHqBrnJ1ykTpY4VrO +6tc2z4kTAgMBAAGjUDBOMB0GA1UdDgQWBBSLvwax1Zd6ZiE7TjRklWYNPwgZ2zAf +BgNVHSMEGDAWgBSLvwax1Zd6ZiE7TjRklWYNPwgZ2zAMBgNVHRMEBTADAQH/MA0G +CSqGSIb3DQEBCwUAA4IBAQCJY/EJxlyiSrnO82QcsWm9cT/ciU/G7Y4vX/tGs74C +tNxuBpc0vMfW4a9u6tmi3cW3EXD/KRvPwKZXxzTOhoQY9ZpbZLZ6VvCQ+aWQaXWT +664IS/mrEUZ/p3pgqTNtifdpPAZqVqNdS+Od8/B3/nWUn6JBkDZ4WaFQgfsSulxK +yzYN6UbwhLHfQUupFFhPfvYIVLH9ErGzcv5ZCHX9FornCc0W/8hL4EdjmpTW2ML2 +hM5aTKynMiR1GuGSdSpJ+BOeiUI7Go1jGwjV+H9Pw/kfmooq2wuuUGti5dr0Qq7h +CQx1a14BmDBwGoMIOdjFATRwnami5e188fAJozL++i+s +-----END CERTIFICATE----- diff --git a/examples/certs/client.key b/examples/certs/client.key new file mode 100644 index 0000000..7805b83 --- /dev/null +++ b/examples/certs/client.key @@ -0,0 +1,28 @@ +-----BEGIN PRIVATE KEY----- +MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDhdN0KH80BF3Dk +RQqAARcf7F87uNhQM05HXK8ffpESvKhzrO9BHuDZ0yS3il0BK9XpTyTtHSLIbphk +rO3BOsmPj0zhaM20LsPtwy8GmMCym3hVNSYYyP5XCdjA3uZIYq2R8ruk+vZTe4Zr +F8GHV/xGYU4zKPMGzsQbICjZhj0yiYF9UQ2J+xw79nsqPTmo8+EdVuunLz39dt2o +SbDA01g/kPTIg9K2CAUH0mm4zegiqytwpn2JKVoemmgrDYECWnhLprWlvN9t/fX9 +IgprDAHN1BsMrzfmfQXZpVmbIlTriVSdYVeTwG8rT7Tg8soIHqBrnJ1ykTpY4VrO +6tc2z4kTAgMBAAECggEBAMZL7SY8dikhnu+HMgcH7njrg4+ZsthHZ/AoOvcucRbT +zC2ByyWxrP6pUUAFeGvRTGHadJYA7FjxvSO/XZZ4yFN2LJ6NeW+jOjzjUXcx3zq4 +t4vqJUnjbqDLTlPFOTItaJBXuGcRPJqMqNuEl3kdEAwvBYLF34r7TUy2and4NFc/ +JziGljkiucoNBk62TCDrffnvxMJXht+ab6PMWO87PzMVs4xUFPe0ezv4O54btUcV +EJsU58013EHeCai8AnxjcIPlMlB+lg4Y3C4VXf0mJ//cBvbCp+kyWybMw/e+e222 +xq/98vnCOIqcy4u+9ENPLJQe7hXZ3Sqh38kf0GuOh8ECgYEA+VFvuuBP0OQHTxeE +dUizR3Iz/xkeGDUZ/8Ix4TCUmRRuhEXrV7ShwUmuanO3pNhChW6hXZ6qj/yuhfOC +D4V4upEnJDccz/cbH1PdBsfALhC8/C0WSGvnEWZMw/SggmY4KwReqWwN9aA8qjdq +kFTOJc2Js+dCHP9kn9J3U16A+oMCgYEA53+2lhckAI8bsrbCayWRZAVx7hUNPijt +MQvH+PCJ3QeZ0z801zk+4ny5WQ1BT0vRzwj8an4Byi2ZuTQU//N4oawDK0JVYi7q +rjKX/AhAx/puoGAgqiS1nDmuiUiplW06HqayCFbpJ1CoXz8+MwdRXiJ8dgioafVJ ++7wHZDVmMjECgYEAoULxd/ia58x2hcv6Wzo469+MjlYaxyGhvXJIfRXFJ/a1PU1U +Whh1/+W+sRBEGpXfARt7uGhmfle8Mtw8pfl5C4PTw3L6afG1U2AVOMt/HMyq0JoB +LbrNbM20nZLfNzkS35AmAoPny5ZnZtoNTWntJTp69SiB9OuklFO35u7bki0CgYAL +qQYkVzQMBylI/iWaygChvhh3+n15RQx1bPd8lXkMNgbMeiGKOaruM4QOdTl16ga+ +W+CC6KfkbBmTF4l7PuMzmXtrYWL1mBFgBtJa8nt41yddUpoyl7jCDrG43n0UNrU3 +uAO9ocsKnOhuK7xRS6wQhsIoG9WHyMAaOuVQadQk8QKBgQDVibcvOPXNcF1aRMG7 +V24nBb+YYz+00g/cLRkDnBX9/HORle0HSfeT70ctRhuFCoHHbHF4fnp/iAwDgxdB +dNufthftTZTtFGITUsJDN36fSXNjEvKzmKEAlEYkGAYijLlDwknPB+bf4NQ6T0R+ +AtnKQY6G4kFSfw9AKgWGy7ZKfg== +-----END PRIVATE KEY----- diff --git a/examples/certs/server.crt b/examples/certs/server.crt new file mode 100644 index 0000000..919c4ff --- /dev/null +++ b/examples/certs/server.crt @@ -0,0 +1,18 @@ +-----BEGIN CERTIFICATE----- +MIIC6zCCAdOgAwIBAgIJAMgY8gND5lFnMA0GCSqGSIb3DQEBCwUAMAwxCjAIBgNV +BAMMASowHhcNMTcxMjA4MjA1MTQyWhcNMjcxMjA2MjA1MTQyWjAMMQowCAYDVQQD +DAEqMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwKcyyXg90wen25yh +QA17MDyzjzBsIL9+kznzRD1azoNqA3RShAAWXn5a81HeWvncpVL+TKPMU3UC02XT +I6GtX1U7xmdKstBLKiHQxGWX04DshSrVgcVzLUI6OHBG6feoL1mGAa8jB2UEE6ER +uXdgYgKbLUrvduSn4fBvPIhhXg9YL2n2TVujkaY9bPZ9M5tQ5K+g4wRwCAYgjTUN +55J82uzAsLCs+AQi9D4bLJmw0z2H7enRLkd9sRE2pArhXm4LLg/QlL8I5ZHv7vfl +RYdOoC3bjgKk+OVOmb2Fb/dWVlOMcnO8qeo9WyQbhAcjNK2W9Tqk5E5orGZ/bkw/ +iZc0MwIDAQABo1AwTjAdBgNVHQ4EFgQUA0xmNKQqxUQgaM9ceCzFyocn9jswHwYD +VR0jBBgwFoAUA0xmNKQqxUQgaM9ceCzFyocn9jswDAYDVR0TBAUwAwEB/zANBgkq +hkiG9w0BAQsFAAOCAQEAnL7VvBTcFyLeNeuTAWmM0bjlwWsuL9Va2LZitnATgzE7 +ACS+ZNURnpK/o3UHGc2ePDCFgPsF2mnh4Jmye2tl5uPxQS2zR96hp16ZGVi9N1gx +4aQyknKt6UFRP/cvWwgDN5N3pnRZQ7J0kaAWCPtAIldeGK7UDjOJ1DLDVLeByr7x +27TCt69ysisTtz6Tzr5vvVDEtu2yNIf/uGk3od+pe/0E1UXVCTItvwM30wvfcTPU +aMZXBYNmSrjnJ4k/9FSjZYNKPtK1c/JR+zUng1h+I3b7itY5VBGdzdq9fEk20PHm +Xdg1Ptbebtl6PJqWX+rydXuen6SUt8vFJE89MkbWSw== +-----END CERTIFICATE----- diff --git a/examples/client.go b/examples/client.go index d8e0efe..69e3751 100644 --- a/examples/client.go +++ b/examples/client.go @@ -17,66 +17,108 @@ package main import ( "flag" "fmt" - "github.com/rdelval/gorealis" - "github.com/rdelval/gorealis/gen-go/apache/aurora" - "github.com/rdelval/gorealis/response" "io/ioutil" - "os" + "log" + "strings" + "time" + + realis "github.com/paypal/gorealis" + "github.com/paypal/gorealis/gen-go/apache/aurora" + "github.com/paypal/gorealis/response" ) -func main() { - cmd := flag.String("cmd", "", "Job request type to send to Aurora Scheduler") - executor := flag.String("executor", "thermos", "Executor to use") - url := flag.String("url", "", "URL at which the Aurora Scheduler exists as [url]:[port]") - clustersConfig := flag.String("clusters", "", "Location of the clusters.json file used by aurora.") - clusterName := flag.String("cluster", "devcluster", "Name of cluster to run job on (only necessary if clusters is set)") - updateId := flag.String("updateId", "", "Update ID to operate on") - username := flag.String("username", "aurora", "Username to use for authorization") - password := flag.String("password", "secret", "Password to use for authorization") +var cmd, executor, url, clustersConfig, clusterName, updateId, username, password, zkUrl, hostList, role string +var caCertsPath string +var clientKey, clientCert string + +var ConnectionTimeout = 20000 + +func init() { + flag.StringVar(&cmd, "cmd", "", "Job request type to send to Aurora Scheduler") + flag.StringVar(&executor, "executor", "thermos", "Executor to use") + flag.StringVar(&url, "url", "", "URL at which the Aurora Scheduler exists as [url]:[port]") + flag.StringVar(&clustersConfig, "clusters", "", "Location of the clusters.json file used by aurora.") + flag.StringVar(&clusterName, "cluster", "devcluster", "Name of cluster to run job on (only necessary if clusters is set)") + flag.StringVar(&updateId, "updateId", "", "Update ID to operate on") + flag.StringVar(&username, "username", "aurora", "Username to use for authorization") + flag.StringVar(&password, "password", "secret", "Password to use for authorization") + flag.StringVar(&zkUrl, "zkurl", "", "zookeeper url") + flag.StringVar(&hostList, "hostList", "", "Comma separated list of hosts to operate on") + flag.StringVar(&role, "role", "", "owner role to use") + flag.StringVar(&caCertsPath, "caCertsPath", "", "Path to CA certs on local machine.") + flag.StringVar(&clientCert, "clientCert", "", "Client certificate to use to connect to Aurora.") + flag.StringVar(&clientKey, "clientKey", "", "Client private key to use to connect to Aurora.") + flag.Parse() - // Attempt to load leader from zookeeper - if *clustersConfig != "" { - clusters, err := realis.LoadClusters(*clustersConfig) + // Attempt to load leader from zookeeper using a + // cluster.json file used for the default aurora client if provided. + // This will override the provided url in the arguments + if clustersConfig != "" { + clusters, err := realis.LoadClusters(clustersConfig) if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatalln(err) } - cluster, ok := clusters[*clusterName] + cluster, ok := clusters[clusterName] if !ok { - fmt.Printf("Cluster %s chosen doesn't exist\n", *clusterName) - os.Exit(1) + log.Fatalf("Cluster %s doesn't exist in the file provided\n", clusterName) } - *url, err = realis.LeaderFromZK(cluster) + url, err = realis.LeaderFromZK(cluster) if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatalln(err) } } +} - //Create new configuration with default transport layer - config, err := realis.NewDefaultConfig(*url) - if err != nil { - fmt.Println(err) - os.Exit(1) +func main() { + + var job realis.Job + var err error + var monitor *realis.Monitor + var r realis.Realis + + clientOptions := []realis.ClientOption{ + realis.BasicAuth(username, password), + realis.ThriftJSON(), + realis.TimeoutMS(ConnectionTimeout), + realis.BackOff(realis.Backoff{ + Steps: 2, + Duration: 10 * time.Second, + Factor: 2.0, + Jitter: 0.1, + }), + realis.Debug(), } - // Configured for vagrant - realis.AddBasicAuth(&config, *username, *password) - r := realis.NewClient(config) + if zkUrl != "" { + fmt.Println("zkUrl: ", zkUrl) + clientOptions = append(clientOptions, realis.ZKUrl(zkUrl)) + } else { + clientOptions = append(clientOptions, realis.SchedulerUrl(url)) + } + + if caCertsPath != "" { + clientOptions = append(clientOptions, realis.Certspath(caCertsPath)) + } + + if clientKey != "" && clientCert != "" { + clientOptions = append(clientOptions, realis.ClientCerts(clientKey, clientCert)) + } + + r, err = realis.NewRealisClient(clientOptions...) + if err != nil { + log.Fatalln(err) + } + monitor = &realis.Monitor{Client: r} defer r.Close() - monitor := &realis.Monitor{r} - var job realis.Job - - switch *executor { + switch executor { case "thermos": - payload, err := ioutil.ReadFile("thermos_payload.json") + payload, err := ioutil.ReadFile("examples/thermos_payload.json") if err != nil { - fmt.Println("Error reading json config file: ", err) - os.Exit(1) + log.Fatalln("Error reading json config file: ", err) } job = realis.NewJob(). @@ -91,23 +133,21 @@ func main() { IsService(true). InstanceCount(1). AddPorts(1) - break case "compose": job = realis.NewJob(). Environment("prod"). Role("vagrant"). - Name("docker-compose"). + Name("docker-compose-test"). ExecutorName("docker-compose-executor"). ExecutorData("{}"). - CPU(1). - RAM(64). + CPU(0.25). + RAM(512). Disk(100). - IsService(false). + IsService(true). InstanceCount(1). - AddPorts(1). + AddPorts(4). AddLabel("fileName", "sample-app/docker-compose.yml"). AddURIs(true, true, "https://github.com/mesos/docker-compose-executor/releases/download/0.1.0/sample-app.tar.gz") - break case "none": job = realis.NewJob(). Environment("prod"). @@ -119,53 +159,82 @@ func main() { IsService(true). InstanceCount(1). AddPorts(1) - break default: - fmt.Println("Only thermos, compose, and none are supported for now") - os.Exit(1) + log.Fatalln("Only thermos, compose, and none are supported for now") } - switch *cmd { + switch cmd { case "create": fmt.Println("Creating job") resp, err := r.CreateJob(job) if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatalln(err) } fmt.Println(resp.String()) - if resp.ResponseCode == aurora.ResponseCode_OK { - if ok, err := monitor.Instances(job.JobKey(), job.GetInstanceCount(), 5, 50); !ok || err != nil { - _, err := r.KillJob(job.JobKey()) - if err != nil { - fmt.Println(err) - os.Exit(1) - } + if ok, mErr := monitor.Instances(job.JobKey(), job.GetInstanceCount(), 5, 50); !ok || mErr != nil { + _, err := r.KillJob(job.JobKey()) + if err != nil { + log.Fatalln(err) } + log.Fatalf("ok: %v\n err: %v", ok, mErr) } - break + + case "createService": + // Create a service with three instances using the update API instead of the createJob API + fmt.Println("Creating service") + settings := realis.NewUpdateSettings() + job.InstanceCount(3) + resp, result, err := r.CreateService(job, settings) + if err != nil { + log.Println("error: ", err) + log.Fatal("response: ", resp.String()) + } + fmt.Println(result.String()) + + if ok, mErr := monitor.JobUpdate(*result.GetKey(), 5, 180); !ok || mErr != nil { + _, err := r.AbortJobUpdate(*result.GetKey(), "Monitor timed out") + _, err = r.KillJob(job.JobKey()) + if err != nil { + log.Fatal(err) + } + log.Fatalf("ok: %v\n err: %v", ok, mErr) + } + case "createDocker": fmt.Println("Creating a docker based job") container := realis.NewDockerContainer().Image("python:2.7").AddParameter("network", "host") job.Container(container) resp, err := r.CreateJob(job) if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatal(err) } fmt.Println(resp.String()) - if resp.ResponseCode == aurora.ResponseCode_OK { - if ok, err := monitor.Instances(job.JobKey(), job.GetInstanceCount(), 10, 300); !ok || err != nil { - _, err := r.KillJob(job.JobKey()) - if err != nil { - fmt.Println(err) - os.Exit(1) - } + if ok, err := monitor.Instances(job.JobKey(), job.GetInstanceCount(), 10, 300); !ok || err != nil { + _, err := r.KillJob(job.JobKey()) + if err != nil { + log.Fatal(err) } } - break + + case "createMesosContainer": + fmt.Println("Creating a docker based job") + container := realis.NewMesosContainer().DockerImage("python", "2.7") + job.Container(container) + resp, err := r.CreateJob(job) + if err != nil { + log.Fatal(err) + } + fmt.Println(resp.String()) + + if ok, err := monitor.Instances(job.JobKey(), job.GetInstanceCount(), 10, 300); !ok || err != nil { + _, err := r.KillJob(job.JobKey()) + if err != nil { + log.Fatal(err) + } + } + case "scheduleCron": fmt.Println("Scheduling a Cron job") // Cron config @@ -173,157 +242,416 @@ func main() { job.IsService(false) resp, err := r.ScheduleCronJob(job) if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatal(err) } fmt.Println(resp.String()) - break case "startCron": fmt.Println("Starting a Cron job") resp, err := r.StartCronJob(job.JobKey()) if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatal(err) } fmt.Println(resp.String()) - break case "descheduleCron": fmt.Println("Descheduling a Cron job") resp, err := r.DescheduleCronJob(job.JobKey()) if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatal(err) } fmt.Println(resp.String()) - break case "kill": fmt.Println("Killing job") resp, err := r.KillJob(job.JobKey()) if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatal(err) } - if resp.ResponseCode == aurora.ResponseCode_OK { - if ok, err := monitor.Instances(job.JobKey(), 0, 5, 50); !ok || err != nil { - fmt.Println("Unable to kill all instances of job") - os.Exit(1) - } + if ok, err := monitor.Instances(job.JobKey(), 0, 5, 50); !ok || err != nil { + log.Fatal("Unable to kill all instances of job") } fmt.Println(resp.String()) - break + case "restart": fmt.Println("Restarting job") resp, err := r.RestartJob(job.JobKey()) if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatal(err) } fmt.Println(resp.String()) - break + case "liveCount": fmt.Println("Getting instance count") live, err := r.GetInstanceIds(job.JobKey(), aurora.LIVE_STATES) if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatal(err) } - fmt.Println("Number of live instances: ", len(live)) - break + fmt.Printf("Live instances: %+v\n", live) + case "activeCount": fmt.Println("Getting instance count") live, err := r.GetInstanceIds(job.JobKey(), aurora.ACTIVE_STATES) if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatal(err) } fmt.Println("Number of live instances: ", len(live)) - break + case "flexUp": fmt.Println("Flexing up job") - numOfInstances := int32(5) - resp, err := r.AddInstances(aurora.InstanceKey{job.JobKey(), 0}, numOfInstances) + numOfInstances := int32(4) + + live, err := r.GetInstanceIds(job.JobKey(), aurora.ACTIVE_STATES) if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatal(err) + } + currInstances := int32(len(live)) + fmt.Println("Current num of instances: ", currInstances) + resp, err := r.AddInstances(aurora.InstanceKey{ + JobKey: job.JobKey(), + InstanceId: live[0], + }, + numOfInstances) + + if err != nil { + log.Fatal(err) } - if resp.ResponseCode == aurora.ResponseCode_OK { - if ok, err := monitor.Instances(job.JobKey(), job.GetInstanceCount()+numOfInstances, 5, 50); !ok || err != nil { - fmt.Println("Flexing up failed") - } + if ok, err := monitor.Instances(job.JobKey(), currInstances+numOfInstances, 5, 50); !ok || err != nil { + fmt.Println("Flexing up failed") } fmt.Println(resp.String()) - break - case "update": - fmt.Println("Updating a job with with more RAM and to 3 instances") - taskConfig, err := r.FetchTaskConfig(aurora.InstanceKey{job.JobKey(), 0}) + + case "flexDown": + fmt.Println("Flexing down job") + + numOfInstances := int32(2) + + live, err := r.GetInstanceIds(job.JobKey(), aurora.ACTIVE_STATES) if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatal(err) } - updateJob := realis.NewUpdateJob(taskConfig) + currInstances := int32(len(live)) + fmt.Println("Current num of instances: ", currInstances) + + resp, err := r.RemoveInstances(job.JobKey(), numOfInstances) + if err != nil { + log.Fatal(err) + } + + if ok, err := monitor.Instances(job.JobKey(), currInstances-numOfInstances, 5, 100); !ok || err != nil { + fmt.Println("flexDown failed") + } + + fmt.Println(resp.String()) + + case "update": + fmt.Println("Updating a job with with more RAM and to 5 instances") + live, err := r.GetInstanceIds(job.JobKey(), aurora.ACTIVE_STATES) + if err != nil { + log.Fatal(err) + } + taskConfig, err := r.FetchTaskConfig(aurora.InstanceKey{ + JobKey: job.JobKey(), + InstanceId: live[0], + }) + if err != nil { + log.Fatal(err) + } + updateJob := realis.NewDefaultUpdateJob(taskConfig) updateJob.InstanceCount(5).RAM(128) resp, err := r.StartJobUpdate(updateJob, "") if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatal(err) } jobUpdateKey := response.JobUpdateKey(resp) - monitor.JobUpdate(*jobUpdateKey, 5, 100) + monitor.JobUpdate(*jobUpdateKey, 5, 500) + + case "pauseJobUpdate": + resp, err := r.PauseJobUpdate(&aurora.JobUpdateKey{ + Job: job.JobKey(), + ID: updateId, + }, "") + + if err != nil { + log.Fatal(err) + } + fmt.Println("PauseJobUpdate response: ", resp.String()) + + case "resumeJobUpdate": + resp, err := r.ResumeJobUpdate(&aurora.JobUpdateKey{ + Job: job.JobKey(), + ID: updateId, + }, "") + + if err != nil { + log.Fatal(err) + } + fmt.Println("ResumeJobUpdate response: ", resp.String()) + + case "pulseJobUpdate": + resp, err := r.PulseJobUpdate(&aurora.JobUpdateKey{ + Job: job.JobKey(), + ID: updateId, + }) + if err != nil { + log.Fatal(err) + } + + fmt.Println("PulseJobUpdate response: ", resp.String()) - break case "updateDetails": resp, err := r.JobUpdateDetails(aurora.JobUpdateQuery{ - Key: &aurora.JobUpdateKey{job.JobKey(), *updateId}, Limit: 1}) + Key: &aurora.JobUpdateKey{ + Job: job.JobKey(), + ID: updateId, + }, + Limit: 1, + }) if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatal(err) } + fmt.Println(response.JobUpdateDetails(resp)) - break + case "abortUpdate": fmt.Println("Abort update") - resp, err := r.AbortJobUpdate(aurora.JobUpdateKey{job.JobKey(), *updateId}, "") + resp, err := r.AbortJobUpdate(aurora.JobUpdateKey{ + Job: job.JobKey(), + ID: updateId, + }, + "") + if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatal(err) } fmt.Println(resp.String()) - break + case "rollbackUpdate": fmt.Println("Abort update") - resp, err := r.RollbackJobUpdate(aurora.JobUpdateKey{job.JobKey(), *updateId}, "") + resp, err := r.RollbackJobUpdate(aurora.JobUpdateKey{ + Job: job.JobKey(), + ID: updateId, + }, + "") + if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatal(err) } fmt.Println(resp.String()) - break + case "taskConfig": fmt.Println("Getting job info") - config, err := r.FetchTaskConfig(aurora.InstanceKey{job.JobKey(), 0}) + live, err := r.GetInstanceIds(job.JobKey(), aurora.ACTIVE_STATES) if err != nil { - fmt.Println(err) - os.Exit(1) + log.Fatal(err) + } - print(config.String()) - break + config, err := r.FetchTaskConfig(aurora.InstanceKey{ + JobKey: job.JobKey(), + InstanceId: live[0], + }) + + if err != nil { + log.Fatal(err) + } + + log.Println(config.String()) + + case "updatesummary": + fmt.Println("Getting job update summary") + jobquery := &aurora.JobUpdateQuery{ + Role: &job.JobKey().Role, + JobKey: job.JobKey(), + } + updatesummary, err := r.GetJobUpdateSummaries(jobquery) + if err != nil { + log.Fatalf("error while getting update summary: %v", err) + } + + fmt.Println(updatesummary) + + case "taskStatus": + fmt.Println("Getting task status") + taskQ := &aurora.TaskQuery{ + Role: &job.JobKey().Role, + Environment: &job.JobKey().Environment, + JobName: &job.JobKey().Name, + } + tasks, err := r.GetTaskStatus(taskQ) + if err != nil { + log.Fatalf("error: %+v\n ", err) + } + + fmt.Printf("length: %d\n ", len(tasks)) + fmt.Printf("tasks: %+v\n", tasks) + + case "tasksWithoutConfig": + fmt.Println("Getting task status") + taskQ := &aurora.TaskQuery{ + Role: &job.JobKey().Role, + Environment: &job.JobKey().Environment, + JobName: &job.JobKey().Name, + } + tasks, err := r.GetTasksWithoutConfigs(taskQ) + if err != nil { + log.Fatalf("error: %+v\n ", err) + } + + fmt.Printf("length: %d\n ", len(tasks)) + fmt.Printf("tasks: %+v\n", tasks) + + case "drainHosts": + fmt.Println("Setting hosts to DRAINING") + if hostList == "" { + log.Fatal("No hosts specified to drain") + } + hosts := strings.Split(hostList, ",") + _, result, err := r.DrainHosts(hosts...) + if err != nil { + log.Fatalf("error: %+v\n", err.Error()) + } + + // Monitor change to DRAINING and DRAINED mode + hostResult, err := monitor.HostMaintenance( + hosts, + []aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED, aurora.MaintenanceMode_DRAINING}, + 5, + 10) + if err != nil { + for host, ok := range hostResult { + if !ok { + fmt.Printf("Host %s did not transtion into desired mode(s)\n", host) + } + } + log.Fatalf("error: %+v\n", err.Error()) + } + + fmt.Print(result.String()) + + case "SLADrainHosts": + fmt.Println("Setting hosts to DRAINING using SLA aware draining") + if hostList == "" { + log.Fatal("No hosts specified to drain") + } + hosts := strings.Split(hostList, ",") + + policy := aurora.SlaPolicy{PercentageSlaPolicy: &aurora.PercentageSlaPolicy{Percentage: 50.0}} + + result, err := r.SLADrainHosts(&policy, 30, hosts...) + if err != nil { + log.Fatalf("error: %+v\n", err.Error()) + } + + // Monitor change to DRAINING and DRAINED mode + hostResult, err := monitor.HostMaintenance( + hosts, + []aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED, aurora.MaintenanceMode_DRAINING}, + 5, + 10) + if err != nil { + for host, ok := range hostResult { + if !ok { + fmt.Printf("Host %s did not transtion into desired mode(s)\n", host) + } + } + log.Fatalf("error: %+v\n", err.Error()) + } + + fmt.Print(result.String()) + + case "endMaintenance": + fmt.Println("Setting hosts to ACTIVE") + if hostList == "" { + log.Fatal("No hosts specified to drain") + } + hosts := strings.Split(hostList, ",") + _, result, err := r.EndMaintenance(hosts...) + if err != nil { + log.Fatalf("error: %+v\n", err.Error()) + } + + // Monitor change to DRAINING and DRAINED mode + hostResult, err := monitor.HostMaintenance( + hosts, + []aurora.MaintenanceMode{aurora.MaintenanceMode_NONE}, + 5, + 10) + if err != nil { + for host, ok := range hostResult { + if !ok { + fmt.Printf("Host %s did not transtion into desired mode(s)\n", host) + } + } + log.Fatalf("error: %+v\n", err.Error()) + } + + fmt.Print(result.String()) + + case "getPendingReasons": + fmt.Println("Getting pending reasons") + taskQ := &aurora.TaskQuery{ + Role: &job.JobKey().Role, + Environment: &job.JobKey().Environment, + JobName: &job.JobKey().Name, + } + reasons, err := r.GetPendingReason(taskQ) + if err != nil { + log.Fatalf("error: %+v\n ", err) + } + + fmt.Printf("length: %d\n ", len(reasons)) + fmt.Printf("tasks: %+v\n", reasons) + + case "getJobs": + fmt.Println("GetJobs...role: ", role) + _, result, err := r.GetJobs(role) + if err != nil { + log.Fatalf("error: %+v\n", err.Error()) + } + fmt.Println("map size: ", len(result.Configs)) + fmt.Println(result.String()) + + case "snapshot": + fmt.Println("Forcing scheduler to write snapshot to mesos replicated log") + err := r.Snapshot() + if err != nil { + log.Fatalf("error: %+v\n", err.Error()) + } + + case "performBackup": + fmt.Println("Writing Backup of Snapshot to file system") + err := r.PerformBackup() + if err != nil { + log.Fatalf("error: %+v\n", err.Error()) + } + + case "forceExplicitRecon": + fmt.Println("Force an explicit recon") + err := r.ForceExplicitTaskReconciliation(nil) + if err != nil { + log.Fatalf("error: %+v\n", err.Error()) + } + + case "forceImplicitRecon": + fmt.Println("Force an implicit recon") + err := r.ForceImplicitTaskReconciliation() + if err != nil { + log.Fatalf("error: %+v\n", err.Error()) + } + default: - fmt.Println("Command not supported") - os.Exit(1) + log.Fatal("Command not supported") } } diff --git a/examples/clusters.json b/examples/clusters.json index 287a618..c456bd8 100644 --- a/examples/clusters.json +++ b/examples/clusters.json @@ -5,4 +5,4 @@ "auth_mechanism": "UNAUTHENTICATED", "slave_run_directory": "latest", "slave_root": "/var/lib/mesos" -}] \ No newline at end of file +}] diff --git a/examples/config.json b/examples/config.json new file mode 100644 index 0000000..3ab87b7 --- /dev/null +++ b/examples/config.json @@ -0,0 +1,13 @@ +{ + "username": "aurora", + "password": "secret", + "sched_url": "http://192.168.33.7:8081", + "cluster" : { + "name": "devcluster", + "zk": "192.168.33.7", + "scheduler_zk_path": "/aurora/scheduler", + "auth_mechanism": "UNAUTHENTICATED", + "slave_run_directory": "latest", + "slave_root": "/var/lib/mesos" + } +} \ No newline at end of file diff --git a/examples/job_dce.json b/examples/job_dce.json new file mode 100644 index 0000000..48d7595 --- /dev/null +++ b/examples/job_dce.json @@ -0,0 +1,21 @@ +{ + "name": "sampleapp", + "cpu": 0.25, + "ram_mb": 256, + "disk_mb": 100, + "executor": "docker-compose-executor", + "service": true, + "ports": 4, + "instances": 1, + "uris": [ + { + "uri": "http://192.168.33.8/app.tar.gz", + "extract": true, + "cache": false + } + ], + "labels":{ + "fileName":"sampleapp/docker-compose.yml,sampleapp/docker-compose-healthcheck.yml" + } + +} \ No newline at end of file diff --git a/examples/job_thermos.json b/examples/job_thermos.json new file mode 100644 index 0000000..88fa878 --- /dev/null +++ b/examples/job_thermos.json @@ -0,0 +1,11 @@ +{ + "name": "hello_world_from_gorealis", + "cpu": 1.0, + "ram_mb": 64, + "disk_mb": 100, + "executor": "thermos", + "exec_data_file": "examples/thermos_payload.json", + "service": true, + "ports": 1, + "instances": 1 +} diff --git a/examples/jsonClient.go b/examples/jsonClient.go index dd57450..c138a63 100644 --- a/examples/jsonClient.go +++ b/examples/jsonClient.go @@ -18,8 +18,14 @@ import ( "encoding/json" "flag" "fmt" - "github.com/rdelval/gorealis" + "io/ioutil" + "log" "os" + "time" + + realis "github.com/paypal/gorealis" + "github.com/paypal/gorealis/gen-go/apache/aurora" + "github.com/pkg/errors" ) type URIJson struct { @@ -29,16 +35,17 @@ type URIJson struct { } type JobJson struct { - Name string `json:"name"` - CPU float64 `json:"cpu"` - RAM int64 `json:"ram_mb"` - Disk int64 `json:"disk_mb"` - Executor string `json:"executor"` - Instances int32 `json:"instances"` - URIs []URIJson `json:"uris"` - Labels map[string]string `json:"labels"` - Service bool `json:"service"` - Ports int `json:"ports"` + Name string `json:"name"` + CPU float64 `json:"cpu"` + RAM int64 `json:"ram_mb"` + Disk int64 `json:"disk_mb"` + Executor string `json:"executor"` + ExecutorDataFile string `json:"exec_data_file,omitempty"` + Instances int32 `json:"instances"` + URIs []URIJson `json:"uris"` + Labels map[string]string `json:"labels"` + Service bool `json:"service"` + Ports int `json:"ports"` } func (j *JobJson) Validate() bool { @@ -62,67 +69,158 @@ func (j *JobJson) Validate() bool { return true } -func main() { +type Config struct { + realis.Cluster `json:"cluster"` + Username string `json:"username"` + Password string `json:"password"` + SchedUrl string `json:"sched_url"` + Transport string `json:"transport,omitempty"` + Debug bool `json:"debug,omitempty"` +} + +// Command-line arguments for config and job JSON files. +var configJSONFile, jobJSONFile string + +var job *JobJson +var config *Config + +// Reading command line arguments and validating. +// If Aurora scheduler URL not provided, then using zookeeper to locate the leader. +func init() { + flag.StringVar(&configJSONFile, "config", "./config.json", "The config file that contains username, password, and the cluster configuration information.") + flag.StringVar(&jobJSONFile, "job", "./job.json", "JSON file containing job definitions.") - jsonFile := flag.String("file", "", "JSON file containing job definition") flag.Parse() - if *jsonFile == "" { + job = new(JobJson) + config = new(Config) + + if jobsFile, jobJSONReadErr := os.Open(jobJSONFile); jobJSONReadErr != nil { flag.Usage() + fmt.Println("Error reading the job JSON file: ", jobJSONReadErr) os.Exit(1) + } else { + if unmarshallErr := json.NewDecoder(jobsFile).Decode(job); unmarshallErr != nil { + flag.Usage() + fmt.Println("Error parsing job json file: ", unmarshallErr) + os.Exit(1) + } + + // Need to validate the job JSON file. + if !job.Validate() { + fmt.Println("Invalid Job.") + os.Exit(1) + } } - file, err := os.Open(*jsonFile) - if err != nil { - fmt.Println("Error opening file ", err) + if configFile, configJSONErr := os.Open(configJSONFile); configJSONErr != nil { + flag.Usage() + fmt.Println("Error reading the config JSON file: ", configJSONErr) os.Exit(1) + } else { + if unmarshallErr := json.NewDecoder(configFile).Decode(config); unmarshallErr != nil { + fmt.Println("Error parsing config JSON file: ", unmarshallErr) + os.Exit(1) + } + } +} + +func CreateRealisClient(config *Config) (realis.Realis, error) { + var transportOption realis.ClientOption + // Configuring transport protocol. If not transport is provided, then using JSON as the + // default transport protocol. + switch config.Transport { + case "binary": + transportOption = realis.ThriftBinary() + case "json", "": + transportOption = realis.ThriftJSON() + default: + fmt.Println("Invalid transport option provided!") + os.Exit(1) + } + + clientOptions := []realis.ClientOption{ + realis.BasicAuth(config.Username, config.Password), + transportOption, + realis.ZKCluster(&config.Cluster), + // realis.SchedulerUrl(config.SchedUrl), + realis.SetLogger(log.New(os.Stdout, "realis-debug: ", log.Ldate)), + realis.BackOff(realis.Backoff{ + Steps: 2, + Duration: 10 * time.Second, + Factor: 2.0, + Jitter: 0.1, + }), + } + + if config.Debug { + clientOptions = append(clientOptions, realis.Debug()) + } + + return realis.NewRealisClient(clientOptions...) +} + +func main() { + if r, clientCreationErr := CreateRealisClient(config); clientCreationErr != nil { + fmt.Println(clientCreationErr) + os.Exit(1) + } else { + monitor := &realis.Monitor{Client: r} + defer r.Close() + uris := job.URIs + labels := job.Labels + + auroraJob := realis.NewJob(). + Environment("prod"). + Role("vagrant"). + Name(job.Name). + CPU(job.CPU). + RAM(job.RAM). + Disk(job.Disk). + IsService(job.Service). + InstanceCount(job.Instances). + AddPorts(job.Ports) + + // If thermos executor, then reading in the thermos payload. + if (job.Executor == aurora.AURORA_EXECUTOR_NAME) || (job.Executor == "thermos") { + payload, err := ioutil.ReadFile(job.ExecutorDataFile) + if err != nil { + fmt.Println(errors.Wrap(err, "Invalid thermos payload file!")) + os.Exit(1) + } + auroraJob.ExecutorName(aurora.AURORA_EXECUTOR_NAME). + ExecutorData(string(payload)) + } else { + auroraJob.ExecutorName(job.Executor) + } + + // Adding URIs. + for _, uri := range uris { + auroraJob.AddURIs(uri.Extract, uri.Cache, uri.URI) + } + + // Adding Labels. + for key, value := range labels { + auroraJob.AddLabel(key, value) + } + + fmt.Println("Creating Job...") + if resp, jobCreationErr := r.CreateJob(auroraJob); jobCreationErr != nil { + fmt.Println("Error creating Aurora job: ", jobCreationErr) + os.Exit(1) + } else { + if resp.ResponseCode == aurora.ResponseCode_OK { + if ok, monitorErr := monitor.Instances(auroraJob.JobKey(), auroraJob.GetInstanceCount(), 5, 50); !ok || monitorErr != nil { + if _, jobErr := r.KillJob(auroraJob.JobKey()); jobErr != + nil { + fmt.Println(jobErr) + os.Exit(1) + } else { + fmt.Println("ok: ", ok) + fmt.Println("jobErr: ", jobErr) + } + } + } + } } - - jsonJob := new(JobJson) - - err = json.NewDecoder(file).Decode(jsonJob) - if err != nil { - fmt.Println("Error parsing file ", err) - os.Exit(1) - } - - jsonJob.Validate() - - //Create new configuration with default transport layer - config, err := realis.NewDefaultConfig("http://192.168.33.7:8081") - if err != nil { - fmt.Print(err) - os.Exit(1) - } - - realis.AddBasicAuth(&config, "aurora", "secret") - r := realis.NewClient(config) - - auroraJob := realis.NewJob(). - Environment("prod"). - Role("vagrant"). - Name(jsonJob.Name). - CPU(jsonJob.CPU). - RAM(jsonJob.RAM). - Disk(jsonJob.Disk). - ExecutorName(jsonJob.Executor). - InstanceCount(jsonJob.Instances). - IsService(jsonJob.Service). - AddPorts(jsonJob.Ports) - - for _, uri := range jsonJob.URIs { - auroraJob.AddURIs(uri.Extract, uri.Cache, uri.URI) - } - - for k, v := range jsonJob.Labels { - auroraJob.AddLabel(k, v) - } - - resp, err := r.CreateJob(auroraJob) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - fmt.Println(resp) } diff --git a/gen-go/apache/aurora/GoUnusedProtection__.go b/gen-go/apache/aurora/GoUnusedProtection__.go new file mode 100644 index 0000000..462b3b4 --- /dev/null +++ b/gen-go/apache/aurora/GoUnusedProtection__.go @@ -0,0 +1,6 @@ +// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT. + +package aurora + +var GoUnusedProtection__ int; + diff --git a/gen-go/apache/aurora/auroraAPI-consts.go b/gen-go/apache/aurora/auroraAPI-consts.go new file mode 100644 index 0000000..d4a319e --- /dev/null +++ b/gen-go/apache/aurora/auroraAPI-consts.go @@ -0,0 +1,53 @@ +// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT. + +package aurora + +import( + "bytes" + "context" + "fmt" + "time" + "github.com/apache/thrift/lib/go/thrift" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = context.Background +var _ = time.Now +var _ = bytes.Equal + +const AURORA_EXECUTOR_NAME = "AuroraExecutor" +var ACTIVE_STATES []ScheduleStatus +var SLAVE_ASSIGNED_STATES []ScheduleStatus +var LIVE_STATES []ScheduleStatus +var TERMINAL_STATES []ScheduleStatus +const GOOD_IDENTIFIER_PATTERN = "^[\\w\\-\\.]+$" +const GOOD_IDENTIFIER_PATTERN_JVM = "^[\\w\\-\\.]+$" +const GOOD_IDENTIFIER_PATTERN_PYTHON = "^[\\w\\-\\.]+$" +var ACTIVE_JOB_UPDATE_STATES []JobUpdateStatus +var AWAITNG_PULSE_JOB_UPDATE_STATES []JobUpdateStatus +const BYPASS_LEADER_REDIRECT_HEADER_NAME = "Bypass-Leader-Redirect" +const TASK_FILESYSTEM_MOUNT_POINT = "taskfs" + +func init() { +ACTIVE_STATES = []ScheduleStatus{ + 9, 17, 6, 0, 13, 12, 2, 1, 18, 16, } + +SLAVE_ASSIGNED_STATES = []ScheduleStatus{ + 9, 17, 6, 13, 12, 2, 18, 1, } + +LIVE_STATES = []ScheduleStatus{ + 6, 13, 12, 17, 18, 2, } + +TERMINAL_STATES = []ScheduleStatus{ + 4, 3, 5, 7, } + +ACTIVE_JOB_UPDATE_STATES = []JobUpdateStatus{ + 0, 1, 2, 3, 9, 10, } + +AWAITNG_PULSE_JOB_UPDATE_STATES = []JobUpdateStatus{ + 9, 10, } + +} + diff --git a/gen-go/apache/aurora/auroraAPI.go b/gen-go/apache/aurora/auroraAPI.go new file mode 100644 index 0000000..914d268 --- /dev/null +++ b/gen-go/apache/aurora/auroraAPI.go @@ -0,0 +1,32711 @@ +// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT. + +package aurora + +import( + "bytes" + "context" + "database/sql/driver" + "errors" + "fmt" + "time" + "github.com/apache/thrift/lib/go/thrift" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = thrift.ZERO +var _ = fmt.Printf +var _ = context.Background +var _ = time.Now +var _ = bytes.Equal + +type ResponseCode int64 +const ( + ResponseCode_INVALID_REQUEST ResponseCode = 0 + ResponseCode_OK ResponseCode = 1 + ResponseCode_ERROR ResponseCode = 2 + ResponseCode_WARNING ResponseCode = 3 + ResponseCode_AUTH_FAILED ResponseCode = 4 + ResponseCode_JOB_UPDATING_ERROR ResponseCode = 5 + ResponseCode_ERROR_TRANSIENT ResponseCode = 6 +) + +func (p ResponseCode) String() string { + switch p { + case ResponseCode_INVALID_REQUEST: return "INVALID_REQUEST" + case ResponseCode_OK: return "OK" + case ResponseCode_ERROR: return "ERROR" + case ResponseCode_WARNING: return "WARNING" + case ResponseCode_AUTH_FAILED: return "AUTH_FAILED" + case ResponseCode_JOB_UPDATING_ERROR: return "JOB_UPDATING_ERROR" + case ResponseCode_ERROR_TRANSIENT: return "ERROR_TRANSIENT" + } + return "" +} + +func ResponseCodeFromString(s string) (ResponseCode, error) { + switch s { + case "INVALID_REQUEST": return ResponseCode_INVALID_REQUEST, nil + case "OK": return ResponseCode_OK, nil + case "ERROR": return ResponseCode_ERROR, nil + case "WARNING": return ResponseCode_WARNING, nil + case "AUTH_FAILED": return ResponseCode_AUTH_FAILED, nil + case "JOB_UPDATING_ERROR": return ResponseCode_JOB_UPDATING_ERROR, nil + case "ERROR_TRANSIENT": return ResponseCode_ERROR_TRANSIENT, nil + } + return ResponseCode(0), fmt.Errorf("not a valid ResponseCode string") +} + + +func ResponseCodePtr(v ResponseCode) *ResponseCode { return &v } + +func (p ResponseCode) MarshalText() ([]byte, error) { +return []byte(p.String()), nil +} + +func (p *ResponseCode) UnmarshalText(text []byte) error { +q, err := ResponseCodeFromString(string(text)) +if (err != nil) { +return err +} +*p = q +return nil +} + +func (p *ResponseCode) Scan(value interface{}) error { +v, ok := value.(int64) +if !ok { +return errors.New("Scan value is not int64") +} +*p = ResponseCode(v) +return nil +} + +func (p * ResponseCode) Value() (driver.Value, error) { + if p == nil { + return nil, nil + } +return int64(*p), nil +} +type MaintenanceMode int64 +const ( + MaintenanceMode_NONE MaintenanceMode = 1 + MaintenanceMode_SCHEDULED MaintenanceMode = 2 + MaintenanceMode_DRAINING MaintenanceMode = 3 + MaintenanceMode_DRAINED MaintenanceMode = 4 +) + +func (p MaintenanceMode) String() string { + switch p { + case MaintenanceMode_NONE: return "NONE" + case MaintenanceMode_SCHEDULED: return "SCHEDULED" + case MaintenanceMode_DRAINING: return "DRAINING" + case MaintenanceMode_DRAINED: return "DRAINED" + } + return "" +} + +func MaintenanceModeFromString(s string) (MaintenanceMode, error) { + switch s { + case "NONE": return MaintenanceMode_NONE, nil + case "SCHEDULED": return MaintenanceMode_SCHEDULED, nil + case "DRAINING": return MaintenanceMode_DRAINING, nil + case "DRAINED": return MaintenanceMode_DRAINED, nil + } + return MaintenanceMode(0), fmt.Errorf("not a valid MaintenanceMode string") +} + + +func MaintenanceModePtr(v MaintenanceMode) *MaintenanceMode { return &v } + +func (p MaintenanceMode) MarshalText() ([]byte, error) { +return []byte(p.String()), nil +} + +func (p *MaintenanceMode) UnmarshalText(text []byte) error { +q, err := MaintenanceModeFromString(string(text)) +if (err != nil) { +return err +} +*p = q +return nil +} + +func (p *MaintenanceMode) Scan(value interface{}) error { +v, ok := value.(int64) +if !ok { +return errors.New("Scan value is not int64") +} +*p = MaintenanceMode(v) +return nil +} + +func (p * MaintenanceMode) Value() (driver.Value, error) { + if p == nil { + return nil, nil + } +return int64(*p), nil +} +//The mode for a volume mount +type Mode int64 +const ( + Mode_RW Mode = 1 + Mode_RO Mode = 2 +) + +func (p Mode) String() string { + switch p { + case Mode_RW: return "RW" + case Mode_RO: return "RO" + } + return "" +} + +func ModeFromString(s string) (Mode, error) { + switch s { + case "RW": return Mode_RW, nil + case "RO": return Mode_RO, nil + } + return Mode(0), fmt.Errorf("not a valid Mode string") +} + + +func ModePtr(v Mode) *Mode { return &v } + +func (p Mode) MarshalText() ([]byte, error) { +return []byte(p.String()), nil +} + +func (p *Mode) UnmarshalText(text []byte) error { +q, err := ModeFromString(string(text)) +if (err != nil) { +return err +} +*p = q +return nil +} + +func (p *Mode) Scan(value interface{}) error { +v, ok := value.(int64) +if !ok { +return errors.New("Scan value is not int64") +} +*p = Mode(v) +return nil +} + +func (p * Mode) Value() (driver.Value, error) { + if p == nil { + return nil, nil + } +return int64(*p), nil +} +//Defines the policy for launching a new cron job when one is already running. +type CronCollisionPolicy int64 +const ( + CronCollisionPolicy_KILL_EXISTING CronCollisionPolicy = 0 + CronCollisionPolicy_CANCEL_NEW CronCollisionPolicy = 1 + CronCollisionPolicy_RUN_OVERLAP CronCollisionPolicy = 2 +) + +func (p CronCollisionPolicy) String() string { + switch p { + case CronCollisionPolicy_KILL_EXISTING: return "KILL_EXISTING" + case CronCollisionPolicy_CANCEL_NEW: return "CANCEL_NEW" + case CronCollisionPolicy_RUN_OVERLAP: return "RUN_OVERLAP" + } + return "" +} + +func CronCollisionPolicyFromString(s string) (CronCollisionPolicy, error) { + switch s { + case "KILL_EXISTING": return CronCollisionPolicy_KILL_EXISTING, nil + case "CANCEL_NEW": return CronCollisionPolicy_CANCEL_NEW, nil + case "RUN_OVERLAP": return CronCollisionPolicy_RUN_OVERLAP, nil + } + return CronCollisionPolicy(0), fmt.Errorf("not a valid CronCollisionPolicy string") +} + + +func CronCollisionPolicyPtr(v CronCollisionPolicy) *CronCollisionPolicy { return &v } + +func (p CronCollisionPolicy) MarshalText() ([]byte, error) { +return []byte(p.String()), nil +} + +func (p *CronCollisionPolicy) UnmarshalText(text []byte) error { +q, err := CronCollisionPolicyFromString(string(text)) +if (err != nil) { +return err +} +*p = q +return nil +} + +func (p *CronCollisionPolicy) Scan(value interface{}) error { +v, ok := value.(int64) +if !ok { +return errors.New("Scan value is not int64") +} +*p = CronCollisionPolicy(v) +return nil +} + +func (p * CronCollisionPolicy) Value() (driver.Value, error) { + if p == nil { + return nil, nil + } +return int64(*p), nil +} +//States that a task may be in. +type ScheduleStatus int64 +const ( + ScheduleStatus_INIT ScheduleStatus = 11 + ScheduleStatus_THROTTLED ScheduleStatus = 16 + ScheduleStatus_PENDING ScheduleStatus = 0 + ScheduleStatus_ASSIGNED ScheduleStatus = 9 + ScheduleStatus_STARTING ScheduleStatus = 1 + ScheduleStatus_RUNNING ScheduleStatus = 2 + ScheduleStatus_FINISHED ScheduleStatus = 3 + ScheduleStatus_PREEMPTING ScheduleStatus = 13 + ScheduleStatus_RESTARTING ScheduleStatus = 12 + ScheduleStatus_DRAINING ScheduleStatus = 17 + ScheduleStatus_FAILED ScheduleStatus = 4 + ScheduleStatus_KILLED ScheduleStatus = 5 + ScheduleStatus_KILLING ScheduleStatus = 6 + ScheduleStatus_LOST ScheduleStatus = 7 + ScheduleStatus_PARTITIONED ScheduleStatus = 18 +) + +func (p ScheduleStatus) String() string { + switch p { + case ScheduleStatus_INIT: return "INIT" + case ScheduleStatus_THROTTLED: return "THROTTLED" + case ScheduleStatus_PENDING: return "PENDING" + case ScheduleStatus_ASSIGNED: return "ASSIGNED" + case ScheduleStatus_STARTING: return "STARTING" + case ScheduleStatus_RUNNING: return "RUNNING" + case ScheduleStatus_FINISHED: return "FINISHED" + case ScheduleStatus_PREEMPTING: return "PREEMPTING" + case ScheduleStatus_RESTARTING: return "RESTARTING" + case ScheduleStatus_DRAINING: return "DRAINING" + case ScheduleStatus_FAILED: return "FAILED" + case ScheduleStatus_KILLED: return "KILLED" + case ScheduleStatus_KILLING: return "KILLING" + case ScheduleStatus_LOST: return "LOST" + case ScheduleStatus_PARTITIONED: return "PARTITIONED" + } + return "" +} + +func ScheduleStatusFromString(s string) (ScheduleStatus, error) { + switch s { + case "INIT": return ScheduleStatus_INIT, nil + case "THROTTLED": return ScheduleStatus_THROTTLED, nil + case "PENDING": return ScheduleStatus_PENDING, nil + case "ASSIGNED": return ScheduleStatus_ASSIGNED, nil + case "STARTING": return ScheduleStatus_STARTING, nil + case "RUNNING": return ScheduleStatus_RUNNING, nil + case "FINISHED": return ScheduleStatus_FINISHED, nil + case "PREEMPTING": return ScheduleStatus_PREEMPTING, nil + case "RESTARTING": return ScheduleStatus_RESTARTING, nil + case "DRAINING": return ScheduleStatus_DRAINING, nil + case "FAILED": return ScheduleStatus_FAILED, nil + case "KILLED": return ScheduleStatus_KILLED, nil + case "KILLING": return ScheduleStatus_KILLING, nil + case "LOST": return ScheduleStatus_LOST, nil + case "PARTITIONED": return ScheduleStatus_PARTITIONED, nil + } + return ScheduleStatus(0), fmt.Errorf("not a valid ScheduleStatus string") +} + + +func ScheduleStatusPtr(v ScheduleStatus) *ScheduleStatus { return &v } + +func (p ScheduleStatus) MarshalText() ([]byte, error) { +return []byte(p.String()), nil +} + +func (p *ScheduleStatus) UnmarshalText(text []byte) error { +q, err := ScheduleStatusFromString(string(text)) +if (err != nil) { +return err +} +*p = q +return nil +} + +func (p *ScheduleStatus) Scan(value interface{}) error { +v, ok := value.(int64) +if !ok { +return errors.New("Scan value is not int64") +} +*p = ScheduleStatus(v) +return nil +} + +func (p * ScheduleStatus) Value() (driver.Value, error) { + if p == nil { + return nil, nil + } +return int64(*p), nil +} +//States that a job update may be in. +type JobUpdateStatus int64 +const ( + JobUpdateStatus_ROLLING_FORWARD JobUpdateStatus = 0 + JobUpdateStatus_ROLLING_BACK JobUpdateStatus = 1 + JobUpdateStatus_ROLL_FORWARD_PAUSED JobUpdateStatus = 2 + JobUpdateStatus_ROLL_BACK_PAUSED JobUpdateStatus = 3 + JobUpdateStatus_ROLLED_FORWARD JobUpdateStatus = 4 + JobUpdateStatus_ROLLED_BACK JobUpdateStatus = 5 + JobUpdateStatus_ABORTED JobUpdateStatus = 6 + JobUpdateStatus_ERROR JobUpdateStatus = 7 + JobUpdateStatus_FAILED JobUpdateStatus = 8 + JobUpdateStatus_ROLL_FORWARD_AWAITING_PULSE JobUpdateStatus = 9 + JobUpdateStatus_ROLL_BACK_AWAITING_PULSE JobUpdateStatus = 10 +) + +func (p JobUpdateStatus) String() string { + switch p { + case JobUpdateStatus_ROLLING_FORWARD: return "ROLLING_FORWARD" + case JobUpdateStatus_ROLLING_BACK: return "ROLLING_BACK" + case JobUpdateStatus_ROLL_FORWARD_PAUSED: return "ROLL_FORWARD_PAUSED" + case JobUpdateStatus_ROLL_BACK_PAUSED: return "ROLL_BACK_PAUSED" + case JobUpdateStatus_ROLLED_FORWARD: return "ROLLED_FORWARD" + case JobUpdateStatus_ROLLED_BACK: return "ROLLED_BACK" + case JobUpdateStatus_ABORTED: return "ABORTED" + case JobUpdateStatus_ERROR: return "ERROR" + case JobUpdateStatus_FAILED: return "FAILED" + case JobUpdateStatus_ROLL_FORWARD_AWAITING_PULSE: return "ROLL_FORWARD_AWAITING_PULSE" + case JobUpdateStatus_ROLL_BACK_AWAITING_PULSE: return "ROLL_BACK_AWAITING_PULSE" + } + return "" +} + +func JobUpdateStatusFromString(s string) (JobUpdateStatus, error) { + switch s { + case "ROLLING_FORWARD": return JobUpdateStatus_ROLLING_FORWARD, nil + case "ROLLING_BACK": return JobUpdateStatus_ROLLING_BACK, nil + case "ROLL_FORWARD_PAUSED": return JobUpdateStatus_ROLL_FORWARD_PAUSED, nil + case "ROLL_BACK_PAUSED": return JobUpdateStatus_ROLL_BACK_PAUSED, nil + case "ROLLED_FORWARD": return JobUpdateStatus_ROLLED_FORWARD, nil + case "ROLLED_BACK": return JobUpdateStatus_ROLLED_BACK, nil + case "ABORTED": return JobUpdateStatus_ABORTED, nil + case "ERROR": return JobUpdateStatus_ERROR, nil + case "FAILED": return JobUpdateStatus_FAILED, nil + case "ROLL_FORWARD_AWAITING_PULSE": return JobUpdateStatus_ROLL_FORWARD_AWAITING_PULSE, nil + case "ROLL_BACK_AWAITING_PULSE": return JobUpdateStatus_ROLL_BACK_AWAITING_PULSE, nil + } + return JobUpdateStatus(0), fmt.Errorf("not a valid JobUpdateStatus string") +} + + +func JobUpdateStatusPtr(v JobUpdateStatus) *JobUpdateStatus { return &v } + +func (p JobUpdateStatus) MarshalText() ([]byte, error) { +return []byte(p.String()), nil +} + +func (p *JobUpdateStatus) UnmarshalText(text []byte) error { +q, err := JobUpdateStatusFromString(string(text)) +if (err != nil) { +return err +} +*p = q +return nil +} + +func (p *JobUpdateStatus) Scan(value interface{}) error { +v, ok := value.(int64) +if !ok { +return errors.New("Scan value is not int64") +} +*p = JobUpdateStatus(v) +return nil +} + +func (p * JobUpdateStatus) Value() (driver.Value, error) { + if p == nil { + return nil, nil + } +return int64(*p), nil +} +//Job update actions that can be applied to job instances. +type JobUpdateAction int64 +const ( + JobUpdateAction_INSTANCE_UPDATED JobUpdateAction = 1 + JobUpdateAction_INSTANCE_ROLLED_BACK JobUpdateAction = 2 + JobUpdateAction_INSTANCE_UPDATING JobUpdateAction = 3 + JobUpdateAction_INSTANCE_ROLLING_BACK JobUpdateAction = 4 + JobUpdateAction_INSTANCE_UPDATE_FAILED JobUpdateAction = 5 + JobUpdateAction_INSTANCE_ROLLBACK_FAILED JobUpdateAction = 6 +) + +func (p JobUpdateAction) String() string { + switch p { + case JobUpdateAction_INSTANCE_UPDATED: return "INSTANCE_UPDATED" + case JobUpdateAction_INSTANCE_ROLLED_BACK: return "INSTANCE_ROLLED_BACK" + case JobUpdateAction_INSTANCE_UPDATING: return "INSTANCE_UPDATING" + case JobUpdateAction_INSTANCE_ROLLING_BACK: return "INSTANCE_ROLLING_BACK" + case JobUpdateAction_INSTANCE_UPDATE_FAILED: return "INSTANCE_UPDATE_FAILED" + case JobUpdateAction_INSTANCE_ROLLBACK_FAILED: return "INSTANCE_ROLLBACK_FAILED" + } + return "" +} + +func JobUpdateActionFromString(s string) (JobUpdateAction, error) { + switch s { + case "INSTANCE_UPDATED": return JobUpdateAction_INSTANCE_UPDATED, nil + case "INSTANCE_ROLLED_BACK": return JobUpdateAction_INSTANCE_ROLLED_BACK, nil + case "INSTANCE_UPDATING": return JobUpdateAction_INSTANCE_UPDATING, nil + case "INSTANCE_ROLLING_BACK": return JobUpdateAction_INSTANCE_ROLLING_BACK, nil + case "INSTANCE_UPDATE_FAILED": return JobUpdateAction_INSTANCE_UPDATE_FAILED, nil + case "INSTANCE_ROLLBACK_FAILED": return JobUpdateAction_INSTANCE_ROLLBACK_FAILED, nil + } + return JobUpdateAction(0), fmt.Errorf("not a valid JobUpdateAction string") +} + + +func JobUpdateActionPtr(v JobUpdateAction) *JobUpdateAction { return &v } + +func (p JobUpdateAction) MarshalText() ([]byte, error) { +return []byte(p.String()), nil +} + +func (p *JobUpdateAction) UnmarshalText(text []byte) error { +q, err := JobUpdateActionFromString(string(text)) +if (err != nil) { +return err +} +*p = q +return nil +} + +func (p *JobUpdateAction) Scan(value interface{}) error { +v, ok := value.(int64) +if !ok { +return errors.New("Scan value is not int64") +} +*p = JobUpdateAction(v) +return nil +} + +func (p * JobUpdateAction) Value() (driver.Value, error) { + if p == nil { + return nil, nil + } +return int64(*p), nil +} +//Status of the coordinated update. Intended as a response to pulseJobUpdate RPC. +type JobUpdatePulseStatus int64 +const ( + JobUpdatePulseStatus_OK JobUpdatePulseStatus = 1 + JobUpdatePulseStatus_FINISHED JobUpdatePulseStatus = 2 +) + +func (p JobUpdatePulseStatus) String() string { + switch p { + case JobUpdatePulseStatus_OK: return "OK" + case JobUpdatePulseStatus_FINISHED: return "FINISHED" + } + return "" +} + +func JobUpdatePulseStatusFromString(s string) (JobUpdatePulseStatus, error) { + switch s { + case "OK": return JobUpdatePulseStatus_OK, nil + case "FINISHED": return JobUpdatePulseStatus_FINISHED, nil + } + return JobUpdatePulseStatus(0), fmt.Errorf("not a valid JobUpdatePulseStatus string") +} + + +func JobUpdatePulseStatusPtr(v JobUpdatePulseStatus) *JobUpdatePulseStatus { return &v } + +func (p JobUpdatePulseStatus) MarshalText() ([]byte, error) { +return []byte(p.String()), nil +} + +func (p *JobUpdatePulseStatus) UnmarshalText(text []byte) error { +q, err := JobUpdatePulseStatusFromString(string(text)) +if (err != nil) { +return err +} +*p = q +return nil +} + +func (p *JobUpdatePulseStatus) Scan(value interface{}) error { +v, ok := value.(int64) +if !ok { +return errors.New("Scan value is not int64") +} +*p = JobUpdatePulseStatus(v) +return nil +} + +func (p * JobUpdatePulseStatus) Value() (driver.Value, error) { + if p == nil { + return nil, nil + } +return int64(*p), nil +} +// Attributes: +// - User +type Identity struct { + // unused field # 1 + User string `thrift:"user,2" db:"user" json:"user"` +} + +func NewIdentity() *Identity { + return &Identity{} +} + + +func (p *Identity) GetUser() string { + return p.User +} +func (p *Identity) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *Identity) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.User = v +} + return nil +} + +func (p *Identity) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Identity"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *Identity) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "user", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:user: ", p), err) } + if err := oprot.WriteString(ctx, string(p.User)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.user (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:user: ", p), err) } + return err +} + +func (p *Identity) Equals(other *Identity) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.User != other.User { return false } + return true +} + +func (p *Identity) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Identity(%+v)", *p) +} + +// A single host attribute. +// +// Attributes: +// - Name +// - Values +type Attribute struct { + Name string `thrift:"name,1" db:"name" json:"name"` + Values []string `thrift:"values,2" db:"values" json:"values"` +} + +func NewAttribute() *Attribute { + return &Attribute{} +} + + +func (p *Attribute) GetName() string { + return p.Name +} + +func (p *Attribute) GetValues() []string { + return p.Values +} +func (p *Attribute) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.SET { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *Attribute) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Name = v +} + return nil +} + +func (p *Attribute) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]string, 0, size) + p.Values = tSet + for i := 0; i < size; i ++ { +var _elem0 string + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _elem0 = v +} + p.Values = append(p.Values, _elem0) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *Attribute) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Attribute"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *Attribute) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } + return err +} + +func (p *Attribute) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "values", thrift.SET, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:values: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRING, len(p.Values)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("Attribute(%+v)", *p) +} + +// The attributes assigned to a host. +// +// Attributes: +// - Host +// - Attributes +// - Mode +// - SlaveId +type HostAttributes struct { + Host string `thrift:"host,1" db:"host" json:"host"` + Attributes []*Attribute `thrift:"attributes,2" db:"attributes" json:"attributes"` + Mode *MaintenanceMode `thrift:"mode,3" db:"mode" json:"mode,omitempty"` + SlaveId *string `thrift:"slaveId,4" db:"slaveId" json:"slaveId,omitempty"` +} + +func NewHostAttributes() *HostAttributes { + return &HostAttributes{} +} + + +func (p *HostAttributes) GetHost() string { + return p.Host +} + +func (p *HostAttributes) GetAttributes() []*Attribute { + return p.Attributes +} +var HostAttributes_Mode_DEFAULT MaintenanceMode +func (p *HostAttributes) GetMode() MaintenanceMode { + if !p.IsSetMode() { + return HostAttributes_Mode_DEFAULT + } +return *p.Mode +} +var HostAttributes_SlaveId_DEFAULT string +func (p *HostAttributes) GetSlaveId() string { + if !p.IsSetSlaveId() { + return HostAttributes_SlaveId_DEFAULT + } +return *p.SlaveId +} +func (p *HostAttributes) IsSetMode() bool { + return p.Mode != nil +} + +func (p *HostAttributes) IsSetSlaveId() bool { + return p.SlaveId != nil +} + +func (p *HostAttributes) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.SET { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.I32 { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.STRING { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *HostAttributes) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Host = v +} + return nil +} + +func (p *HostAttributes) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*Attribute, 0, size) + p.Attributes = tSet + for i := 0; i < size; i ++ { + _elem2 := &Attribute{} + if err := _elem2.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem2), err) + } + p.Attributes = append(p.Attributes, _elem2) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *HostAttributes) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + temp := MaintenanceMode(v) + p.Mode = &temp +} + return nil +} + +func (p *HostAttributes) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 4: ", err) +} else { + p.SlaveId = &v +} + return nil +} + +func (p *HostAttributes) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "HostAttributes"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *HostAttributes) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "host", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:host: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Host)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.host (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:host: ", p), err) } + return err +} + +func (p *HostAttributes) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "attributes", thrift.SET, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:attributes: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Attributes)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("HostAttributes(%+v)", *p) +} + +// A constraint that specifies an explicit set of values, at least one of which must be present +// on a host for a task to be scheduled there. +// +// Attributes: +// - Negated: If true, treat this as a 'not' - to avoid specific values. +// - Values +type ValueConstraint struct { + Negated bool `thrift:"negated,1" db:"negated" json:"negated"` + Values []string `thrift:"values,2" db:"values" json:"values"` +} + +func NewValueConstraint() *ValueConstraint { + return &ValueConstraint{} +} + + +func (p *ValueConstraint) GetNegated() bool { + return p.Negated +} + +func (p *ValueConstraint) GetValues() []string { + return p.Values +} +func (p *ValueConstraint) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.BOOL { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.SET { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ValueConstraint) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Negated = v +} + return nil +} + +func (p *ValueConstraint) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]string, 0, size) + p.Values = tSet + for i := 0; i < size; i ++ { +var _elem4 string + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _elem4 = v +} + p.Values = append(p.Values, _elem4) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *ValueConstraint) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ValueConstraint"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ValueConstraint) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "negated", thrift.BOOL, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:negated: ", p), err) } + if err := oprot.WriteBool(ctx, bool(p.Negated)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.negated (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:negated: ", p), err) } + return err +} + +func (p *ValueConstraint) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "values", thrift.SET, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:values: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRING, len(p.Values)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("ValueConstraint(%+v)", *p) +} + +// A constraint the specifies the maximum number of active tasks on a host with a matching +// attribute that may be scheduled simultaneously. +// +// Attributes: +// - Limit +type LimitConstraint struct { + Limit int32 `thrift:"limit,1" db:"limit" json:"limit"` +} + +func NewLimitConstraint() *LimitConstraint { + return &LimitConstraint{} +} + + +func (p *LimitConstraint) GetLimit() int32 { + return p.Limit +} +func (p *LimitConstraint) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *LimitConstraint) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Limit = v +} + return nil +} + +func (p *LimitConstraint) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "LimitConstraint"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *LimitConstraint) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "limit", thrift.I32, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:limit: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.Limit)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.limit (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:limit: ", p), err) } + return err +} + +func (p *LimitConstraint) Equals(other *LimitConstraint) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Limit != other.Limit { return false } + return true +} + +func (p *LimitConstraint) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("LimitConstraint(%+v)", *p) +} + +// Types of constraints that may be applied to a task. +// +// Attributes: +// - Value +// - Limit +type TaskConstraint struct { + Value *ValueConstraint `thrift:"value,1" db:"value" json:"value,omitempty"` + Limit *LimitConstraint `thrift:"limit,2" db:"limit" json:"limit,omitempty"` +} + +func NewTaskConstraint() *TaskConstraint { + return &TaskConstraint{} +} + +var TaskConstraint_Value_DEFAULT *ValueConstraint +func (p *TaskConstraint) GetValue() *ValueConstraint { + if !p.IsSetValue() { + return TaskConstraint_Value_DEFAULT + } +return p.Value +} +var TaskConstraint_Limit_DEFAULT *LimitConstraint +func (p *TaskConstraint) GetLimit() *LimitConstraint { + if !p.IsSetLimit() { + return TaskConstraint_Limit_DEFAULT + } +return p.Limit +} +func (p *TaskConstraint) CountSetFieldsTaskConstraint() int { + count := 0 + if (p.IsSetValue()) { + count++ + } + if (p.IsSetLimit()) { + count++ + } + return count + +} + +func (p *TaskConstraint) IsSetValue() bool { + return p.Value != nil +} + +func (p *TaskConstraint) IsSetLimit() bool { + return p.Limit != nil +} + +func (p *TaskConstraint) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TaskConstraint) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Value = &ValueConstraint{} + if err := p.Value.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Value), err) + } + return nil +} + +func (p *TaskConstraint) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.Limit = &LimitConstraint{} + if err := p.Limit.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Limit), err) + } + return nil +} + +func (p *TaskConstraint) Write(ctx context.Context, oprot thrift.TProtocol) error { + if c := p.CountSetFieldsTaskConstraint(); c != 1 { + return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) + } + if err := oprot.WriteStructBegin(ctx, "TaskConstraint"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TaskConstraint) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetValue() { + if err := oprot.WriteFieldBegin(ctx, "value", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } + if err := p.Value.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Value), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } + } + return err +} + +func (p *TaskConstraint) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetLimit() { + if err := oprot.WriteFieldBegin(ctx, "limit", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:limit: ", p), err) } + if err := p.Limit.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Limit), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:limit: ", p), err) } + } + return err +} + +func (p *TaskConstraint) Equals(other *TaskConstraint) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Value.Equals(other.Value) { return false } + if !p.Limit.Equals(other.Limit) { return false } + return true +} + +func (p *TaskConstraint) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TaskConstraint(%+v)", *p) +} + +// A constraint that defines whether a task may be scheduled on a host. +// +// Attributes: +// - Name: Mesos slave attribute that the constraint is matched against. +// - Constraint +type Constraint struct { + Name string `thrift:"name,1" db:"name" json:"name"` + Constraint *TaskConstraint `thrift:"constraint,2" db:"constraint" json:"constraint"` +} + +func NewConstraint() *Constraint { + return &Constraint{} +} + + +func (p *Constraint) GetName() string { + return p.Name +} +var Constraint_Constraint_DEFAULT *TaskConstraint +func (p *Constraint) GetConstraint() *TaskConstraint { + if !p.IsSetConstraint() { + return Constraint_Constraint_DEFAULT + } +return p.Constraint +} +func (p *Constraint) IsSetConstraint() bool { + return p.Constraint != nil +} + +func (p *Constraint) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *Constraint) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Name = v +} + return nil +} + +func (p *Constraint) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.Constraint = &TaskConstraint{} + if err := p.Constraint.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Constraint), err) + } + return nil +} + +func (p *Constraint) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Constraint"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *Constraint) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } + return err +} + +func (p *Constraint) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "constraint", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:constraint: ", p), err) } + if err := p.Constraint.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Constraint), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:constraint: ", p), err) } + return err +} + +func (p *Constraint) Equals(other *Constraint) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Name != other.Name { return false } + if !p.Constraint.Equals(other.Constraint) { return false } + return true +} + +func (p *Constraint) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Constraint(%+v)", *p) +} + +// Attributes: +// - Role +// - Name +// - Version +type Package struct { + Role string `thrift:"role,1" db:"role" json:"role"` + Name string `thrift:"name,2" db:"name" json:"name"` + Version int32 `thrift:"version,3" db:"version" json:"version"` +} + +func NewPackage() *Package { + return &Package{} +} + + +func (p *Package) GetRole() string { + return p.Role +} + +func (p *Package) GetName() string { + return p.Name +} + +func (p *Package) GetVersion() int32 { + return p.Version +} +func (p *Package) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.I32 { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *Package) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Role = v +} + return nil +} + +func (p *Package) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.Name = v +} + return nil +} + +func (p *Package) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.Version = v +} + return nil +} + +func (p *Package) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Package"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *Package) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "role", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:role: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Role)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.role (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:role: ", p), err) } + return err +} + +func (p *Package) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:name: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.name (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:name: ", p), err) } + return err +} + +func (p *Package) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "version", thrift.I32, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:version: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.Version)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.version (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:version: ", p), err) } + return err +} + +func (p *Package) Equals(other *Package) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Role != other.Role { return false } + if p.Name != other.Name { return false } + if p.Version != other.Version { return false } + return true +} + +func (p *Package) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Package(%+v)", *p) +} + +// Arbitrary key-value metadata to be included into TaskConfig. +// +// Attributes: +// - Key +// - Value +type Metadata struct { + Key string `thrift:"key,1" db:"key" json:"key"` + Value string `thrift:"value,2" db:"value" json:"value"` +} + +func NewMetadata() *Metadata { + return &Metadata{} +} + + +func (p *Metadata) GetKey() string { + return p.Key +} + +func (p *Metadata) GetValue() string { + return p.Value +} +func (p *Metadata) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *Metadata) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Key = v +} + return nil +} + +func (p *Metadata) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.Value = v +} + return nil +} + +func (p *Metadata) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Metadata"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *Metadata) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Key)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.key (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } + return err +} + +func (p *Metadata) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "value", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:value: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Value)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.value (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:value: ", p), err) } + return err +} + +func (p *Metadata) Equals(other *Metadata) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Key != other.Key { return false } + if p.Value != other.Value { return false } + return true +} + +func (p *Metadata) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Metadata(%+v)", *p) +} + +// A unique identifier for a Job. +// +// Attributes: +// - Role: User role (Unix service account), for example "mesos" +// - Environment: Environment, for example "devel" +// - Name: Name, for example "labrat" +type JobKey struct { + Role string `thrift:"role,1" db:"role" json:"role"` + Environment string `thrift:"environment,2" db:"environment" json:"environment"` + Name string `thrift:"name,3" db:"name" json:"name"` +} + +func NewJobKey() *JobKey { + return &JobKey{} +} + + +func (p *JobKey) GetRole() string { + return p.Role +} + +func (p *JobKey) GetEnvironment() string { + return p.Environment +} + +func (p *JobKey) GetName() string { + return p.Name +} +func (p *JobKey) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRING { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JobKey) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Role = v +} + return nil +} + +func (p *JobKey) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.Environment = v +} + return nil +} + +func (p *JobKey) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.Name = v +} + return nil +} + +func (p *JobKey) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobKey"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JobKey) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "role", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:role: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Role)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.role (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:role: ", p), err) } + return err +} + +func (p *JobKey) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "environment", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:environment: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Environment)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.environment (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:environment: ", p), err) } + return err +} + +func (p *JobKey) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:name: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.name (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:name: ", p), err) } + return err +} + +func (p *JobKey) Equals(other *JobKey) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Role != other.Role { return false } + if p.Environment != other.Environment { return false } + if p.Name != other.Name { return false } + return true +} + +func (p *JobKey) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("JobKey(%+v)", *p) +} + +// A unique lock key. +// +// Attributes: +// - Job +type LockKey struct { + Job *JobKey `thrift:"job,1" db:"job" json:"job,omitempty"` +} + +func NewLockKey() *LockKey { + return &LockKey{} +} + +var LockKey_Job_DEFAULT *JobKey +func (p *LockKey) GetJob() *JobKey { + if !p.IsSetJob() { + return LockKey_Job_DEFAULT + } +return p.Job +} +func (p *LockKey) CountSetFieldsLockKey() int { + count := 0 + if (p.IsSetJob()) { + count++ + } + return count + +} + +func (p *LockKey) IsSetJob() bool { + return p.Job != nil +} + +func (p *LockKey) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *LockKey) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Job = &JobKey{} + if err := p.Job.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) + } + return nil +} + +func (p *LockKey) Write(ctx context.Context, oprot thrift.TProtocol) error { + if c := p.CountSetFieldsLockKey(); c != 1 { + return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) + } + if err := oprot.WriteStructBegin(ctx, "LockKey"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *LockKey) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetJob() { + if err := oprot.WriteFieldBegin(ctx, "job", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:job: ", p), err) } + if err := p.Job.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:job: ", p), err) } + } + return err +} + +func (p *LockKey) Equals(other *LockKey) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Job.Equals(other.Job) { return false } + return true +} + +func (p *LockKey) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("LockKey(%+v)", *p) +} + +// A generic lock struct to facilitate context specific resource/operation serialization. +// +// Attributes: +// - Key: ID of the lock - unique per storage +// - Token: UUID - facilitating soft lock authorization +// - User: Lock creator +// - TimestampMs: Lock creation timestamp in milliseconds +// - Message: Optional message to record with the lock +type Lock struct { + Key *LockKey `thrift:"key,1" db:"key" json:"key"` + Token string `thrift:"token,2" db:"token" json:"token"` + User string `thrift:"user,3" db:"user" json:"user"` + TimestampMs int64 `thrift:"timestampMs,4" db:"timestampMs" json:"timestampMs"` + Message *string `thrift:"message,5" db:"message" json:"message,omitempty"` +} + +func NewLock() *Lock { + return &Lock{} +} + +var Lock_Key_DEFAULT *LockKey +func (p *Lock) GetKey() *LockKey { + if !p.IsSetKey() { + return Lock_Key_DEFAULT + } +return p.Key +} + +func (p *Lock) GetToken() string { + return p.Token +} + +func (p *Lock) GetUser() string { + return p.User +} + +func (p *Lock) GetTimestampMs() int64 { + return p.TimestampMs +} +var Lock_Message_DEFAULT string +func (p *Lock) GetMessage() string { + if !p.IsSetMessage() { + return Lock_Message_DEFAULT + } +return *p.Message +} +func (p *Lock) IsSetKey() bool { + return p.Key != nil +} + +func (p *Lock) IsSetMessage() bool { + return p.Message != nil +} + +func (p *Lock) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRING { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.I64 { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 5: + if fieldTypeId == thrift.STRING { + if err := p.ReadField5(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *Lock) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Key = &LockKey{} + if err := p.Key.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) + } + return nil +} + +func (p *Lock) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.Token = v +} + return nil +} + +func (p *Lock) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.User = v +} + return nil +} + +func (p *Lock) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 4: ", err) +} else { + p.TimestampMs = v +} + return nil +} + +func (p *Lock) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 5: ", err) +} else { + p.Message = &v +} + return nil +} + +func (p *Lock) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Lock"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *Lock) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } + if err := p.Key.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } + return err +} + +func (p *Lock) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "token", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:token: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Token)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.token (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:token: ", p), err) } + return err +} + +func (p *Lock) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "user", thrift.STRING, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:user: ", p), err) } + if err := oprot.WriteString(ctx, string(p.User)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.user (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:user: ", p), err) } + return err +} + +func (p *Lock) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "timestampMs", thrift.I64, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:timestampMs: ", p), err) } + if err := oprot.WriteI64(ctx, int64(p.TimestampMs)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.timestampMs (4) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:timestampMs: ", p), err) } + return err +} + +func (p *Lock) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetMessage() { + if err := oprot.WriteFieldBegin(ctx, "message", thrift.STRING, 5); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:message: ", p), err) } + if err := oprot.WriteString(ctx, string(*p.Message)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.message (5) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 5:message: ", p), err) } + } + return err +} + +func (p *Lock) Equals(other *Lock) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Key.Equals(other.Key) { return false } + if p.Token != other.Token { return false } + if p.User != other.User { return false } + if p.TimestampMs != other.TimestampMs { return false } + if p.Message != other.Message { + if p.Message == nil || other.Message == nil { + return false + } + if (*p.Message) != (*other.Message) { return false } + } + return true +} + +func (p *Lock) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Lock(%+v)", *p) +} + +// A unique identifier for the active task within a job. +// +// Attributes: +// - JobKey: Key identifying the job. +// - InstanceId: Unique instance ID for the active task in a job. +type InstanceKey struct { + JobKey *JobKey `thrift:"jobKey,1" db:"jobKey" json:"jobKey"` + InstanceId int32 `thrift:"instanceId,2" db:"instanceId" json:"instanceId"` +} + +func NewInstanceKey() *InstanceKey { + return &InstanceKey{} +} + +var InstanceKey_JobKey_DEFAULT *JobKey +func (p *InstanceKey) GetJobKey() *JobKey { + if !p.IsSetJobKey() { + return InstanceKey_JobKey_DEFAULT + } +return p.JobKey +} + +func (p *InstanceKey) GetInstanceId() int32 { + return p.InstanceId +} +func (p *InstanceKey) IsSetJobKey() bool { + return p.JobKey != nil +} + +func (p *InstanceKey) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I32 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *InstanceKey) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.JobKey = &JobKey{} + if err := p.JobKey.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.JobKey), err) + } + return nil +} + +func (p *InstanceKey) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.InstanceId = v +} + return nil +} + +func (p *InstanceKey) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "InstanceKey"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *InstanceKey) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "jobKey", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:jobKey: ", p), err) } + if err := p.JobKey.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.JobKey), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:jobKey: ", p), err) } + return err +} + +func (p *InstanceKey) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instanceId", thrift.I32, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:instanceId: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.InstanceId)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.instanceId (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:instanceId: ", p), err) } + return err +} + +func (p *InstanceKey) Equals(other *InstanceKey) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.JobKey.Equals(other.JobKey) { return false } + if p.InstanceId != other.InstanceId { return false } + return true +} + +func (p *InstanceKey) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("InstanceKey(%+v)", *p) +} + +// URI which mirrors CommandInfo.URI in the Mesos Protobuf +// +// Attributes: +// - Value: Where to get the resource from +// - Extract: Extract compressed archive after downloading +// - Cache: Cache value using Mesos Fetcher caching mechanism * +type MesosFetcherURI struct { + Value string `thrift:"value,1" db:"value" json:"value"` + Extract *bool `thrift:"extract,2" db:"extract" json:"extract,omitempty"` + Cache *bool `thrift:"cache,3" db:"cache" json:"cache,omitempty"` +} + +func NewMesosFetcherURI() *MesosFetcherURI { + return &MesosFetcherURI{} +} + + +func (p *MesosFetcherURI) GetValue() string { + return p.Value +} +var MesosFetcherURI_Extract_DEFAULT bool +func (p *MesosFetcherURI) GetExtract() bool { + if !p.IsSetExtract() { + return MesosFetcherURI_Extract_DEFAULT + } +return *p.Extract +} +var MesosFetcherURI_Cache_DEFAULT bool +func (p *MesosFetcherURI) GetCache() bool { + if !p.IsSetCache() { + return MesosFetcherURI_Cache_DEFAULT + } +return *p.Cache +} +func (p *MesosFetcherURI) IsSetExtract() bool { + return p.Extract != nil +} + +func (p *MesosFetcherURI) IsSetCache() bool { + return p.Cache != nil +} + +func (p *MesosFetcherURI) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.BOOL { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.BOOL { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *MesosFetcherURI) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Value = v +} + return nil +} + +func (p *MesosFetcherURI) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.Extract = &v +} + return nil +} + +func (p *MesosFetcherURI) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.Cache = &v +} + return nil +} + +func (p *MesosFetcherURI) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "MesosFetcherURI"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *MesosFetcherURI) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "value", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Value)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) } + return err +} + +func (p *MesosFetcherURI) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetExtract() { + if err := oprot.WriteFieldBegin(ctx, "extract", thrift.BOOL, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:extract: ", p), err) } + if err := oprot.WriteBool(ctx, bool(*p.Extract)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.extract (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:extract: ", p), err) } + } + return err +} + +func (p *MesosFetcherURI) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetCache() { + if err := oprot.WriteFieldBegin(ctx, "cache", thrift.BOOL, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:cache: ", p), err) } + if err := oprot.WriteBool(ctx, bool(*p.Cache)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.cache (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:cache: ", p), err) } + } + return err +} + +func (p *MesosFetcherURI) Equals(other *MesosFetcherURI) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Value != other.Value { return false } + if p.Extract != other.Extract { + if p.Extract == nil || other.Extract == nil { + return false + } + if (*p.Extract) != (*other.Extract) { return false } + } + if p.Cache != other.Cache { + if p.Cache == nil || other.Cache == nil { + return false + } + if (*p.Cache) != (*other.Cache) { return false } + } + return true +} + +func (p *MesosFetcherURI) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("MesosFetcherURI(%+v)", *p) +} + +// Attributes: +// - Name: Name identifying the Executor. +// - Data: Executor configuration data. +type ExecutorConfig struct { + Name string `thrift:"name,1" db:"name" json:"name"` + Data string `thrift:"data,2" db:"data" json:"data"` +} + +func NewExecutorConfig() *ExecutorConfig { + return &ExecutorConfig{} +} + + +func (p *ExecutorConfig) GetName() string { + return p.Name +} + +func (p *ExecutorConfig) GetData() string { + return p.Data +} +func (p *ExecutorConfig) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ExecutorConfig) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Name = v +} + return nil +} + +func (p *ExecutorConfig) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.Data = v +} + return nil +} + +func (p *ExecutorConfig) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ExecutorConfig"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ExecutorConfig) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } + return err +} + +func (p *ExecutorConfig) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "data", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:data: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Data)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.data (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:data: ", p), err) } + return err +} + +func (p *ExecutorConfig) Equals(other *ExecutorConfig) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Name != other.Name { return false } + if p.Data != other.Data { return false } + return true +} + +func (p *ExecutorConfig) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ExecutorConfig(%+v)", *p) +} + +// A volume mount point within a container +// +// Attributes: +// - ContainerPath: The path inside the container where the mount will be created. +// - HostPath: The path on the host that will serve as the source for the mount. +// - Mode: The access mode +type Volume struct { + ContainerPath string `thrift:"containerPath,1" db:"containerPath" json:"containerPath"` + HostPath string `thrift:"hostPath,2" db:"hostPath" json:"hostPath"` + Mode Mode `thrift:"mode,3" db:"mode" json:"mode"` +} + +func NewVolume() *Volume { + return &Volume{} +} + + +func (p *Volume) GetContainerPath() string { + return p.ContainerPath +} + +func (p *Volume) GetHostPath() string { + return p.HostPath +} + +func (p *Volume) GetMode() Mode { + return p.Mode +} +func (p *Volume) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.I32 { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *Volume) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.ContainerPath = v +} + return nil +} + +func (p *Volume) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.HostPath = v +} + return nil +} + +func (p *Volume) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + temp := Mode(v) + p.Mode = temp +} + return nil +} + +func (p *Volume) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Volume"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *Volume) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "containerPath", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:containerPath: ", p), err) } + if err := oprot.WriteString(ctx, string(p.ContainerPath)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.containerPath (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:containerPath: ", p), err) } + return err +} + +func (p *Volume) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "hostPath", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:hostPath: ", p), err) } + if err := oprot.WriteString(ctx, string(p.HostPath)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.hostPath (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:hostPath: ", p), err) } + return err +} + +func (p *Volume) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "mode", thrift.I32, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:mode: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.Mode)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.mode (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:mode: ", p), err) } + return err +} + +func (p *Volume) Equals(other *Volume) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.ContainerPath != other.ContainerPath { return false } + if p.HostPath != other.HostPath { return false } + if p.Mode != other.Mode { return false } + return true +} + +func (p *Volume) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Volume(%+v)", *p) +} + +// Describes an image for use with the Mesos unified containerizer in the Docker format +// +// Attributes: +// - Name: The name of the image to run +// - Tag: The Docker tag identifying the image +type DockerImage struct { + Name string `thrift:"name,1" db:"name" json:"name"` + Tag string `thrift:"tag,2" db:"tag" json:"tag"` +} + +func NewDockerImage() *DockerImage { + return &DockerImage{} +} + + +func (p *DockerImage) GetName() string { + return p.Name +} + +func (p *DockerImage) GetTag() string { + return p.Tag +} +func (p *DockerImage) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *DockerImage) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Name = v +} + return nil +} + +func (p *DockerImage) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.Tag = v +} + return nil +} + +func (p *DockerImage) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "DockerImage"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *DockerImage) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } + return err +} + +func (p *DockerImage) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "tag", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:tag: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Tag)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.tag (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:tag: ", p), err) } + return err +} + +func (p *DockerImage) Equals(other *DockerImage) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Name != other.Name { return false } + if p.Tag != other.Tag { return false } + return true +} + +func (p *DockerImage) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("DockerImage(%+v)", *p) +} + +// Describes an image for use with the Mesos unified containerizer in the AppC format +// +// Attributes: +// - Name: The name of the image to run +// - ImageId: The appc image id identifying the image +type AppcImage struct { + Name string `thrift:"name,1" db:"name" json:"name"` + ImageId string `thrift:"imageId,2" db:"imageId" json:"imageId"` +} + +func NewAppcImage() *AppcImage { + return &AppcImage{} +} + + +func (p *AppcImage) GetName() string { + return p.Name +} + +func (p *AppcImage) GetImageId() string { + return p.ImageId +} +func (p *AppcImage) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AppcImage) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Name = v +} + return nil +} + +func (p *AppcImage) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.ImageId = v +} + return nil +} + +func (p *AppcImage) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "AppcImage"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AppcImage) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } + return err +} + +func (p *AppcImage) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "imageId", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:imageId: ", p), err) } + if err := oprot.WriteString(ctx, string(p.ImageId)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.imageId (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:imageId: ", p), err) } + return err +} + +func (p *AppcImage) Equals(other *AppcImage) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Name != other.Name { return false } + if p.ImageId != other.ImageId { return false } + return true +} + +func (p *AppcImage) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AppcImage(%+v)", *p) +} + +// Describes an image to be used with the Mesos unified containerizer +// +// Attributes: +// - Docker +// - Appc +type Image struct { + Docker *DockerImage `thrift:"docker,1" db:"docker" json:"docker,omitempty"` + Appc *AppcImage `thrift:"appc,2" db:"appc" json:"appc,omitempty"` +} + +func NewImage() *Image { + return &Image{} +} + +var Image_Docker_DEFAULT *DockerImage +func (p *Image) GetDocker() *DockerImage { + if !p.IsSetDocker() { + return Image_Docker_DEFAULT + } +return p.Docker +} +var Image_Appc_DEFAULT *AppcImage +func (p *Image) GetAppc() *AppcImage { + if !p.IsSetAppc() { + return Image_Appc_DEFAULT + } +return p.Appc +} +func (p *Image) CountSetFieldsImage() int { + count := 0 + if (p.IsSetDocker()) { + count++ + } + if (p.IsSetAppc()) { + count++ + } + return count + +} + +func (p *Image) IsSetDocker() bool { + return p.Docker != nil +} + +func (p *Image) IsSetAppc() bool { + return p.Appc != nil +} + +func (p *Image) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *Image) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Docker = &DockerImage{} + if err := p.Docker.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Docker), err) + } + return nil +} + +func (p *Image) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.Appc = &AppcImage{} + if err := p.Appc.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Appc), err) + } + return nil +} + +func (p *Image) Write(ctx context.Context, oprot thrift.TProtocol) error { + if c := p.CountSetFieldsImage(); c != 1 { + return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) + } + if err := oprot.WriteStructBegin(ctx, "Image"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *Image) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetDocker() { + if err := oprot.WriteFieldBegin(ctx, "docker", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:docker: ", p), err) } + if err := p.Docker.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Docker), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:docker: ", p), err) } + } + return err +} + +func (p *Image) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetAppc() { + if err := oprot.WriteFieldBegin(ctx, "appc", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:appc: ", p), err) } + if err := p.Appc.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Appc), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:appc: ", p), err) } + } + return err +} + +func (p *Image) Equals(other *Image) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Docker.Equals(other.Docker) { return false } + if !p.Appc.Equals(other.Appc) { return false } + return true +} + +func (p *Image) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Image(%+v)", *p) +} + +// Describes a mesos container, this is the default +// +// Attributes: +// - Image: the optional filesystem image to use when launching this task. +// - Volumes: the optional list of volumes to mount into the task. +type MesosContainer struct { + Image *Image `thrift:"image,1" db:"image" json:"image,omitempty"` + Volumes []*Volume `thrift:"volumes,2" db:"volumes" json:"volumes,omitempty"` +} + +func NewMesosContainer() *MesosContainer { + return &MesosContainer{} +} + +var MesosContainer_Image_DEFAULT *Image +func (p *MesosContainer) GetImage() *Image { + if !p.IsSetImage() { + return MesosContainer_Image_DEFAULT + } +return p.Image +} +var MesosContainer_Volumes_DEFAULT []*Volume + +func (p *MesosContainer) GetVolumes() []*Volume { + return p.Volumes +} +func (p *MesosContainer) IsSetImage() bool { + return p.Image != nil +} + +func (p *MesosContainer) IsSetVolumes() bool { + return p.Volumes != nil +} + +func (p *MesosContainer) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.LIST { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *MesosContainer) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Image = &Image{} + if err := p.Image.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Image), err) + } + return nil +} + +func (p *MesosContainer) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]*Volume, 0, size) + p.Volumes = tSlice + for i := 0; i < size; i ++ { + _elem6 := &Volume{} + if err := _elem6.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem6), err) + } + p.Volumes = append(p.Volumes, _elem6) + } + if err := iprot.ReadListEnd(ctx); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *MesosContainer) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "MesosContainer"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *MesosContainer) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetImage() { + if err := oprot.WriteFieldBegin(ctx, "image", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:image: ", p), err) } + if err := p.Image.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Image), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:image: ", p), err) } + } + return err +} + +func (p *MesosContainer) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetVolumes() { + if err := oprot.WriteFieldBegin(ctx, "volumes", thrift.LIST, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:volumes: ", p), err) } + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.Volumes)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.Volumes { + if err := v.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) + } + } + if err := oprot.WriteListEnd(ctx); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:volumes: ", p), err) } + } + return err +} + +func (p *MesosContainer) Equals(other *MesosContainer) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Image.Equals(other.Image) { return false } + if len(p.Volumes) != len(other.Volumes) { return false } + for i, _tgt := range p.Volumes { + _src7 := other.Volumes[i] + if !_tgt.Equals(_src7) { return false } + } + return true +} + +func (p *MesosContainer) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("MesosContainer(%+v)", *p) +} + +// Describes a parameter passed to docker cli +// +// Attributes: +// - Name: a parameter to pass to docker. (e.g. volume) +// - Value: the value to pass to a parameter (e.g. /src/webapp:/opt/webapp) +type DockerParameter struct { + Name string `thrift:"name,1" db:"name" json:"name"` + Value string `thrift:"value,2" db:"value" json:"value"` +} + +func NewDockerParameter() *DockerParameter { + return &DockerParameter{} +} + + +func (p *DockerParameter) GetName() string { + return p.Name +} + +func (p *DockerParameter) GetValue() string { + return p.Value +} +func (p *DockerParameter) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *DockerParameter) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Name = v +} + return nil +} + +func (p *DockerParameter) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.Value = v +} + return nil +} + +func (p *DockerParameter) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "DockerParameter"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *DockerParameter) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } + return err +} + +func (p *DockerParameter) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "value", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:value: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Value)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.value (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:value: ", p), err) } + return err +} + +func (p *DockerParameter) Equals(other *DockerParameter) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Name != other.Name { return false } + if p.Value != other.Value { return false } + return true +} + +func (p *DockerParameter) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("DockerParameter(%+v)", *p) +} + +// Describes a docker container +// +// Attributes: +// - Image: The container image to be run +// - Parameters: The arbitrary parameters to pass to container +type DockerContainer struct { + Image string `thrift:"image,1" db:"image" json:"image"` + Parameters []*DockerParameter `thrift:"parameters,2" db:"parameters" json:"parameters,omitempty"` +} + +func NewDockerContainer() *DockerContainer { + return &DockerContainer{} +} + + +func (p *DockerContainer) GetImage() string { + return p.Image +} +var DockerContainer_Parameters_DEFAULT []*DockerParameter + +func (p *DockerContainer) GetParameters() []*DockerParameter { + return p.Parameters +} +func (p *DockerContainer) IsSetParameters() bool { + return p.Parameters != nil +} + +func (p *DockerContainer) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.LIST { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *DockerContainer) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Image = v +} + return nil +} + +func (p *DockerContainer) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]*DockerParameter, 0, size) + p.Parameters = tSlice + for i := 0; i < size; i ++ { + _elem8 := &DockerParameter{} + if err := _elem8.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem8), err) + } + p.Parameters = append(p.Parameters, _elem8) + } + if err := iprot.ReadListEnd(ctx); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *DockerContainer) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "DockerContainer"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *DockerContainer) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "image", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:image: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Image)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.image (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:image: ", p), err) } + return err +} + +func (p *DockerContainer) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetParameters() { + if err := oprot.WriteFieldBegin(ctx, "parameters", thrift.LIST, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:parameters: ", p), err) } + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.Parameters)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.Parameters { + if err := v.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) + } + } + if err := oprot.WriteListEnd(ctx); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:parameters: ", p), err) } + } + return err +} + +func (p *DockerContainer) Equals(other *DockerContainer) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Image != other.Image { return false } + if len(p.Parameters) != len(other.Parameters) { return false } + for i, _tgt := range p.Parameters { + _src9 := other.Parameters[i] + if !_tgt.Equals(_src9) { return false } + } + return true +} + +func (p *DockerContainer) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("DockerContainer(%+v)", *p) +} + +// Describes a container to be used in a task +// +// Attributes: +// - Mesos +// - Docker +type Container struct { + Mesos *MesosContainer `thrift:"mesos,1" db:"mesos" json:"mesos,omitempty"` + Docker *DockerContainer `thrift:"docker,2" db:"docker" json:"docker,omitempty"` +} + +func NewContainer() *Container { + return &Container{} +} + +var Container_Mesos_DEFAULT *MesosContainer +func (p *Container) GetMesos() *MesosContainer { + if !p.IsSetMesos() { + return Container_Mesos_DEFAULT + } +return p.Mesos +} +var Container_Docker_DEFAULT *DockerContainer +func (p *Container) GetDocker() *DockerContainer { + if !p.IsSetDocker() { + return Container_Docker_DEFAULT + } +return p.Docker +} +func (p *Container) CountSetFieldsContainer() int { + count := 0 + if (p.IsSetMesos()) { + count++ + } + if (p.IsSetDocker()) { + count++ + } + return count + +} + +func (p *Container) IsSetMesos() bool { + return p.Mesos != nil +} + +func (p *Container) IsSetDocker() bool { + return p.Docker != nil +} + +func (p *Container) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *Container) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Mesos = &MesosContainer{} + if err := p.Mesos.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Mesos), err) + } + return nil +} + +func (p *Container) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.Docker = &DockerContainer{} + if err := p.Docker.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Docker), err) + } + return nil +} + +func (p *Container) Write(ctx context.Context, oprot thrift.TProtocol) error { + if c := p.CountSetFieldsContainer(); c != 1 { + return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) + } + if err := oprot.WriteStructBegin(ctx, "Container"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *Container) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetMesos() { + if err := oprot.WriteFieldBegin(ctx, "mesos", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:mesos: ", p), err) } + if err := p.Mesos.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Mesos), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:mesos: ", p), err) } + } + return err +} + +func (p *Container) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetDocker() { + if err := oprot.WriteFieldBegin(ctx, "docker", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:docker: ", p), err) } + if err := p.Docker.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Docker), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:docker: ", p), err) } + } + return err +} + +func (p *Container) Equals(other *Container) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Mesos.Equals(other.Mesos) { return false } + if !p.Docker.Equals(other.Docker) { return false } + return true +} + +func (p *Container) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Container(%+v)", *p) +} + +// Describes resource value required to run a task. +// +// Attributes: +// - NumCpus +// - RamMb +// - DiskMb +// - NamedPort +// - NumGpus +type Resource struct { + NumCpus *float64 `thrift:"numCpus,1" db:"numCpus" json:"numCpus,omitempty"` + RamMb *int64 `thrift:"ramMb,2" db:"ramMb" json:"ramMb,omitempty"` + DiskMb *int64 `thrift:"diskMb,3" db:"diskMb" json:"diskMb,omitempty"` + NamedPort *string `thrift:"namedPort,4" db:"namedPort" json:"namedPort,omitempty"` + NumGpus *int64 `thrift:"numGpus,5" db:"numGpus" json:"numGpus,omitempty"` +} + +func NewResource() *Resource { + return &Resource{} +} + +var Resource_NumCpus_DEFAULT float64 +func (p *Resource) GetNumCpus() float64 { + if !p.IsSetNumCpus() { + return Resource_NumCpus_DEFAULT + } +return *p.NumCpus +} +var Resource_RamMb_DEFAULT int64 +func (p *Resource) GetRamMb() int64 { + if !p.IsSetRamMb() { + return Resource_RamMb_DEFAULT + } +return *p.RamMb +} +var Resource_DiskMb_DEFAULT int64 +func (p *Resource) GetDiskMb() int64 { + if !p.IsSetDiskMb() { + return Resource_DiskMb_DEFAULT + } +return *p.DiskMb +} +var Resource_NamedPort_DEFAULT string +func (p *Resource) GetNamedPort() string { + if !p.IsSetNamedPort() { + return Resource_NamedPort_DEFAULT + } +return *p.NamedPort +} +var Resource_NumGpus_DEFAULT int64 +func (p *Resource) GetNumGpus() int64 { + if !p.IsSetNumGpus() { + return Resource_NumGpus_DEFAULT + } +return *p.NumGpus +} +func (p *Resource) CountSetFieldsResource() int { + count := 0 + if (p.IsSetNumCpus()) { + count++ + } + if (p.IsSetRamMb()) { + count++ + } + if (p.IsSetDiskMb()) { + count++ + } + if (p.IsSetNamedPort()) { + count++ + } + if (p.IsSetNumGpus()) { + count++ + } + return count + +} + +func (p *Resource) IsSetNumCpus() bool { + return p.NumCpus != nil +} + +func (p *Resource) IsSetRamMb() bool { + return p.RamMb != nil +} + +func (p *Resource) IsSetDiskMb() bool { + return p.DiskMb != nil +} + +func (p *Resource) IsSetNamedPort() bool { + return p.NamedPort != nil +} + +func (p *Resource) IsSetNumGpus() bool { + return p.NumGpus != nil +} + +func (p *Resource) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.DOUBLE { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I64 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.I64 { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.STRING { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 5: + if fieldTypeId == thrift.I64 { + if err := p.ReadField5(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *Resource) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadDouble(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.NumCpus = &v +} + return nil +} + +func (p *Resource) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.RamMb = &v +} + return nil +} + +func (p *Resource) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.DiskMb = &v +} + return nil +} + +func (p *Resource) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 4: ", err) +} else { + p.NamedPort = &v +} + return nil +} + +func (p *Resource) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 5: ", err) +} else { + p.NumGpus = &v +} + return nil +} + +func (p *Resource) Write(ctx context.Context, oprot thrift.TProtocol) error { + if c := p.CountSetFieldsResource(); c != 1 { + return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) + } + if err := oprot.WriteStructBegin(ctx, "Resource"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *Resource) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetNumCpus() { + if err := oprot.WriteFieldBegin(ctx, "numCpus", thrift.DOUBLE, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:numCpus: ", p), err) } + if err := oprot.WriteDouble(ctx, float64(*p.NumCpus)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.numCpus (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:numCpus: ", p), err) } + } + return err +} + +func (p *Resource) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetRamMb() { + if err := oprot.WriteFieldBegin(ctx, "ramMb", thrift.I64, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:ramMb: ", p), err) } + if err := oprot.WriteI64(ctx, int64(*p.RamMb)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.ramMb (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:ramMb: ", p), err) } + } + return err +} + +func (p *Resource) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetDiskMb() { + if err := oprot.WriteFieldBegin(ctx, "diskMb", thrift.I64, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:diskMb: ", p), err) } + if err := oprot.WriteI64(ctx, int64(*p.DiskMb)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.diskMb (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:diskMb: ", p), err) } + } + return err +} + +func (p *Resource) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetNamedPort() { + if err := oprot.WriteFieldBegin(ctx, "namedPort", thrift.STRING, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:namedPort: ", p), err) } + if err := oprot.WriteString(ctx, string(*p.NamedPort)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.namedPort (4) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:namedPort: ", p), err) } + } + return err +} + +func (p *Resource) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetNumGpus() { + if err := oprot.WriteFieldBegin(ctx, "numGpus", thrift.I64, 5); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:numGpus: ", p), err) } + if err := oprot.WriteI64(ctx, int64(*p.NumGpus)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.numGpus (5) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 5:numGpus: ", p), err) } + } + return err +} + +func (p *Resource) Equals(other *Resource) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.NumCpus != other.NumCpus { + if p.NumCpus == nil || other.NumCpus == nil { + return false + } + if (*p.NumCpus) != (*other.NumCpus) { return false } + } + if p.RamMb != other.RamMb { + if p.RamMb == nil || other.RamMb == nil { + return false + } + if (*p.RamMb) != (*other.RamMb) { return false } + } + if p.DiskMb != other.DiskMb { + if p.DiskMb == nil || other.DiskMb == nil { + return false + } + if (*p.DiskMb) != (*other.DiskMb) { return false } + } + if p.NamedPort != other.NamedPort { + if p.NamedPort == nil || other.NamedPort == nil { + return false + } + if (*p.NamedPort) != (*other.NamedPort) { return false } + } + if p.NumGpus != other.NumGpus { + if p.NumGpus == nil || other.NumGpus == nil { + return false + } + if (*p.NumGpus) != (*other.NumGpus) { return false } + } + return true +} + +func (p *Resource) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Resource(%+v)", *p) +} + +// Attributes: +// - Reschedule +// - DelaySecs +type PartitionPolicy struct { + Reschedule bool `thrift:"reschedule,1" db:"reschedule" json:"reschedule"` + DelaySecs *int64 `thrift:"delaySecs,2" db:"delaySecs" json:"delaySecs,omitempty"` +} + +func NewPartitionPolicy() *PartitionPolicy { + return &PartitionPolicy{} +} + + +func (p *PartitionPolicy) GetReschedule() bool { + return p.Reschedule +} +var PartitionPolicy_DelaySecs_DEFAULT int64 +func (p *PartitionPolicy) GetDelaySecs() int64 { + if !p.IsSetDelaySecs() { + return PartitionPolicy_DelaySecs_DEFAULT + } +return *p.DelaySecs +} +func (p *PartitionPolicy) IsSetDelaySecs() bool { + return p.DelaySecs != nil +} + +func (p *PartitionPolicy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.BOOL { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I64 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *PartitionPolicy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Reschedule = v +} + return nil +} + +func (p *PartitionPolicy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.DelaySecs = &v +} + return nil +} + +func (p *PartitionPolicy) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "PartitionPolicy"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *PartitionPolicy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "reschedule", thrift.BOOL, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:reschedule: ", p), err) } + if err := oprot.WriteBool(ctx, bool(p.Reschedule)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.reschedule (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:reschedule: ", p), err) } + return err +} + +func (p *PartitionPolicy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetDelaySecs() { + if err := oprot.WriteFieldBegin(ctx, "delaySecs", thrift.I64, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:delaySecs: ", p), err) } + if err := oprot.WriteI64(ctx, int64(*p.DelaySecs)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.delaySecs (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:delaySecs: ", p), err) } + } + return err +} + +func (p *PartitionPolicy) Equals(other *PartitionPolicy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Reschedule != other.Reschedule { return false } + if p.DelaySecs != other.DelaySecs { + if p.DelaySecs == nil || other.DelaySecs == nil { + return false + } + if (*p.DelaySecs) != (*other.DelaySecs) { return false } + } + return true +} + +func (p *PartitionPolicy) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PartitionPolicy(%+v)", *p) +} + +// SLA requirements expressed as the percentage of instances to be RUNNING every durationSecs +// +// Attributes: +// - Percentage +// - DurationSecs: Minimum time duration a task needs to be `RUNNING` to be treated as active +type PercentageSlaPolicy struct { + Percentage float64 `thrift:"percentage,1" db:"percentage" json:"percentage"` + DurationSecs int64 `thrift:"durationSecs,2" db:"durationSecs" json:"durationSecs"` +} + +func NewPercentageSlaPolicy() *PercentageSlaPolicy { + return &PercentageSlaPolicy{} +} + + +func (p *PercentageSlaPolicy) GetPercentage() float64 { + return p.Percentage +} + +func (p *PercentageSlaPolicy) GetDurationSecs() int64 { + return p.DurationSecs +} +func (p *PercentageSlaPolicy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.DOUBLE { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I64 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *PercentageSlaPolicy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadDouble(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Percentage = v +} + return nil +} + +func (p *PercentageSlaPolicy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.DurationSecs = v +} + return nil +} + +func (p *PercentageSlaPolicy) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "PercentageSlaPolicy"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *PercentageSlaPolicy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "percentage", thrift.DOUBLE, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:percentage: ", p), err) } + if err := oprot.WriteDouble(ctx, float64(p.Percentage)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.percentage (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:percentage: ", p), err) } + return err +} + +func (p *PercentageSlaPolicy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "durationSecs", thrift.I64, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:durationSecs: ", p), err) } + if err := oprot.WriteI64(ctx, int64(p.DurationSecs)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.durationSecs (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:durationSecs: ", p), err) } + return err +} + +func (p *PercentageSlaPolicy) Equals(other *PercentageSlaPolicy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Percentage != other.Percentage { return false } + if p.DurationSecs != other.DurationSecs { return false } + return true +} + +func (p *PercentageSlaPolicy) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PercentageSlaPolicy(%+v)", *p) +} + +// SLA requirements expressed as the number of instances to be RUNNING every durationSecs +// +// Attributes: +// - Count: The number of active instances required every `durationSecs` +// - DurationSecs: Minimum time duration a task needs to be `RUNNING` to be treated as active +type CountSlaPolicy struct { + Count int64 `thrift:"count,1" db:"count" json:"count"` + DurationSecs int64 `thrift:"durationSecs,2" db:"durationSecs" json:"durationSecs"` +} + +func NewCountSlaPolicy() *CountSlaPolicy { + return &CountSlaPolicy{} +} + + +func (p *CountSlaPolicy) GetCount() int64 { + return p.Count +} + +func (p *CountSlaPolicy) GetDurationSecs() int64 { + return p.DurationSecs +} +func (p *CountSlaPolicy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.I64 { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I64 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *CountSlaPolicy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Count = v +} + return nil +} + +func (p *CountSlaPolicy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.DurationSecs = v +} + return nil +} + +func (p *CountSlaPolicy) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "CountSlaPolicy"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *CountSlaPolicy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "count", thrift.I64, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:count: ", p), err) } + if err := oprot.WriteI64(ctx, int64(p.Count)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.count (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:count: ", p), err) } + return err +} + +func (p *CountSlaPolicy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "durationSecs", thrift.I64, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:durationSecs: ", p), err) } + if err := oprot.WriteI64(ctx, int64(p.DurationSecs)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.durationSecs (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:durationSecs: ", p), err) } + return err +} + +func (p *CountSlaPolicy) Equals(other *CountSlaPolicy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Count != other.Count { return false } + if p.DurationSecs != other.DurationSecs { return false } + return true +} + +func (p *CountSlaPolicy) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("CountSlaPolicy(%+v)", *p) +} + +// SLA requirements to be delegated to an external coordinator +// +// Attributes: +// - CoordinatorUrl: URL for the coordinator service that needs to be contacted for SLA checks +// - StatusKey: Field in the Coordinator response json indicating if the action is allowed or not +type CoordinatorSlaPolicy struct { + CoordinatorUrl string `thrift:"coordinatorUrl,1" db:"coordinatorUrl" json:"coordinatorUrl"` + StatusKey string `thrift:"statusKey,2" db:"statusKey" json:"statusKey"` +} + +func NewCoordinatorSlaPolicy() *CoordinatorSlaPolicy { + return &CoordinatorSlaPolicy{} +} + + +func (p *CoordinatorSlaPolicy) GetCoordinatorUrl() string { + return p.CoordinatorUrl +} + +func (p *CoordinatorSlaPolicy) GetStatusKey() string { + return p.StatusKey +} +func (p *CoordinatorSlaPolicy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *CoordinatorSlaPolicy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.CoordinatorUrl = v +} + return nil +} + +func (p *CoordinatorSlaPolicy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.StatusKey = v +} + return nil +} + +func (p *CoordinatorSlaPolicy) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "CoordinatorSlaPolicy"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *CoordinatorSlaPolicy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "coordinatorUrl", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:coordinatorUrl: ", p), err) } + if err := oprot.WriteString(ctx, string(p.CoordinatorUrl)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.coordinatorUrl (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:coordinatorUrl: ", p), err) } + return err +} + +func (p *CoordinatorSlaPolicy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "statusKey", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:statusKey: ", p), err) } + if err := oprot.WriteString(ctx, string(p.StatusKey)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.statusKey (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:statusKey: ", p), err) } + return err +} + +func (p *CoordinatorSlaPolicy) Equals(other *CoordinatorSlaPolicy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.CoordinatorUrl != other.CoordinatorUrl { return false } + if p.StatusKey != other.StatusKey { return false } + return true +} + +func (p *CoordinatorSlaPolicy) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("CoordinatorSlaPolicy(%+v)", *p) +} + +// SLA requirements expressed in one of the many types +// +// Attributes: +// - PercentageSlaPolicy +// - CountSlaPolicy +// - CoordinatorSlaPolicy +type SlaPolicy struct { + PercentageSlaPolicy *PercentageSlaPolicy `thrift:"percentageSlaPolicy,1" db:"percentageSlaPolicy" json:"percentageSlaPolicy,omitempty"` + CountSlaPolicy *CountSlaPolicy `thrift:"countSlaPolicy,2" db:"countSlaPolicy" json:"countSlaPolicy,omitempty"` + CoordinatorSlaPolicy *CoordinatorSlaPolicy `thrift:"coordinatorSlaPolicy,3" db:"coordinatorSlaPolicy" json:"coordinatorSlaPolicy,omitempty"` +} + +func NewSlaPolicy() *SlaPolicy { + return &SlaPolicy{} +} + +var SlaPolicy_PercentageSlaPolicy_DEFAULT *PercentageSlaPolicy +func (p *SlaPolicy) GetPercentageSlaPolicy() *PercentageSlaPolicy { + if !p.IsSetPercentageSlaPolicy() { + return SlaPolicy_PercentageSlaPolicy_DEFAULT + } +return p.PercentageSlaPolicy +} +var SlaPolicy_CountSlaPolicy_DEFAULT *CountSlaPolicy +func (p *SlaPolicy) GetCountSlaPolicy() *CountSlaPolicy { + if !p.IsSetCountSlaPolicy() { + return SlaPolicy_CountSlaPolicy_DEFAULT + } +return p.CountSlaPolicy +} +var SlaPolicy_CoordinatorSlaPolicy_DEFAULT *CoordinatorSlaPolicy +func (p *SlaPolicy) GetCoordinatorSlaPolicy() *CoordinatorSlaPolicy { + if !p.IsSetCoordinatorSlaPolicy() { + return SlaPolicy_CoordinatorSlaPolicy_DEFAULT + } +return p.CoordinatorSlaPolicy +} +func (p *SlaPolicy) CountSetFieldsSlaPolicy() int { + count := 0 + if (p.IsSetPercentageSlaPolicy()) { + count++ + } + if (p.IsSetCountSlaPolicy()) { + count++ + } + if (p.IsSetCoordinatorSlaPolicy()) { + count++ + } + return count + +} + +func (p *SlaPolicy) IsSetPercentageSlaPolicy() bool { + return p.PercentageSlaPolicy != nil +} + +func (p *SlaPolicy) IsSetCountSlaPolicy() bool { + return p.CountSlaPolicy != nil +} + +func (p *SlaPolicy) IsSetCoordinatorSlaPolicy() bool { + return p.CoordinatorSlaPolicy != nil +} + +func (p *SlaPolicy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *SlaPolicy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.PercentageSlaPolicy = &PercentageSlaPolicy{} + if err := p.PercentageSlaPolicy.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PercentageSlaPolicy), err) + } + return nil +} + +func (p *SlaPolicy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.CountSlaPolicy = &CountSlaPolicy{} + if err := p.CountSlaPolicy.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.CountSlaPolicy), err) + } + return nil +} + +func (p *SlaPolicy) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + p.CoordinatorSlaPolicy = &CoordinatorSlaPolicy{} + if err := p.CoordinatorSlaPolicy.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.CoordinatorSlaPolicy), err) + } + return nil +} + +func (p *SlaPolicy) Write(ctx context.Context, oprot thrift.TProtocol) error { + if c := p.CountSetFieldsSlaPolicy(); c != 1 { + return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) + } + if err := oprot.WriteStructBegin(ctx, "SlaPolicy"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *SlaPolicy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetPercentageSlaPolicy() { + if err := oprot.WriteFieldBegin(ctx, "percentageSlaPolicy", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:percentageSlaPolicy: ", p), err) } + if err := p.PercentageSlaPolicy.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PercentageSlaPolicy), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:percentageSlaPolicy: ", p), err) } + } + return err +} + +func (p *SlaPolicy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetCountSlaPolicy() { + if err := oprot.WriteFieldBegin(ctx, "countSlaPolicy", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:countSlaPolicy: ", p), err) } + if err := p.CountSlaPolicy.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.CountSlaPolicy), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:countSlaPolicy: ", p), err) } + } + return err +} + +func (p *SlaPolicy) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetCoordinatorSlaPolicy() { + if err := oprot.WriteFieldBegin(ctx, "coordinatorSlaPolicy", thrift.STRUCT, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:coordinatorSlaPolicy: ", p), err) } + if err := p.CoordinatorSlaPolicy.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.CoordinatorSlaPolicy), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:coordinatorSlaPolicy: ", p), err) } + } + return err +} + +func (p *SlaPolicy) Equals(other *SlaPolicy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.PercentageSlaPolicy.Equals(other.PercentageSlaPolicy) { return false } + if !p.CountSlaPolicy.Equals(other.CountSlaPolicy) { return false } + if !p.CoordinatorSlaPolicy.Equals(other.CoordinatorSlaPolicy) { return false } + return true +} + +func (p *SlaPolicy) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("SlaPolicy(%+v)", *p) +} + +// Description of the tasks contained within a job. +// +// Attributes: +// - Job: Job task belongs to. +// - Owner: contains the role component of JobKey +// - IsService +// - Priority +// - MaxTaskFailures +// - Production: Whether this is a production task, which can preempt. +// - Tier: Task tier type. +// - Resources: All resources required to run a task. +// - Constraints +// - MesosFetcherUris: Resources to retrieve with Mesos Fetcher +// - TaskLinks: Custom links to include when displaying this task on the scheduler dashboard. Keys are anchor +// text, values are URLs. Wildcards are supported for dynamic link crafting based on host, ports, +// instance, etc. +// - ContactEmail +// - ExecutorConfig: Executor configuration +// - Metadata: Used to display additional details in the UI. +// - PartitionPolicy: Policy for how to deal with task partitions +// - SlaPolicy: SLA requirements to be met during maintenance +// - Container: the container the task should use to execute +type TaskConfig struct { + // unused fields # 1 to 6 + IsService bool `thrift:"isService,7" db:"isService" json:"isService"` + // unused fields # 8 to 10 + Priority int32 `thrift:"priority,11" db:"priority" json:"priority"` + // unused field # 12 + MaxTaskFailures int32 `thrift:"maxTaskFailures,13" db:"maxTaskFailures" json:"maxTaskFailures"` + // unused fields # 14 to 16 + Owner *Identity `thrift:"owner,17" db:"owner" json:"owner"` + Production *bool `thrift:"production,18" db:"production" json:"production,omitempty"` + // unused field # 19 + Constraints []*Constraint `thrift:"constraints,20" db:"constraints" json:"constraints"` + // unused field # 21 + TaskLinks map[string]string `thrift:"taskLinks,22" db:"taskLinks" json:"taskLinks,omitempty"` + ContactEmail *string `thrift:"contactEmail,23" db:"contactEmail" json:"contactEmail,omitempty"` + // unused field # 24 + ExecutorConfig *ExecutorConfig `thrift:"executorConfig,25" db:"executorConfig" json:"executorConfig,omitempty"` + // unused field # 26 + Metadata []*Metadata `thrift:"metadata,27" db:"metadata" json:"metadata,omitempty"` + Job *JobKey `thrift:"job,28" db:"job" json:"job"` + Container *Container `thrift:"container,29" db:"container" json:"container"` + Tier *string `thrift:"tier,30" db:"tier" json:"tier,omitempty"` + // unused field # 31 + Resources []*Resource `thrift:"resources,32" db:"resources" json:"resources"` + MesosFetcherUris []*MesosFetcherURI `thrift:"mesosFetcherUris,33" db:"mesosFetcherUris" json:"mesosFetcherUris,omitempty"` + PartitionPolicy *PartitionPolicy `thrift:"partitionPolicy,34" db:"partitionPolicy" json:"partitionPolicy,omitempty"` + SlaPolicy *SlaPolicy `thrift:"slaPolicy,35" db:"slaPolicy" json:"slaPolicy,omitempty"` +} + +func NewTaskConfig() *TaskConfig { + return &TaskConfig{} +} + +var TaskConfig_Job_DEFAULT *JobKey +func (p *TaskConfig) GetJob() *JobKey { + if !p.IsSetJob() { + return TaskConfig_Job_DEFAULT + } +return p.Job +} +var TaskConfig_Owner_DEFAULT *Identity +func (p *TaskConfig) GetOwner() *Identity { + if !p.IsSetOwner() { + return TaskConfig_Owner_DEFAULT + } +return p.Owner +} + +func (p *TaskConfig) GetIsService() bool { + return p.IsService +} + +func (p *TaskConfig) GetPriority() int32 { + return p.Priority +} + +func (p *TaskConfig) GetMaxTaskFailures() int32 { + return p.MaxTaskFailures +} +var TaskConfig_Production_DEFAULT bool +func (p *TaskConfig) GetProduction() bool { + if !p.IsSetProduction() { + return TaskConfig_Production_DEFAULT + } +return *p.Production +} +var TaskConfig_Tier_DEFAULT string +func (p *TaskConfig) GetTier() string { + if !p.IsSetTier() { + return TaskConfig_Tier_DEFAULT + } +return *p.Tier +} + +func (p *TaskConfig) GetResources() []*Resource { + return p.Resources +} + +func (p *TaskConfig) GetConstraints() []*Constraint { + return p.Constraints +} +var TaskConfig_MesosFetcherUris_DEFAULT []*MesosFetcherURI + +func (p *TaskConfig) GetMesosFetcherUris() []*MesosFetcherURI { + return p.MesosFetcherUris +} +var TaskConfig_TaskLinks_DEFAULT map[string]string + +func (p *TaskConfig) GetTaskLinks() map[string]string { + return p.TaskLinks +} +var TaskConfig_ContactEmail_DEFAULT string +func (p *TaskConfig) GetContactEmail() string { + if !p.IsSetContactEmail() { + return TaskConfig_ContactEmail_DEFAULT + } +return *p.ContactEmail +} +var TaskConfig_ExecutorConfig_DEFAULT *ExecutorConfig +func (p *TaskConfig) GetExecutorConfig() *ExecutorConfig { + if !p.IsSetExecutorConfig() { + return TaskConfig_ExecutorConfig_DEFAULT + } +return p.ExecutorConfig +} +var TaskConfig_Metadata_DEFAULT []*Metadata + +func (p *TaskConfig) GetMetadata() []*Metadata { + return p.Metadata +} +var TaskConfig_PartitionPolicy_DEFAULT *PartitionPolicy +func (p *TaskConfig) GetPartitionPolicy() *PartitionPolicy { + if !p.IsSetPartitionPolicy() { + return TaskConfig_PartitionPolicy_DEFAULT + } +return p.PartitionPolicy +} +var TaskConfig_SlaPolicy_DEFAULT *SlaPolicy +func (p *TaskConfig) GetSlaPolicy() *SlaPolicy { + if !p.IsSetSlaPolicy() { + return TaskConfig_SlaPolicy_DEFAULT + } +return p.SlaPolicy +} +var TaskConfig_Container_DEFAULT *Container = &Container{ + Mesos: &MesosContainer{}, +} +func (p *TaskConfig) GetContainer() *Container { + if !p.IsSetContainer() { + return TaskConfig_Container_DEFAULT + } +return p.Container +} +func (p *TaskConfig) IsSetJob() bool { + return p.Job != nil +} + +func (p *TaskConfig) IsSetOwner() bool { + return p.Owner != nil +} + +func (p *TaskConfig) IsSetProduction() bool { + return p.Production != nil +} + +func (p *TaskConfig) IsSetTier() bool { + return p.Tier != nil +} + +func (p *TaskConfig) IsSetMesosFetcherUris() bool { + return p.MesosFetcherUris != nil +} + +func (p *TaskConfig) IsSetTaskLinks() bool { + return p.TaskLinks != nil +} + +func (p *TaskConfig) IsSetContactEmail() bool { + return p.ContactEmail != nil +} + +func (p *TaskConfig) IsSetExecutorConfig() bool { + return p.ExecutorConfig != nil +} + +func (p *TaskConfig) IsSetMetadata() bool { + return p.Metadata != nil +} + +func (p *TaskConfig) IsSetPartitionPolicy() bool { + return p.PartitionPolicy != nil +} + +func (p *TaskConfig) IsSetSlaPolicy() bool { + return p.SlaPolicy != nil +} + +func (p *TaskConfig) IsSetContainer() bool { + return p.Container != nil +} + +func (p *TaskConfig) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 28: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField28(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 17: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField17(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 7: + if fieldTypeId == thrift.BOOL { + if err := p.ReadField7(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 11: + if fieldTypeId == thrift.I32 { + if err := p.ReadField11(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 13: + if fieldTypeId == thrift.I32 { + if err := p.ReadField13(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 18: + if fieldTypeId == thrift.BOOL { + if err := p.ReadField18(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 30: + if fieldTypeId == thrift.STRING { + if err := p.ReadField30(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 32: + if fieldTypeId == thrift.SET { + if err := p.ReadField32(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 20: + if fieldTypeId == thrift.SET { + if err := p.ReadField20(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 33: + if fieldTypeId == thrift.SET { + if err := p.ReadField33(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 22: + if fieldTypeId == thrift.MAP { + if err := p.ReadField22(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 23: + if fieldTypeId == thrift.STRING { + if err := p.ReadField23(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 25: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField25(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 27: + if fieldTypeId == thrift.SET { + if err := p.ReadField27(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 34: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField34(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 35: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField35(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 29: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField29(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TaskConfig) ReadField28(ctx context.Context, iprot thrift.TProtocol) error { + p.Job = &JobKey{} + if err := p.Job.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) + } + return nil +} + +func (p *TaskConfig) ReadField17(ctx context.Context, iprot thrift.TProtocol) error { + p.Owner = &Identity{} + if err := p.Owner.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Owner), err) + } + return nil +} + +func (p *TaskConfig) ReadField7(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { + return thrift.PrependError("error reading field 7: ", err) +} else { + p.IsService = v +} + return nil +} + +func (p *TaskConfig) ReadField11(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 11: ", err) +} else { + p.Priority = v +} + return nil +} + +func (p *TaskConfig) ReadField13(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 13: ", err) +} else { + p.MaxTaskFailures = v +} + return nil +} + +func (p *TaskConfig) ReadField18(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { + return thrift.PrependError("error reading field 18: ", err) +} else { + p.Production = &v +} + return nil +} + +func (p *TaskConfig) ReadField30(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 30: ", err) +} else { + p.Tier = &v +} + return nil +} + +func (p *TaskConfig) ReadField32(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*Resource, 0, size) + p.Resources = tSet + for i := 0; i < size; i ++ { + _elem10 := &Resource{} + if err := _elem10.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem10), err) + } + p.Resources = append(p.Resources, _elem10) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *TaskConfig) ReadField20(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*Constraint, 0, size) + p.Constraints = tSet + for i := 0; i < size; i ++ { + _elem11 := &Constraint{} + if err := _elem11.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem11), err) + } + p.Constraints = append(p.Constraints, _elem11) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *TaskConfig) ReadField33(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*MesosFetcherURI, 0, size) + p.MesosFetcherUris = tSet + for i := 0; i < size; i ++ { + _elem12 := &MesosFetcherURI{} + if err := _elem12.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem12), err) + } + p.MesosFetcherUris = append(p.MesosFetcherUris, _elem12) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *TaskConfig) ReadField22(ctx context.Context, iprot thrift.TProtocol) error { + _, _, size, err := iprot.ReadMapBegin(ctx) + if err != nil { + return thrift.PrependError("error reading map begin: ", err) + } + tMap := make(map[string]string, size) + p.TaskLinks = tMap + for i := 0; i < size; i ++ { +var _key13 string + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _key13 = v +} +var _val14 string + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _val14 = v +} + p.TaskLinks[_key13] = _val14 + } + if err := iprot.ReadMapEnd(ctx); err != nil { + return thrift.PrependError("error reading map end: ", err) + } + return nil +} + +func (p *TaskConfig) ReadField23(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 23: ", err) +} else { + p.ContactEmail = &v +} + return nil +} + +func (p *TaskConfig) ReadField25(ctx context.Context, iprot thrift.TProtocol) error { + p.ExecutorConfig = &ExecutorConfig{} + if err := p.ExecutorConfig.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ExecutorConfig), err) + } + return nil +} + +func (p *TaskConfig) ReadField27(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*Metadata, 0, size) + p.Metadata = tSet + for i := 0; i < size; i ++ { + _elem15 := &Metadata{} + if err := _elem15.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem15), err) + } + p.Metadata = append(p.Metadata, _elem15) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *TaskConfig) ReadField34(ctx context.Context, iprot thrift.TProtocol) error { + p.PartitionPolicy = &PartitionPolicy{} + if err := p.PartitionPolicy.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PartitionPolicy), err) + } + return nil +} + +func (p *TaskConfig) ReadField35(ctx context.Context, iprot thrift.TProtocol) error { + p.SlaPolicy = &SlaPolicy{} + if err := p.SlaPolicy.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.SlaPolicy), err) + } + return nil +} + +func (p *TaskConfig) ReadField29(ctx context.Context, iprot thrift.TProtocol) error { + p.Container = &Container{} + if err := p.Container.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Container), err) + } + return nil +} + +func (p *TaskConfig) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "TaskConfig"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField7(ctx, oprot); err != nil { return err } + if err := p.writeField11(ctx, oprot); err != nil { return err } + if err := p.writeField13(ctx, oprot); err != nil { return err } + if err := p.writeField17(ctx, oprot); err != nil { return err } + if err := p.writeField18(ctx, oprot); err != nil { return err } + if err := p.writeField20(ctx, oprot); err != nil { return err } + if err := p.writeField22(ctx, oprot); err != nil { return err } + if err := p.writeField23(ctx, oprot); err != nil { return err } + if err := p.writeField25(ctx, oprot); err != nil { return err } + if err := p.writeField27(ctx, oprot); err != nil { return err } + if err := p.writeField28(ctx, oprot); err != nil { return err } + if err := p.writeField29(ctx, oprot); err != nil { return err } + if err := p.writeField30(ctx, oprot); err != nil { return err } + if err := p.writeField32(ctx, oprot); err != nil { return err } + if err := p.writeField33(ctx, oprot); err != nil { return err } + if err := p.writeField34(ctx, oprot); err != nil { return err } + if err := p.writeField35(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TaskConfig) writeField7(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "isService", thrift.BOOL, 7); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:isService: ", p), err) } + if err := oprot.WriteBool(ctx, bool(p.IsService)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.isService (7) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 7:isService: ", p), err) } + return err +} + +func (p *TaskConfig) writeField11(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "priority", thrift.I32, 11); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:priority: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.Priority)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.priority (11) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 11:priority: ", p), err) } + return err +} + +func (p *TaskConfig) writeField13(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "maxTaskFailures", thrift.I32, 13); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 13:maxTaskFailures: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.MaxTaskFailures)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.maxTaskFailures (13) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 13:maxTaskFailures: ", p), err) } + return err +} + +func (p *TaskConfig) writeField17(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "owner", thrift.STRUCT, 17); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 17:owner: ", p), err) } + if err := p.Owner.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Owner), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 17:owner: ", p), err) } + return err +} + +func (p *TaskConfig) writeField18(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetProduction() { + if err := oprot.WriteFieldBegin(ctx, "production", thrift.BOOL, 18); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 18:production: ", p), err) } + if err := oprot.WriteBool(ctx, bool(*p.Production)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.production (18) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 18:production: ", p), err) } + } + return err +} + +func (p *TaskConfig) writeField20(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "constraints", thrift.SET, 20); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 20:constraints: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Constraints)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("TaskConfig(%+v)", *p) +} + +// Attributes: +// - Resources: Aggregated resource values. +type ResourceAggregate struct { + // unused fields # 1 to 3 + Resources []*Resource `thrift:"resources,4" db:"resources" json:"resources"` +} + +func NewResourceAggregate() *ResourceAggregate { + return &ResourceAggregate{} +} + + +func (p *ResourceAggregate) GetResources() []*Resource { + return p.Resources +} +func (p *ResourceAggregate) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 4: + if fieldTypeId == thrift.SET { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ResourceAggregate) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*Resource, 0, size) + p.Resources = tSet + for i := 0; i < size; i ++ { + _elem21 := &Resource{} + if err := _elem21.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem21), err) + } + p.Resources = append(p.Resources, _elem21) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *ResourceAggregate) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ResourceAggregate"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField4(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ResourceAggregate) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "resources", thrift.SET, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:resources: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Resources)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("ResourceAggregate(%+v)", *p) +} + +// Description of an Aurora job. One task will be scheduled for each instance within the job. +// +// Attributes: +// - Key: Key for this job. If not specified name, owner.role, and a reasonable default environment are +// used to construct it server-side. +// - Owner: Owner of this job. +// - CronSchedule: If present, the job will be handled as a cron job with this crontab-syntax schedule. +// - CronCollisionPolicy: Collision policy to use when handling overlapping cron runs. Default is KILL_EXISTING. +// - TaskConfig: Task configuration for this job. +// - InstanceCount: The number of instances in the job. Generated instance IDs for tasks will be in the range +// [0, instances). +type JobConfiguration struct { + // unused fields # 1 to 3 + CronSchedule *string `thrift:"cronSchedule,4" db:"cronSchedule" json:"cronSchedule,omitempty"` + CronCollisionPolicy CronCollisionPolicy `thrift:"cronCollisionPolicy,5" db:"cronCollisionPolicy" json:"cronCollisionPolicy"` + TaskConfig *TaskConfig `thrift:"taskConfig,6" db:"taskConfig" json:"taskConfig"` + Owner *Identity `thrift:"owner,7" db:"owner" json:"owner"` + InstanceCount int32 `thrift:"instanceCount,8" db:"instanceCount" json:"instanceCount"` + Key *JobKey `thrift:"key,9" db:"key" json:"key"` +} + +func NewJobConfiguration() *JobConfiguration { + return &JobConfiguration{} +} + +var JobConfiguration_Key_DEFAULT *JobKey +func (p *JobConfiguration) GetKey() *JobKey { + if !p.IsSetKey() { + return JobConfiguration_Key_DEFAULT + } +return p.Key +} +var JobConfiguration_Owner_DEFAULT *Identity +func (p *JobConfiguration) GetOwner() *Identity { + if !p.IsSetOwner() { + return JobConfiguration_Owner_DEFAULT + } +return p.Owner +} +var JobConfiguration_CronSchedule_DEFAULT string +func (p *JobConfiguration) GetCronSchedule() string { + if !p.IsSetCronSchedule() { + return JobConfiguration_CronSchedule_DEFAULT + } +return *p.CronSchedule +} + +func (p *JobConfiguration) GetCronCollisionPolicy() CronCollisionPolicy { + return p.CronCollisionPolicy +} +var JobConfiguration_TaskConfig_DEFAULT *TaskConfig +func (p *JobConfiguration) GetTaskConfig() *TaskConfig { + if !p.IsSetTaskConfig() { + return JobConfiguration_TaskConfig_DEFAULT + } +return p.TaskConfig +} + +func (p *JobConfiguration) GetInstanceCount() int32 { + return p.InstanceCount +} +func (p *JobConfiguration) IsSetKey() bool { + return p.Key != nil +} + +func (p *JobConfiguration) IsSetOwner() bool { + return p.Owner != nil +} + +func (p *JobConfiguration) IsSetCronSchedule() bool { + return p.CronSchedule != nil +} + +func (p *JobConfiguration) IsSetTaskConfig() bool { + return p.TaskConfig != nil +} + +func (p *JobConfiguration) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 9: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField9(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 7: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField7(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.STRING { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 5: + if fieldTypeId == thrift.I32 { + if err := p.ReadField5(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 6: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField6(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 8: + if fieldTypeId == thrift.I32 { + if err := p.ReadField8(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JobConfiguration) ReadField9(ctx context.Context, iprot thrift.TProtocol) error { + p.Key = &JobKey{} + if err := p.Key.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) + } + return nil +} + +func (p *JobConfiguration) ReadField7(ctx context.Context, iprot thrift.TProtocol) error { + p.Owner = &Identity{} + if err := p.Owner.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Owner), err) + } + return nil +} + +func (p *JobConfiguration) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 4: ", err) +} else { + p.CronSchedule = &v +} + return nil +} + +func (p *JobConfiguration) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 5: ", err) +} else { + temp := CronCollisionPolicy(v) + p.CronCollisionPolicy = temp +} + return nil +} + +func (p *JobConfiguration) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { + p.TaskConfig = &TaskConfig{} + if err := p.TaskConfig.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.TaskConfig), err) + } + return nil +} + +func (p *JobConfiguration) ReadField8(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 8: ", err) +} else { + p.InstanceCount = v +} + return nil +} + +func (p *JobConfiguration) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobConfiguration"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } + if err := p.writeField7(ctx, oprot); err != nil { return err } + if err := p.writeField8(ctx, oprot); err != nil { return err } + if err := p.writeField9(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JobConfiguration) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetCronSchedule() { + if err := oprot.WriteFieldBegin(ctx, "cronSchedule", thrift.STRING, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:cronSchedule: ", p), err) } + if err := oprot.WriteString(ctx, string(*p.CronSchedule)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.cronSchedule (4) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:cronSchedule: ", p), err) } + } + return err +} + +func (p *JobConfiguration) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "cronCollisionPolicy", thrift.I32, 5); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:cronCollisionPolicy: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.CronCollisionPolicy)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.cronCollisionPolicy (5) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 5:cronCollisionPolicy: ", p), err) } + return err +} + +func (p *JobConfiguration) writeField6(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "taskConfig", thrift.STRUCT, 6); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:taskConfig: ", p), err) } + if err := p.TaskConfig.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.TaskConfig), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 6:taskConfig: ", p), err) } + return err +} + +func (p *JobConfiguration) writeField7(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "owner", thrift.STRUCT, 7); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:owner: ", p), err) } + if err := p.Owner.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Owner), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 7:owner: ", p), err) } + return err +} + +func (p *JobConfiguration) writeField8(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instanceCount", thrift.I32, 8); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:instanceCount: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.InstanceCount)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.instanceCount (8) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 8:instanceCount: ", p), err) } + return err +} + +func (p *JobConfiguration) writeField9(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 9); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:key: ", p), err) } + if err := p.Key.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 9:key: ", p), err) } + return err +} + +func (p *JobConfiguration) Equals(other *JobConfiguration) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.CronSchedule != other.CronSchedule { + if p.CronSchedule == nil || other.CronSchedule == nil { + return false + } + if (*p.CronSchedule) != (*other.CronSchedule) { return false } + } + if p.CronCollisionPolicy != other.CronCollisionPolicy { return false } + if !p.TaskConfig.Equals(other.TaskConfig) { return false } + if !p.Owner.Equals(other.Owner) { return false } + if p.InstanceCount != other.InstanceCount { return false } + if !p.Key.Equals(other.Key) { return false } + return true +} + +func (p *JobConfiguration) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("JobConfiguration(%+v)", *p) +} + +// Attributes: +// - ActiveTaskCount: Number of tasks in active state for this job. +// - FinishedTaskCount: Number of tasks in finished state for this job. +// - FailedTaskCount: Number of failed tasks for this job. +// - PendingTaskCount: Number of tasks in pending state for this job. +type JobStats struct { + ActiveTaskCount int32 `thrift:"activeTaskCount,1" db:"activeTaskCount" json:"activeTaskCount"` + FinishedTaskCount int32 `thrift:"finishedTaskCount,2" db:"finishedTaskCount" json:"finishedTaskCount"` + FailedTaskCount int32 `thrift:"failedTaskCount,3" db:"failedTaskCount" json:"failedTaskCount"` + PendingTaskCount int32 `thrift:"pendingTaskCount,4" db:"pendingTaskCount" json:"pendingTaskCount"` +} + +func NewJobStats() *JobStats { + return &JobStats{} +} + + +func (p *JobStats) GetActiveTaskCount() int32 { + return p.ActiveTaskCount +} + +func (p *JobStats) GetFinishedTaskCount() int32 { + return p.FinishedTaskCount +} + +func (p *JobStats) GetFailedTaskCount() int32 { + return p.FailedTaskCount +} + +func (p *JobStats) GetPendingTaskCount() int32 { + return p.PendingTaskCount +} +func (p *JobStats) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I32 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.I32 { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.I32 { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JobStats) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.ActiveTaskCount = v +} + return nil +} + +func (p *JobStats) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.FinishedTaskCount = v +} + return nil +} + +func (p *JobStats) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.FailedTaskCount = v +} + return nil +} + +func (p *JobStats) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 4: ", err) +} else { + p.PendingTaskCount = v +} + return nil +} + +func (p *JobStats) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobStats"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JobStats) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "activeTaskCount", thrift.I32, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:activeTaskCount: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.ActiveTaskCount)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.activeTaskCount (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:activeTaskCount: ", p), err) } + return err +} + +func (p *JobStats) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "finishedTaskCount", thrift.I32, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:finishedTaskCount: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.FinishedTaskCount)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.finishedTaskCount (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:finishedTaskCount: ", p), err) } + return err +} + +func (p *JobStats) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "failedTaskCount", thrift.I32, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:failedTaskCount: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.FailedTaskCount)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.failedTaskCount (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:failedTaskCount: ", p), err) } + return err +} + +func (p *JobStats) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "pendingTaskCount", thrift.I32, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:pendingTaskCount: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.PendingTaskCount)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.pendingTaskCount (4) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:pendingTaskCount: ", p), err) } + return err +} + +func (p *JobStats) Equals(other *JobStats) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.ActiveTaskCount != other.ActiveTaskCount { return false } + if p.FinishedTaskCount != other.FinishedTaskCount { return false } + if p.FailedTaskCount != other.FailedTaskCount { return false } + if p.PendingTaskCount != other.PendingTaskCount { return false } + return true +} + +func (p *JobStats) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("JobStats(%+v)", *p) +} + +// Attributes: +// - Job +// - Stats +// - NextCronRunMs: Timestamp of next cron run in ms since epoch, for a cron job +type JobSummary struct { + Job *JobConfiguration `thrift:"job,1" db:"job" json:"job"` + Stats *JobStats `thrift:"stats,2" db:"stats" json:"stats"` + NextCronRunMs *int64 `thrift:"nextCronRunMs,3" db:"nextCronRunMs" json:"nextCronRunMs,omitempty"` +} + +func NewJobSummary() *JobSummary { + return &JobSummary{} +} + +var JobSummary_Job_DEFAULT *JobConfiguration +func (p *JobSummary) GetJob() *JobConfiguration { + if !p.IsSetJob() { + return JobSummary_Job_DEFAULT + } +return p.Job +} +var JobSummary_Stats_DEFAULT *JobStats +func (p *JobSummary) GetStats() *JobStats { + if !p.IsSetStats() { + return JobSummary_Stats_DEFAULT + } +return p.Stats +} +var JobSummary_NextCronRunMs_DEFAULT int64 +func (p *JobSummary) GetNextCronRunMs() int64 { + if !p.IsSetNextCronRunMs() { + return JobSummary_NextCronRunMs_DEFAULT + } +return *p.NextCronRunMs +} +func (p *JobSummary) IsSetJob() bool { + return p.Job != nil +} + +func (p *JobSummary) IsSetStats() bool { + return p.Stats != nil +} + +func (p *JobSummary) IsSetNextCronRunMs() bool { + return p.NextCronRunMs != nil +} + +func (p *JobSummary) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.I64 { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JobSummary) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Job = &JobConfiguration{} + if err := p.Job.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) + } + return nil +} + +func (p *JobSummary) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.Stats = &JobStats{} + if err := p.Stats.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Stats), err) + } + return nil +} + +func (p *JobSummary) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.NextCronRunMs = &v +} + return nil +} + +func (p *JobSummary) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobSummary"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JobSummary) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "job", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:job: ", p), err) } + if err := p.Job.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:job: ", p), err) } + return err +} + +func (p *JobSummary) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "stats", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:stats: ", p), err) } + if err := p.Stats.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Stats), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:stats: ", p), err) } + return err +} + +func (p *JobSummary) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetNextCronRunMs() { + if err := oprot.WriteFieldBegin(ctx, "nextCronRunMs", thrift.I64, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:nextCronRunMs: ", p), err) } + if err := oprot.WriteI64(ctx, int64(*p.NextCronRunMs)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.nextCronRunMs (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:nextCronRunMs: ", p), err) } + } + return err +} + +func (p *JobSummary) Equals(other *JobSummary) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Job.Equals(other.Job) { return false } + if !p.Stats.Equals(other.Stats) { return false } + if p.NextCronRunMs != other.NextCronRunMs { + if p.NextCronRunMs == nil || other.NextCronRunMs == nil { + return false + } + if (*p.NextCronRunMs) != (*other.NextCronRunMs) { return false } + } + return true +} + +func (p *JobSummary) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("JobSummary(%+v)", *p) +} + +// Closed range of integers. +// +// Attributes: +// - First +// - Last +type Range struct { + First int32 `thrift:"first,1" db:"first" json:"first"` + Last int32 `thrift:"last,2" db:"last" json:"last"` +} + +func NewRange() *Range { + return &Range{} +} + + +func (p *Range) GetFirst() int32 { + return p.First +} + +func (p *Range) GetLast() int32 { + return p.Last +} +func (p *Range) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I32 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *Range) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.First = v +} + return nil +} + +func (p *Range) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.Last = v +} + return nil +} + +func (p *Range) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Range"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *Range) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "first", thrift.I32, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:first: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.First)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.first (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:first: ", p), err) } + return err +} + +func (p *Range) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "last", thrift.I32, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:last: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.Last)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.last (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:last: ", p), err) } + return err +} + +func (p *Range) Equals(other *Range) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.First != other.First { return false } + if p.Last != other.Last { return false } + return true +} + +func (p *Range) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Range(%+v)", *p) +} + +// Attributes: +// - Config +// - Instances +type ConfigGroup struct { + Config *TaskConfig `thrift:"config,1" db:"config" json:"config"` + // unused field # 2 + Instances []*Range `thrift:"instances,3" db:"instances" json:"instances"` +} + +func NewConfigGroup() *ConfigGroup { + return &ConfigGroup{} +} + +var ConfigGroup_Config_DEFAULT *TaskConfig +func (p *ConfigGroup) GetConfig() *TaskConfig { + if !p.IsSetConfig() { + return ConfigGroup_Config_DEFAULT + } +return p.Config +} + +func (p *ConfigGroup) GetInstances() []*Range { + return p.Instances +} +func (p *ConfigGroup) IsSetConfig() bool { + return p.Config != nil +} + +func (p *ConfigGroup) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.SET { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ConfigGroup) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Config = &TaskConfig{} + if err := p.Config.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Config), err) + } + return nil +} + +func (p *ConfigGroup) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*Range, 0, size) + p.Instances = tSet + for i := 0; i < size; i ++ { + _elem23 := &Range{} + if err := _elem23.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem23), err) + } + p.Instances = append(p.Instances, _elem23) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *ConfigGroup) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ConfigGroup"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ConfigGroup) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "config", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:config: ", p), err) } + if err := p.Config.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Config), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:config: ", p), err) } + return err +} + +func (p *ConfigGroup) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instances", thrift.SET, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:instances: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Instances)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("ConfigGroup(%+v)", *p) +} + +// Attributes: +// - Key +// - Groups +type ConfigSummary struct { + Key *JobKey `thrift:"key,1" db:"key" json:"key"` + Groups []*ConfigGroup `thrift:"groups,2" db:"groups" json:"groups"` +} + +func NewConfigSummary() *ConfigSummary { + return &ConfigSummary{} +} + +var ConfigSummary_Key_DEFAULT *JobKey +func (p *ConfigSummary) GetKey() *JobKey { + if !p.IsSetKey() { + return ConfigSummary_Key_DEFAULT + } +return p.Key +} + +func (p *ConfigSummary) GetGroups() []*ConfigGroup { + return p.Groups +} +func (p *ConfigSummary) IsSetKey() bool { + return p.Key != nil +} + +func (p *ConfigSummary) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.SET { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ConfigSummary) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Key = &JobKey{} + if err := p.Key.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) + } + return nil +} + +func (p *ConfigSummary) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*ConfigGroup, 0, size) + p.Groups = tSet + for i := 0; i < size; i ++ { + _elem25 := &ConfigGroup{} + if err := _elem25.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem25), err) + } + p.Groups = append(p.Groups, _elem25) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *ConfigSummary) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ConfigSummary"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ConfigSummary) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } + if err := p.Key.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } + return err +} + +func (p *ConfigSummary) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "groups", thrift.SET, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:groups: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Groups)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("ConfigSummary(%+v)", *p) +} + +// Attributes: +// - TaskConfig +type PopulateJobResult_ struct { + // unused field # 1 + TaskConfig *TaskConfig `thrift:"taskConfig,2" db:"taskConfig" json:"taskConfig"` +} + +func NewPopulateJobResult_() *PopulateJobResult_ { + return &PopulateJobResult_{} +} + +var PopulateJobResult__TaskConfig_DEFAULT *TaskConfig +func (p *PopulateJobResult_) GetTaskConfig() *TaskConfig { + if !p.IsSetTaskConfig() { + return PopulateJobResult__TaskConfig_DEFAULT + } +return p.TaskConfig +} +func (p *PopulateJobResult_) IsSetTaskConfig() bool { + return p.TaskConfig != nil +} + +func (p *PopulateJobResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *PopulateJobResult_) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.TaskConfig = &TaskConfig{} + if err := p.TaskConfig.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.TaskConfig), err) + } + return nil +} + +func (p *PopulateJobResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "PopulateJobResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *PopulateJobResult_) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "taskConfig", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:taskConfig: ", p), err) } + if err := p.TaskConfig.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.TaskConfig), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:taskConfig: ", p), err) } + return err +} + +func (p *PopulateJobResult_) Equals(other *PopulateJobResult_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.TaskConfig.Equals(other.TaskConfig) { return false } + return true +} + +func (p *PopulateJobResult_) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PopulateJobResult_(%+v)", *p) +} + +// Attributes: +// - Quota: Total allocated resource quota. +// - ProdSharedConsumption: Resources consumed by production jobs from a shared resource pool. +// - NonProdSharedConsumption: Resources consumed by non-production jobs from a shared resource pool. +// - ProdDedicatedConsumption: Resources consumed by production jobs from a dedicated resource pool. +// - NonProdDedicatedConsumption: Resources consumed by non-production jobs from a dedicated resource pool. +type GetQuotaResult_ struct { + Quota *ResourceAggregate `thrift:"quota,1" db:"quota" json:"quota"` + ProdSharedConsumption *ResourceAggregate `thrift:"prodSharedConsumption,2" db:"prodSharedConsumption" json:"prodSharedConsumption,omitempty"` + NonProdSharedConsumption *ResourceAggregate `thrift:"nonProdSharedConsumption,3" db:"nonProdSharedConsumption" json:"nonProdSharedConsumption,omitempty"` + ProdDedicatedConsumption *ResourceAggregate `thrift:"prodDedicatedConsumption,4" db:"prodDedicatedConsumption" json:"prodDedicatedConsumption,omitempty"` + NonProdDedicatedConsumption *ResourceAggregate `thrift:"nonProdDedicatedConsumption,5" db:"nonProdDedicatedConsumption" json:"nonProdDedicatedConsumption,omitempty"` +} + +func NewGetQuotaResult_() *GetQuotaResult_ { + return &GetQuotaResult_{} +} + +var GetQuotaResult__Quota_DEFAULT *ResourceAggregate +func (p *GetQuotaResult_) GetQuota() *ResourceAggregate { + if !p.IsSetQuota() { + return GetQuotaResult__Quota_DEFAULT + } +return p.Quota +} +var GetQuotaResult__ProdSharedConsumption_DEFAULT *ResourceAggregate +func (p *GetQuotaResult_) GetProdSharedConsumption() *ResourceAggregate { + if !p.IsSetProdSharedConsumption() { + return GetQuotaResult__ProdSharedConsumption_DEFAULT + } +return p.ProdSharedConsumption +} +var GetQuotaResult__NonProdSharedConsumption_DEFAULT *ResourceAggregate +func (p *GetQuotaResult_) GetNonProdSharedConsumption() *ResourceAggregate { + if !p.IsSetNonProdSharedConsumption() { + return GetQuotaResult__NonProdSharedConsumption_DEFAULT + } +return p.NonProdSharedConsumption +} +var GetQuotaResult__ProdDedicatedConsumption_DEFAULT *ResourceAggregate +func (p *GetQuotaResult_) GetProdDedicatedConsumption() *ResourceAggregate { + if !p.IsSetProdDedicatedConsumption() { + return GetQuotaResult__ProdDedicatedConsumption_DEFAULT + } +return p.ProdDedicatedConsumption +} +var GetQuotaResult__NonProdDedicatedConsumption_DEFAULT *ResourceAggregate +func (p *GetQuotaResult_) GetNonProdDedicatedConsumption() *ResourceAggregate { + if !p.IsSetNonProdDedicatedConsumption() { + return GetQuotaResult__NonProdDedicatedConsumption_DEFAULT + } +return p.NonProdDedicatedConsumption +} +func (p *GetQuotaResult_) IsSetQuota() bool { + return p.Quota != nil +} + +func (p *GetQuotaResult_) IsSetProdSharedConsumption() bool { + return p.ProdSharedConsumption != nil +} + +func (p *GetQuotaResult_) IsSetNonProdSharedConsumption() bool { + return p.NonProdSharedConsumption != nil +} + +func (p *GetQuotaResult_) IsSetProdDedicatedConsumption() bool { + return p.ProdDedicatedConsumption != nil +} + +func (p *GetQuotaResult_) IsSetNonProdDedicatedConsumption() bool { + return p.NonProdDedicatedConsumption != nil +} + +func (p *GetQuotaResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 5: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField5(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *GetQuotaResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Quota = &ResourceAggregate{} + if err := p.Quota.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Quota), err) + } + return nil +} + +func (p *GetQuotaResult_) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.ProdSharedConsumption = &ResourceAggregate{} + if err := p.ProdSharedConsumption.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ProdSharedConsumption), err) + } + return nil +} + +func (p *GetQuotaResult_) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + p.NonProdSharedConsumption = &ResourceAggregate{} + if err := p.NonProdSharedConsumption.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.NonProdSharedConsumption), err) + } + return nil +} + +func (p *GetQuotaResult_) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + p.ProdDedicatedConsumption = &ResourceAggregate{} + if err := p.ProdDedicatedConsumption.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ProdDedicatedConsumption), err) + } + return nil +} + +func (p *GetQuotaResult_) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + p.NonProdDedicatedConsumption = &ResourceAggregate{} + if err := p.NonProdDedicatedConsumption.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.NonProdDedicatedConsumption), err) + } + return nil +} + +func (p *GetQuotaResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "GetQuotaResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *GetQuotaResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "quota", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:quota: ", p), err) } + if err := p.Quota.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Quota), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:quota: ", p), err) } + return err +} + +func (p *GetQuotaResult_) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetProdSharedConsumption() { + if err := oprot.WriteFieldBegin(ctx, "prodSharedConsumption", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:prodSharedConsumption: ", p), err) } + if err := p.ProdSharedConsumption.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ProdSharedConsumption), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:prodSharedConsumption: ", p), err) } + } + return err +} + +func (p *GetQuotaResult_) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetNonProdSharedConsumption() { + if err := oprot.WriteFieldBegin(ctx, "nonProdSharedConsumption", thrift.STRUCT, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:nonProdSharedConsumption: ", p), err) } + if err := p.NonProdSharedConsumption.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.NonProdSharedConsumption), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:nonProdSharedConsumption: ", p), err) } + } + return err +} + +func (p *GetQuotaResult_) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetProdDedicatedConsumption() { + if err := oprot.WriteFieldBegin(ctx, "prodDedicatedConsumption", thrift.STRUCT, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:prodDedicatedConsumption: ", p), err) } + if err := p.ProdDedicatedConsumption.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ProdDedicatedConsumption), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:prodDedicatedConsumption: ", p), err) } + } + return err +} + +func (p *GetQuotaResult_) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetNonProdDedicatedConsumption() { + if err := oprot.WriteFieldBegin(ctx, "nonProdDedicatedConsumption", thrift.STRUCT, 5); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:nonProdDedicatedConsumption: ", p), err) } + if err := p.NonProdDedicatedConsumption.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.NonProdDedicatedConsumption), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 5:nonProdDedicatedConsumption: ", p), err) } + } + return err +} + +func (p *GetQuotaResult_) Equals(other *GetQuotaResult_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Quota.Equals(other.Quota) { return false } + if !p.ProdSharedConsumption.Equals(other.ProdSharedConsumption) { return false } + if !p.NonProdSharedConsumption.Equals(other.NonProdSharedConsumption) { return false } + if !p.ProdDedicatedConsumption.Equals(other.ProdDedicatedConsumption) { return false } + if !p.NonProdDedicatedConsumption.Equals(other.NonProdDedicatedConsumption) { return false } + return true +} + +func (p *GetQuotaResult_) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetQuotaResult_(%+v)", *p) +} + +// Event marking a state transition within a task's lifecycle. +// +// Attributes: +// - Timestamp: Epoch timestamp in milliseconds. +// - Status: New status of the task. +// - Message: Audit message that explains why a transition occurred. +// - Scheduler: Hostname of the scheduler machine that performed the event. +type TaskEvent struct { + Timestamp int64 `thrift:"timestamp,1" db:"timestamp" json:"timestamp"` + Status ScheduleStatus `thrift:"status,2" db:"status" json:"status"` + Message *string `thrift:"message,3" db:"message" json:"message,omitempty"` + Scheduler *string `thrift:"scheduler,4" db:"scheduler" json:"scheduler,omitempty"` +} + +func NewTaskEvent() *TaskEvent { + return &TaskEvent{} +} + + +func (p *TaskEvent) GetTimestamp() int64 { + return p.Timestamp +} + +func (p *TaskEvent) GetStatus() ScheduleStatus { + return p.Status +} +var TaskEvent_Message_DEFAULT string +func (p *TaskEvent) GetMessage() string { + if !p.IsSetMessage() { + return TaskEvent_Message_DEFAULT + } +return *p.Message +} +var TaskEvent_Scheduler_DEFAULT string +func (p *TaskEvent) GetScheduler() string { + if !p.IsSetScheduler() { + return TaskEvent_Scheduler_DEFAULT + } +return *p.Scheduler +} +func (p *TaskEvent) IsSetMessage() bool { + return p.Message != nil +} + +func (p *TaskEvent) IsSetScheduler() bool { + return p.Scheduler != nil +} + +func (p *TaskEvent) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.I64 { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I32 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRING { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.STRING { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TaskEvent) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Timestamp = v +} + return nil +} + +func (p *TaskEvent) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + temp := ScheduleStatus(v) + p.Status = temp +} + return nil +} + +func (p *TaskEvent) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.Message = &v +} + return nil +} + +func (p *TaskEvent) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 4: ", err) +} else { + p.Scheduler = &v +} + return nil +} + +func (p *TaskEvent) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "TaskEvent"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TaskEvent) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "timestamp", thrift.I64, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:timestamp: ", p), err) } + if err := oprot.WriteI64(ctx, int64(p.Timestamp)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.timestamp (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:timestamp: ", p), err) } + return err +} + +func (p *TaskEvent) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "status", thrift.I32, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:status: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.Status)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.status (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:status: ", p), err) } + return err +} + +func (p *TaskEvent) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetMessage() { + if err := oprot.WriteFieldBegin(ctx, "message", thrift.STRING, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:message: ", p), err) } + if err := oprot.WriteString(ctx, string(*p.Message)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.message (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:message: ", p), err) } + } + return err +} + +func (p *TaskEvent) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetScheduler() { + if err := oprot.WriteFieldBegin(ctx, "scheduler", thrift.STRING, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:scheduler: ", p), err) } + if err := oprot.WriteString(ctx, string(*p.Scheduler)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.scheduler (4) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:scheduler: ", p), err) } + } + return err +} + +func (p *TaskEvent) Equals(other *TaskEvent) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Timestamp != other.Timestamp { return false } + if p.Status != other.Status { return false } + if p.Message != other.Message { + if p.Message == nil || other.Message == nil { + return false + } + if (*p.Message) != (*other.Message) { return false } + } + if p.Scheduler != other.Scheduler { + if p.Scheduler == nil || other.Scheduler == nil { + return false + } + if (*p.Scheduler) != (*other.Scheduler) { return false } + } + return true +} + +func (p *TaskEvent) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TaskEvent(%+v)", *p) +} + +// A task assignment that is provided to an executor. +// +// Attributes: +// - TaskId: The mesos task ID for this task. Guaranteed to be globally unique +// - SlaveId: The mesos slave ID that this task has been assigned to. +// This will not be populated for a PENDING task. +// - SlaveHost: The name of the machine that this task has been assigned to. +// This will not be populated for a PENDING task. +// - Task: Information about how to run this task. +// - AssignedPorts: Ports reserved on the machine while this task is running. +// - InstanceId: The instance ID assigned to this task. Instance IDs must be unique and contiguous within a +// job, and will be in the range [0, N-1] (inclusive) for a job that has N instances. +type AssignedTask struct { + TaskId string `thrift:"taskId,1" db:"taskId" json:"taskId"` + SlaveId string `thrift:"slaveId,2" db:"slaveId" json:"slaveId"` + SlaveHost string `thrift:"slaveHost,3" db:"slaveHost" json:"slaveHost"` + Task *TaskConfig `thrift:"task,4" db:"task" json:"task"` + AssignedPorts map[string]int32 `thrift:"assignedPorts,5" db:"assignedPorts" json:"assignedPorts"` + InstanceId int32 `thrift:"instanceId,6" db:"instanceId" json:"instanceId"` +} + +func NewAssignedTask() *AssignedTask { + return &AssignedTask{} +} + + +func (p *AssignedTask) GetTaskId() string { + return p.TaskId +} + +func (p *AssignedTask) GetSlaveId() string { + return p.SlaveId +} + +func (p *AssignedTask) GetSlaveHost() string { + return p.SlaveHost +} +var AssignedTask_Task_DEFAULT *TaskConfig +func (p *AssignedTask) GetTask() *TaskConfig { + if !p.IsSetTask() { + return AssignedTask_Task_DEFAULT + } +return p.Task +} + +func (p *AssignedTask) GetAssignedPorts() map[string]int32 { + return p.AssignedPorts +} + +func (p *AssignedTask) GetInstanceId() int32 { + return p.InstanceId +} +func (p *AssignedTask) IsSetTask() bool { + return p.Task != nil +} + +func (p *AssignedTask) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRING { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 5: + if fieldTypeId == thrift.MAP { + if err := p.ReadField5(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 6: + if fieldTypeId == thrift.I32 { + if err := p.ReadField6(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AssignedTask) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.TaskId = v +} + return nil +} + +func (p *AssignedTask) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.SlaveId = v +} + return nil +} + +func (p *AssignedTask) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.SlaveHost = v +} + return nil +} + +func (p *AssignedTask) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + p.Task = &TaskConfig{} + if err := p.Task.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Task), err) + } + return nil +} + +func (p *AssignedTask) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + _, _, size, err := iprot.ReadMapBegin(ctx) + if err != nil { + return thrift.PrependError("error reading map begin: ", err) + } + tMap := make(map[string]int32, size) + p.AssignedPorts = tMap + for i := 0; i < size; i ++ { +var _key27 string + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _key27 = v +} +var _val28 int32 + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _val28 = v +} + p.AssignedPorts[_key27] = _val28 + } + if err := iprot.ReadMapEnd(ctx); err != nil { + return thrift.PrependError("error reading map end: ", err) + } + return nil +} + +func (p *AssignedTask) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 6: ", err) +} else { + p.InstanceId = v +} + return nil +} + +func (p *AssignedTask) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "AssignedTask"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AssignedTask) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "taskId", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:taskId: ", p), err) } + if err := oprot.WriteString(ctx, string(p.TaskId)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.taskId (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:taskId: ", p), err) } + return err +} + +func (p *AssignedTask) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "slaveId", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:slaveId: ", p), err) } + if err := oprot.WriteString(ctx, string(p.SlaveId)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.slaveId (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:slaveId: ", p), err) } + return err +} + +func (p *AssignedTask) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "slaveHost", thrift.STRING, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:slaveHost: ", p), err) } + if err := oprot.WriteString(ctx, string(p.SlaveHost)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.slaveHost (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:slaveHost: ", p), err) } + return err +} + +func (p *AssignedTask) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "task", thrift.STRUCT, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:task: ", p), err) } + if err := p.Task.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Task), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:task: ", p), err) } + return err +} + +func (p *AssignedTask) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "assignedPorts", thrift.MAP, 5); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:assignedPorts: ", p), err) } + if err := oprot.WriteMapBegin(ctx, thrift.STRING, thrift.I32, len(p.AssignedPorts)); err != nil { + return thrift.PrependError("error writing map begin: ", err) + } + for k, v := range p.AssignedPorts { + if err := oprot.WriteString(ctx, string(k)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } + if err := oprot.WriteI32(ctx, int32(v)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } + } + if err := oprot.WriteMapEnd(ctx); err != nil { + return thrift.PrependError("error writing map end: ", err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 5:assignedPorts: ", p), err) } + return err +} + +func (p *AssignedTask) writeField6(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instanceId", thrift.I32, 6); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:instanceId: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.InstanceId)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.instanceId (6) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 6:instanceId: ", p), err) } + return err +} + +func (p *AssignedTask) Equals(other *AssignedTask) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.TaskId != other.TaskId { return false } + if p.SlaveId != other.SlaveId { return false } + if p.SlaveHost != other.SlaveHost { return false } + if !p.Task.Equals(other.Task) { return false } + if len(p.AssignedPorts) != len(other.AssignedPorts) { return false } + for k, _tgt := range p.AssignedPorts { + _src29 := other.AssignedPorts[k] + if _tgt != _src29 { return false } + } + if p.InstanceId != other.InstanceId { return false } + return true +} + +func (p *AssignedTask) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AssignedTask(%+v)", *p) +} + +// A task that has been scheduled. +// +// Attributes: +// - AssignedTask: The task that was scheduled. +// - Status: The current status of this task. +// - FailureCount: The number of failures that this task has accumulated over the multi-generational history of +// this task. +// - TimesPartitioned: The number of partitions this task has accumulated over its lifetime. +// - TaskEvents: State change history for this task. +// - AncestorId: The task ID of the previous generation of this task. When a task is automatically rescheduled, +// a copy of the task is created and ancestor ID of the previous task's task ID. +type ScheduledTask struct { + AssignedTask *AssignedTask `thrift:"assignedTask,1" db:"assignedTask" json:"assignedTask"` + Status ScheduleStatus `thrift:"status,2" db:"status" json:"status"` + FailureCount int32 `thrift:"failureCount,3" db:"failureCount" json:"failureCount"` + TaskEvents []*TaskEvent `thrift:"taskEvents,4" db:"taskEvents" json:"taskEvents"` + AncestorId string `thrift:"ancestorId,5" db:"ancestorId" json:"ancestorId"` + TimesPartitioned int32 `thrift:"timesPartitioned,6" db:"timesPartitioned" json:"timesPartitioned"` +} + +func NewScheduledTask() *ScheduledTask { + return &ScheduledTask{} +} + +var ScheduledTask_AssignedTask_DEFAULT *AssignedTask +func (p *ScheduledTask) GetAssignedTask() *AssignedTask { + if !p.IsSetAssignedTask() { + return ScheduledTask_AssignedTask_DEFAULT + } +return p.AssignedTask +} + +func (p *ScheduledTask) GetStatus() ScheduleStatus { + return p.Status +} + +func (p *ScheduledTask) GetFailureCount() int32 { + return p.FailureCount +} + +func (p *ScheduledTask) GetTimesPartitioned() int32 { + return p.TimesPartitioned +} + +func (p *ScheduledTask) GetTaskEvents() []*TaskEvent { + return p.TaskEvents +} + +func (p *ScheduledTask) GetAncestorId() string { + return p.AncestorId +} +func (p *ScheduledTask) IsSetAssignedTask() bool { + return p.AssignedTask != nil +} + +func (p *ScheduledTask) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I32 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.I32 { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 6: + if fieldTypeId == thrift.I32 { + if err := p.ReadField6(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.LIST { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 5: + if fieldTypeId == thrift.STRING { + if err := p.ReadField5(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ScheduledTask) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.AssignedTask = &AssignedTask{} + if err := p.AssignedTask.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.AssignedTask), err) + } + return nil +} + +func (p *ScheduledTask) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + temp := ScheduleStatus(v) + p.Status = temp +} + return nil +} + +func (p *ScheduledTask) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.FailureCount = v +} + return nil +} + +func (p *ScheduledTask) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 6: ", err) +} else { + p.TimesPartitioned = v +} + return nil +} + +func (p *ScheduledTask) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]*TaskEvent, 0, size) + p.TaskEvents = tSlice + for i := 0; i < size; i ++ { + _elem30 := &TaskEvent{} + if err := _elem30.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem30), err) + } + p.TaskEvents = append(p.TaskEvents, _elem30) + } + if err := iprot.ReadListEnd(ctx); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *ScheduledTask) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 5: ", err) +} else { + p.AncestorId = v +} + return nil +} + +func (p *ScheduledTask) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ScheduledTask"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ScheduledTask) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "assignedTask", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assignedTask: ", p), err) } + if err := p.AssignedTask.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.AssignedTask), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assignedTask: ", p), err) } + return err +} + +func (p *ScheduledTask) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "status", thrift.I32, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:status: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.Status)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.status (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:status: ", p), err) } + return err +} + +func (p *ScheduledTask) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "failureCount", thrift.I32, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:failureCount: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.FailureCount)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.failureCount (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:failureCount: ", p), err) } + return err +} + +func (p *ScheduledTask) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "taskEvents", thrift.LIST, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:taskEvents: ", p), err) } + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.TaskEvents)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.TaskEvents { + if err := v.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) + } + } + if err := oprot.WriteListEnd(ctx); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:taskEvents: ", p), err) } + return err +} + +func (p *ScheduledTask) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "ancestorId", thrift.STRING, 5); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:ancestorId: ", p), err) } + if err := oprot.WriteString(ctx, string(p.AncestorId)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.ancestorId (5) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 5:ancestorId: ", p), err) } + return err +} + +func (p *ScheduledTask) writeField6(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "timesPartitioned", thrift.I32, 6); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:timesPartitioned: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.TimesPartitioned)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.timesPartitioned (6) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 6:timesPartitioned: ", p), err) } + return err +} + +func (p *ScheduledTask) Equals(other *ScheduledTask) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.AssignedTask.Equals(other.AssignedTask) { return false } + if p.Status != other.Status { return false } + if p.FailureCount != other.FailureCount { return false } + if len(p.TaskEvents) != len(other.TaskEvents) { return false } + for i, _tgt := range p.TaskEvents { + _src31 := other.TaskEvents[i] + if !_tgt.Equals(_src31) { return false } + } + if p.AncestorId != other.AncestorId { return false } + if p.TimesPartitioned != other.TimesPartitioned { return false } + return true +} + +func (p *ScheduledTask) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ScheduledTask(%+v)", *p) +} + +// Attributes: +// - Tasks +type ScheduleStatusResult_ struct { + Tasks []*ScheduledTask `thrift:"tasks,1" db:"tasks" json:"tasks"` +} + +func NewScheduleStatusResult_() *ScheduleStatusResult_ { + return &ScheduleStatusResult_{} +} + + +func (p *ScheduleStatusResult_) GetTasks() []*ScheduledTask { + return p.Tasks +} +func (p *ScheduleStatusResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.LIST { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ScheduleStatusResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]*ScheduledTask, 0, size) + p.Tasks = tSlice + for i := 0; i < size; i ++ { + _elem32 := &ScheduledTask{} + if err := _elem32.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem32), err) + } + p.Tasks = append(p.Tasks, _elem32) + } + if err := iprot.ReadListEnd(ctx); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *ScheduleStatusResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ScheduleStatusResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ScheduleStatusResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "tasks", thrift.LIST, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:tasks: ", p), err) } + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.Tasks)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.Tasks { + if err := v.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) + } + } + if err := oprot.WriteListEnd(ctx); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:tasks: ", p), err) } + return err +} + +func (p *ScheduleStatusResult_) Equals(other *ScheduleStatusResult_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if len(p.Tasks) != len(other.Tasks) { return false } + for i, _tgt := range p.Tasks { + _src33 := other.Tasks[i] + if !_tgt.Equals(_src33) { return false } + } + return true +} + +func (p *ScheduleStatusResult_) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ScheduleStatusResult_(%+v)", *p) +} + +// Attributes: +// - Configs +type GetJobsResult_ struct { + Configs []*JobConfiguration `thrift:"configs,1" db:"configs" json:"configs"` +} + +func NewGetJobsResult_() *GetJobsResult_ { + return &GetJobsResult_{} +} + + +func (p *GetJobsResult_) GetConfigs() []*JobConfiguration { + return p.Configs +} +func (p *GetJobsResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.SET { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *GetJobsResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*JobConfiguration, 0, size) + p.Configs = tSet + for i := 0; i < size; i ++ { + _elem34 := &JobConfiguration{} + if err := _elem34.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem34), err) + } + p.Configs = append(p.Configs, _elem34) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *GetJobsResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "GetJobsResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *GetJobsResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "configs", thrift.SET, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:configs: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Configs)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("GetJobsResult_(%+v)", *p) +} + +// Contains a set of restrictions on matching tasks where all restrictions must be met +// (terms are AND'ed together). +// +// Attributes: +// - Role +// - Environment +// - JobName +// - TaskIds +// - Statuses +// - InstanceIds +// - SlaveHosts +// - JobKeys +// - Offset +// - Limit +type TaskQuery struct { + // unused field # 1 + JobName *string `thrift:"jobName,2" db:"jobName" json:"jobName,omitempty"` + // unused field # 3 + TaskIds []string `thrift:"taskIds,4" db:"taskIds" json:"taskIds,omitempty"` + Statuses []ScheduleStatus `thrift:"statuses,5" db:"statuses" json:"statuses,omitempty"` + // unused field # 6 + InstanceIds []int32 `thrift:"instanceIds,7" db:"instanceIds" json:"instanceIds,omitempty"` + // unused field # 8 + Environment *string `thrift:"environment,9" db:"environment" json:"environment,omitempty"` + SlaveHosts []string `thrift:"slaveHosts,10" db:"slaveHosts" json:"slaveHosts,omitempty"` + JobKeys []*JobKey `thrift:"jobKeys,11" db:"jobKeys" json:"jobKeys,omitempty"` + Offset *int32 `thrift:"offset,12" db:"offset" json:"offset,omitempty"` + Limit *int32 `thrift:"limit,13" db:"limit" json:"limit,omitempty"` + Role *string `thrift:"role,14" db:"role" json:"role,omitempty"` +} + +func NewTaskQuery() *TaskQuery { + return &TaskQuery{} +} + +var TaskQuery_Role_DEFAULT string +func (p *TaskQuery) GetRole() string { + if !p.IsSetRole() { + return TaskQuery_Role_DEFAULT + } +return *p.Role +} +var TaskQuery_Environment_DEFAULT string +func (p *TaskQuery) GetEnvironment() string { + if !p.IsSetEnvironment() { + return TaskQuery_Environment_DEFAULT + } +return *p.Environment +} +var TaskQuery_JobName_DEFAULT string +func (p *TaskQuery) GetJobName() string { + if !p.IsSetJobName() { + return TaskQuery_JobName_DEFAULT + } +return *p.JobName +} +var TaskQuery_TaskIds_DEFAULT []string + +func (p *TaskQuery) GetTaskIds() []string { + return p.TaskIds +} +var TaskQuery_Statuses_DEFAULT []ScheduleStatus + +func (p *TaskQuery) GetStatuses() []ScheduleStatus { + return p.Statuses +} +var TaskQuery_InstanceIds_DEFAULT []int32 + +func (p *TaskQuery) GetInstanceIds() []int32 { + return p.InstanceIds +} +var TaskQuery_SlaveHosts_DEFAULT []string + +func (p *TaskQuery) GetSlaveHosts() []string { + return p.SlaveHosts +} +var TaskQuery_JobKeys_DEFAULT []*JobKey + +func (p *TaskQuery) GetJobKeys() []*JobKey { + return p.JobKeys +} +var TaskQuery_Offset_DEFAULT int32 +func (p *TaskQuery) GetOffset() int32 { + if !p.IsSetOffset() { + return TaskQuery_Offset_DEFAULT + } +return *p.Offset +} +var TaskQuery_Limit_DEFAULT int32 +func (p *TaskQuery) GetLimit() int32 { + if !p.IsSetLimit() { + return TaskQuery_Limit_DEFAULT + } +return *p.Limit +} +func (p *TaskQuery) IsSetRole() bool { + return p.Role != nil +} + +func (p *TaskQuery) IsSetEnvironment() bool { + return p.Environment != nil +} + +func (p *TaskQuery) IsSetJobName() bool { + return p.JobName != nil +} + +func (p *TaskQuery) IsSetTaskIds() bool { + return p.TaskIds != nil +} + +func (p *TaskQuery) IsSetStatuses() bool { + return p.Statuses != nil +} + +func (p *TaskQuery) IsSetInstanceIds() bool { + return p.InstanceIds != nil +} + +func (p *TaskQuery) IsSetSlaveHosts() bool { + return p.SlaveHosts != nil +} + +func (p *TaskQuery) IsSetJobKeys() bool { + return p.JobKeys != nil +} + +func (p *TaskQuery) IsSetOffset() bool { + return p.Offset != nil +} + +func (p *TaskQuery) IsSetLimit() bool { + return p.Limit != nil +} + +func (p *TaskQuery) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 14: + if fieldTypeId == thrift.STRING { + if err := p.ReadField14(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 9: + if fieldTypeId == thrift.STRING { + if err := p.ReadField9(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.SET { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 5: + if fieldTypeId == thrift.SET { + if err := p.ReadField5(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 7: + if fieldTypeId == thrift.SET { + if err := p.ReadField7(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 10: + if fieldTypeId == thrift.SET { + if err := p.ReadField10(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 11: + if fieldTypeId == thrift.SET { + if err := p.ReadField11(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 12: + if fieldTypeId == thrift.I32 { + if err := p.ReadField12(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 13: + if fieldTypeId == thrift.I32 { + if err := p.ReadField13(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TaskQuery) ReadField14(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 14: ", err) +} else { + p.Role = &v +} + return nil +} + +func (p *TaskQuery) ReadField9(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 9: ", err) +} else { + p.Environment = &v +} + return nil +} + +func (p *TaskQuery) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.JobName = &v +} + return nil +} + +func (p *TaskQuery) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]string, 0, size) + p.TaskIds = tSet + for i := 0; i < size; i ++ { +var _elem36 string + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _elem36 = v +} + p.TaskIds = append(p.TaskIds, _elem36) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *TaskQuery) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]ScheduleStatus, 0, size) + p.Statuses = tSet + for i := 0; i < size; i ++ { +var _elem37 ScheduleStatus + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + temp := ScheduleStatus(v) + _elem37 = temp +} + p.Statuses = append(p.Statuses, _elem37) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *TaskQuery) ReadField7(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]int32, 0, size) + p.InstanceIds = tSet + for i := 0; i < size; i ++ { +var _elem38 int32 + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _elem38 = v +} + p.InstanceIds = append(p.InstanceIds, _elem38) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *TaskQuery) ReadField10(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]string, 0, size) + p.SlaveHosts = tSet + for i := 0; i < size; i ++ { +var _elem39 string + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _elem39 = v +} + p.SlaveHosts = append(p.SlaveHosts, _elem39) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *TaskQuery) ReadField11(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*JobKey, 0, size) + p.JobKeys = tSet + for i := 0; i < size; i ++ { + _elem40 := &JobKey{} + if err := _elem40.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem40), err) + } + p.JobKeys = append(p.JobKeys, _elem40) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *TaskQuery) ReadField12(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 12: ", err) +} else { + p.Offset = &v +} + return nil +} + +func (p *TaskQuery) ReadField13(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 13: ", err) +} else { + p.Limit = &v +} + return nil +} + +func (p *TaskQuery) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "TaskQuery"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField7(ctx, oprot); err != nil { return err } + if err := p.writeField9(ctx, oprot); err != nil { return err } + if err := p.writeField10(ctx, oprot); err != nil { return err } + if err := p.writeField11(ctx, oprot); err != nil { return err } + if err := p.writeField12(ctx, oprot); err != nil { return err } + if err := p.writeField13(ctx, oprot); err != nil { return err } + if err := p.writeField14(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TaskQuery) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetJobName() { + if err := oprot.WriteFieldBegin(ctx, "jobName", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:jobName: ", p), err) } + if err := oprot.WriteString(ctx, string(*p.JobName)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.jobName (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:jobName: ", p), err) } + } + return err +} + +func (p *TaskQuery) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetTaskIds() { + if err := oprot.WriteFieldBegin(ctx, "taskIds", thrift.SET, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:taskIds: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRING, len(p.TaskIds)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("TaskQuery(%+v)", *p) +} + +// Attributes: +// - Host +// - Mode +type HostStatus struct { + Host string `thrift:"host,1" db:"host" json:"host"` + Mode MaintenanceMode `thrift:"mode,2" db:"mode" json:"mode"` +} + +func NewHostStatus() *HostStatus { + return &HostStatus{} +} + + +func (p *HostStatus) GetHost() string { + return p.Host +} + +func (p *HostStatus) GetMode() MaintenanceMode { + return p.Mode +} +func (p *HostStatus) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I32 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *HostStatus) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Host = v +} + return nil +} + +func (p *HostStatus) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + temp := MaintenanceMode(v) + p.Mode = temp +} + return nil +} + +func (p *HostStatus) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "HostStatus"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *HostStatus) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "host", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:host: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Host)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.host (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:host: ", p), err) } + return err +} + +func (p *HostStatus) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "mode", thrift.I32, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:mode: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.Mode)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.mode (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:mode: ", p), err) } + return err +} + +func (p *HostStatus) Equals(other *HostStatus) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Host != other.Host { return false } + if p.Mode != other.Mode { return false } + return true +} + +func (p *HostStatus) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("HostStatus(%+v)", *p) +} + +// Attributes: +// - Role +// - JobCount +// - CronJobCount +type RoleSummary struct { + Role string `thrift:"role,1" db:"role" json:"role"` + JobCount int32 `thrift:"jobCount,2" db:"jobCount" json:"jobCount"` + CronJobCount int32 `thrift:"cronJobCount,3" db:"cronJobCount" json:"cronJobCount"` +} + +func NewRoleSummary() *RoleSummary { + return &RoleSummary{} +} + + +func (p *RoleSummary) GetRole() string { + return p.Role +} + +func (p *RoleSummary) GetJobCount() int32 { + return p.JobCount +} + +func (p *RoleSummary) GetCronJobCount() int32 { + return p.CronJobCount +} +func (p *RoleSummary) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I32 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.I32 { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *RoleSummary) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Role = v +} + return nil +} + +func (p *RoleSummary) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.JobCount = v +} + return nil +} + +func (p *RoleSummary) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.CronJobCount = v +} + return nil +} + +func (p *RoleSummary) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "RoleSummary"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *RoleSummary) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "role", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:role: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Role)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.role (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:role: ", p), err) } + return err +} + +func (p *RoleSummary) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "jobCount", thrift.I32, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:jobCount: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.JobCount)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.jobCount (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:jobCount: ", p), err) } + return err +} + +func (p *RoleSummary) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "cronJobCount", thrift.I32, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:cronJobCount: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.CronJobCount)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.cronJobCount (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:cronJobCount: ", p), err) } + return err +} + +func (p *RoleSummary) Equals(other *RoleSummary) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Role != other.Role { return false } + if p.JobCount != other.JobCount { return false } + if p.CronJobCount != other.CronJobCount { return false } + return true +} + +func (p *RoleSummary) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("RoleSummary(%+v)", *p) +} + +// Attributes: +// - HostNames +type Hosts struct { + HostNames []string `thrift:"hostNames,1" db:"hostNames" json:"hostNames"` +} + +func NewHosts() *Hosts { + return &Hosts{} +} + + +func (p *Hosts) GetHostNames() []string { + return p.HostNames +} +func (p *Hosts) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.SET { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *Hosts) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]string, 0, size) + p.HostNames = tSet + for i := 0; i < size; i ++ { +var _elem46 string + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _elem46 = v +} + p.HostNames = append(p.HostNames, _elem46) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *Hosts) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Hosts"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *Hosts) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "hostNames", thrift.SET, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:hostNames: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRING, len(p.HostNames)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("Hosts(%+v)", *p) +} + +// Attributes: +// - TaskId +// - Reason +type PendingReason struct { + TaskId string `thrift:"taskId,1" db:"taskId" json:"taskId"` + Reason string `thrift:"reason,2" db:"reason" json:"reason"` +} + +func NewPendingReason() *PendingReason { + return &PendingReason{} +} + + +func (p *PendingReason) GetTaskId() string { + return p.TaskId +} + +func (p *PendingReason) GetReason() string { + return p.Reason +} +func (p *PendingReason) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *PendingReason) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.TaskId = v +} + return nil +} + +func (p *PendingReason) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.Reason = v +} + return nil +} + +func (p *PendingReason) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "PendingReason"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *PendingReason) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "taskId", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:taskId: ", p), err) } + if err := oprot.WriteString(ctx, string(p.TaskId)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.taskId (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:taskId: ", p), err) } + return err +} + +func (p *PendingReason) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "reason", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:reason: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Reason)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.reason (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:reason: ", p), err) } + return err +} + +func (p *PendingReason) Equals(other *PendingReason) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.TaskId != other.TaskId { return false } + if p.Reason != other.Reason { return false } + return true +} + +func (p *PendingReason) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PendingReason(%+v)", *p) +} + +// Job update key. +// +// Attributes: +// - Job: Job being updated +// - ID: Update ID. +type JobUpdateKey struct { + Job *JobKey `thrift:"job,1" db:"job" json:"job"` + ID string `thrift:"id,2" db:"id" json:"id"` +} + +func NewJobUpdateKey() *JobUpdateKey { + return &JobUpdateKey{} +} + +var JobUpdateKey_Job_DEFAULT *JobKey +func (p *JobUpdateKey) GetJob() *JobKey { + if !p.IsSetJob() { + return JobUpdateKey_Job_DEFAULT + } +return p.Job +} + +func (p *JobUpdateKey) GetID() string { + return p.ID +} +func (p *JobUpdateKey) IsSetJob() bool { + return p.Job != nil +} + +func (p *JobUpdateKey) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JobUpdateKey) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Job = &JobKey{} + if err := p.Job.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) + } + return nil +} + +func (p *JobUpdateKey) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.ID = v +} + return nil +} + +func (p *JobUpdateKey) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateKey"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JobUpdateKey) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "job", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:job: ", p), err) } + if err := p.Job.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:job: ", p), err) } + return err +} + +func (p *JobUpdateKey) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "id", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:id: ", p), err) } + if err := oprot.WriteString(ctx, string(p.ID)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.id (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:id: ", p), err) } + return err +} + +func (p *JobUpdateKey) Equals(other *JobUpdateKey) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Job.Equals(other.Job) { return false } + if p.ID != other.ID { return false } + return true +} + +func (p *JobUpdateKey) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("JobUpdateKey(%+v)", *p) +} + +// Limits the amount of active changes being made to instances to groupSize. +// +// Attributes: +// - GroupSize +type QueueJobUpdateStrategy struct { + GroupSize int32 `thrift:"groupSize,1" db:"groupSize" json:"groupSize"` +} + +func NewQueueJobUpdateStrategy() *QueueJobUpdateStrategy { + return &QueueJobUpdateStrategy{} +} + + +func (p *QueueJobUpdateStrategy) GetGroupSize() int32 { + return p.GroupSize +} +func (p *QueueJobUpdateStrategy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *QueueJobUpdateStrategy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.GroupSize = v +} + return nil +} + +func (p *QueueJobUpdateStrategy) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "QueueJobUpdateStrategy"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *QueueJobUpdateStrategy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "groupSize", thrift.I32, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:groupSize: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.GroupSize)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.groupSize (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:groupSize: ", p), err) } + return err +} + +func (p *QueueJobUpdateStrategy) Equals(other *QueueJobUpdateStrategy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.GroupSize != other.GroupSize { return false } + return true +} + +func (p *QueueJobUpdateStrategy) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("QueueJobUpdateStrategy(%+v)", *p) +} + +// Similar to Queue strategy but will not start a new group until all instances in an active +// group have finished updating. +// +// Attributes: +// - GroupSize +// - AutopauseAfterBatch +type BatchJobUpdateStrategy struct { + GroupSize int32 `thrift:"groupSize,1" db:"groupSize" json:"groupSize"` + AutopauseAfterBatch bool `thrift:"autopauseAfterBatch,2" db:"autopauseAfterBatch" json:"autopauseAfterBatch"` +} + +func NewBatchJobUpdateStrategy() *BatchJobUpdateStrategy { + return &BatchJobUpdateStrategy{} +} + + +func (p *BatchJobUpdateStrategy) GetGroupSize() int32 { + return p.GroupSize +} + +func (p *BatchJobUpdateStrategy) GetAutopauseAfterBatch() bool { + return p.AutopauseAfterBatch +} +func (p *BatchJobUpdateStrategy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.BOOL { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *BatchJobUpdateStrategy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.GroupSize = v +} + return nil +} + +func (p *BatchJobUpdateStrategy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.AutopauseAfterBatch = v +} + return nil +} + +func (p *BatchJobUpdateStrategy) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "BatchJobUpdateStrategy"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *BatchJobUpdateStrategy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "groupSize", thrift.I32, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:groupSize: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.GroupSize)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.groupSize (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:groupSize: ", p), err) } + return err +} + +func (p *BatchJobUpdateStrategy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "autopauseAfterBatch", thrift.BOOL, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:autopauseAfterBatch: ", p), err) } + if err := oprot.WriteBool(ctx, bool(p.AutopauseAfterBatch)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.autopauseAfterBatch (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:autopauseAfterBatch: ", p), err) } + return err +} + +func (p *BatchJobUpdateStrategy) Equals(other *BatchJobUpdateStrategy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.GroupSize != other.GroupSize { return false } + if p.AutopauseAfterBatch != other.AutopauseAfterBatch { return false } + return true +} + +func (p *BatchJobUpdateStrategy) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("BatchJobUpdateStrategy(%+v)", *p) +} + +// Same as Batch strategy but each time an active group completes, the size of the next active +// group may change. +// +// Attributes: +// - GroupSizes +// - AutopauseAfterBatch +type VariableBatchJobUpdateStrategy struct { + GroupSizes []int32 `thrift:"groupSizes,1" db:"groupSizes" json:"groupSizes"` + AutopauseAfterBatch bool `thrift:"autopauseAfterBatch,2" db:"autopauseAfterBatch" json:"autopauseAfterBatch"` +} + +func NewVariableBatchJobUpdateStrategy() *VariableBatchJobUpdateStrategy { + return &VariableBatchJobUpdateStrategy{} +} + + +func (p *VariableBatchJobUpdateStrategy) GetGroupSizes() []int32 { + return p.GroupSizes +} + +func (p *VariableBatchJobUpdateStrategy) GetAutopauseAfterBatch() bool { + return p.AutopauseAfterBatch +} +func (p *VariableBatchJobUpdateStrategy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.LIST { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.BOOL { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *VariableBatchJobUpdateStrategy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]int32, 0, size) + p.GroupSizes = tSlice + for i := 0; i < size; i ++ { +var _elem48 int32 + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _elem48 = v +} + p.GroupSizes = append(p.GroupSizes, _elem48) + } + if err := iprot.ReadListEnd(ctx); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *VariableBatchJobUpdateStrategy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.AutopauseAfterBatch = v +} + return nil +} + +func (p *VariableBatchJobUpdateStrategy) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "VariableBatchJobUpdateStrategy"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *VariableBatchJobUpdateStrategy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "groupSizes", thrift.LIST, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:groupSizes: ", p), err) } + if err := oprot.WriteListBegin(ctx, thrift.I32, len(p.GroupSizes)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.GroupSizes { + if err := oprot.WriteI32(ctx, int32(v)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } + } + if err := oprot.WriteListEnd(ctx); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:groupSizes: ", p), err) } + return err +} + +func (p *VariableBatchJobUpdateStrategy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "autopauseAfterBatch", thrift.BOOL, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:autopauseAfterBatch: ", p), err) } + if err := oprot.WriteBool(ctx, bool(p.AutopauseAfterBatch)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.autopauseAfterBatch (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:autopauseAfterBatch: ", p), err) } + return err +} + +func (p *VariableBatchJobUpdateStrategy) Equals(other *VariableBatchJobUpdateStrategy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if len(p.GroupSizes) != len(other.GroupSizes) { return false } + for i, _tgt := range p.GroupSizes { + _src49 := other.GroupSizes[i] + if _tgt != _src49 { return false } + } + if p.AutopauseAfterBatch != other.AutopauseAfterBatch { return false } + return true +} + +func (p *VariableBatchJobUpdateStrategy) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("VariableBatchJobUpdateStrategy(%+v)", *p) +} + +// Attributes: +// - QueueStrategy +// - BatchStrategy +// - VarBatchStrategy +type JobUpdateStrategy struct { + QueueStrategy *QueueJobUpdateStrategy `thrift:"queueStrategy,1" db:"queueStrategy" json:"queueStrategy,omitempty"` + BatchStrategy *BatchJobUpdateStrategy `thrift:"batchStrategy,2" db:"batchStrategy" json:"batchStrategy,omitempty"` + VarBatchStrategy *VariableBatchJobUpdateStrategy `thrift:"varBatchStrategy,3" db:"varBatchStrategy" json:"varBatchStrategy,omitempty"` +} + +func NewJobUpdateStrategy() *JobUpdateStrategy { + return &JobUpdateStrategy{} +} + +var JobUpdateStrategy_QueueStrategy_DEFAULT *QueueJobUpdateStrategy +func (p *JobUpdateStrategy) GetQueueStrategy() *QueueJobUpdateStrategy { + if !p.IsSetQueueStrategy() { + return JobUpdateStrategy_QueueStrategy_DEFAULT + } +return p.QueueStrategy +} +var JobUpdateStrategy_BatchStrategy_DEFAULT *BatchJobUpdateStrategy +func (p *JobUpdateStrategy) GetBatchStrategy() *BatchJobUpdateStrategy { + if !p.IsSetBatchStrategy() { + return JobUpdateStrategy_BatchStrategy_DEFAULT + } +return p.BatchStrategy +} +var JobUpdateStrategy_VarBatchStrategy_DEFAULT *VariableBatchJobUpdateStrategy +func (p *JobUpdateStrategy) GetVarBatchStrategy() *VariableBatchJobUpdateStrategy { + if !p.IsSetVarBatchStrategy() { + return JobUpdateStrategy_VarBatchStrategy_DEFAULT + } +return p.VarBatchStrategy +} +func (p *JobUpdateStrategy) CountSetFieldsJobUpdateStrategy() int { + count := 0 + if (p.IsSetQueueStrategy()) { + count++ + } + if (p.IsSetBatchStrategy()) { + count++ + } + if (p.IsSetVarBatchStrategy()) { + count++ + } + return count + +} + +func (p *JobUpdateStrategy) IsSetQueueStrategy() bool { + return p.QueueStrategy != nil +} + +func (p *JobUpdateStrategy) IsSetBatchStrategy() bool { + return p.BatchStrategy != nil +} + +func (p *JobUpdateStrategy) IsSetVarBatchStrategy() bool { + return p.VarBatchStrategy != nil +} + +func (p *JobUpdateStrategy) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JobUpdateStrategy) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.QueueStrategy = &QueueJobUpdateStrategy{} + if err := p.QueueStrategy.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.QueueStrategy), err) + } + return nil +} + +func (p *JobUpdateStrategy) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.BatchStrategy = &BatchJobUpdateStrategy{} + if err := p.BatchStrategy.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.BatchStrategy), err) + } + return nil +} + +func (p *JobUpdateStrategy) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + p.VarBatchStrategy = &VariableBatchJobUpdateStrategy{} + if err := p.VarBatchStrategy.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.VarBatchStrategy), err) + } + return nil +} + +func (p *JobUpdateStrategy) Write(ctx context.Context, oprot thrift.TProtocol) error { + if c := p.CountSetFieldsJobUpdateStrategy(); c != 1 { + return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) + } + if err := oprot.WriteStructBegin(ctx, "JobUpdateStrategy"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JobUpdateStrategy) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetQueueStrategy() { + if err := oprot.WriteFieldBegin(ctx, "queueStrategy", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:queueStrategy: ", p), err) } + if err := p.QueueStrategy.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.QueueStrategy), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:queueStrategy: ", p), err) } + } + return err +} + +func (p *JobUpdateStrategy) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetBatchStrategy() { + if err := oprot.WriteFieldBegin(ctx, "batchStrategy", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:batchStrategy: ", p), err) } + if err := p.BatchStrategy.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.BatchStrategy), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:batchStrategy: ", p), err) } + } + return err +} + +func (p *JobUpdateStrategy) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetVarBatchStrategy() { + if err := oprot.WriteFieldBegin(ctx, "varBatchStrategy", thrift.STRUCT, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:varBatchStrategy: ", p), err) } + if err := p.VarBatchStrategy.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.VarBatchStrategy), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:varBatchStrategy: ", p), err) } + } + return err +} + +func (p *JobUpdateStrategy) Equals(other *JobUpdateStrategy) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.QueueStrategy.Equals(other.QueueStrategy) { return false } + if !p.BatchStrategy.Equals(other.BatchStrategy) { return false } + if !p.VarBatchStrategy.Equals(other.VarBatchStrategy) { return false } + return true +} + +func (p *JobUpdateStrategy) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("JobUpdateStrategy(%+v)", *p) +} + +// Job update thresholds and limits. +// +// Attributes: +// - UpdateGroupSize: Deprecated, please set value inside of desired update strategy instead. +// Max number of instances being updated at any given moment. +// - MaxPerInstanceFailures: Max number of instance failures to tolerate before marking instance as FAILED. +// - MaxFailedInstances: Max number of FAILED instances to tolerate before terminating the update. +// - MinWaitInInstanceRunningMs: Min time to watch a RUNNING instance. +// - RollbackOnFailure: If true, enables failed update rollback. +// - UpdateOnlyTheseInstances: Instance IDs to act on. All instances will be affected if this is not set. +// - WaitForBatchCompletion: Deprecated, please set updateStrategy to the Batch strategy instead. +// If true, use updateGroupSize as strict batching boundaries, and avoid proceeding to another +// batch until the preceding batch finishes updating. +// - BlockIfNoPulsesAfterMs: If set, requires external calls to pulseJobUpdate RPC within the specified rate for the +// update to make progress. If no pulses received within specified interval the update will +// block. A blocked update is unable to continue but retains its current status. It may only get +// unblocked by a fresh pulseJobUpdate call. +// - SlaAware: If true, updates will obey the SLA requirements of the tasks being updated. If the SLA policy +// differs between the old and new task configurations, updates will use the newest configuration. +// - UpdateStrategy: Update strategy to be used for the update. See JobUpdateStrategy for choices. +type JobUpdateSettings struct { + UpdateGroupSize int32 `thrift:"updateGroupSize,1" db:"updateGroupSize" json:"updateGroupSize"` + MaxPerInstanceFailures int32 `thrift:"maxPerInstanceFailures,2" db:"maxPerInstanceFailures" json:"maxPerInstanceFailures"` + MaxFailedInstances int32 `thrift:"maxFailedInstances,3" db:"maxFailedInstances" json:"maxFailedInstances"` + // unused field # 4 + MinWaitInInstanceRunningMs int32 `thrift:"minWaitInInstanceRunningMs,5" db:"minWaitInInstanceRunningMs" json:"minWaitInInstanceRunningMs"` + RollbackOnFailure bool `thrift:"rollbackOnFailure,6" db:"rollbackOnFailure" json:"rollbackOnFailure"` + UpdateOnlyTheseInstances []*Range `thrift:"updateOnlyTheseInstances,7" db:"updateOnlyTheseInstances" json:"updateOnlyTheseInstances"` + WaitForBatchCompletion bool `thrift:"waitForBatchCompletion,8" db:"waitForBatchCompletion" json:"waitForBatchCompletion"` + BlockIfNoPulsesAfterMs *int32 `thrift:"blockIfNoPulsesAfterMs,9" db:"blockIfNoPulsesAfterMs" json:"blockIfNoPulsesAfterMs,omitempty"` + SlaAware *bool `thrift:"slaAware,10" db:"slaAware" json:"slaAware,omitempty"` + UpdateStrategy *JobUpdateStrategy `thrift:"updateStrategy,11" db:"updateStrategy" json:"updateStrategy,omitempty"` +} + +func NewJobUpdateSettings() *JobUpdateSettings { + return &JobUpdateSettings{} +} + + +func (p *JobUpdateSettings) GetUpdateGroupSize() int32 { + return p.UpdateGroupSize +} + +func (p *JobUpdateSettings) GetMaxPerInstanceFailures() int32 { + return p.MaxPerInstanceFailures +} + +func (p *JobUpdateSettings) GetMaxFailedInstances() int32 { + return p.MaxFailedInstances +} + +func (p *JobUpdateSettings) GetMinWaitInInstanceRunningMs() int32 { + return p.MinWaitInInstanceRunningMs +} + +func (p *JobUpdateSettings) GetRollbackOnFailure() bool { + return p.RollbackOnFailure +} + +func (p *JobUpdateSettings) GetUpdateOnlyTheseInstances() []*Range { + return p.UpdateOnlyTheseInstances +} + +func (p *JobUpdateSettings) GetWaitForBatchCompletion() bool { + return p.WaitForBatchCompletion +} +var JobUpdateSettings_BlockIfNoPulsesAfterMs_DEFAULT int32 +func (p *JobUpdateSettings) GetBlockIfNoPulsesAfterMs() int32 { + if !p.IsSetBlockIfNoPulsesAfterMs() { + return JobUpdateSettings_BlockIfNoPulsesAfterMs_DEFAULT + } +return *p.BlockIfNoPulsesAfterMs +} +var JobUpdateSettings_SlaAware_DEFAULT bool +func (p *JobUpdateSettings) GetSlaAware() bool { + if !p.IsSetSlaAware() { + return JobUpdateSettings_SlaAware_DEFAULT + } +return *p.SlaAware +} +var JobUpdateSettings_UpdateStrategy_DEFAULT *JobUpdateStrategy +func (p *JobUpdateSettings) GetUpdateStrategy() *JobUpdateStrategy { + if !p.IsSetUpdateStrategy() { + return JobUpdateSettings_UpdateStrategy_DEFAULT + } +return p.UpdateStrategy +} +func (p *JobUpdateSettings) IsSetBlockIfNoPulsesAfterMs() bool { + return p.BlockIfNoPulsesAfterMs != nil +} + +func (p *JobUpdateSettings) IsSetSlaAware() bool { + return p.SlaAware != nil +} + +func (p *JobUpdateSettings) IsSetUpdateStrategy() bool { + return p.UpdateStrategy != nil +} + +func (p *JobUpdateSettings) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I32 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.I32 { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 5: + if fieldTypeId == thrift.I32 { + if err := p.ReadField5(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 6: + if fieldTypeId == thrift.BOOL { + if err := p.ReadField6(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 7: + if fieldTypeId == thrift.SET { + if err := p.ReadField7(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 8: + if fieldTypeId == thrift.BOOL { + if err := p.ReadField8(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 9: + if fieldTypeId == thrift.I32 { + if err := p.ReadField9(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 10: + if fieldTypeId == thrift.BOOL { + if err := p.ReadField10(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 11: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField11(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JobUpdateSettings) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.UpdateGroupSize = v +} + return nil +} + +func (p *JobUpdateSettings) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.MaxPerInstanceFailures = v +} + return nil +} + +func (p *JobUpdateSettings) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.MaxFailedInstances = v +} + return nil +} + +func (p *JobUpdateSettings) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 5: ", err) +} else { + p.MinWaitInInstanceRunningMs = v +} + return nil +} + +func (p *JobUpdateSettings) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { + return thrift.PrependError("error reading field 6: ", err) +} else { + p.RollbackOnFailure = v +} + return nil +} + +func (p *JobUpdateSettings) ReadField7(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*Range, 0, size) + p.UpdateOnlyTheseInstances = tSet + for i := 0; i < size; i ++ { + _elem50 := &Range{} + if err := _elem50.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem50), err) + } + p.UpdateOnlyTheseInstances = append(p.UpdateOnlyTheseInstances, _elem50) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *JobUpdateSettings) ReadField8(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { + return thrift.PrependError("error reading field 8: ", err) +} else { + p.WaitForBatchCompletion = v +} + return nil +} + +func (p *JobUpdateSettings) ReadField9(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 9: ", err) +} else { + p.BlockIfNoPulsesAfterMs = &v +} + return nil +} + +func (p *JobUpdateSettings) ReadField10(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadBool(ctx); err != nil { + return thrift.PrependError("error reading field 10: ", err) +} else { + p.SlaAware = &v +} + return nil +} + +func (p *JobUpdateSettings) ReadField11(ctx context.Context, iprot thrift.TProtocol) error { + p.UpdateStrategy = &JobUpdateStrategy{} + if err := p.UpdateStrategy.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.UpdateStrategy), err) + } + return nil +} + +func (p *JobUpdateSettings) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateSettings"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } + if err := p.writeField7(ctx, oprot); err != nil { return err } + if err := p.writeField8(ctx, oprot); err != nil { return err } + if err := p.writeField9(ctx, oprot); err != nil { return err } + if err := p.writeField10(ctx, oprot); err != nil { return err } + if err := p.writeField11(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JobUpdateSettings) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "updateGroupSize", thrift.I32, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:updateGroupSize: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.UpdateGroupSize)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.updateGroupSize (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:updateGroupSize: ", p), err) } + return err +} + +func (p *JobUpdateSettings) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "maxPerInstanceFailures", thrift.I32, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:maxPerInstanceFailures: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.MaxPerInstanceFailures)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.maxPerInstanceFailures (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:maxPerInstanceFailures: ", p), err) } + return err +} + +func (p *JobUpdateSettings) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "maxFailedInstances", thrift.I32, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:maxFailedInstances: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.MaxFailedInstances)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.maxFailedInstances (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:maxFailedInstances: ", p), err) } + return err +} + +func (p *JobUpdateSettings) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "minWaitInInstanceRunningMs", thrift.I32, 5); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:minWaitInInstanceRunningMs: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.MinWaitInInstanceRunningMs)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.minWaitInInstanceRunningMs (5) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 5:minWaitInInstanceRunningMs: ", p), err) } + return err +} + +func (p *JobUpdateSettings) writeField6(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "rollbackOnFailure", thrift.BOOL, 6); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:rollbackOnFailure: ", p), err) } + if err := oprot.WriteBool(ctx, bool(p.RollbackOnFailure)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.rollbackOnFailure (6) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 6:rollbackOnFailure: ", p), err) } + return err +} + +func (p *JobUpdateSettings) writeField7(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "updateOnlyTheseInstances", thrift.SET, 7); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:updateOnlyTheseInstances: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.UpdateOnlyTheseInstances)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("JobUpdateSettings(%+v)", *p) +} + +// Event marking a state transition in job update lifecycle. +// +// Attributes: +// - Status: Update status. +// - TimestampMs: Epoch timestamp in milliseconds. +// - User: User who performed this event (if user-initiated). +// - Message: Message from the user (for user-initiated transitions) or the scheduler about why the state was +// changed. +type JobUpdateEvent struct { + Status JobUpdateStatus `thrift:"status,1" db:"status" json:"status"` + TimestampMs int64 `thrift:"timestampMs,2" db:"timestampMs" json:"timestampMs"` + User *string `thrift:"user,3" db:"user" json:"user,omitempty"` + Message *string `thrift:"message,4" db:"message" json:"message,omitempty"` +} + +func NewJobUpdateEvent() *JobUpdateEvent { + return &JobUpdateEvent{} +} + + +func (p *JobUpdateEvent) GetStatus() JobUpdateStatus { + return p.Status +} + +func (p *JobUpdateEvent) GetTimestampMs() int64 { + return p.TimestampMs +} +var JobUpdateEvent_User_DEFAULT string +func (p *JobUpdateEvent) GetUser() string { + if !p.IsSetUser() { + return JobUpdateEvent_User_DEFAULT + } +return *p.User +} +var JobUpdateEvent_Message_DEFAULT string +func (p *JobUpdateEvent) GetMessage() string { + if !p.IsSetMessage() { + return JobUpdateEvent_Message_DEFAULT + } +return *p.Message +} +func (p *JobUpdateEvent) IsSetUser() bool { + return p.User != nil +} + +func (p *JobUpdateEvent) IsSetMessage() bool { + return p.Message != nil +} + +func (p *JobUpdateEvent) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I64 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRING { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.STRING { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JobUpdateEvent) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + temp := JobUpdateStatus(v) + p.Status = temp +} + return nil +} + +func (p *JobUpdateEvent) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.TimestampMs = v +} + return nil +} + +func (p *JobUpdateEvent) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.User = &v +} + return nil +} + +func (p *JobUpdateEvent) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 4: ", err) +} else { + p.Message = &v +} + return nil +} + +func (p *JobUpdateEvent) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateEvent"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JobUpdateEvent) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "status", thrift.I32, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:status: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.Status)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.status (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:status: ", p), err) } + return err +} + +func (p *JobUpdateEvent) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "timestampMs", thrift.I64, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:timestampMs: ", p), err) } + if err := oprot.WriteI64(ctx, int64(p.TimestampMs)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.timestampMs (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:timestampMs: ", p), err) } + return err +} + +func (p *JobUpdateEvent) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetUser() { + if err := oprot.WriteFieldBegin(ctx, "user", thrift.STRING, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:user: ", p), err) } + if err := oprot.WriteString(ctx, string(*p.User)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.user (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:user: ", p), err) } + } + return err +} + +func (p *JobUpdateEvent) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetMessage() { + if err := oprot.WriteFieldBegin(ctx, "message", thrift.STRING, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:message: ", p), err) } + if err := oprot.WriteString(ctx, string(*p.Message)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.message (4) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:message: ", p), err) } + } + return err +} + +func (p *JobUpdateEvent) Equals(other *JobUpdateEvent) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Status != other.Status { return false } + if p.TimestampMs != other.TimestampMs { return false } + if p.User != other.User { + if p.User == nil || other.User == nil { + return false + } + if (*p.User) != (*other.User) { return false } + } + if p.Message != other.Message { + if p.Message == nil || other.Message == nil { + return false + } + if (*p.Message) != (*other.Message) { return false } + } + return true +} + +func (p *JobUpdateEvent) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("JobUpdateEvent(%+v)", *p) +} + +// Event marking a state transition in job instance update lifecycle. +// +// Attributes: +// - InstanceId: Job instance ID. +// - TimestampMs: Epoch timestamp in milliseconds. +// - Action: Job update action taken on the instance. +// - Message: Optional message explaining the instance update event. +type JobInstanceUpdateEvent struct { + InstanceId int32 `thrift:"instanceId,1" db:"instanceId" json:"instanceId"` + TimestampMs int64 `thrift:"timestampMs,2" db:"timestampMs" json:"timestampMs"` + Action JobUpdateAction `thrift:"action,3" db:"action" json:"action"` + Message *string `thrift:"message,4" db:"message" json:"message,omitempty"` +} + +func NewJobInstanceUpdateEvent() *JobInstanceUpdateEvent { + return &JobInstanceUpdateEvent{} +} + + +func (p *JobInstanceUpdateEvent) GetInstanceId() int32 { + return p.InstanceId +} + +func (p *JobInstanceUpdateEvent) GetTimestampMs() int64 { + return p.TimestampMs +} + +func (p *JobInstanceUpdateEvent) GetAction() JobUpdateAction { + return p.Action +} +var JobInstanceUpdateEvent_Message_DEFAULT string +func (p *JobInstanceUpdateEvent) GetMessage() string { + if !p.IsSetMessage() { + return JobInstanceUpdateEvent_Message_DEFAULT + } +return *p.Message +} +func (p *JobInstanceUpdateEvent) IsSetMessage() bool { + return p.Message != nil +} + +func (p *JobInstanceUpdateEvent) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I64 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.I32 { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.STRING { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JobInstanceUpdateEvent) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.InstanceId = v +} + return nil +} + +func (p *JobInstanceUpdateEvent) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.TimestampMs = v +} + return nil +} + +func (p *JobInstanceUpdateEvent) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + temp := JobUpdateAction(v) + p.Action = temp +} + return nil +} + +func (p *JobInstanceUpdateEvent) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 4: ", err) +} else { + p.Message = &v +} + return nil +} + +func (p *JobInstanceUpdateEvent) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobInstanceUpdateEvent"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JobInstanceUpdateEvent) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instanceId", thrift.I32, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:instanceId: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.InstanceId)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.instanceId (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:instanceId: ", p), err) } + return err +} + +func (p *JobInstanceUpdateEvent) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "timestampMs", thrift.I64, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:timestampMs: ", p), err) } + if err := oprot.WriteI64(ctx, int64(p.TimestampMs)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.timestampMs (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:timestampMs: ", p), err) } + return err +} + +func (p *JobInstanceUpdateEvent) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "action", thrift.I32, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:action: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.Action)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.action (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:action: ", p), err) } + return err +} + +func (p *JobInstanceUpdateEvent) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetMessage() { + if err := oprot.WriteFieldBegin(ctx, "message", thrift.STRING, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:message: ", p), err) } + if err := oprot.WriteString(ctx, string(*p.Message)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.message (4) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:message: ", p), err) } + } + return err +} + +func (p *JobInstanceUpdateEvent) Equals(other *JobInstanceUpdateEvent) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.InstanceId != other.InstanceId { return false } + if p.TimestampMs != other.TimestampMs { return false } + if p.Action != other.Action { return false } + if p.Message != other.Message { + if p.Message == nil || other.Message == nil { + return false + } + if (*p.Message) != (*other.Message) { return false } + } + return true +} + +func (p *JobInstanceUpdateEvent) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("JobInstanceUpdateEvent(%+v)", *p) +} + +// Maps instance IDs to TaskConfigs it. +// +// Attributes: +// - Task: A TaskConfig associated with instances. +// - Instances: Instances associated with the TaskConfig. +type InstanceTaskConfig struct { + Task *TaskConfig `thrift:"task,1" db:"task" json:"task"` + Instances []*Range `thrift:"instances,2" db:"instances" json:"instances"` +} + +func NewInstanceTaskConfig() *InstanceTaskConfig { + return &InstanceTaskConfig{} +} + +var InstanceTaskConfig_Task_DEFAULT *TaskConfig +func (p *InstanceTaskConfig) GetTask() *TaskConfig { + if !p.IsSetTask() { + return InstanceTaskConfig_Task_DEFAULT + } +return p.Task +} + +func (p *InstanceTaskConfig) GetInstances() []*Range { + return p.Instances +} +func (p *InstanceTaskConfig) IsSetTask() bool { + return p.Task != nil +} + +func (p *InstanceTaskConfig) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.SET { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *InstanceTaskConfig) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Task = &TaskConfig{} + if err := p.Task.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Task), err) + } + return nil +} + +func (p *InstanceTaskConfig) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*Range, 0, size) + p.Instances = tSet + for i := 0; i < size; i ++ { + _elem52 := &Range{} + if err := _elem52.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem52), err) + } + p.Instances = append(p.Instances, _elem52) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *InstanceTaskConfig) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "InstanceTaskConfig"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *InstanceTaskConfig) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "task", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:task: ", p), err) } + if err := p.Task.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Task), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:task: ", p), err) } + return err +} + +func (p *InstanceTaskConfig) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instances", thrift.SET, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:instances: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Instances)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("InstanceTaskConfig(%+v)", *p) +} + +// Current job update state including status and created/modified timestamps. +// +// Attributes: +// - Status: Current status of the update. +// - CreatedTimestampMs: Created timestamp in milliseconds. +// - LastModifiedTimestampMs: Last modified timestamp in milliseconds. +type JobUpdateState struct { + Status JobUpdateStatus `thrift:"status,1" db:"status" json:"status"` + CreatedTimestampMs int64 `thrift:"createdTimestampMs,2" db:"createdTimestampMs" json:"createdTimestampMs"` + LastModifiedTimestampMs int64 `thrift:"lastModifiedTimestampMs,3" db:"lastModifiedTimestampMs" json:"lastModifiedTimestampMs"` +} + +func NewJobUpdateState() *JobUpdateState { + return &JobUpdateState{} +} + + +func (p *JobUpdateState) GetStatus() JobUpdateStatus { + return p.Status +} + +func (p *JobUpdateState) GetCreatedTimestampMs() int64 { + return p.CreatedTimestampMs +} + +func (p *JobUpdateState) GetLastModifiedTimestampMs() int64 { + return p.LastModifiedTimestampMs +} +func (p *JobUpdateState) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I64 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.I64 { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JobUpdateState) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + temp := JobUpdateStatus(v) + p.Status = temp +} + return nil +} + +func (p *JobUpdateState) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.CreatedTimestampMs = v +} + return nil +} + +func (p *JobUpdateState) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.LastModifiedTimestampMs = v +} + return nil +} + +func (p *JobUpdateState) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateState"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JobUpdateState) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "status", thrift.I32, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:status: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.Status)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.status (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:status: ", p), err) } + return err +} + +func (p *JobUpdateState) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "createdTimestampMs", thrift.I64, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:createdTimestampMs: ", p), err) } + if err := oprot.WriteI64(ctx, int64(p.CreatedTimestampMs)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.createdTimestampMs (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:createdTimestampMs: ", p), err) } + return err +} + +func (p *JobUpdateState) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "lastModifiedTimestampMs", thrift.I64, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:lastModifiedTimestampMs: ", p), err) } + if err := oprot.WriteI64(ctx, int64(p.LastModifiedTimestampMs)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.lastModifiedTimestampMs (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:lastModifiedTimestampMs: ", p), err) } + return err +} + +func (p *JobUpdateState) Equals(other *JobUpdateState) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Status != other.Status { return false } + if p.CreatedTimestampMs != other.CreatedTimestampMs { return false } + if p.LastModifiedTimestampMs != other.LastModifiedTimestampMs { return false } + return true +} + +func (p *JobUpdateState) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("JobUpdateState(%+v)", *p) +} + +// Summary of the job update including job key, user and current state. +// +// Attributes: +// - Key: Unique identifier for the update. +// - User: User initiated an update. +// - State: Current job update state. +// - Metadata: Update metadata supplied by the client. +type JobUpdateSummary struct { + // unused fields # 1 to 2 + User string `thrift:"user,3" db:"user" json:"user"` + State *JobUpdateState `thrift:"state,4" db:"state" json:"state"` + Key *JobUpdateKey `thrift:"key,5" db:"key" json:"key"` + Metadata []*Metadata `thrift:"metadata,6" db:"metadata" json:"metadata,omitempty"` +} + +func NewJobUpdateSummary() *JobUpdateSummary { + return &JobUpdateSummary{} +} + +var JobUpdateSummary_Key_DEFAULT *JobUpdateKey +func (p *JobUpdateSummary) GetKey() *JobUpdateKey { + if !p.IsSetKey() { + return JobUpdateSummary_Key_DEFAULT + } +return p.Key +} + +func (p *JobUpdateSummary) GetUser() string { + return p.User +} +var JobUpdateSummary_State_DEFAULT *JobUpdateState +func (p *JobUpdateSummary) GetState() *JobUpdateState { + if !p.IsSetState() { + return JobUpdateSummary_State_DEFAULT + } +return p.State +} +var JobUpdateSummary_Metadata_DEFAULT []*Metadata + +func (p *JobUpdateSummary) GetMetadata() []*Metadata { + return p.Metadata +} +func (p *JobUpdateSummary) IsSetKey() bool { + return p.Key != nil +} + +func (p *JobUpdateSummary) IsSetState() bool { + return p.State != nil +} + +func (p *JobUpdateSummary) IsSetMetadata() bool { + return p.Metadata != nil +} + +func (p *JobUpdateSummary) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 5: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField5(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRING { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 6: + if fieldTypeId == thrift.SET { + if err := p.ReadField6(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JobUpdateSummary) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + p.Key = &JobUpdateKey{} + if err := p.Key.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) + } + return nil +} + +func (p *JobUpdateSummary) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.User = v +} + return nil +} + +func (p *JobUpdateSummary) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + p.State = &JobUpdateState{} + if err := p.State.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.State), err) + } + return nil +} + +func (p *JobUpdateSummary) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*Metadata, 0, size) + p.Metadata = tSet + for i := 0; i < size; i ++ { + _elem54 := &Metadata{} + if err := _elem54.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem54), err) + } + p.Metadata = append(p.Metadata, _elem54) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *JobUpdateSummary) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateSummary"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JobUpdateSummary) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "user", thrift.STRING, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:user: ", p), err) } + if err := oprot.WriteString(ctx, string(p.User)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.user (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:user: ", p), err) } + return err +} + +func (p *JobUpdateSummary) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "state", thrift.STRUCT, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:state: ", p), err) } + if err := p.State.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.State), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:state: ", p), err) } + return err +} + +func (p *JobUpdateSummary) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 5); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:key: ", p), err) } + if err := p.Key.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 5:key: ", p), err) } + return err +} + +func (p *JobUpdateSummary) writeField6(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetMetadata() { + if err := oprot.WriteFieldBegin(ctx, "metadata", thrift.SET, 6); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:metadata: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Metadata)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("JobUpdateSummary(%+v)", *p) +} + +// Update configuration and setting details. +// +// Attributes: +// - InitialState: Actual InstanceId -> TaskConfig mapping when the update was requested. +// - DesiredState: Desired configuration when the update completes. +// - Settings: Update specific settings. +type JobUpdateInstructions struct { + InitialState []*InstanceTaskConfig `thrift:"initialState,1" db:"initialState" json:"initialState"` + DesiredState *InstanceTaskConfig `thrift:"desiredState,2" db:"desiredState" json:"desiredState"` + Settings *JobUpdateSettings `thrift:"settings,3" db:"settings" json:"settings"` +} + +func NewJobUpdateInstructions() *JobUpdateInstructions { + return &JobUpdateInstructions{} +} + + +func (p *JobUpdateInstructions) GetInitialState() []*InstanceTaskConfig { + return p.InitialState +} +var JobUpdateInstructions_DesiredState_DEFAULT *InstanceTaskConfig +func (p *JobUpdateInstructions) GetDesiredState() *InstanceTaskConfig { + if !p.IsSetDesiredState() { + return JobUpdateInstructions_DesiredState_DEFAULT + } +return p.DesiredState +} +var JobUpdateInstructions_Settings_DEFAULT *JobUpdateSettings +func (p *JobUpdateInstructions) GetSettings() *JobUpdateSettings { + if !p.IsSetSettings() { + return JobUpdateInstructions_Settings_DEFAULT + } +return p.Settings +} +func (p *JobUpdateInstructions) IsSetDesiredState() bool { + return p.DesiredState != nil +} + +func (p *JobUpdateInstructions) IsSetSettings() bool { + return p.Settings != nil +} + +func (p *JobUpdateInstructions) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.SET { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JobUpdateInstructions) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*InstanceTaskConfig, 0, size) + p.InitialState = tSet + for i := 0; i < size; i ++ { + _elem56 := &InstanceTaskConfig{} + if err := _elem56.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem56), err) + } + p.InitialState = append(p.InitialState, _elem56) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *JobUpdateInstructions) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.DesiredState = &InstanceTaskConfig{} + if err := p.DesiredState.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.DesiredState), err) + } + return nil +} + +func (p *JobUpdateInstructions) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + p.Settings = &JobUpdateSettings{} + if err := p.Settings.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Settings), err) + } + return nil +} + +func (p *JobUpdateInstructions) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateInstructions"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JobUpdateInstructions) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "initialState", thrift.SET, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:initialState: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.InitialState)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("JobUpdateInstructions(%+v)", *p) +} + +// Full definition of the job update. +// +// Attributes: +// - Summary: Update summary. +// - Instructions: Update configuration. +type JobUpdate struct { + Summary *JobUpdateSummary `thrift:"summary,1" db:"summary" json:"summary"` + Instructions *JobUpdateInstructions `thrift:"instructions,2" db:"instructions" json:"instructions"` +} + +func NewJobUpdate() *JobUpdate { + return &JobUpdate{} +} + +var JobUpdate_Summary_DEFAULT *JobUpdateSummary +func (p *JobUpdate) GetSummary() *JobUpdateSummary { + if !p.IsSetSummary() { + return JobUpdate_Summary_DEFAULT + } +return p.Summary +} +var JobUpdate_Instructions_DEFAULT *JobUpdateInstructions +func (p *JobUpdate) GetInstructions() *JobUpdateInstructions { + if !p.IsSetInstructions() { + return JobUpdate_Instructions_DEFAULT + } +return p.Instructions +} +func (p *JobUpdate) IsSetSummary() bool { + return p.Summary != nil +} + +func (p *JobUpdate) IsSetInstructions() bool { + return p.Instructions != nil +} + +func (p *JobUpdate) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JobUpdate) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Summary = &JobUpdateSummary{} + if err := p.Summary.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Summary), err) + } + return nil +} + +func (p *JobUpdate) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.Instructions = &JobUpdateInstructions{} + if err := p.Instructions.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Instructions), err) + } + return nil +} + +func (p *JobUpdate) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdate"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JobUpdate) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "summary", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:summary: ", p), err) } + if err := p.Summary.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Summary), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:summary: ", p), err) } + return err +} + +func (p *JobUpdate) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instructions", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:instructions: ", p), err) } + if err := p.Instructions.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Instructions), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:instructions: ", p), err) } + return err +} + +func (p *JobUpdate) Equals(other *JobUpdate) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Summary.Equals(other.Summary) { return false } + if !p.Instructions.Equals(other.Instructions) { return false } + return true +} + +func (p *JobUpdate) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("JobUpdate(%+v)", *p) +} + +// Attributes: +// - Update: Update definition. +// - UpdateEvents: History for this update. +// - InstanceEvents: History for the individual instances updated. +type JobUpdateDetails struct { + Update *JobUpdate `thrift:"update,1" db:"update" json:"update"` + UpdateEvents []*JobUpdateEvent `thrift:"updateEvents,2" db:"updateEvents" json:"updateEvents"` + InstanceEvents []*JobInstanceUpdateEvent `thrift:"instanceEvents,3" db:"instanceEvents" json:"instanceEvents"` +} + +func NewJobUpdateDetails() *JobUpdateDetails { + return &JobUpdateDetails{} +} + +var JobUpdateDetails_Update_DEFAULT *JobUpdate +func (p *JobUpdateDetails) GetUpdate() *JobUpdate { + if !p.IsSetUpdate() { + return JobUpdateDetails_Update_DEFAULT + } +return p.Update +} + +func (p *JobUpdateDetails) GetUpdateEvents() []*JobUpdateEvent { + return p.UpdateEvents +} + +func (p *JobUpdateDetails) GetInstanceEvents() []*JobInstanceUpdateEvent { + return p.InstanceEvents +} +func (p *JobUpdateDetails) IsSetUpdate() bool { + return p.Update != nil +} + +func (p *JobUpdateDetails) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.LIST { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.LIST { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JobUpdateDetails) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Update = &JobUpdate{} + if err := p.Update.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Update), err) + } + return nil +} + +func (p *JobUpdateDetails) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]*JobUpdateEvent, 0, size) + p.UpdateEvents = tSlice + for i := 0; i < size; i ++ { + _elem58 := &JobUpdateEvent{} + if err := _elem58.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem58), err) + } + p.UpdateEvents = append(p.UpdateEvents, _elem58) + } + if err := iprot.ReadListEnd(ctx); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *JobUpdateDetails) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]*JobInstanceUpdateEvent, 0, size) + p.InstanceEvents = tSlice + for i := 0; i < size; i ++ { + _elem59 := &JobInstanceUpdateEvent{} + if err := _elem59.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem59), err) + } + p.InstanceEvents = append(p.InstanceEvents, _elem59) + } + if err := iprot.ReadListEnd(ctx); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *JobUpdateDetails) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateDetails"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JobUpdateDetails) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "update", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:update: ", p), err) } + if err := p.Update.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Update), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:update: ", p), err) } + return err +} + +func (p *JobUpdateDetails) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "updateEvents", thrift.LIST, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:updateEvents: ", p), err) } + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.UpdateEvents)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.UpdateEvents { + if err := v.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) + } + } + if err := oprot.WriteListEnd(ctx); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:updateEvents: ", p), err) } + return err +} + +func (p *JobUpdateDetails) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instanceEvents", thrift.LIST, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:instanceEvents: ", p), err) } + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.InstanceEvents)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.InstanceEvents { + if err := v.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) + } + } + if err := oprot.WriteListEnd(ctx); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:instanceEvents: ", p), err) } + return err +} + +func (p *JobUpdateDetails) Equals(other *JobUpdateDetails) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Update.Equals(other.Update) { return false } + if len(p.UpdateEvents) != len(other.UpdateEvents) { return false } + for i, _tgt := range p.UpdateEvents { + _src60 := other.UpdateEvents[i] + if !_tgt.Equals(_src60) { return false } + } + if len(p.InstanceEvents) != len(other.InstanceEvents) { return false } + for i, _tgt := range p.InstanceEvents { + _src61 := other.InstanceEvents[i] + if !_tgt.Equals(_src61) { return false } + } + return true +} + +func (p *JobUpdateDetails) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("JobUpdateDetails(%+v)", *p) +} + +// A request to update the following instances of an existing job. Used by startUpdate. +// +// Attributes: +// - TaskConfig: Desired TaskConfig to apply. +// - InstanceCount: Desired number of instances of the task config. +// - Settings: Update settings and limits. +// - Metadata: Update metadata supplied by the client issuing the JobUpdateRequest. +type JobUpdateRequest struct { + TaskConfig *TaskConfig `thrift:"taskConfig,1" db:"taskConfig" json:"taskConfig"` + InstanceCount int32 `thrift:"instanceCount,2" db:"instanceCount" json:"instanceCount"` + Settings *JobUpdateSettings `thrift:"settings,3" db:"settings" json:"settings"` + Metadata []*Metadata `thrift:"metadata,4" db:"metadata" json:"metadata,omitempty"` +} + +func NewJobUpdateRequest() *JobUpdateRequest { + return &JobUpdateRequest{} +} + +var JobUpdateRequest_TaskConfig_DEFAULT *TaskConfig +func (p *JobUpdateRequest) GetTaskConfig() *TaskConfig { + if !p.IsSetTaskConfig() { + return JobUpdateRequest_TaskConfig_DEFAULT + } +return p.TaskConfig +} + +func (p *JobUpdateRequest) GetInstanceCount() int32 { + return p.InstanceCount +} +var JobUpdateRequest_Settings_DEFAULT *JobUpdateSettings +func (p *JobUpdateRequest) GetSettings() *JobUpdateSettings { + if !p.IsSetSettings() { + return JobUpdateRequest_Settings_DEFAULT + } +return p.Settings +} +var JobUpdateRequest_Metadata_DEFAULT []*Metadata + +func (p *JobUpdateRequest) GetMetadata() []*Metadata { + return p.Metadata +} +func (p *JobUpdateRequest) IsSetTaskConfig() bool { + return p.TaskConfig != nil +} + +func (p *JobUpdateRequest) IsSetSettings() bool { + return p.Settings != nil +} + +func (p *JobUpdateRequest) IsSetMetadata() bool { + return p.Metadata != nil +} + +func (p *JobUpdateRequest) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I32 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.SET { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JobUpdateRequest) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.TaskConfig = &TaskConfig{} + if err := p.TaskConfig.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.TaskConfig), err) + } + return nil +} + +func (p *JobUpdateRequest) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.InstanceCount = v +} + return nil +} + +func (p *JobUpdateRequest) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + p.Settings = &JobUpdateSettings{} + if err := p.Settings.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Settings), err) + } + return nil +} + +func (p *JobUpdateRequest) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*Metadata, 0, size) + p.Metadata = tSet + for i := 0; i < size; i ++ { + _elem62 := &Metadata{} + if err := _elem62.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem62), err) + } + p.Metadata = append(p.Metadata, _elem62) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *JobUpdateRequest) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateRequest"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JobUpdateRequest) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "taskConfig", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:taskConfig: ", p), err) } + if err := p.TaskConfig.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.TaskConfig), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:taskConfig: ", p), err) } + return err +} + +func (p *JobUpdateRequest) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instanceCount", thrift.I32, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:instanceCount: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.InstanceCount)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.instanceCount (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:instanceCount: ", p), err) } + return err +} + +func (p *JobUpdateRequest) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "settings", thrift.STRUCT, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:settings: ", p), err) } + if err := p.Settings.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Settings), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:settings: ", p), err) } + return err +} + +func (p *JobUpdateRequest) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetMetadata() { + if err := oprot.WriteFieldBegin(ctx, "metadata", thrift.SET, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:metadata: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Metadata)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("JobUpdateRequest(%+v)", *p) +} + +// Contains a set of restrictions on matching job updates where all restrictions must be met +// (terms are AND'ed together). +// +// Attributes: +// - Role: Job role. +// - Key: Unique identifier for a job update. +// - JobKey: Job key. +// - User: User who created the update. +// - UpdateStatuses: Set of update statuses. +// - Offset: Offset to serve data from. Used by pagination. +// - Limit: Number or records to serve. Used by pagination. +type JobUpdateQuery struct { + // unused field # 1 + Role *string `thrift:"role,2" db:"role" json:"role,omitempty"` + JobKey *JobKey `thrift:"jobKey,3" db:"jobKey" json:"jobKey,omitempty"` + User *string `thrift:"user,4" db:"user" json:"user,omitempty"` + UpdateStatuses []JobUpdateStatus `thrift:"updateStatuses,5" db:"updateStatuses" json:"updateStatuses,omitempty"` + Offset int32 `thrift:"offset,6" db:"offset" json:"offset"` + Limit int32 `thrift:"limit,7" db:"limit" json:"limit"` + Key *JobUpdateKey `thrift:"key,8" db:"key" json:"key,omitempty"` +} + +func NewJobUpdateQuery() *JobUpdateQuery { + return &JobUpdateQuery{} +} + +var JobUpdateQuery_Role_DEFAULT string +func (p *JobUpdateQuery) GetRole() string { + if !p.IsSetRole() { + return JobUpdateQuery_Role_DEFAULT + } +return *p.Role +} +var JobUpdateQuery_Key_DEFAULT *JobUpdateKey +func (p *JobUpdateQuery) GetKey() *JobUpdateKey { + if !p.IsSetKey() { + return JobUpdateQuery_Key_DEFAULT + } +return p.Key +} +var JobUpdateQuery_JobKey_DEFAULT *JobKey +func (p *JobUpdateQuery) GetJobKey() *JobKey { + if !p.IsSetJobKey() { + return JobUpdateQuery_JobKey_DEFAULT + } +return p.JobKey +} +var JobUpdateQuery_User_DEFAULT string +func (p *JobUpdateQuery) GetUser() string { + if !p.IsSetUser() { + return JobUpdateQuery_User_DEFAULT + } +return *p.User +} +var JobUpdateQuery_UpdateStatuses_DEFAULT []JobUpdateStatus + +func (p *JobUpdateQuery) GetUpdateStatuses() []JobUpdateStatus { + return p.UpdateStatuses +} + +func (p *JobUpdateQuery) GetOffset() int32 { + return p.Offset +} + +func (p *JobUpdateQuery) GetLimit() int32 { + return p.Limit +} +func (p *JobUpdateQuery) IsSetRole() bool { + return p.Role != nil +} + +func (p *JobUpdateQuery) IsSetKey() bool { + return p.Key != nil +} + +func (p *JobUpdateQuery) IsSetJobKey() bool { + return p.JobKey != nil +} + +func (p *JobUpdateQuery) IsSetUser() bool { + return p.User != nil +} + +func (p *JobUpdateQuery) IsSetUpdateStatuses() bool { + return p.UpdateStatuses != nil +} + +func (p *JobUpdateQuery) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 8: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField8(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.STRING { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 5: + if fieldTypeId == thrift.SET { + if err := p.ReadField5(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 6: + if fieldTypeId == thrift.I32 { + if err := p.ReadField6(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 7: + if fieldTypeId == thrift.I32 { + if err := p.ReadField7(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JobUpdateQuery) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.Role = &v +} + return nil +} + +func (p *JobUpdateQuery) ReadField8(ctx context.Context, iprot thrift.TProtocol) error { + p.Key = &JobUpdateKey{} + if err := p.Key.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) + } + return nil +} + +func (p *JobUpdateQuery) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + p.JobKey = &JobKey{} + if err := p.JobKey.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.JobKey), err) + } + return nil +} + +func (p *JobUpdateQuery) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 4: ", err) +} else { + p.User = &v +} + return nil +} + +func (p *JobUpdateQuery) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]JobUpdateStatus, 0, size) + p.UpdateStatuses = tSet + for i := 0; i < size; i ++ { +var _elem64 JobUpdateStatus + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + temp := JobUpdateStatus(v) + _elem64 = temp +} + p.UpdateStatuses = append(p.UpdateStatuses, _elem64) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *JobUpdateQuery) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 6: ", err) +} else { + p.Offset = v +} + return nil +} + +func (p *JobUpdateQuery) ReadField7(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 7: ", err) +} else { + p.Limit = v +} + return nil +} + +func (p *JobUpdateQuery) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobUpdateQuery"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } + if err := p.writeField7(ctx, oprot); err != nil { return err } + if err := p.writeField8(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JobUpdateQuery) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetRole() { + if err := oprot.WriteFieldBegin(ctx, "role", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:role: ", p), err) } + if err := oprot.WriteString(ctx, string(*p.Role)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.role (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:role: ", p), err) } + } + return err +} + +func (p *JobUpdateQuery) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetJobKey() { + if err := oprot.WriteFieldBegin(ctx, "jobKey", thrift.STRUCT, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:jobKey: ", p), err) } + if err := p.JobKey.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.JobKey), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:jobKey: ", p), err) } + } + return err +} + +func (p *JobUpdateQuery) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetUser() { + if err := oprot.WriteFieldBegin(ctx, "user", thrift.STRING, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:user: ", p), err) } + if err := oprot.WriteString(ctx, string(*p.User)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.user (4) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:user: ", p), err) } + } + return err +} + +func (p *JobUpdateQuery) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetUpdateStatuses() { + if err := oprot.WriteFieldBegin(ctx, "updateStatuses", thrift.SET, 5); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:updateStatuses: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.I32, len(p.UpdateStatuses)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("JobUpdateQuery(%+v)", *p) +} + +// Attributes: +// - Host +// - DefaultSlaPolicy +// - TimeoutSecs +// - CreatedTimestampMs +type HostMaintenanceRequest struct { + Host string `thrift:"host,1" db:"host" json:"host"` + DefaultSlaPolicy *SlaPolicy `thrift:"defaultSlaPolicy,2" db:"defaultSlaPolicy" json:"defaultSlaPolicy"` + TimeoutSecs int64 `thrift:"timeoutSecs,3" db:"timeoutSecs" json:"timeoutSecs"` + CreatedTimestampMs int64 `thrift:"createdTimestampMs,4" db:"createdTimestampMs" json:"createdTimestampMs"` +} + +func NewHostMaintenanceRequest() *HostMaintenanceRequest { + return &HostMaintenanceRequest{} +} + + +func (p *HostMaintenanceRequest) GetHost() string { + return p.Host +} +var HostMaintenanceRequest_DefaultSlaPolicy_DEFAULT *SlaPolicy +func (p *HostMaintenanceRequest) GetDefaultSlaPolicy() *SlaPolicy { + if !p.IsSetDefaultSlaPolicy() { + return HostMaintenanceRequest_DefaultSlaPolicy_DEFAULT + } +return p.DefaultSlaPolicy +} + +func (p *HostMaintenanceRequest) GetTimeoutSecs() int64 { + return p.TimeoutSecs +} + +func (p *HostMaintenanceRequest) GetCreatedTimestampMs() int64 { + return p.CreatedTimestampMs +} +func (p *HostMaintenanceRequest) IsSetDefaultSlaPolicy() bool { + return p.DefaultSlaPolicy != nil +} + +func (p *HostMaintenanceRequest) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.I64 { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.I64 { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *HostMaintenanceRequest) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Host = v +} + return nil +} + +func (p *HostMaintenanceRequest) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.DefaultSlaPolicy = &SlaPolicy{} + if err := p.DefaultSlaPolicy.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.DefaultSlaPolicy), err) + } + return nil +} + +func (p *HostMaintenanceRequest) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.TimeoutSecs = v +} + return nil +} + +func (p *HostMaintenanceRequest) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 4: ", err) +} else { + p.CreatedTimestampMs = v +} + return nil +} + +func (p *HostMaintenanceRequest) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "HostMaintenanceRequest"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *HostMaintenanceRequest) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "host", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:host: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Host)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.host (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:host: ", p), err) } + return err +} + +func (p *HostMaintenanceRequest) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "defaultSlaPolicy", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:defaultSlaPolicy: ", p), err) } + if err := p.DefaultSlaPolicy.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.DefaultSlaPolicy), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:defaultSlaPolicy: ", p), err) } + return err +} + +func (p *HostMaintenanceRequest) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "timeoutSecs", thrift.I64, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:timeoutSecs: ", p), err) } + if err := oprot.WriteI64(ctx, int64(p.TimeoutSecs)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.timeoutSecs (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:timeoutSecs: ", p), err) } + return err +} + +func (p *HostMaintenanceRequest) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "createdTimestampMs", thrift.I64, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:createdTimestampMs: ", p), err) } + if err := oprot.WriteI64(ctx, int64(p.CreatedTimestampMs)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.createdTimestampMs (4) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:createdTimestampMs: ", p), err) } + return err +} + +func (p *HostMaintenanceRequest) Equals(other *HostMaintenanceRequest) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Host != other.Host { return false } + if !p.DefaultSlaPolicy.Equals(other.DefaultSlaPolicy) { return false } + if p.TimeoutSecs != other.TimeoutSecs { return false } + if p.CreatedTimestampMs != other.CreatedTimestampMs { return false } + return true +} + +func (p *HostMaintenanceRequest) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("HostMaintenanceRequest(%+v)", *p) +} + +// Attributes: +// - Backups +type ListBackupsResult_ struct { + Backups []string `thrift:"backups,1" db:"backups" json:"backups"` +} + +func NewListBackupsResult_() *ListBackupsResult_ { + return &ListBackupsResult_{} +} + + +func (p *ListBackupsResult_) GetBackups() []string { + return p.Backups +} +func (p *ListBackupsResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.SET { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ListBackupsResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]string, 0, size) + p.Backups = tSet + for i := 0; i < size; i ++ { +var _elem66 string + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _elem66 = v +} + p.Backups = append(p.Backups, _elem66) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *ListBackupsResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ListBackupsResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ListBackupsResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "backups", thrift.SET, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:backups: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRING, len(p.Backups)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("ListBackupsResult_(%+v)", *p) +} + +// Attributes: +// - Statuses +type StartMaintenanceResult_ struct { + Statuses []*HostStatus `thrift:"statuses,1" db:"statuses" json:"statuses"` +} + +func NewStartMaintenanceResult_() *StartMaintenanceResult_ { + return &StartMaintenanceResult_{} +} + + +func (p *StartMaintenanceResult_) GetStatuses() []*HostStatus { + return p.Statuses +} +func (p *StartMaintenanceResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.SET { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *StartMaintenanceResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*HostStatus, 0, size) + p.Statuses = tSet + for i := 0; i < size; i ++ { + _elem68 := &HostStatus{} + if err := _elem68.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem68), err) + } + p.Statuses = append(p.Statuses, _elem68) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *StartMaintenanceResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "StartMaintenanceResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *StartMaintenanceResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "statuses", thrift.SET, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:statuses: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Statuses)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("StartMaintenanceResult_(%+v)", *p) +} + +// Attributes: +// - Statuses +type DrainHostsResult_ struct { + Statuses []*HostStatus `thrift:"statuses,1" db:"statuses" json:"statuses"` +} + +func NewDrainHostsResult_() *DrainHostsResult_ { + return &DrainHostsResult_{} +} + + +func (p *DrainHostsResult_) GetStatuses() []*HostStatus { + return p.Statuses +} +func (p *DrainHostsResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.SET { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *DrainHostsResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*HostStatus, 0, size) + p.Statuses = tSet + for i := 0; i < size; i ++ { + _elem70 := &HostStatus{} + if err := _elem70.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem70), err) + } + p.Statuses = append(p.Statuses, _elem70) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *DrainHostsResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "DrainHostsResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *DrainHostsResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "statuses", thrift.SET, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:statuses: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Statuses)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("DrainHostsResult_(%+v)", *p) +} + +// Attributes: +// - Tasks +type QueryRecoveryResult_ struct { + Tasks []*ScheduledTask `thrift:"tasks,1" db:"tasks" json:"tasks"` +} + +func NewQueryRecoveryResult_() *QueryRecoveryResult_ { + return &QueryRecoveryResult_{} +} + + +func (p *QueryRecoveryResult_) GetTasks() []*ScheduledTask { + return p.Tasks +} +func (p *QueryRecoveryResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.SET { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *QueryRecoveryResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*ScheduledTask, 0, size) + p.Tasks = tSet + for i := 0; i < size; i ++ { + _elem72 := &ScheduledTask{} + if err := _elem72.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem72), err) + } + p.Tasks = append(p.Tasks, _elem72) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *QueryRecoveryResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "QueryRecoveryResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *QueryRecoveryResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "tasks", thrift.SET, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:tasks: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Tasks)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("QueryRecoveryResult_(%+v)", *p) +} + +// Attributes: +// - Statuses +type MaintenanceStatusResult_ struct { + Statuses []*HostStatus `thrift:"statuses,1" db:"statuses" json:"statuses"` +} + +func NewMaintenanceStatusResult_() *MaintenanceStatusResult_ { + return &MaintenanceStatusResult_{} +} + + +func (p *MaintenanceStatusResult_) GetStatuses() []*HostStatus { + return p.Statuses +} +func (p *MaintenanceStatusResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.SET { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *MaintenanceStatusResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*HostStatus, 0, size) + p.Statuses = tSet + for i := 0; i < size; i ++ { + _elem74 := &HostStatus{} + if err := _elem74.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem74), err) + } + p.Statuses = append(p.Statuses, _elem74) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *MaintenanceStatusResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "MaintenanceStatusResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *MaintenanceStatusResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "statuses", thrift.SET, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:statuses: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Statuses)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("MaintenanceStatusResult_(%+v)", *p) +} + +// Attributes: +// - Statuses +type EndMaintenanceResult_ struct { + Statuses []*HostStatus `thrift:"statuses,1" db:"statuses" json:"statuses"` +} + +func NewEndMaintenanceResult_() *EndMaintenanceResult_ { + return &EndMaintenanceResult_{} +} + + +func (p *EndMaintenanceResult_) GetStatuses() []*HostStatus { + return p.Statuses +} +func (p *EndMaintenanceResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.SET { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *EndMaintenanceResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*HostStatus, 0, size) + p.Statuses = tSet + for i := 0; i < size; i ++ { + _elem76 := &HostStatus{} + if err := _elem76.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem76), err) + } + p.Statuses = append(p.Statuses, _elem76) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *EndMaintenanceResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "EndMaintenanceResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *EndMaintenanceResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "statuses", thrift.SET, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:statuses: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Statuses)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("EndMaintenanceResult_(%+v)", *p) +} + +// Attributes: +// - Summaries +type RoleSummaryResult_ struct { + Summaries []*RoleSummary `thrift:"summaries,1" db:"summaries" json:"summaries"` +} + +func NewRoleSummaryResult_() *RoleSummaryResult_ { + return &RoleSummaryResult_{} +} + + +func (p *RoleSummaryResult_) GetSummaries() []*RoleSummary { + return p.Summaries +} +func (p *RoleSummaryResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.SET { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *RoleSummaryResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*RoleSummary, 0, size) + p.Summaries = tSet + for i := 0; i < size; i ++ { + _elem78 := &RoleSummary{} + if err := _elem78.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem78), err) + } + p.Summaries = append(p.Summaries, _elem78) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *RoleSummaryResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "RoleSummaryResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *RoleSummaryResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "summaries", thrift.SET, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:summaries: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Summaries)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("RoleSummaryResult_(%+v)", *p) +} + +// Attributes: +// - Summaries +type JobSummaryResult_ struct { + Summaries []*JobSummary `thrift:"summaries,1" db:"summaries" json:"summaries"` +} + +func NewJobSummaryResult_() *JobSummaryResult_ { + return &JobSummaryResult_{} +} + + +func (p *JobSummaryResult_) GetSummaries() []*JobSummary { + return p.Summaries +} +func (p *JobSummaryResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.SET { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *JobSummaryResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*JobSummary, 0, size) + p.Summaries = tSet + for i := 0; i < size; i ++ { + _elem80 := &JobSummary{} + if err := _elem80.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem80), err) + } + p.Summaries = append(p.Summaries, _elem80) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *JobSummaryResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "JobSummaryResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *JobSummaryResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "summaries", thrift.SET, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:summaries: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Summaries)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("JobSummaryResult_(%+v)", *p) +} + +// Attributes: +// - Summary +type ConfigSummaryResult_ struct { + Summary *ConfigSummary `thrift:"summary,1" db:"summary" json:"summary"` +} + +func NewConfigSummaryResult_() *ConfigSummaryResult_ { + return &ConfigSummaryResult_{} +} + +var ConfigSummaryResult__Summary_DEFAULT *ConfigSummary +func (p *ConfigSummaryResult_) GetSummary() *ConfigSummary { + if !p.IsSetSummary() { + return ConfigSummaryResult__Summary_DEFAULT + } +return p.Summary +} +func (p *ConfigSummaryResult_) IsSetSummary() bool { + return p.Summary != nil +} + +func (p *ConfigSummaryResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ConfigSummaryResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Summary = &ConfigSummary{} + if err := p.Summary.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Summary), err) + } + return nil +} + +func (p *ConfigSummaryResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ConfigSummaryResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ConfigSummaryResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "summary", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:summary: ", p), err) } + if err := p.Summary.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Summary), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:summary: ", p), err) } + return err +} + +func (p *ConfigSummaryResult_) Equals(other *ConfigSummaryResult_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Summary.Equals(other.Summary) { return false } + return true +} + +func (p *ConfigSummaryResult_) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ConfigSummaryResult_(%+v)", *p) +} + +// Attributes: +// - Reasons +type GetPendingReasonResult_ struct { + Reasons []*PendingReason `thrift:"reasons,1" db:"reasons" json:"reasons"` +} + +func NewGetPendingReasonResult_() *GetPendingReasonResult_ { + return &GetPendingReasonResult_{} +} + + +func (p *GetPendingReasonResult_) GetReasons() []*PendingReason { + return p.Reasons +} +func (p *GetPendingReasonResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.SET { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *GetPendingReasonResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*PendingReason, 0, size) + p.Reasons = tSet + for i := 0; i < size; i ++ { + _elem82 := &PendingReason{} + if err := _elem82.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem82), err) + } + p.Reasons = append(p.Reasons, _elem82) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *GetPendingReasonResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "GetPendingReasonResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *GetPendingReasonResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "reasons", thrift.SET, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:reasons: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Reasons)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("GetPendingReasonResult_(%+v)", *p) +} + +// Result of the startUpdate call. +// +// Attributes: +// - Key: Unique identifier for the job update. +// - UpdateSummary: Summary of the update that is in progress for the given JobKey. +type StartJobUpdateResult_ struct { + Key *JobUpdateKey `thrift:"key,1" db:"key" json:"key"` + UpdateSummary *JobUpdateSummary `thrift:"updateSummary,2" db:"updateSummary" json:"updateSummary,omitempty"` +} + +func NewStartJobUpdateResult_() *StartJobUpdateResult_ { + return &StartJobUpdateResult_{} +} + +var StartJobUpdateResult__Key_DEFAULT *JobUpdateKey +func (p *StartJobUpdateResult_) GetKey() *JobUpdateKey { + if !p.IsSetKey() { + return StartJobUpdateResult__Key_DEFAULT + } +return p.Key +} +var StartJobUpdateResult__UpdateSummary_DEFAULT *JobUpdateSummary +func (p *StartJobUpdateResult_) GetUpdateSummary() *JobUpdateSummary { + if !p.IsSetUpdateSummary() { + return StartJobUpdateResult__UpdateSummary_DEFAULT + } +return p.UpdateSummary +} +func (p *StartJobUpdateResult_) IsSetKey() bool { + return p.Key != nil +} + +func (p *StartJobUpdateResult_) IsSetUpdateSummary() bool { + return p.UpdateSummary != nil +} + +func (p *StartJobUpdateResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *StartJobUpdateResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Key = &JobUpdateKey{} + if err := p.Key.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) + } + return nil +} + +func (p *StartJobUpdateResult_) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.UpdateSummary = &JobUpdateSummary{} + if err := p.UpdateSummary.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.UpdateSummary), err) + } + return nil +} + +func (p *StartJobUpdateResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "StartJobUpdateResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *StartJobUpdateResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } + if err := p.Key.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } + return err +} + +func (p *StartJobUpdateResult_) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetUpdateSummary() { + if err := oprot.WriteFieldBegin(ctx, "updateSummary", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:updateSummary: ", p), err) } + if err := p.UpdateSummary.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.UpdateSummary), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:updateSummary: ", p), err) } + } + return err +} + +func (p *StartJobUpdateResult_) Equals(other *StartJobUpdateResult_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Key.Equals(other.Key) { return false } + if !p.UpdateSummary.Equals(other.UpdateSummary) { return false } + return true +} + +func (p *StartJobUpdateResult_) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("StartJobUpdateResult_(%+v)", *p) +} + +// Result of the getJobUpdateSummaries call. +// +// Attributes: +// - UpdateSummaries +type GetJobUpdateSummariesResult_ struct { + UpdateSummaries []*JobUpdateSummary `thrift:"updateSummaries,1" db:"updateSummaries" json:"updateSummaries"` +} + +func NewGetJobUpdateSummariesResult_() *GetJobUpdateSummariesResult_ { + return &GetJobUpdateSummariesResult_{} +} + + +func (p *GetJobUpdateSummariesResult_) GetUpdateSummaries() []*JobUpdateSummary { + return p.UpdateSummaries +} +func (p *GetJobUpdateSummariesResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.LIST { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *GetJobUpdateSummariesResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]*JobUpdateSummary, 0, size) + p.UpdateSummaries = tSlice + for i := 0; i < size; i ++ { + _elem84 := &JobUpdateSummary{} + if err := _elem84.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem84), err) + } + p.UpdateSummaries = append(p.UpdateSummaries, _elem84) + } + if err := iprot.ReadListEnd(ctx); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *GetJobUpdateSummariesResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "GetJobUpdateSummariesResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *GetJobUpdateSummariesResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "updateSummaries", thrift.LIST, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:updateSummaries: ", p), err) } + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.UpdateSummaries)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.UpdateSummaries { + if err := v.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) + } + } + if err := oprot.WriteListEnd(ctx); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:updateSummaries: ", p), err) } + return err +} + +func (p *GetJobUpdateSummariesResult_) Equals(other *GetJobUpdateSummariesResult_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if len(p.UpdateSummaries) != len(other.UpdateSummaries) { return false } + for i, _tgt := range p.UpdateSummaries { + _src85 := other.UpdateSummaries[i] + if !_tgt.Equals(_src85) { return false } + } + return true +} + +func (p *GetJobUpdateSummariesResult_) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetJobUpdateSummariesResult_(%+v)", *p) +} + +// Result of the getJobUpdateDetails call. +// +// Attributes: +// - Details +// - DetailsList +type GetJobUpdateDetailsResult_ struct { + Details *JobUpdateDetails `thrift:"details,1" db:"details" json:"details"` + DetailsList []*JobUpdateDetails `thrift:"detailsList,2" db:"detailsList" json:"detailsList"` +} + +func NewGetJobUpdateDetailsResult_() *GetJobUpdateDetailsResult_ { + return &GetJobUpdateDetailsResult_{} +} + +var GetJobUpdateDetailsResult__Details_DEFAULT *JobUpdateDetails +func (p *GetJobUpdateDetailsResult_) GetDetails() *JobUpdateDetails { + if !p.IsSetDetails() { + return GetJobUpdateDetailsResult__Details_DEFAULT + } +return p.Details +} + +func (p *GetJobUpdateDetailsResult_) GetDetailsList() []*JobUpdateDetails { + return p.DetailsList +} +func (p *GetJobUpdateDetailsResult_) IsSetDetails() bool { + return p.Details != nil +} + +func (p *GetJobUpdateDetailsResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.LIST { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *GetJobUpdateDetailsResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Details = &JobUpdateDetails{} + if err := p.Details.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Details), err) + } + return nil +} + +func (p *GetJobUpdateDetailsResult_) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]*JobUpdateDetails, 0, size) + p.DetailsList = tSlice + for i := 0; i < size; i ++ { + _elem86 := &JobUpdateDetails{} + if err := _elem86.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem86), err) + } + p.DetailsList = append(p.DetailsList, _elem86) + } + if err := iprot.ReadListEnd(ctx); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *GetJobUpdateDetailsResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "GetJobUpdateDetailsResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *GetJobUpdateDetailsResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "details", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:details: ", p), err) } + if err := p.Details.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Details), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:details: ", p), err) } + return err +} + +func (p *GetJobUpdateDetailsResult_) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "detailsList", thrift.LIST, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:detailsList: ", p), err) } + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.DetailsList)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.DetailsList { + if err := v.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) + } + } + if err := oprot.WriteListEnd(ctx); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:detailsList: ", p), err) } + return err +} + +func (p *GetJobUpdateDetailsResult_) Equals(other *GetJobUpdateDetailsResult_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.Details.Equals(other.Details) { return false } + if len(p.DetailsList) != len(other.DetailsList) { return false } + for i, _tgt := range p.DetailsList { + _src87 := other.DetailsList[i] + if !_tgt.Equals(_src87) { return false } + } + return true +} + +func (p *GetJobUpdateDetailsResult_) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("GetJobUpdateDetailsResult_(%+v)", *p) +} + +// Result of the pulseJobUpdate call. +// +// Attributes: +// - Status +type PulseJobUpdateResult_ struct { + Status JobUpdatePulseStatus `thrift:"status,1" db:"status" json:"status"` +} + +func NewPulseJobUpdateResult_() *PulseJobUpdateResult_ { + return &PulseJobUpdateResult_{} +} + + +func (p *PulseJobUpdateResult_) GetStatus() JobUpdatePulseStatus { + return p.Status +} +func (p *PulseJobUpdateResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *PulseJobUpdateResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + temp := JobUpdatePulseStatus(v) + p.Status = temp +} + return nil +} + +func (p *PulseJobUpdateResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "PulseJobUpdateResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *PulseJobUpdateResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "status", thrift.I32, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:status: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.Status)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.status (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:status: ", p), err) } + return err +} + +func (p *PulseJobUpdateResult_) Equals(other *PulseJobUpdateResult_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Status != other.Status { return false } + return true +} + +func (p *PulseJobUpdateResult_) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("PulseJobUpdateResult_(%+v)", *p) +} + +// Attributes: +// - Add: Instance addition diff details. +// - Remove: Instance removal diff details. +// - Update: Instance update diff details. +// - Unchanged: Instances unchanged by the update. +type GetJobUpdateDiffResult_ struct { + Add []*ConfigGroup `thrift:"add,1" db:"add" json:"add"` + Remove []*ConfigGroup `thrift:"remove,2" db:"remove" json:"remove"` + Update []*ConfigGroup `thrift:"update,3" db:"update" json:"update"` + Unchanged []*ConfigGroup `thrift:"unchanged,4" db:"unchanged" json:"unchanged"` +} + +func NewGetJobUpdateDiffResult_() *GetJobUpdateDiffResult_ { + return &GetJobUpdateDiffResult_{} +} + + +func (p *GetJobUpdateDiffResult_) GetAdd() []*ConfigGroup { + return p.Add +} + +func (p *GetJobUpdateDiffResult_) GetRemove() []*ConfigGroup { + return p.Remove +} + +func (p *GetJobUpdateDiffResult_) GetUpdate() []*ConfigGroup { + return p.Update +} + +func (p *GetJobUpdateDiffResult_) GetUnchanged() []*ConfigGroup { + return p.Unchanged +} +func (p *GetJobUpdateDiffResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.SET { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.SET { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.SET { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.SET { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *GetJobUpdateDiffResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*ConfigGroup, 0, size) + p.Add = tSet + for i := 0; i < size; i ++ { + _elem88 := &ConfigGroup{} + if err := _elem88.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem88), err) + } + p.Add = append(p.Add, _elem88) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *GetJobUpdateDiffResult_) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*ConfigGroup, 0, size) + p.Remove = tSet + for i := 0; i < size; i ++ { + _elem89 := &ConfigGroup{} + if err := _elem89.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem89), err) + } + p.Remove = append(p.Remove, _elem89) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *GetJobUpdateDiffResult_) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*ConfigGroup, 0, size) + p.Update = tSet + for i := 0; i < size; i ++ { + _elem90 := &ConfigGroup{} + if err := _elem90.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem90), err) + } + p.Update = append(p.Update, _elem90) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *GetJobUpdateDiffResult_) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*ConfigGroup, 0, size) + p.Unchanged = tSet + for i := 0; i < size; i ++ { + _elem91 := &ConfigGroup{} + if err := _elem91.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem91), err) + } + p.Unchanged = append(p.Unchanged, _elem91) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *GetJobUpdateDiffResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "GetJobUpdateDiffResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *GetJobUpdateDiffResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "add", thrift.SET, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:add: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Add)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("GetJobUpdateDiffResult_(%+v)", *p) +} + +// Tier information. +// +// Attributes: +// - Name: Name of tier. +// - Settings: Tier attributes. +type TierConfig struct { + Name string `thrift:"name,1" db:"name" json:"name"` + Settings map[string]string `thrift:"settings,2" db:"settings" json:"settings"` +} + +func NewTierConfig() *TierConfig { + return &TierConfig{} +} + + +func (p *TierConfig) GetName() string { + return p.Name +} + +func (p *TierConfig) GetSettings() map[string]string { + return p.Settings +} +func (p *TierConfig) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.MAP { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *TierConfig) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Name = v +} + return nil +} + +func (p *TierConfig) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, _, size, err := iprot.ReadMapBegin(ctx) + if err != nil { + return thrift.PrependError("error reading map begin: ", err) + } + tMap := make(map[string]string, size) + p.Settings = tMap + for i := 0; i < size; i ++ { +var _key96 string + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _key96 = v +} +var _val97 string + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _val97 = v +} + p.Settings[_key96] = _val97 + } + if err := iprot.ReadMapEnd(ctx); err != nil { + return thrift.PrependError("error reading map end: ", err) + } + return nil +} + +func (p *TierConfig) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "TierConfig"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *TierConfig) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "name", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Name)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) } + return err +} + +func (p *TierConfig) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "settings", thrift.MAP, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:settings: ", p), err) } + if err := oprot.WriteMapBegin(ctx, thrift.STRING, thrift.STRING, len(p.Settings)); err != nil { + return thrift.PrependError("error writing map begin: ", err) + } + for k, v := range p.Settings { + if err := oprot.WriteString(ctx, string(k)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } + if err := oprot.WriteString(ctx, string(v)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) } + } + if err := oprot.WriteMapEnd(ctx); err != nil { + return thrift.PrependError("error writing map end: ", err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:settings: ", p), err) } + return err +} + +func (p *TierConfig) Equals(other *TierConfig) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Name != other.Name { return false } + if len(p.Settings) != len(other.Settings) { return false } + for k, _tgt := range p.Settings { + _src98 := other.Settings[k] + if _tgt != _src98 { return false } + } + return true +} + +func (p *TierConfig) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("TierConfig(%+v)", *p) +} + +// Result of the getTierConfigResult call. +// +// Attributes: +// - DefaultTierName: Name of the default tier. +// - Tiers: Set of tier configurations. +type GetTierConfigResult_ struct { + DefaultTierName string `thrift:"defaultTierName,1" db:"defaultTierName" json:"defaultTierName"` + Tiers []*TierConfig `thrift:"tiers,2" db:"tiers" json:"tiers"` +} + +func NewGetTierConfigResult_() *GetTierConfigResult_ { + return &GetTierConfigResult_{} +} + + +func (p *GetTierConfigResult_) GetDefaultTierName() string { + return p.DefaultTierName +} + +func (p *GetTierConfigResult_) GetTiers() []*TierConfig { + return p.Tiers +} +func (p *GetTierConfigResult_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.SET { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *GetTierConfigResult_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.DefaultTierName = v +} + return nil +} + +func (p *GetTierConfigResult_) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]*TierConfig, 0, size) + p.Tiers = tSet + for i := 0; i < size; i ++ { + _elem99 := &TierConfig{} + if err := _elem99.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem99), err) + } + p.Tiers = append(p.Tiers, _elem99) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *GetTierConfigResult_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "GetTierConfigResult"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *GetTierConfigResult_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "defaultTierName", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:defaultTierName: ", p), err) } + if err := oprot.WriteString(ctx, string(p.DefaultTierName)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.defaultTierName (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:defaultTierName: ", p), err) } + return err +} + +func (p *GetTierConfigResult_) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "tiers", thrift.SET, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:tiers: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.STRUCT, len(p.Tiers)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("GetTierConfigResult_(%+v)", *p) +} + +// Information about the scheduler. +// +// Attributes: +// - ClusterName +// - StatsUrlPrefix: A url prefix for job container stats. +type ServerInfo struct { + ClusterName string `thrift:"clusterName,1" db:"clusterName" json:"clusterName"` + // unused field # 2 + StatsUrlPrefix string `thrift:"statsUrlPrefix,3" db:"statsUrlPrefix" json:"statsUrlPrefix"` +} + +func NewServerInfo() *ServerInfo { + return &ServerInfo{} +} + + +func (p *ServerInfo) GetClusterName() string { + return p.ClusterName +} + +func (p *ServerInfo) GetStatsUrlPrefix() string { + return p.StatsUrlPrefix +} +func (p *ServerInfo) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRING { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ServerInfo) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.ClusterName = v +} + return nil +} + +func (p *ServerInfo) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.StatsUrlPrefix = v +} + return nil +} + +func (p *ServerInfo) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ServerInfo"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ServerInfo) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "clusterName", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:clusterName: ", p), err) } + if err := oprot.WriteString(ctx, string(p.ClusterName)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.clusterName (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:clusterName: ", p), err) } + return err +} + +func (p *ServerInfo) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "statsUrlPrefix", thrift.STRING, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:statsUrlPrefix: ", p), err) } + if err := oprot.WriteString(ctx, string(p.StatsUrlPrefix)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.statsUrlPrefix (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:statsUrlPrefix: ", p), err) } + return err +} + +func (p *ServerInfo) Equals(other *ServerInfo) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.ClusterName != other.ClusterName { return false } + if p.StatsUrlPrefix != other.StatsUrlPrefix { return false } + return true +} + +func (p *ServerInfo) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ServerInfo(%+v)", *p) +} + +// Attributes: +// - PopulateJobResult_ +// - ScheduleStatusResult_ +// - GetJobsResult_ +// - GetQuotaResult_ +// - ListBackupsResult_ +// - StartMaintenanceResult_ +// - DrainHostsResult_ +// - QueryRecoveryResult_ +// - MaintenanceStatusResult_ +// - EndMaintenanceResult_ +// - RoleSummaryResult_ +// - JobSummaryResult_ +// - ConfigSummaryResult_ +// - GetPendingReasonResult_ +// - StartJobUpdateResult_ +// - GetJobUpdateSummariesResult_ +// - GetJobUpdateDetailsResult_ +// - PulseJobUpdateResult_ +// - GetJobUpdateDiffResult_ +// - GetTierConfigResult_ +type Result_ struct { + PopulateJobResult_ *PopulateJobResult_ `thrift:"populateJobResult,1" db:"populateJobResult" json:"populateJobResult,omitempty"` + // unused field # 2 + ScheduleStatusResult_ *ScheduleStatusResult_ `thrift:"scheduleStatusResult,3" db:"scheduleStatusResult" json:"scheduleStatusResult,omitempty"` + GetJobsResult_ *GetJobsResult_ `thrift:"getJobsResult,4" db:"getJobsResult" json:"getJobsResult,omitempty"` + GetQuotaResult_ *GetQuotaResult_ `thrift:"getQuotaResult,5" db:"getQuotaResult" json:"getQuotaResult,omitempty"` + ListBackupsResult_ *ListBackupsResult_ `thrift:"listBackupsResult,6" db:"listBackupsResult" json:"listBackupsResult,omitempty"` + StartMaintenanceResult_ *StartMaintenanceResult_ `thrift:"startMaintenanceResult,7" db:"startMaintenanceResult" json:"startMaintenanceResult,omitempty"` + DrainHostsResult_ *DrainHostsResult_ `thrift:"drainHostsResult,8" db:"drainHostsResult" json:"drainHostsResult,omitempty"` + QueryRecoveryResult_ *QueryRecoveryResult_ `thrift:"queryRecoveryResult,9" db:"queryRecoveryResult" json:"queryRecoveryResult,omitempty"` + MaintenanceStatusResult_ *MaintenanceStatusResult_ `thrift:"maintenanceStatusResult,10" db:"maintenanceStatusResult" json:"maintenanceStatusResult,omitempty"` + EndMaintenanceResult_ *EndMaintenanceResult_ `thrift:"endMaintenanceResult,11" db:"endMaintenanceResult" json:"endMaintenanceResult,omitempty"` + // unused fields # 12 to 16 + RoleSummaryResult_ *RoleSummaryResult_ `thrift:"roleSummaryResult,17" db:"roleSummaryResult" json:"roleSummaryResult,omitempty"` + JobSummaryResult_ *JobSummaryResult_ `thrift:"jobSummaryResult,18" db:"jobSummaryResult" json:"jobSummaryResult,omitempty"` + // unused field # 19 + ConfigSummaryResult_ *ConfigSummaryResult_ `thrift:"configSummaryResult,20" db:"configSummaryResult" json:"configSummaryResult,omitempty"` + GetPendingReasonResult_ *GetPendingReasonResult_ `thrift:"getPendingReasonResult,21" db:"getPendingReasonResult" json:"getPendingReasonResult,omitempty"` + StartJobUpdateResult_ *StartJobUpdateResult_ `thrift:"startJobUpdateResult,22" db:"startJobUpdateResult" json:"startJobUpdateResult,omitempty"` + GetJobUpdateSummariesResult_ *GetJobUpdateSummariesResult_ `thrift:"getJobUpdateSummariesResult,23" db:"getJobUpdateSummariesResult" json:"getJobUpdateSummariesResult,omitempty"` + GetJobUpdateDetailsResult_ *GetJobUpdateDetailsResult_ `thrift:"getJobUpdateDetailsResult,24" db:"getJobUpdateDetailsResult" json:"getJobUpdateDetailsResult,omitempty"` + PulseJobUpdateResult_ *PulseJobUpdateResult_ `thrift:"pulseJobUpdateResult,25" db:"pulseJobUpdateResult" json:"pulseJobUpdateResult,omitempty"` + GetJobUpdateDiffResult_ *GetJobUpdateDiffResult_ `thrift:"getJobUpdateDiffResult,26" db:"getJobUpdateDiffResult" json:"getJobUpdateDiffResult,omitempty"` + GetTierConfigResult_ *GetTierConfigResult_ `thrift:"getTierConfigResult,27" db:"getTierConfigResult" json:"getTierConfigResult,omitempty"` +} + +func NewResult_() *Result_ { + return &Result_{} +} + +var Result__PopulateJobResult__DEFAULT *PopulateJobResult_ +func (p *Result_) GetPopulateJobResult_() *PopulateJobResult_ { + if !p.IsSetPopulateJobResult_() { + return Result__PopulateJobResult__DEFAULT + } +return p.PopulateJobResult_ +} +var Result__ScheduleStatusResult__DEFAULT *ScheduleStatusResult_ +func (p *Result_) GetScheduleStatusResult_() *ScheduleStatusResult_ { + if !p.IsSetScheduleStatusResult_() { + return Result__ScheduleStatusResult__DEFAULT + } +return p.ScheduleStatusResult_ +} +var Result__GetJobsResult__DEFAULT *GetJobsResult_ +func (p *Result_) GetGetJobsResult_() *GetJobsResult_ { + if !p.IsSetGetJobsResult_() { + return Result__GetJobsResult__DEFAULT + } +return p.GetJobsResult_ +} +var Result__GetQuotaResult__DEFAULT *GetQuotaResult_ +func (p *Result_) GetGetQuotaResult_() *GetQuotaResult_ { + if !p.IsSetGetQuotaResult_() { + return Result__GetQuotaResult__DEFAULT + } +return p.GetQuotaResult_ +} +var Result__ListBackupsResult__DEFAULT *ListBackupsResult_ +func (p *Result_) GetListBackupsResult_() *ListBackupsResult_ { + if !p.IsSetListBackupsResult_() { + return Result__ListBackupsResult__DEFAULT + } +return p.ListBackupsResult_ +} +var Result__StartMaintenanceResult__DEFAULT *StartMaintenanceResult_ +func (p *Result_) GetStartMaintenanceResult_() *StartMaintenanceResult_ { + if !p.IsSetStartMaintenanceResult_() { + return Result__StartMaintenanceResult__DEFAULT + } +return p.StartMaintenanceResult_ +} +var Result__DrainHostsResult__DEFAULT *DrainHostsResult_ +func (p *Result_) GetDrainHostsResult_() *DrainHostsResult_ { + if !p.IsSetDrainHostsResult_() { + return Result__DrainHostsResult__DEFAULT + } +return p.DrainHostsResult_ +} +var Result__QueryRecoveryResult__DEFAULT *QueryRecoveryResult_ +func (p *Result_) GetQueryRecoveryResult_() *QueryRecoveryResult_ { + if !p.IsSetQueryRecoveryResult_() { + return Result__QueryRecoveryResult__DEFAULT + } +return p.QueryRecoveryResult_ +} +var Result__MaintenanceStatusResult__DEFAULT *MaintenanceStatusResult_ +func (p *Result_) GetMaintenanceStatusResult_() *MaintenanceStatusResult_ { + if !p.IsSetMaintenanceStatusResult_() { + return Result__MaintenanceStatusResult__DEFAULT + } +return p.MaintenanceStatusResult_ +} +var Result__EndMaintenanceResult__DEFAULT *EndMaintenanceResult_ +func (p *Result_) GetEndMaintenanceResult_() *EndMaintenanceResult_ { + if !p.IsSetEndMaintenanceResult_() { + return Result__EndMaintenanceResult__DEFAULT + } +return p.EndMaintenanceResult_ +} +var Result__RoleSummaryResult__DEFAULT *RoleSummaryResult_ +func (p *Result_) GetRoleSummaryResult_() *RoleSummaryResult_ { + if !p.IsSetRoleSummaryResult_() { + return Result__RoleSummaryResult__DEFAULT + } +return p.RoleSummaryResult_ +} +var Result__JobSummaryResult__DEFAULT *JobSummaryResult_ +func (p *Result_) GetJobSummaryResult_() *JobSummaryResult_ { + if !p.IsSetJobSummaryResult_() { + return Result__JobSummaryResult__DEFAULT + } +return p.JobSummaryResult_ +} +var Result__ConfigSummaryResult__DEFAULT *ConfigSummaryResult_ +func (p *Result_) GetConfigSummaryResult_() *ConfigSummaryResult_ { + if !p.IsSetConfigSummaryResult_() { + return Result__ConfigSummaryResult__DEFAULT + } +return p.ConfigSummaryResult_ +} +var Result__GetPendingReasonResult__DEFAULT *GetPendingReasonResult_ +func (p *Result_) GetGetPendingReasonResult_() *GetPendingReasonResult_ { + if !p.IsSetGetPendingReasonResult_() { + return Result__GetPendingReasonResult__DEFAULT + } +return p.GetPendingReasonResult_ +} +var Result__StartJobUpdateResult__DEFAULT *StartJobUpdateResult_ +func (p *Result_) GetStartJobUpdateResult_() *StartJobUpdateResult_ { + if !p.IsSetStartJobUpdateResult_() { + return Result__StartJobUpdateResult__DEFAULT + } +return p.StartJobUpdateResult_ +} +var Result__GetJobUpdateSummariesResult__DEFAULT *GetJobUpdateSummariesResult_ +func (p *Result_) GetGetJobUpdateSummariesResult_() *GetJobUpdateSummariesResult_ { + if !p.IsSetGetJobUpdateSummariesResult_() { + return Result__GetJobUpdateSummariesResult__DEFAULT + } +return p.GetJobUpdateSummariesResult_ +} +var Result__GetJobUpdateDetailsResult__DEFAULT *GetJobUpdateDetailsResult_ +func (p *Result_) GetGetJobUpdateDetailsResult_() *GetJobUpdateDetailsResult_ { + if !p.IsSetGetJobUpdateDetailsResult_() { + return Result__GetJobUpdateDetailsResult__DEFAULT + } +return p.GetJobUpdateDetailsResult_ +} +var Result__PulseJobUpdateResult__DEFAULT *PulseJobUpdateResult_ +func (p *Result_) GetPulseJobUpdateResult_() *PulseJobUpdateResult_ { + if !p.IsSetPulseJobUpdateResult_() { + return Result__PulseJobUpdateResult__DEFAULT + } +return p.PulseJobUpdateResult_ +} +var Result__GetJobUpdateDiffResult__DEFAULT *GetJobUpdateDiffResult_ +func (p *Result_) GetGetJobUpdateDiffResult_() *GetJobUpdateDiffResult_ { + if !p.IsSetGetJobUpdateDiffResult_() { + return Result__GetJobUpdateDiffResult__DEFAULT + } +return p.GetJobUpdateDiffResult_ +} +var Result__GetTierConfigResult__DEFAULT *GetTierConfigResult_ +func (p *Result_) GetGetTierConfigResult_() *GetTierConfigResult_ { + if !p.IsSetGetTierConfigResult_() { + return Result__GetTierConfigResult__DEFAULT + } +return p.GetTierConfigResult_ +} +func (p *Result_) CountSetFieldsResult_() int { + count := 0 + if (p.IsSetPopulateJobResult_()) { + count++ + } + if (p.IsSetScheduleStatusResult_()) { + count++ + } + if (p.IsSetGetJobsResult_()) { + count++ + } + if (p.IsSetGetQuotaResult_()) { + count++ + } + if (p.IsSetListBackupsResult_()) { + count++ + } + if (p.IsSetStartMaintenanceResult_()) { + count++ + } + if (p.IsSetDrainHostsResult_()) { + count++ + } + if (p.IsSetQueryRecoveryResult_()) { + count++ + } + if (p.IsSetMaintenanceStatusResult_()) { + count++ + } + if (p.IsSetEndMaintenanceResult_()) { + count++ + } + if (p.IsSetRoleSummaryResult_()) { + count++ + } + if (p.IsSetJobSummaryResult_()) { + count++ + } + if (p.IsSetConfigSummaryResult_()) { + count++ + } + if (p.IsSetGetPendingReasonResult_()) { + count++ + } + if (p.IsSetStartJobUpdateResult_()) { + count++ + } + if (p.IsSetGetJobUpdateSummariesResult_()) { + count++ + } + if (p.IsSetGetJobUpdateDetailsResult_()) { + count++ + } + if (p.IsSetPulseJobUpdateResult_()) { + count++ + } + if (p.IsSetGetJobUpdateDiffResult_()) { + count++ + } + if (p.IsSetGetTierConfigResult_()) { + count++ + } + return count + +} + +func (p *Result_) IsSetPopulateJobResult_() bool { + return p.PopulateJobResult_ != nil +} + +func (p *Result_) IsSetScheduleStatusResult_() bool { + return p.ScheduleStatusResult_ != nil +} + +func (p *Result_) IsSetGetJobsResult_() bool { + return p.GetJobsResult_ != nil +} + +func (p *Result_) IsSetGetQuotaResult_() bool { + return p.GetQuotaResult_ != nil +} + +func (p *Result_) IsSetListBackupsResult_() bool { + return p.ListBackupsResult_ != nil +} + +func (p *Result_) IsSetStartMaintenanceResult_() bool { + return p.StartMaintenanceResult_ != nil +} + +func (p *Result_) IsSetDrainHostsResult_() bool { + return p.DrainHostsResult_ != nil +} + +func (p *Result_) IsSetQueryRecoveryResult_() bool { + return p.QueryRecoveryResult_ != nil +} + +func (p *Result_) IsSetMaintenanceStatusResult_() bool { + return p.MaintenanceStatusResult_ != nil +} + +func (p *Result_) IsSetEndMaintenanceResult_() bool { + return p.EndMaintenanceResult_ != nil +} + +func (p *Result_) IsSetRoleSummaryResult_() bool { + return p.RoleSummaryResult_ != nil +} + +func (p *Result_) IsSetJobSummaryResult_() bool { + return p.JobSummaryResult_ != nil +} + +func (p *Result_) IsSetConfigSummaryResult_() bool { + return p.ConfigSummaryResult_ != nil +} + +func (p *Result_) IsSetGetPendingReasonResult_() bool { + return p.GetPendingReasonResult_ != nil +} + +func (p *Result_) IsSetStartJobUpdateResult_() bool { + return p.StartJobUpdateResult_ != nil +} + +func (p *Result_) IsSetGetJobUpdateSummariesResult_() bool { + return p.GetJobUpdateSummariesResult_ != nil +} + +func (p *Result_) IsSetGetJobUpdateDetailsResult_() bool { + return p.GetJobUpdateDetailsResult_ != nil +} + +func (p *Result_) IsSetPulseJobUpdateResult_() bool { + return p.PulseJobUpdateResult_ != nil +} + +func (p *Result_) IsSetGetJobUpdateDiffResult_() bool { + return p.GetJobUpdateDiffResult_ != nil +} + +func (p *Result_) IsSetGetTierConfigResult_() bool { + return p.GetTierConfigResult_ != nil +} + +func (p *Result_) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 5: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField5(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 6: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField6(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 7: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField7(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 8: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField8(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 9: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField9(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 10: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField10(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 11: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField11(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 17: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField17(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 18: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField18(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 20: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField20(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 21: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField21(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 22: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField22(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 23: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField23(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 24: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField24(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 25: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField25(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 26: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField26(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 27: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField27(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *Result_) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.PopulateJobResult_ = &PopulateJobResult_{} + if err := p.PopulateJobResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PopulateJobResult_), err) + } + return nil +} + +func (p *Result_) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + p.ScheduleStatusResult_ = &ScheduleStatusResult_{} + if err := p.ScheduleStatusResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ScheduleStatusResult_), err) + } + return nil +} + +func (p *Result_) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + p.GetJobsResult_ = &GetJobsResult_{} + if err := p.GetJobsResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetJobsResult_), err) + } + return nil +} + +func (p *Result_) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + p.GetQuotaResult_ = &GetQuotaResult_{} + if err := p.GetQuotaResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetQuotaResult_), err) + } + return nil +} + +func (p *Result_) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { + p.ListBackupsResult_ = &ListBackupsResult_{} + if err := p.ListBackupsResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ListBackupsResult_), err) + } + return nil +} + +func (p *Result_) ReadField7(ctx context.Context, iprot thrift.TProtocol) error { + p.StartMaintenanceResult_ = &StartMaintenanceResult_{} + if err := p.StartMaintenanceResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StartMaintenanceResult_), err) + } + return nil +} + +func (p *Result_) ReadField8(ctx context.Context, iprot thrift.TProtocol) error { + p.DrainHostsResult_ = &DrainHostsResult_{} + if err := p.DrainHostsResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.DrainHostsResult_), err) + } + return nil +} + +func (p *Result_) ReadField9(ctx context.Context, iprot thrift.TProtocol) error { + p.QueryRecoveryResult_ = &QueryRecoveryResult_{} + if err := p.QueryRecoveryResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.QueryRecoveryResult_), err) + } + return nil +} + +func (p *Result_) ReadField10(ctx context.Context, iprot thrift.TProtocol) error { + p.MaintenanceStatusResult_ = &MaintenanceStatusResult_{} + if err := p.MaintenanceStatusResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.MaintenanceStatusResult_), err) + } + return nil +} + +func (p *Result_) ReadField11(ctx context.Context, iprot thrift.TProtocol) error { + p.EndMaintenanceResult_ = &EndMaintenanceResult_{} + if err := p.EndMaintenanceResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.EndMaintenanceResult_), err) + } + return nil +} + +func (p *Result_) ReadField17(ctx context.Context, iprot thrift.TProtocol) error { + p.RoleSummaryResult_ = &RoleSummaryResult_{} + if err := p.RoleSummaryResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.RoleSummaryResult_), err) + } + return nil +} + +func (p *Result_) ReadField18(ctx context.Context, iprot thrift.TProtocol) error { + p.JobSummaryResult_ = &JobSummaryResult_{} + if err := p.JobSummaryResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.JobSummaryResult_), err) + } + return nil +} + +func (p *Result_) ReadField20(ctx context.Context, iprot thrift.TProtocol) error { + p.ConfigSummaryResult_ = &ConfigSummaryResult_{} + if err := p.ConfigSummaryResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ConfigSummaryResult_), err) + } + return nil +} + +func (p *Result_) ReadField21(ctx context.Context, iprot thrift.TProtocol) error { + p.GetPendingReasonResult_ = &GetPendingReasonResult_{} + if err := p.GetPendingReasonResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetPendingReasonResult_), err) + } + return nil +} + +func (p *Result_) ReadField22(ctx context.Context, iprot thrift.TProtocol) error { + p.StartJobUpdateResult_ = &StartJobUpdateResult_{} + if err := p.StartJobUpdateResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StartJobUpdateResult_), err) + } + return nil +} + +func (p *Result_) ReadField23(ctx context.Context, iprot thrift.TProtocol) error { + p.GetJobUpdateSummariesResult_ = &GetJobUpdateSummariesResult_{} + if err := p.GetJobUpdateSummariesResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetJobUpdateSummariesResult_), err) + } + return nil +} + +func (p *Result_) ReadField24(ctx context.Context, iprot thrift.TProtocol) error { + p.GetJobUpdateDetailsResult_ = &GetJobUpdateDetailsResult_{} + if err := p.GetJobUpdateDetailsResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetJobUpdateDetailsResult_), err) + } + return nil +} + +func (p *Result_) ReadField25(ctx context.Context, iprot thrift.TProtocol) error { + p.PulseJobUpdateResult_ = &PulseJobUpdateResult_{} + if err := p.PulseJobUpdateResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PulseJobUpdateResult_), err) + } + return nil +} + +func (p *Result_) ReadField26(ctx context.Context, iprot thrift.TProtocol) error { + p.GetJobUpdateDiffResult_ = &GetJobUpdateDiffResult_{} + if err := p.GetJobUpdateDiffResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetJobUpdateDiffResult_), err) + } + return nil +} + +func (p *Result_) ReadField27(ctx context.Context, iprot thrift.TProtocol) error { + p.GetTierConfigResult_ = &GetTierConfigResult_{} + if err := p.GetTierConfigResult_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetTierConfigResult_), err) + } + return nil +} + +func (p *Result_) Write(ctx context.Context, oprot thrift.TProtocol) error { + if c := p.CountSetFieldsResult_(); c != 1 { + return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) + } + if err := oprot.WriteStructBegin(ctx, "Result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } + if err := p.writeField7(ctx, oprot); err != nil { return err } + if err := p.writeField8(ctx, oprot); err != nil { return err } + if err := p.writeField9(ctx, oprot); err != nil { return err } + if err := p.writeField10(ctx, oprot); err != nil { return err } + if err := p.writeField11(ctx, oprot); err != nil { return err } + if err := p.writeField17(ctx, oprot); err != nil { return err } + if err := p.writeField18(ctx, oprot); err != nil { return err } + if err := p.writeField20(ctx, oprot); err != nil { return err } + if err := p.writeField21(ctx, oprot); err != nil { return err } + if err := p.writeField22(ctx, oprot); err != nil { return err } + if err := p.writeField23(ctx, oprot); err != nil { return err } + if err := p.writeField24(ctx, oprot); err != nil { return err } + if err := p.writeField25(ctx, oprot); err != nil { return err } + if err := p.writeField26(ctx, oprot); err != nil { return err } + if err := p.writeField27(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *Result_) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetPopulateJobResult_() { + if err := oprot.WriteFieldBegin(ctx, "populateJobResult", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:populateJobResult: ", p), err) } + if err := p.PopulateJobResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PopulateJobResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:populateJobResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetScheduleStatusResult_() { + if err := oprot.WriteFieldBegin(ctx, "scheduleStatusResult", thrift.STRUCT, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:scheduleStatusResult: ", p), err) } + if err := p.ScheduleStatusResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ScheduleStatusResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:scheduleStatusResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetGetJobsResult_() { + if err := oprot.WriteFieldBegin(ctx, "getJobsResult", thrift.STRUCT, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:getJobsResult: ", p), err) } + if err := p.GetJobsResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetJobsResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:getJobsResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetGetQuotaResult_() { + if err := oprot.WriteFieldBegin(ctx, "getQuotaResult", thrift.STRUCT, 5); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:getQuotaResult: ", p), err) } + if err := p.GetQuotaResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetQuotaResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 5:getQuotaResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField6(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetListBackupsResult_() { + if err := oprot.WriteFieldBegin(ctx, "listBackupsResult", thrift.STRUCT, 6); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:listBackupsResult: ", p), err) } + if err := p.ListBackupsResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ListBackupsResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 6:listBackupsResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField7(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetStartMaintenanceResult_() { + if err := oprot.WriteFieldBegin(ctx, "startMaintenanceResult", thrift.STRUCT, 7); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:startMaintenanceResult: ", p), err) } + if err := p.StartMaintenanceResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StartMaintenanceResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 7:startMaintenanceResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField8(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetDrainHostsResult_() { + if err := oprot.WriteFieldBegin(ctx, "drainHostsResult", thrift.STRUCT, 8); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:drainHostsResult: ", p), err) } + if err := p.DrainHostsResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.DrainHostsResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 8:drainHostsResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField9(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetQueryRecoveryResult_() { + if err := oprot.WriteFieldBegin(ctx, "queryRecoveryResult", thrift.STRUCT, 9); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:queryRecoveryResult: ", p), err) } + if err := p.QueryRecoveryResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.QueryRecoveryResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 9:queryRecoveryResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField10(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetMaintenanceStatusResult_() { + if err := oprot.WriteFieldBegin(ctx, "maintenanceStatusResult", thrift.STRUCT, 10); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:maintenanceStatusResult: ", p), err) } + if err := p.MaintenanceStatusResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.MaintenanceStatusResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 10:maintenanceStatusResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField11(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetEndMaintenanceResult_() { + if err := oprot.WriteFieldBegin(ctx, "endMaintenanceResult", thrift.STRUCT, 11); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:endMaintenanceResult: ", p), err) } + if err := p.EndMaintenanceResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.EndMaintenanceResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 11:endMaintenanceResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField17(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetRoleSummaryResult_() { + if err := oprot.WriteFieldBegin(ctx, "roleSummaryResult", thrift.STRUCT, 17); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 17:roleSummaryResult: ", p), err) } + if err := p.RoleSummaryResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.RoleSummaryResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 17:roleSummaryResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField18(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetJobSummaryResult_() { + if err := oprot.WriteFieldBegin(ctx, "jobSummaryResult", thrift.STRUCT, 18); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 18:jobSummaryResult: ", p), err) } + if err := p.JobSummaryResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.JobSummaryResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 18:jobSummaryResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField20(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetConfigSummaryResult_() { + if err := oprot.WriteFieldBegin(ctx, "configSummaryResult", thrift.STRUCT, 20); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 20:configSummaryResult: ", p), err) } + if err := p.ConfigSummaryResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ConfigSummaryResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 20:configSummaryResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField21(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetGetPendingReasonResult_() { + if err := oprot.WriteFieldBegin(ctx, "getPendingReasonResult", thrift.STRUCT, 21); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 21:getPendingReasonResult: ", p), err) } + if err := p.GetPendingReasonResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetPendingReasonResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 21:getPendingReasonResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField22(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetStartJobUpdateResult_() { + if err := oprot.WriteFieldBegin(ctx, "startJobUpdateResult", thrift.STRUCT, 22); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 22:startJobUpdateResult: ", p), err) } + if err := p.StartJobUpdateResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StartJobUpdateResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 22:startJobUpdateResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField23(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetGetJobUpdateSummariesResult_() { + if err := oprot.WriteFieldBegin(ctx, "getJobUpdateSummariesResult", thrift.STRUCT, 23); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 23:getJobUpdateSummariesResult: ", p), err) } + if err := p.GetJobUpdateSummariesResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetJobUpdateSummariesResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 23:getJobUpdateSummariesResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField24(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetGetJobUpdateDetailsResult_() { + if err := oprot.WriteFieldBegin(ctx, "getJobUpdateDetailsResult", thrift.STRUCT, 24); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 24:getJobUpdateDetailsResult: ", p), err) } + if err := p.GetJobUpdateDetailsResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetJobUpdateDetailsResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 24:getJobUpdateDetailsResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField25(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetPulseJobUpdateResult_() { + if err := oprot.WriteFieldBegin(ctx, "pulseJobUpdateResult", thrift.STRUCT, 25); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 25:pulseJobUpdateResult: ", p), err) } + if err := p.PulseJobUpdateResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PulseJobUpdateResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 25:pulseJobUpdateResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField26(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetGetJobUpdateDiffResult_() { + if err := oprot.WriteFieldBegin(ctx, "getJobUpdateDiffResult", thrift.STRUCT, 26); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 26:getJobUpdateDiffResult: ", p), err) } + if err := p.GetJobUpdateDiffResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetJobUpdateDiffResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 26:getJobUpdateDiffResult: ", p), err) } + } + return err +} + +func (p *Result_) writeField27(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetGetTierConfigResult_() { + if err := oprot.WriteFieldBegin(ctx, "getTierConfigResult", thrift.STRUCT, 27); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 27:getTierConfigResult: ", p), err) } + if err := p.GetTierConfigResult_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetTierConfigResult_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 27:getTierConfigResult: ", p), err) } + } + return err +} + +func (p *Result_) Equals(other *Result_) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if !p.PopulateJobResult_.Equals(other.PopulateJobResult_) { return false } + if !p.ScheduleStatusResult_.Equals(other.ScheduleStatusResult_) { return false } + if !p.GetJobsResult_.Equals(other.GetJobsResult_) { return false } + if !p.GetQuotaResult_.Equals(other.GetQuotaResult_) { return false } + if !p.ListBackupsResult_.Equals(other.ListBackupsResult_) { return false } + if !p.StartMaintenanceResult_.Equals(other.StartMaintenanceResult_) { return false } + if !p.DrainHostsResult_.Equals(other.DrainHostsResult_) { return false } + if !p.QueryRecoveryResult_.Equals(other.QueryRecoveryResult_) { return false } + if !p.MaintenanceStatusResult_.Equals(other.MaintenanceStatusResult_) { return false } + if !p.EndMaintenanceResult_.Equals(other.EndMaintenanceResult_) { return false } + if !p.RoleSummaryResult_.Equals(other.RoleSummaryResult_) { return false } + if !p.JobSummaryResult_.Equals(other.JobSummaryResult_) { return false } + if !p.ConfigSummaryResult_.Equals(other.ConfigSummaryResult_) { return false } + if !p.GetPendingReasonResult_.Equals(other.GetPendingReasonResult_) { return false } + if !p.StartJobUpdateResult_.Equals(other.StartJobUpdateResult_) { return false } + if !p.GetJobUpdateSummariesResult_.Equals(other.GetJobUpdateSummariesResult_) { return false } + if !p.GetJobUpdateDetailsResult_.Equals(other.GetJobUpdateDetailsResult_) { return false } + if !p.PulseJobUpdateResult_.Equals(other.PulseJobUpdateResult_) { return false } + if !p.GetJobUpdateDiffResult_.Equals(other.GetJobUpdateDiffResult_) { return false } + if !p.GetTierConfigResult_.Equals(other.GetTierConfigResult_) { return false } + return true +} + +func (p *Result_) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Result_(%+v)", *p) +} + +// Attributes: +// - Message +type ResponseDetail struct { + Message string `thrift:"message,1" db:"message" json:"message"` +} + +func NewResponseDetail() *ResponseDetail { + return &ResponseDetail{} +} + + +func (p *ResponseDetail) GetMessage() string { + return p.Message +} +func (p *ResponseDetail) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ResponseDetail) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Message = v +} + return nil +} + +func (p *ResponseDetail) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ResponseDetail"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ResponseDetail) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "message", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:message: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Message)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.message (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:message: ", p), err) } + return err +} + +func (p *ResponseDetail) Equals(other *ResponseDetail) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.Message != other.Message { return false } + return true +} + +func (p *ResponseDetail) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ResponseDetail(%+v)", *p) +} + +// Attributes: +// - ResponseCode +// - ServerInfo +// - Result_: Payload from the invoked RPC. +// - Details: Messages from the server relevant to the request, such as warnings or use of deprecated +// features. +type Response struct { + ResponseCode ResponseCode `thrift:"responseCode,1" db:"responseCode" json:"responseCode"` + // unused field # 2 + Result_ *Result_ `thrift:"result,3" db:"result" json:"result,omitempty"` + // unused field # 4 + ServerInfo *ServerInfo `thrift:"serverInfo,5" db:"serverInfo" json:"serverInfo"` + Details []*ResponseDetail `thrift:"details,6" db:"details" json:"details"` +} + +func NewResponse() *Response { + return &Response{} +} + + +func (p *Response) GetResponseCode() ResponseCode { + return p.ResponseCode +} +var Response_ServerInfo_DEFAULT *ServerInfo +func (p *Response) GetServerInfo() *ServerInfo { + if !p.IsSetServerInfo() { + return Response_ServerInfo_DEFAULT + } +return p.ServerInfo +} +var Response_Result__DEFAULT *Result_ +func (p *Response) GetResult_() *Result_ { + if !p.IsSetResult_() { + return Response_Result__DEFAULT + } +return p.Result_ +} + +func (p *Response) GetDetails() []*ResponseDetail { + return p.Details +} +func (p *Response) IsSetServerInfo() bool { + return p.ServerInfo != nil +} + +func (p *Response) IsSetResult_() bool { + return p.Result_ != nil +} + +func (p *Response) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 5: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField5(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 6: + if fieldTypeId == thrift.LIST { + if err := p.ReadField6(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *Response) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + temp := ResponseCode(v) + p.ResponseCode = temp +} + return nil +} + +func (p *Response) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + p.ServerInfo = &ServerInfo{} + if err := p.ServerInfo.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ServerInfo), err) + } + return nil +} + +func (p *Response) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + p.Result_ = &Result_{} + if err := p.Result_.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Result_), err) + } + return nil +} + +func (p *Response) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadListBegin(ctx) + if err != nil { + return thrift.PrependError("error reading list begin: ", err) + } + tSlice := make([]*ResponseDetail, 0, size) + p.Details = tSlice + for i := 0; i < size; i ++ { + _elem101 := &ResponseDetail{} + if err := _elem101.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem101), err) + } + p.Details = append(p.Details, _elem101) + } + if err := iprot.ReadListEnd(ctx); err != nil { + return thrift.PrependError("error reading list end: ", err) + } + return nil +} + +func (p *Response) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "Response"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *Response) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "responseCode", thrift.I32, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:responseCode: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.ResponseCode)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.responseCode (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:responseCode: ", p), err) } + return err +} + +func (p *Response) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetResult_() { + if err := oprot.WriteFieldBegin(ctx, "result", thrift.STRUCT, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:result: ", p), err) } + if err := p.Result_.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Result_), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:result: ", p), err) } + } + return err +} + +func (p *Response) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "serverInfo", thrift.STRUCT, 5); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:serverInfo: ", p), err) } + if err := p.ServerInfo.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ServerInfo), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 5:serverInfo: ", p), err) } + return err +} + +func (p *Response) writeField6(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "details", thrift.LIST, 6); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:details: ", p), err) } + if err := oprot.WriteListBegin(ctx, thrift.STRUCT, len(p.Details)); err != nil { + return thrift.PrependError("error writing list begin: ", err) + } + for _, v := range p.Details { + if err := v.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) + } + } + if err := oprot.WriteListEnd(ctx); err != nil { + return thrift.PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 6:details: ", p), err) } + return err +} + +func (p *Response) Equals(other *Response) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.ResponseCode != other.ResponseCode { return false } + if !p.Result_.Equals(other.Result_) { return false } + if !p.ServerInfo.Equals(other.ServerInfo) { return false } + if len(p.Details) != len(other.Details) { return false } + for i, _tgt := range p.Details { + _src102 := other.Details[i] + if !_tgt.Equals(_src102) { return false } + } + return true +} + +func (p *Response) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("Response(%+v)", *p) +} + +// Attributes: +// - BatchSize +type ExplicitReconciliationSettings struct { + BatchSize *int32 `thrift:"batchSize,1" db:"batchSize" json:"batchSize,omitempty"` +} + +func NewExplicitReconciliationSettings() *ExplicitReconciliationSettings { + return &ExplicitReconciliationSettings{} +} + +var ExplicitReconciliationSettings_BatchSize_DEFAULT int32 +func (p *ExplicitReconciliationSettings) GetBatchSize() int32 { + if !p.IsSetBatchSize() { + return ExplicitReconciliationSettings_BatchSize_DEFAULT + } +return *p.BatchSize +} +func (p *ExplicitReconciliationSettings) IsSetBatchSize() bool { + return p.BatchSize != nil +} + +func (p *ExplicitReconciliationSettings) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.I32 { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ExplicitReconciliationSettings) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.BatchSize = &v +} + return nil +} + +func (p *ExplicitReconciliationSettings) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "ExplicitReconciliationSettings"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ExplicitReconciliationSettings) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetBatchSize() { + if err := oprot.WriteFieldBegin(ctx, "batchSize", thrift.I32, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:batchSize: ", p), err) } + if err := oprot.WriteI32(ctx, int32(*p.BatchSize)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.batchSize (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:batchSize: ", p), err) } + } + return err +} + +func (p *ExplicitReconciliationSettings) Equals(other *ExplicitReconciliationSettings) bool { + if p == other { + return true + } else if p == nil || other == nil { + return false + } + if p.BatchSize != other.BatchSize { + if p.BatchSize == nil || other.BatchSize == nil { + return false + } + if (*p.BatchSize) != (*other.BatchSize) { return false } + } + return true +} + +func (p *ExplicitReconciliationSettings) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ExplicitReconciliationSettings(%+v)", *p) +} + +type ReadOnlyScheduler interface { + // Returns a summary of the jobs grouped by role. + GetRoleSummary(ctx context.Context) (r *Response, err error) + // Returns a summary of jobs, optionally only those owned by a specific role. + // + // Parameters: + // - Role + GetJobSummary(ctx context.Context, role string) (r *Response, err error) + // Fetches the status of tasks. + // + // Parameters: + // - Query + GetTasksStatus(ctx context.Context, query *TaskQuery) (r *Response, err error) + // Same as getTaskStatus but without the TaskConfig.ExecutorConfig data set. + // This is an interim solution until we have a better way to query TaskConfigs (AURORA-541). + // + // Parameters: + // - Query + GetTasksWithoutConfigs(ctx context.Context, query *TaskQuery) (r *Response, err error) + // Returns user-friendly reasons (if available) for tasks retained in PENDING state. + // + // Parameters: + // - Query + GetPendingReason(ctx context.Context, query *TaskQuery) (r *Response, err error) + // Fetches the configuration summary of active tasks for the specified job. + // + // Parameters: + // - Job + GetConfigSummary(ctx context.Context, job *JobKey) (r *Response, err error) + // Fetches the status of jobs. + // ownerRole is optional, in which case all jobs are returned. + // + // Parameters: + // - OwnerRole + GetJobs(ctx context.Context, ownerRole string) (r *Response, err error) + // Fetches the quota allocated for a user. + // + // Parameters: + // - OwnerRole + GetQuota(ctx context.Context, ownerRole string) (r *Response, err error) + // Populates fields in a job configuration as though it were about to be run. + // This can be used to diff a configuration running tasks. + // + // Parameters: + // - Description + PopulateJobConfig(ctx context.Context, description *JobConfiguration) (r *Response, err error) + // Gets job update summaries. + // + // Parameters: + // - JobUpdateQuery + GetJobUpdateSummaries(ctx context.Context, jobUpdateQuery *JobUpdateQuery) (r *Response, err error) + // Gets job update details. + // + // Parameters: + // - Query + GetJobUpdateDetails(ctx context.Context, query *JobUpdateQuery) (r *Response, err error) + // Gets the diff between client (desired) and server (current) job states. + // + // Parameters: + // - Request + GetJobUpdateDiff(ctx context.Context, request *JobUpdateRequest) (r *Response, err error) + // Gets tier configurations. + GetTierConfigs(ctx context.Context) (r *Response, err error) +} + +type ReadOnlySchedulerClient struct { + c thrift.TClient + meta thrift.ResponseMeta +} + +func NewReadOnlySchedulerClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ReadOnlySchedulerClient { + return &ReadOnlySchedulerClient{ + c: thrift.NewTStandardClient(f.GetProtocol(t), f.GetProtocol(t)), + } +} + +func NewReadOnlySchedulerClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ReadOnlySchedulerClient { + return &ReadOnlySchedulerClient{ + c: thrift.NewTStandardClient(iprot, oprot), + } +} + +func NewReadOnlySchedulerClient(c thrift.TClient) *ReadOnlySchedulerClient { + return &ReadOnlySchedulerClient{ + c: c, + } +} + +func (p *ReadOnlySchedulerClient) Client_() thrift.TClient { + return p.c +} + +func (p *ReadOnlySchedulerClient) LastResponseMeta_() thrift.ResponseMeta { + return p.meta +} + +func (p *ReadOnlySchedulerClient) SetLastResponseMeta_(meta thrift.ResponseMeta) { + p.meta = meta +} + +// Returns a summary of the jobs grouped by role. +func (p *ReadOnlySchedulerClient) GetRoleSummary(ctx context.Context) (r *Response, err error) { + var _args103 ReadOnlySchedulerGetRoleSummaryArgs + var _result104 ReadOnlySchedulerGetRoleSummaryResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getRoleSummary", &_args103, &_result104) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result104.GetSuccess(), nil +} + +// Returns a summary of jobs, optionally only those owned by a specific role. +// +// Parameters: +// - Role +func (p *ReadOnlySchedulerClient) GetJobSummary(ctx context.Context, role string) (r *Response, err error) { + var _args105 ReadOnlySchedulerGetJobSummaryArgs + _args105.Role = role + var _result106 ReadOnlySchedulerGetJobSummaryResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getJobSummary", &_args105, &_result106) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result106.GetSuccess(), nil +} + +// Fetches the status of tasks. +// +// Parameters: +// - Query +func (p *ReadOnlySchedulerClient) GetTasksStatus(ctx context.Context, query *TaskQuery) (r *Response, err error) { + var _args107 ReadOnlySchedulerGetTasksStatusArgs + _args107.Query = query + var _result108 ReadOnlySchedulerGetTasksStatusResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getTasksStatus", &_args107, &_result108) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result108.GetSuccess(), nil +} + +// Same as getTaskStatus but without the TaskConfig.ExecutorConfig data set. +// This is an interim solution until we have a better way to query TaskConfigs (AURORA-541). +// +// Parameters: +// - Query +func (p *ReadOnlySchedulerClient) GetTasksWithoutConfigs(ctx context.Context, query *TaskQuery) (r *Response, err error) { + var _args109 ReadOnlySchedulerGetTasksWithoutConfigsArgs + _args109.Query = query + var _result110 ReadOnlySchedulerGetTasksWithoutConfigsResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getTasksWithoutConfigs", &_args109, &_result110) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result110.GetSuccess(), nil +} + +// Returns user-friendly reasons (if available) for tasks retained in PENDING state. +// +// Parameters: +// - Query +func (p *ReadOnlySchedulerClient) GetPendingReason(ctx context.Context, query *TaskQuery) (r *Response, err error) { + var _args111 ReadOnlySchedulerGetPendingReasonArgs + _args111.Query = query + var _result112 ReadOnlySchedulerGetPendingReasonResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getPendingReason", &_args111, &_result112) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result112.GetSuccess(), nil +} + +// Fetches the configuration summary of active tasks for the specified job. +// +// Parameters: +// - Job +func (p *ReadOnlySchedulerClient) GetConfigSummary(ctx context.Context, job *JobKey) (r *Response, err error) { + var _args113 ReadOnlySchedulerGetConfigSummaryArgs + _args113.Job = job + var _result114 ReadOnlySchedulerGetConfigSummaryResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getConfigSummary", &_args113, &_result114) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result114.GetSuccess(), nil +} + +// Fetches the status of jobs. +// ownerRole is optional, in which case all jobs are returned. +// +// Parameters: +// - OwnerRole +func (p *ReadOnlySchedulerClient) GetJobs(ctx context.Context, ownerRole string) (r *Response, err error) { + var _args115 ReadOnlySchedulerGetJobsArgs + _args115.OwnerRole = ownerRole + var _result116 ReadOnlySchedulerGetJobsResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getJobs", &_args115, &_result116) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result116.GetSuccess(), nil +} + +// Fetches the quota allocated for a user. +// +// Parameters: +// - OwnerRole +func (p *ReadOnlySchedulerClient) GetQuota(ctx context.Context, ownerRole string) (r *Response, err error) { + var _args117 ReadOnlySchedulerGetQuotaArgs + _args117.OwnerRole = ownerRole + var _result118 ReadOnlySchedulerGetQuotaResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getQuota", &_args117, &_result118) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result118.GetSuccess(), nil +} + +// Populates fields in a job configuration as though it were about to be run. +// This can be used to diff a configuration running tasks. +// +// Parameters: +// - Description +func (p *ReadOnlySchedulerClient) PopulateJobConfig(ctx context.Context, description *JobConfiguration) (r *Response, err error) { + var _args119 ReadOnlySchedulerPopulateJobConfigArgs + _args119.Description = description + var _result120 ReadOnlySchedulerPopulateJobConfigResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "populateJobConfig", &_args119, &_result120) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result120.GetSuccess(), nil +} + +// Gets job update summaries. +// +// Parameters: +// - JobUpdateQuery +func (p *ReadOnlySchedulerClient) GetJobUpdateSummaries(ctx context.Context, jobUpdateQuery *JobUpdateQuery) (r *Response, err error) { + var _args121 ReadOnlySchedulerGetJobUpdateSummariesArgs + _args121.JobUpdateQuery = jobUpdateQuery + var _result122 ReadOnlySchedulerGetJobUpdateSummariesResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getJobUpdateSummaries", &_args121, &_result122) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result122.GetSuccess(), nil +} + +// Gets job update details. +// +// Parameters: +// - Query +func (p *ReadOnlySchedulerClient) GetJobUpdateDetails(ctx context.Context, query *JobUpdateQuery) (r *Response, err error) { + var _args123 ReadOnlySchedulerGetJobUpdateDetailsArgs + _args123.Query = query + var _result124 ReadOnlySchedulerGetJobUpdateDetailsResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getJobUpdateDetails", &_args123, &_result124) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result124.GetSuccess(), nil +} + +// Gets the diff between client (desired) and server (current) job states. +// +// Parameters: +// - Request +func (p *ReadOnlySchedulerClient) GetJobUpdateDiff(ctx context.Context, request *JobUpdateRequest) (r *Response, err error) { + var _args125 ReadOnlySchedulerGetJobUpdateDiffArgs + _args125.Request = request + var _result126 ReadOnlySchedulerGetJobUpdateDiffResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getJobUpdateDiff", &_args125, &_result126) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result126.GetSuccess(), nil +} + +// Gets tier configurations. +func (p *ReadOnlySchedulerClient) GetTierConfigs(ctx context.Context) (r *Response, err error) { + var _args127 ReadOnlySchedulerGetTierConfigsArgs + var _result128 ReadOnlySchedulerGetTierConfigsResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "getTierConfigs", &_args127, &_result128) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result128.GetSuccess(), nil +} + +type ReadOnlySchedulerProcessor struct { + processorMap map[string]thrift.TProcessorFunction + handler ReadOnlyScheduler +} + +func (p *ReadOnlySchedulerProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { + p.processorMap[key] = processor +} + +func (p *ReadOnlySchedulerProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { + processor, ok = p.processorMap[key] + return processor, ok +} + +func (p *ReadOnlySchedulerProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { + return p.processorMap +} + +func NewReadOnlySchedulerProcessor(handler ReadOnlyScheduler) *ReadOnlySchedulerProcessor { + + self129 := &ReadOnlySchedulerProcessor{handler:handler, processorMap:make(map[string]thrift.TProcessorFunction)} + self129.processorMap["getRoleSummary"] = &readOnlySchedulerProcessorGetRoleSummary{handler:handler} + self129.processorMap["getJobSummary"] = &readOnlySchedulerProcessorGetJobSummary{handler:handler} + self129.processorMap["getTasksStatus"] = &readOnlySchedulerProcessorGetTasksStatus{handler:handler} + self129.processorMap["getTasksWithoutConfigs"] = &readOnlySchedulerProcessorGetTasksWithoutConfigs{handler:handler} + self129.processorMap["getPendingReason"] = &readOnlySchedulerProcessorGetPendingReason{handler:handler} + self129.processorMap["getConfigSummary"] = &readOnlySchedulerProcessorGetConfigSummary{handler:handler} + self129.processorMap["getJobs"] = &readOnlySchedulerProcessorGetJobs{handler:handler} + self129.processorMap["getQuota"] = &readOnlySchedulerProcessorGetQuota{handler:handler} + self129.processorMap["populateJobConfig"] = &readOnlySchedulerProcessorPopulateJobConfig{handler:handler} + self129.processorMap["getJobUpdateSummaries"] = &readOnlySchedulerProcessorGetJobUpdateSummaries{handler:handler} + self129.processorMap["getJobUpdateDetails"] = &readOnlySchedulerProcessorGetJobUpdateDetails{handler:handler} + self129.processorMap["getJobUpdateDiff"] = &readOnlySchedulerProcessorGetJobUpdateDiff{handler:handler} + self129.processorMap["getTierConfigs"] = &readOnlySchedulerProcessorGetTierConfigs{handler:handler} +return self129 +} + +func (p *ReadOnlySchedulerProcessor) Process(ctx context.Context, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + name, _, seqId, err2 := iprot.ReadMessageBegin(ctx) + if err2 != nil { return false, thrift.WrapTException(err2) } + if processor, ok := p.GetProcessorFunction(name); ok { + return processor.Process(ctx, seqId, iprot, oprot) + } + iprot.Skip(ctx, thrift.STRUCT) + iprot.ReadMessageEnd(ctx) + x130 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function " + name) + oprot.WriteMessageBegin(ctx, name, thrift.EXCEPTION, seqId) + x130.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, x130 + +} + +type readOnlySchedulerProcessorGetRoleSummary struct { + handler ReadOnlyScheduler +} + +func (p *readOnlySchedulerProcessorGetRoleSummary) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ReadOnlySchedulerGetRoleSummaryArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getRoleSummary", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := ReadOnlySchedulerGetRoleSummaryResult{} + var retval *Response + if retval, err2 = p.handler.GetRoleSummary(ctx); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getRoleSummary: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "getRoleSummary", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getRoleSummary", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type readOnlySchedulerProcessorGetJobSummary struct { + handler ReadOnlyScheduler +} + +func (p *readOnlySchedulerProcessorGetJobSummary) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ReadOnlySchedulerGetJobSummaryArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getJobSummary", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := ReadOnlySchedulerGetJobSummaryResult{} + var retval *Response + if retval, err2 = p.handler.GetJobSummary(ctx, args.Role); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getJobSummary: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "getJobSummary", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getJobSummary", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type readOnlySchedulerProcessorGetTasksStatus struct { + handler ReadOnlyScheduler +} + +func (p *readOnlySchedulerProcessorGetTasksStatus) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ReadOnlySchedulerGetTasksStatusArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getTasksStatus", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := ReadOnlySchedulerGetTasksStatusResult{} + var retval *Response + if retval, err2 = p.handler.GetTasksStatus(ctx, args.Query); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTasksStatus: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "getTasksStatus", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getTasksStatus", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type readOnlySchedulerProcessorGetTasksWithoutConfigs struct { + handler ReadOnlyScheduler +} + +func (p *readOnlySchedulerProcessorGetTasksWithoutConfigs) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ReadOnlySchedulerGetTasksWithoutConfigsArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getTasksWithoutConfigs", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := ReadOnlySchedulerGetTasksWithoutConfigsResult{} + var retval *Response + if retval, err2 = p.handler.GetTasksWithoutConfigs(ctx, args.Query); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTasksWithoutConfigs: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "getTasksWithoutConfigs", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getTasksWithoutConfigs", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type readOnlySchedulerProcessorGetPendingReason struct { + handler ReadOnlyScheduler +} + +func (p *readOnlySchedulerProcessorGetPendingReason) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ReadOnlySchedulerGetPendingReasonArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getPendingReason", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := ReadOnlySchedulerGetPendingReasonResult{} + var retval *Response + if retval, err2 = p.handler.GetPendingReason(ctx, args.Query); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getPendingReason: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "getPendingReason", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getPendingReason", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type readOnlySchedulerProcessorGetConfigSummary struct { + handler ReadOnlyScheduler +} + +func (p *readOnlySchedulerProcessorGetConfigSummary) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ReadOnlySchedulerGetConfigSummaryArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getConfigSummary", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := ReadOnlySchedulerGetConfigSummaryResult{} + var retval *Response + if retval, err2 = p.handler.GetConfigSummary(ctx, args.Job); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getConfigSummary: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "getConfigSummary", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getConfigSummary", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type readOnlySchedulerProcessorGetJobs struct { + handler ReadOnlyScheduler +} + +func (p *readOnlySchedulerProcessorGetJobs) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ReadOnlySchedulerGetJobsArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getJobs", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := ReadOnlySchedulerGetJobsResult{} + var retval *Response + if retval, err2 = p.handler.GetJobs(ctx, args.OwnerRole); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getJobs: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "getJobs", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getJobs", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type readOnlySchedulerProcessorGetQuota struct { + handler ReadOnlyScheduler +} + +func (p *readOnlySchedulerProcessorGetQuota) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ReadOnlySchedulerGetQuotaArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getQuota", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := ReadOnlySchedulerGetQuotaResult{} + var retval *Response + if retval, err2 = p.handler.GetQuota(ctx, args.OwnerRole); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getQuota: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "getQuota", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getQuota", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type readOnlySchedulerProcessorPopulateJobConfig struct { + handler ReadOnlyScheduler +} + +func (p *readOnlySchedulerProcessorPopulateJobConfig) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ReadOnlySchedulerPopulateJobConfigArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "populateJobConfig", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := ReadOnlySchedulerPopulateJobConfigResult{} + var retval *Response + if retval, err2 = p.handler.PopulateJobConfig(ctx, args.Description); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing populateJobConfig: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "populateJobConfig", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "populateJobConfig", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type readOnlySchedulerProcessorGetJobUpdateSummaries struct { + handler ReadOnlyScheduler +} + +func (p *readOnlySchedulerProcessorGetJobUpdateSummaries) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ReadOnlySchedulerGetJobUpdateSummariesArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getJobUpdateSummaries", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := ReadOnlySchedulerGetJobUpdateSummariesResult{} + var retval *Response + if retval, err2 = p.handler.GetJobUpdateSummaries(ctx, args.JobUpdateQuery); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getJobUpdateSummaries: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "getJobUpdateSummaries", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getJobUpdateSummaries", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type readOnlySchedulerProcessorGetJobUpdateDetails struct { + handler ReadOnlyScheduler +} + +func (p *readOnlySchedulerProcessorGetJobUpdateDetails) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ReadOnlySchedulerGetJobUpdateDetailsArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getJobUpdateDetails", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := ReadOnlySchedulerGetJobUpdateDetailsResult{} + var retval *Response + if retval, err2 = p.handler.GetJobUpdateDetails(ctx, args.Query); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getJobUpdateDetails: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "getJobUpdateDetails", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getJobUpdateDetails", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type readOnlySchedulerProcessorGetJobUpdateDiff struct { + handler ReadOnlyScheduler +} + +func (p *readOnlySchedulerProcessorGetJobUpdateDiff) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ReadOnlySchedulerGetJobUpdateDiffArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getJobUpdateDiff", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := ReadOnlySchedulerGetJobUpdateDiffResult{} + var retval *Response + if retval, err2 = p.handler.GetJobUpdateDiff(ctx, args.Request); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getJobUpdateDiff: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "getJobUpdateDiff", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getJobUpdateDiff", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type readOnlySchedulerProcessorGetTierConfigs struct { + handler ReadOnlyScheduler +} + +func (p *readOnlySchedulerProcessorGetTierConfigs) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := ReadOnlySchedulerGetTierConfigsArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "getTierConfigs", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := ReadOnlySchedulerGetTierConfigsResult{} + var retval *Response + if retval, err2 = p.handler.GetTierConfigs(ctx); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTierConfigs: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "getTierConfigs", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "getTierConfigs", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + + +// HELPER FUNCTIONS AND STRUCTURES + +type ReadOnlySchedulerGetRoleSummaryArgs struct { +} + +func NewReadOnlySchedulerGetRoleSummaryArgs() *ReadOnlySchedulerGetRoleSummaryArgs { + return &ReadOnlySchedulerGetRoleSummaryArgs{} +} + +func (p *ReadOnlySchedulerGetRoleSummaryArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetRoleSummaryArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getRoleSummary_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetRoleSummaryArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetRoleSummaryArgs(%+v)", *p) +} + +// Attributes: +// - Success +type ReadOnlySchedulerGetRoleSummaryResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewReadOnlySchedulerGetRoleSummaryResult() *ReadOnlySchedulerGetRoleSummaryResult { + return &ReadOnlySchedulerGetRoleSummaryResult{} +} + +var ReadOnlySchedulerGetRoleSummaryResult_Success_DEFAULT *Response +func (p *ReadOnlySchedulerGetRoleSummaryResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return ReadOnlySchedulerGetRoleSummaryResult_Success_DEFAULT + } +return p.Success +} +func (p *ReadOnlySchedulerGetRoleSummaryResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ReadOnlySchedulerGetRoleSummaryResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetRoleSummaryResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetRoleSummaryResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getRoleSummary_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetRoleSummaryResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *ReadOnlySchedulerGetRoleSummaryResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetRoleSummaryResult(%+v)", *p) +} + +// Attributes: +// - Role +type ReadOnlySchedulerGetJobSummaryArgs struct { + Role string `thrift:"role,1" db:"role" json:"role"` +} + +func NewReadOnlySchedulerGetJobSummaryArgs() *ReadOnlySchedulerGetJobSummaryArgs { + return &ReadOnlySchedulerGetJobSummaryArgs{} +} + + +func (p *ReadOnlySchedulerGetJobSummaryArgs) GetRole() string { + return p.Role +} +func (p *ReadOnlySchedulerGetJobSummaryArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobSummaryArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.Role = v +} + return nil +} + +func (p *ReadOnlySchedulerGetJobSummaryArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobSummary_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetJobSummaryArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "role", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:role: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Role)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.role (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:role: ", p), err) } + return err +} + +func (p *ReadOnlySchedulerGetJobSummaryArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetJobSummaryArgs(%+v)", *p) +} + +// Attributes: +// - Success +type ReadOnlySchedulerGetJobSummaryResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewReadOnlySchedulerGetJobSummaryResult() *ReadOnlySchedulerGetJobSummaryResult { + return &ReadOnlySchedulerGetJobSummaryResult{} +} + +var ReadOnlySchedulerGetJobSummaryResult_Success_DEFAULT *Response +func (p *ReadOnlySchedulerGetJobSummaryResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return ReadOnlySchedulerGetJobSummaryResult_Success_DEFAULT + } +return p.Success +} +func (p *ReadOnlySchedulerGetJobSummaryResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ReadOnlySchedulerGetJobSummaryResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobSummaryResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobSummaryResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobSummary_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetJobSummaryResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *ReadOnlySchedulerGetJobSummaryResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetJobSummaryResult(%+v)", *p) +} + +// Attributes: +// - Query +type ReadOnlySchedulerGetTasksStatusArgs struct { + Query *TaskQuery `thrift:"query,1" db:"query" json:"query"` +} + +func NewReadOnlySchedulerGetTasksStatusArgs() *ReadOnlySchedulerGetTasksStatusArgs { + return &ReadOnlySchedulerGetTasksStatusArgs{} +} + +var ReadOnlySchedulerGetTasksStatusArgs_Query_DEFAULT *TaskQuery +func (p *ReadOnlySchedulerGetTasksStatusArgs) GetQuery() *TaskQuery { + if !p.IsSetQuery() { + return ReadOnlySchedulerGetTasksStatusArgs_Query_DEFAULT + } +return p.Query +} +func (p *ReadOnlySchedulerGetTasksStatusArgs) IsSetQuery() bool { + return p.Query != nil +} + +func (p *ReadOnlySchedulerGetTasksStatusArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetTasksStatusArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Query = &TaskQuery{} + if err := p.Query.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetTasksStatusArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getTasksStatus_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetTasksStatusArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "query", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:query: ", p), err) } + if err := p.Query.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:query: ", p), err) } + return err +} + +func (p *ReadOnlySchedulerGetTasksStatusArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetTasksStatusArgs(%+v)", *p) +} + +// Attributes: +// - Success +type ReadOnlySchedulerGetTasksStatusResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewReadOnlySchedulerGetTasksStatusResult() *ReadOnlySchedulerGetTasksStatusResult { + return &ReadOnlySchedulerGetTasksStatusResult{} +} + +var ReadOnlySchedulerGetTasksStatusResult_Success_DEFAULT *Response +func (p *ReadOnlySchedulerGetTasksStatusResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return ReadOnlySchedulerGetTasksStatusResult_Success_DEFAULT + } +return p.Success +} +func (p *ReadOnlySchedulerGetTasksStatusResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ReadOnlySchedulerGetTasksStatusResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetTasksStatusResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetTasksStatusResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getTasksStatus_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetTasksStatusResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *ReadOnlySchedulerGetTasksStatusResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetTasksStatusResult(%+v)", *p) +} + +// Attributes: +// - Query +type ReadOnlySchedulerGetTasksWithoutConfigsArgs struct { + Query *TaskQuery `thrift:"query,1" db:"query" json:"query"` +} + +func NewReadOnlySchedulerGetTasksWithoutConfigsArgs() *ReadOnlySchedulerGetTasksWithoutConfigsArgs { + return &ReadOnlySchedulerGetTasksWithoutConfigsArgs{} +} + +var ReadOnlySchedulerGetTasksWithoutConfigsArgs_Query_DEFAULT *TaskQuery +func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) GetQuery() *TaskQuery { + if !p.IsSetQuery() { + return ReadOnlySchedulerGetTasksWithoutConfigsArgs_Query_DEFAULT + } +return p.Query +} +func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) IsSetQuery() bool { + return p.Query != nil +} + +func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Query = &TaskQuery{} + if err := p.Query.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getTasksWithoutConfigs_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "query", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:query: ", p), err) } + if err := p.Query.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:query: ", p), err) } + return err +} + +func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetTasksWithoutConfigsArgs(%+v)", *p) +} + +// Attributes: +// - Success +type ReadOnlySchedulerGetTasksWithoutConfigsResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewReadOnlySchedulerGetTasksWithoutConfigsResult() *ReadOnlySchedulerGetTasksWithoutConfigsResult { + return &ReadOnlySchedulerGetTasksWithoutConfigsResult{} +} + +var ReadOnlySchedulerGetTasksWithoutConfigsResult_Success_DEFAULT *Response +func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return ReadOnlySchedulerGetTasksWithoutConfigsResult_Success_DEFAULT + } +return p.Success +} +func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getTasksWithoutConfigs_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetTasksWithoutConfigsResult(%+v)", *p) +} + +// Attributes: +// - Query +type ReadOnlySchedulerGetPendingReasonArgs struct { + Query *TaskQuery `thrift:"query,1" db:"query" json:"query"` +} + +func NewReadOnlySchedulerGetPendingReasonArgs() *ReadOnlySchedulerGetPendingReasonArgs { + return &ReadOnlySchedulerGetPendingReasonArgs{} +} + +var ReadOnlySchedulerGetPendingReasonArgs_Query_DEFAULT *TaskQuery +func (p *ReadOnlySchedulerGetPendingReasonArgs) GetQuery() *TaskQuery { + if !p.IsSetQuery() { + return ReadOnlySchedulerGetPendingReasonArgs_Query_DEFAULT + } +return p.Query +} +func (p *ReadOnlySchedulerGetPendingReasonArgs) IsSetQuery() bool { + return p.Query != nil +} + +func (p *ReadOnlySchedulerGetPendingReasonArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetPendingReasonArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Query = &TaskQuery{} + if err := p.Query.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetPendingReasonArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getPendingReason_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetPendingReasonArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "query", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:query: ", p), err) } + if err := p.Query.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:query: ", p), err) } + return err +} + +func (p *ReadOnlySchedulerGetPendingReasonArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetPendingReasonArgs(%+v)", *p) +} + +// Attributes: +// - Success +type ReadOnlySchedulerGetPendingReasonResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewReadOnlySchedulerGetPendingReasonResult() *ReadOnlySchedulerGetPendingReasonResult { + return &ReadOnlySchedulerGetPendingReasonResult{} +} + +var ReadOnlySchedulerGetPendingReasonResult_Success_DEFAULT *Response +func (p *ReadOnlySchedulerGetPendingReasonResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return ReadOnlySchedulerGetPendingReasonResult_Success_DEFAULT + } +return p.Success +} +func (p *ReadOnlySchedulerGetPendingReasonResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ReadOnlySchedulerGetPendingReasonResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetPendingReasonResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetPendingReasonResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getPendingReason_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetPendingReasonResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *ReadOnlySchedulerGetPendingReasonResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetPendingReasonResult(%+v)", *p) +} + +// Attributes: +// - Job +type ReadOnlySchedulerGetConfigSummaryArgs struct { + Job *JobKey `thrift:"job,1" db:"job" json:"job"` +} + +func NewReadOnlySchedulerGetConfigSummaryArgs() *ReadOnlySchedulerGetConfigSummaryArgs { + return &ReadOnlySchedulerGetConfigSummaryArgs{} +} + +var ReadOnlySchedulerGetConfigSummaryArgs_Job_DEFAULT *JobKey +func (p *ReadOnlySchedulerGetConfigSummaryArgs) GetJob() *JobKey { + if !p.IsSetJob() { + return ReadOnlySchedulerGetConfigSummaryArgs_Job_DEFAULT + } +return p.Job +} +func (p *ReadOnlySchedulerGetConfigSummaryArgs) IsSetJob() bool { + return p.Job != nil +} + +func (p *ReadOnlySchedulerGetConfigSummaryArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetConfigSummaryArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Job = &JobKey{} + if err := p.Job.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetConfigSummaryArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getConfigSummary_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetConfigSummaryArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "job", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:job: ", p), err) } + if err := p.Job.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:job: ", p), err) } + return err +} + +func (p *ReadOnlySchedulerGetConfigSummaryArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetConfigSummaryArgs(%+v)", *p) +} + +// Attributes: +// - Success +type ReadOnlySchedulerGetConfigSummaryResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewReadOnlySchedulerGetConfigSummaryResult() *ReadOnlySchedulerGetConfigSummaryResult { + return &ReadOnlySchedulerGetConfigSummaryResult{} +} + +var ReadOnlySchedulerGetConfigSummaryResult_Success_DEFAULT *Response +func (p *ReadOnlySchedulerGetConfigSummaryResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return ReadOnlySchedulerGetConfigSummaryResult_Success_DEFAULT + } +return p.Success +} +func (p *ReadOnlySchedulerGetConfigSummaryResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ReadOnlySchedulerGetConfigSummaryResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetConfigSummaryResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetConfigSummaryResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getConfigSummary_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetConfigSummaryResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *ReadOnlySchedulerGetConfigSummaryResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetConfigSummaryResult(%+v)", *p) +} + +// Attributes: +// - OwnerRole +type ReadOnlySchedulerGetJobsArgs struct { + OwnerRole string `thrift:"ownerRole,1" db:"ownerRole" json:"ownerRole"` +} + +func NewReadOnlySchedulerGetJobsArgs() *ReadOnlySchedulerGetJobsArgs { + return &ReadOnlySchedulerGetJobsArgs{} +} + + +func (p *ReadOnlySchedulerGetJobsArgs) GetOwnerRole() string { + return p.OwnerRole +} +func (p *ReadOnlySchedulerGetJobsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobsArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.OwnerRole = v +} + return nil +} + +func (p *ReadOnlySchedulerGetJobsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobs_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetJobsArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "ownerRole", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ownerRole: ", p), err) } + if err := oprot.WriteString(ctx, string(p.OwnerRole)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.ownerRole (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ownerRole: ", p), err) } + return err +} + +func (p *ReadOnlySchedulerGetJobsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetJobsArgs(%+v)", *p) +} + +// Attributes: +// - Success +type ReadOnlySchedulerGetJobsResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewReadOnlySchedulerGetJobsResult() *ReadOnlySchedulerGetJobsResult { + return &ReadOnlySchedulerGetJobsResult{} +} + +var ReadOnlySchedulerGetJobsResult_Success_DEFAULT *Response +func (p *ReadOnlySchedulerGetJobsResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return ReadOnlySchedulerGetJobsResult_Success_DEFAULT + } +return p.Success +} +func (p *ReadOnlySchedulerGetJobsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ReadOnlySchedulerGetJobsResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobsResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobsResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobs_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetJobsResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *ReadOnlySchedulerGetJobsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetJobsResult(%+v)", *p) +} + +// Attributes: +// - OwnerRole +type ReadOnlySchedulerGetQuotaArgs struct { + OwnerRole string `thrift:"ownerRole,1" db:"ownerRole" json:"ownerRole"` +} + +func NewReadOnlySchedulerGetQuotaArgs() *ReadOnlySchedulerGetQuotaArgs { + return &ReadOnlySchedulerGetQuotaArgs{} +} + + +func (p *ReadOnlySchedulerGetQuotaArgs) GetOwnerRole() string { + return p.OwnerRole +} +func (p *ReadOnlySchedulerGetQuotaArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetQuotaArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.OwnerRole = v +} + return nil +} + +func (p *ReadOnlySchedulerGetQuotaArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getQuota_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetQuotaArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "ownerRole", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ownerRole: ", p), err) } + if err := oprot.WriteString(ctx, string(p.OwnerRole)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.ownerRole (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ownerRole: ", p), err) } + return err +} + +func (p *ReadOnlySchedulerGetQuotaArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetQuotaArgs(%+v)", *p) +} + +// Attributes: +// - Success +type ReadOnlySchedulerGetQuotaResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewReadOnlySchedulerGetQuotaResult() *ReadOnlySchedulerGetQuotaResult { + return &ReadOnlySchedulerGetQuotaResult{} +} + +var ReadOnlySchedulerGetQuotaResult_Success_DEFAULT *Response +func (p *ReadOnlySchedulerGetQuotaResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return ReadOnlySchedulerGetQuotaResult_Success_DEFAULT + } +return p.Success +} +func (p *ReadOnlySchedulerGetQuotaResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ReadOnlySchedulerGetQuotaResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetQuotaResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetQuotaResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getQuota_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetQuotaResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *ReadOnlySchedulerGetQuotaResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetQuotaResult(%+v)", *p) +} + +// Attributes: +// - Description +type ReadOnlySchedulerPopulateJobConfigArgs struct { + Description *JobConfiguration `thrift:"description,1" db:"description" json:"description"` +} + +func NewReadOnlySchedulerPopulateJobConfigArgs() *ReadOnlySchedulerPopulateJobConfigArgs { + return &ReadOnlySchedulerPopulateJobConfigArgs{} +} + +var ReadOnlySchedulerPopulateJobConfigArgs_Description_DEFAULT *JobConfiguration +func (p *ReadOnlySchedulerPopulateJobConfigArgs) GetDescription() *JobConfiguration { + if !p.IsSetDescription() { + return ReadOnlySchedulerPopulateJobConfigArgs_Description_DEFAULT + } +return p.Description +} +func (p *ReadOnlySchedulerPopulateJobConfigArgs) IsSetDescription() bool { + return p.Description != nil +} + +func (p *ReadOnlySchedulerPopulateJobConfigArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerPopulateJobConfigArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Description = &JobConfiguration{} + if err := p.Description.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Description), err) + } + return nil +} + +func (p *ReadOnlySchedulerPopulateJobConfigArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "populateJobConfig_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerPopulateJobConfigArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "description", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:description: ", p), err) } + if err := p.Description.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Description), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:description: ", p), err) } + return err +} + +func (p *ReadOnlySchedulerPopulateJobConfigArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerPopulateJobConfigArgs(%+v)", *p) +} + +// Attributes: +// - Success +type ReadOnlySchedulerPopulateJobConfigResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewReadOnlySchedulerPopulateJobConfigResult() *ReadOnlySchedulerPopulateJobConfigResult { + return &ReadOnlySchedulerPopulateJobConfigResult{} +} + +var ReadOnlySchedulerPopulateJobConfigResult_Success_DEFAULT *Response +func (p *ReadOnlySchedulerPopulateJobConfigResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return ReadOnlySchedulerPopulateJobConfigResult_Success_DEFAULT + } +return p.Success +} +func (p *ReadOnlySchedulerPopulateJobConfigResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ReadOnlySchedulerPopulateJobConfigResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerPopulateJobConfigResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *ReadOnlySchedulerPopulateJobConfigResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "populateJobConfig_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerPopulateJobConfigResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *ReadOnlySchedulerPopulateJobConfigResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerPopulateJobConfigResult(%+v)", *p) +} + +// Attributes: +// - JobUpdateQuery +type ReadOnlySchedulerGetJobUpdateSummariesArgs struct { + JobUpdateQuery *JobUpdateQuery `thrift:"jobUpdateQuery,1" db:"jobUpdateQuery" json:"jobUpdateQuery"` +} + +func NewReadOnlySchedulerGetJobUpdateSummariesArgs() *ReadOnlySchedulerGetJobUpdateSummariesArgs { + return &ReadOnlySchedulerGetJobUpdateSummariesArgs{} +} + +var ReadOnlySchedulerGetJobUpdateSummariesArgs_JobUpdateQuery_DEFAULT *JobUpdateQuery +func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) GetJobUpdateQuery() *JobUpdateQuery { + if !p.IsSetJobUpdateQuery() { + return ReadOnlySchedulerGetJobUpdateSummariesArgs_JobUpdateQuery_DEFAULT + } +return p.JobUpdateQuery +} +func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) IsSetJobUpdateQuery() bool { + return p.JobUpdateQuery != nil +} + +func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.JobUpdateQuery = &JobUpdateQuery{} + if err := p.JobUpdateQuery.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.JobUpdateQuery), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobUpdateSummaries_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "jobUpdateQuery", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:jobUpdateQuery: ", p), err) } + if err := p.JobUpdateQuery.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.JobUpdateQuery), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:jobUpdateQuery: ", p), err) } + return err +} + +func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetJobUpdateSummariesArgs(%+v)", *p) +} + +// Attributes: +// - Success +type ReadOnlySchedulerGetJobUpdateSummariesResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewReadOnlySchedulerGetJobUpdateSummariesResult() *ReadOnlySchedulerGetJobUpdateSummariesResult { + return &ReadOnlySchedulerGetJobUpdateSummariesResult{} +} + +var ReadOnlySchedulerGetJobUpdateSummariesResult_Success_DEFAULT *Response +func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return ReadOnlySchedulerGetJobUpdateSummariesResult_Success_DEFAULT + } +return p.Success +} +func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobUpdateSummaries_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetJobUpdateSummariesResult(%+v)", *p) +} + +// Attributes: +// - Query +type ReadOnlySchedulerGetJobUpdateDetailsArgs struct { + // unused field # 1 + Query *JobUpdateQuery `thrift:"query,2" db:"query" json:"query"` +} + +func NewReadOnlySchedulerGetJobUpdateDetailsArgs() *ReadOnlySchedulerGetJobUpdateDetailsArgs { + return &ReadOnlySchedulerGetJobUpdateDetailsArgs{} +} + +var ReadOnlySchedulerGetJobUpdateDetailsArgs_Query_DEFAULT *JobUpdateQuery +func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) GetQuery() *JobUpdateQuery { + if !p.IsSetQuery() { + return ReadOnlySchedulerGetJobUpdateDetailsArgs_Query_DEFAULT + } +return p.Query +} +func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) IsSetQuery() bool { + return p.Query != nil +} + +func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.Query = &JobUpdateQuery{} + if err := p.Query.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobUpdateDetails_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "query", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:query: ", p), err) } + if err := p.Query.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:query: ", p), err) } + return err +} + +func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetJobUpdateDetailsArgs(%+v)", *p) +} + +// Attributes: +// - Success +type ReadOnlySchedulerGetJobUpdateDetailsResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewReadOnlySchedulerGetJobUpdateDetailsResult() *ReadOnlySchedulerGetJobUpdateDetailsResult { + return &ReadOnlySchedulerGetJobUpdateDetailsResult{} +} + +var ReadOnlySchedulerGetJobUpdateDetailsResult_Success_DEFAULT *Response +func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return ReadOnlySchedulerGetJobUpdateDetailsResult_Success_DEFAULT + } +return p.Success +} +func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobUpdateDetails_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetJobUpdateDetailsResult(%+v)", *p) +} + +// Attributes: +// - Request +type ReadOnlySchedulerGetJobUpdateDiffArgs struct { + Request *JobUpdateRequest `thrift:"request,1" db:"request" json:"request"` +} + +func NewReadOnlySchedulerGetJobUpdateDiffArgs() *ReadOnlySchedulerGetJobUpdateDiffArgs { + return &ReadOnlySchedulerGetJobUpdateDiffArgs{} +} + +var ReadOnlySchedulerGetJobUpdateDiffArgs_Request_DEFAULT *JobUpdateRequest +func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) GetRequest() *JobUpdateRequest { + if !p.IsSetRequest() { + return ReadOnlySchedulerGetJobUpdateDiffArgs_Request_DEFAULT + } +return p.Request +} +func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) IsSetRequest() bool { + return p.Request != nil +} + +func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Request = &JobUpdateRequest{} + if err := p.Request.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Request), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobUpdateDiff_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "request", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:request: ", p), err) } + if err := p.Request.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Request), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:request: ", p), err) } + return err +} + +func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetJobUpdateDiffArgs(%+v)", *p) +} + +// Attributes: +// - Success +type ReadOnlySchedulerGetJobUpdateDiffResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewReadOnlySchedulerGetJobUpdateDiffResult() *ReadOnlySchedulerGetJobUpdateDiffResult { + return &ReadOnlySchedulerGetJobUpdateDiffResult{} +} + +var ReadOnlySchedulerGetJobUpdateDiffResult_Success_DEFAULT *Response +func (p *ReadOnlySchedulerGetJobUpdateDiffResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return ReadOnlySchedulerGetJobUpdateDiffResult_Success_DEFAULT + } +return p.Success +} +func (p *ReadOnlySchedulerGetJobUpdateDiffResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ReadOnlySchedulerGetJobUpdateDiffResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateDiffResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateDiffResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getJobUpdateDiff_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetJobUpdateDiffResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *ReadOnlySchedulerGetJobUpdateDiffResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetJobUpdateDiffResult(%+v)", *p) +} + +type ReadOnlySchedulerGetTierConfigsArgs struct { +} + +func NewReadOnlySchedulerGetTierConfigsArgs() *ReadOnlySchedulerGetTierConfigsArgs { + return &ReadOnlySchedulerGetTierConfigsArgs{} +} + +func (p *ReadOnlySchedulerGetTierConfigsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetTierConfigsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getTierConfigs_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetTierConfigsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetTierConfigsArgs(%+v)", *p) +} + +// Attributes: +// - Success +type ReadOnlySchedulerGetTierConfigsResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewReadOnlySchedulerGetTierConfigsResult() *ReadOnlySchedulerGetTierConfigsResult { + return &ReadOnlySchedulerGetTierConfigsResult{} +} + +var ReadOnlySchedulerGetTierConfigsResult_Success_DEFAULT *Response +func (p *ReadOnlySchedulerGetTierConfigsResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return ReadOnlySchedulerGetTierConfigsResult_Success_DEFAULT + } +return p.Success +} +func (p *ReadOnlySchedulerGetTierConfigsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *ReadOnlySchedulerGetTierConfigsResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetTierConfigsResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *ReadOnlySchedulerGetTierConfigsResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "getTierConfigs_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *ReadOnlySchedulerGetTierConfigsResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *ReadOnlySchedulerGetTierConfigsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("ReadOnlySchedulerGetTierConfigsResult(%+v)", *p) +} + + +type AuroraSchedulerManager interface { +ReadOnlyScheduler + + // Creates a new job. The request will be denied if a job with the provided name already exists + // in the cluster. + // + // Parameters: + // - Description + CreateJob(ctx context.Context, description *JobConfiguration) (r *Response, err error) + // Enters a job into the cron schedule, without actually starting the job. + // If the job is already present in the schedule, this will update the schedule entry with the new + // configuration. + // + // Parameters: + // - Description + ScheduleCronJob(ctx context.Context, description *JobConfiguration) (r *Response, err error) + // Removes a job from the cron schedule. The request will be denied if the job was not previously + // scheduled with scheduleCronJob. + // + // Parameters: + // - Job + DescheduleCronJob(ctx context.Context, job *JobKey) (r *Response, err error) + // Starts a cron job immediately. The request will be denied if the specified job does not + // exist for the role account, or the job is not a cron job. + // + // Parameters: + // - Job + StartCronJob(ctx context.Context, job *JobKey) (r *Response, err error) + // Restarts a batch of shards. + // + // Parameters: + // - Job + // - ShardIds + RestartShards(ctx context.Context, job *JobKey, shardIds []int32) (r *Response, err error) + // Initiates a kill on tasks. + // + // Parameters: + // - Job + // - Instances + // - Message + KillTasks(ctx context.Context, job *JobKey, instances []int32, message string) (r *Response, err error) + // Adds new instances with the TaskConfig of the existing instance pointed by the key. + // + // Parameters: + // - Key + // - Count + AddInstances(ctx context.Context, key *InstanceKey, count int32) (r *Response, err error) + // Replaces the template (configuration) for the existing cron job. + // The cron job template (configuration) must exist for the call to succeed. + // + // Parameters: + // - Config + ReplaceCronTemplate(ctx context.Context, config *JobConfiguration) (r *Response, err error) + // Starts update of the existing service job. + // + // Parameters: + // - Request: A description of how to change the job. + // - Message: A user-specified message to include with the induced job update state change. + StartJobUpdate(ctx context.Context, request *JobUpdateRequest, message string) (r *Response, err error) + // Pauses the specified job update. Can be resumed by resumeUpdate call. + // + // Parameters: + // - Key: The update to pause. + // - Message: A user-specified message to include with the induced job update state change. + PauseJobUpdate(ctx context.Context, key *JobUpdateKey, message string) (r *Response, err error) + // Resumes progress of a previously paused job update. + // + // Parameters: + // - Key: The update to resume. + // - Message: A user-specified message to include with the induced job update state change. + ResumeJobUpdate(ctx context.Context, key *JobUpdateKey, message string) (r *Response, err error) + // Permanently aborts the job update. Does not remove the update history. + // + // Parameters: + // - Key: The update to abort. + // - Message: A user-specified message to include with the induced job update state change. + AbortJobUpdate(ctx context.Context, key *JobUpdateKey, message string) (r *Response, err error) + // Rollbacks the specified active job update to the initial state. + // + // Parameters: + // - Key: The update to rollback. + // - Message: A user-specified message to include with the induced job update state change. + RollbackJobUpdate(ctx context.Context, key *JobUpdateKey, message string) (r *Response, err error) + // Allows progress of the job update in case blockIfNoPulsesAfterMs is specified in + // JobUpdateSettings. Unblocks progress if the update was previously blocked. + // Responds with ResponseCode.INVALID_REQUEST in case an unknown update key is specified. + // + // Parameters: + // - Key + PulseJobUpdate(ctx context.Context, key *JobUpdateKey) (r *Response, err error) +} + +type AuroraSchedulerManagerClient struct { + *ReadOnlySchedulerClient +} + +func NewAuroraSchedulerManagerClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *AuroraSchedulerManagerClient { + return &AuroraSchedulerManagerClient{ReadOnlySchedulerClient: NewReadOnlySchedulerClientFactory(t, f)}} + +func NewAuroraSchedulerManagerClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *AuroraSchedulerManagerClient { + return &AuroraSchedulerManagerClient{ReadOnlySchedulerClient: NewReadOnlySchedulerClientProtocol(t, iprot, oprot)} +} + +func NewAuroraSchedulerManagerClient(c thrift.TClient) *AuroraSchedulerManagerClient { + return &AuroraSchedulerManagerClient{ + ReadOnlySchedulerClient: NewReadOnlySchedulerClient(c), + } +} + +// Creates a new job. The request will be denied if a job with the provided name already exists +// in the cluster. +// +// Parameters: +// - Description +func (p *AuroraSchedulerManagerClient) CreateJob(ctx context.Context, description *JobConfiguration) (r *Response, err error) { + var _args182 AuroraSchedulerManagerCreateJobArgs + _args182.Description = description + var _result183 AuroraSchedulerManagerCreateJobResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "createJob", &_args182, &_result183) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result183.GetSuccess(), nil +} + +// Enters a job into the cron schedule, without actually starting the job. +// If the job is already present in the schedule, this will update the schedule entry with the new +// configuration. +// +// Parameters: +// - Description +func (p *AuroraSchedulerManagerClient) ScheduleCronJob(ctx context.Context, description *JobConfiguration) (r *Response, err error) { + var _args184 AuroraSchedulerManagerScheduleCronJobArgs + _args184.Description = description + var _result185 AuroraSchedulerManagerScheduleCronJobResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "scheduleCronJob", &_args184, &_result185) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result185.GetSuccess(), nil +} + +// Removes a job from the cron schedule. The request will be denied if the job was not previously +// scheduled with scheduleCronJob. +// +// Parameters: +// - Job +func (p *AuroraSchedulerManagerClient) DescheduleCronJob(ctx context.Context, job *JobKey) (r *Response, err error) { + var _args186 AuroraSchedulerManagerDescheduleCronJobArgs + _args186.Job = job + var _result187 AuroraSchedulerManagerDescheduleCronJobResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "descheduleCronJob", &_args186, &_result187) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result187.GetSuccess(), nil +} + +// Starts a cron job immediately. The request will be denied if the specified job does not +// exist for the role account, or the job is not a cron job. +// +// Parameters: +// - Job +func (p *AuroraSchedulerManagerClient) StartCronJob(ctx context.Context, job *JobKey) (r *Response, err error) { + var _args188 AuroraSchedulerManagerStartCronJobArgs + _args188.Job = job + var _result189 AuroraSchedulerManagerStartCronJobResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "startCronJob", &_args188, &_result189) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result189.GetSuccess(), nil +} + +// Restarts a batch of shards. +// +// Parameters: +// - Job +// - ShardIds +func (p *AuroraSchedulerManagerClient) RestartShards(ctx context.Context, job *JobKey, shardIds []int32) (r *Response, err error) { + var _args190 AuroraSchedulerManagerRestartShardsArgs + _args190.Job = job + _args190.ShardIds = shardIds + var _result191 AuroraSchedulerManagerRestartShardsResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "restartShards", &_args190, &_result191) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result191.GetSuccess(), nil +} + +// Initiates a kill on tasks. +// +// Parameters: +// - Job +// - Instances +// - Message +func (p *AuroraSchedulerManagerClient) KillTasks(ctx context.Context, job *JobKey, instances []int32, message string) (r *Response, err error) { + var _args192 AuroraSchedulerManagerKillTasksArgs + _args192.Job = job + _args192.Instances = instances + _args192.Message = message + var _result193 AuroraSchedulerManagerKillTasksResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "killTasks", &_args192, &_result193) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result193.GetSuccess(), nil +} + +// Adds new instances with the TaskConfig of the existing instance pointed by the key. +// +// Parameters: +// - Key +// - Count +func (p *AuroraSchedulerManagerClient) AddInstances(ctx context.Context, key *InstanceKey, count int32) (r *Response, err error) { + var _args194 AuroraSchedulerManagerAddInstancesArgs + _args194.Key = key + _args194.Count = count + var _result195 AuroraSchedulerManagerAddInstancesResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "addInstances", &_args194, &_result195) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result195.GetSuccess(), nil +} + +// Replaces the template (configuration) for the existing cron job. +// The cron job template (configuration) must exist for the call to succeed. +// +// Parameters: +// - Config +func (p *AuroraSchedulerManagerClient) ReplaceCronTemplate(ctx context.Context, config *JobConfiguration) (r *Response, err error) { + var _args196 AuroraSchedulerManagerReplaceCronTemplateArgs + _args196.Config = config + var _result197 AuroraSchedulerManagerReplaceCronTemplateResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "replaceCronTemplate", &_args196, &_result197) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result197.GetSuccess(), nil +} + +// Starts update of the existing service job. +// +// Parameters: +// - Request: A description of how to change the job. +// - Message: A user-specified message to include with the induced job update state change. +func (p *AuroraSchedulerManagerClient) StartJobUpdate(ctx context.Context, request *JobUpdateRequest, message string) (r *Response, err error) { + var _args198 AuroraSchedulerManagerStartJobUpdateArgs + _args198.Request = request + _args198.Message = message + var _result199 AuroraSchedulerManagerStartJobUpdateResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "startJobUpdate", &_args198, &_result199) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result199.GetSuccess(), nil +} + +// Pauses the specified job update. Can be resumed by resumeUpdate call. +// +// Parameters: +// - Key: The update to pause. +// - Message: A user-specified message to include with the induced job update state change. +func (p *AuroraSchedulerManagerClient) PauseJobUpdate(ctx context.Context, key *JobUpdateKey, message string) (r *Response, err error) { + var _args200 AuroraSchedulerManagerPauseJobUpdateArgs + _args200.Key = key + _args200.Message = message + var _result201 AuroraSchedulerManagerPauseJobUpdateResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "pauseJobUpdate", &_args200, &_result201) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result201.GetSuccess(), nil +} + +// Resumes progress of a previously paused job update. +// +// Parameters: +// - Key: The update to resume. +// - Message: A user-specified message to include with the induced job update state change. +func (p *AuroraSchedulerManagerClient) ResumeJobUpdate(ctx context.Context, key *JobUpdateKey, message string) (r *Response, err error) { + var _args202 AuroraSchedulerManagerResumeJobUpdateArgs + _args202.Key = key + _args202.Message = message + var _result203 AuroraSchedulerManagerResumeJobUpdateResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "resumeJobUpdate", &_args202, &_result203) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result203.GetSuccess(), nil +} + +// Permanently aborts the job update. Does not remove the update history. +// +// Parameters: +// - Key: The update to abort. +// - Message: A user-specified message to include with the induced job update state change. +func (p *AuroraSchedulerManagerClient) AbortJobUpdate(ctx context.Context, key *JobUpdateKey, message string) (r *Response, err error) { + var _args204 AuroraSchedulerManagerAbortJobUpdateArgs + _args204.Key = key + _args204.Message = message + var _result205 AuroraSchedulerManagerAbortJobUpdateResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "abortJobUpdate", &_args204, &_result205) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result205.GetSuccess(), nil +} + +// Rollbacks the specified active job update to the initial state. +// +// Parameters: +// - Key: The update to rollback. +// - Message: A user-specified message to include with the induced job update state change. +func (p *AuroraSchedulerManagerClient) RollbackJobUpdate(ctx context.Context, key *JobUpdateKey, message string) (r *Response, err error) { + var _args206 AuroraSchedulerManagerRollbackJobUpdateArgs + _args206.Key = key + _args206.Message = message + var _result207 AuroraSchedulerManagerRollbackJobUpdateResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "rollbackJobUpdate", &_args206, &_result207) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result207.GetSuccess(), nil +} + +// Allows progress of the job update in case blockIfNoPulsesAfterMs is specified in +// JobUpdateSettings. Unblocks progress if the update was previously blocked. +// Responds with ResponseCode.INVALID_REQUEST in case an unknown update key is specified. +// +// Parameters: +// - Key +func (p *AuroraSchedulerManagerClient) PulseJobUpdate(ctx context.Context, key *JobUpdateKey) (r *Response, err error) { + var _args208 AuroraSchedulerManagerPulseJobUpdateArgs + _args208.Key = key + var _result209 AuroraSchedulerManagerPulseJobUpdateResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "pulseJobUpdate", &_args208, &_result209) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result209.GetSuccess(), nil +} + +type AuroraSchedulerManagerProcessor struct { + *ReadOnlySchedulerProcessor +} + +func NewAuroraSchedulerManagerProcessor(handler AuroraSchedulerManager) *AuroraSchedulerManagerProcessor { + self210 := &AuroraSchedulerManagerProcessor{NewReadOnlySchedulerProcessor(handler)} + self210.AddToProcessorMap("createJob", &auroraSchedulerManagerProcessorCreateJob{handler:handler}) + self210.AddToProcessorMap("scheduleCronJob", &auroraSchedulerManagerProcessorScheduleCronJob{handler:handler}) + self210.AddToProcessorMap("descheduleCronJob", &auroraSchedulerManagerProcessorDescheduleCronJob{handler:handler}) + self210.AddToProcessorMap("startCronJob", &auroraSchedulerManagerProcessorStartCronJob{handler:handler}) + self210.AddToProcessorMap("restartShards", &auroraSchedulerManagerProcessorRestartShards{handler:handler}) + self210.AddToProcessorMap("killTasks", &auroraSchedulerManagerProcessorKillTasks{handler:handler}) + self210.AddToProcessorMap("addInstances", &auroraSchedulerManagerProcessorAddInstances{handler:handler}) + self210.AddToProcessorMap("replaceCronTemplate", &auroraSchedulerManagerProcessorReplaceCronTemplate{handler:handler}) + self210.AddToProcessorMap("startJobUpdate", &auroraSchedulerManagerProcessorStartJobUpdate{handler:handler}) + self210.AddToProcessorMap("pauseJobUpdate", &auroraSchedulerManagerProcessorPauseJobUpdate{handler:handler}) + self210.AddToProcessorMap("resumeJobUpdate", &auroraSchedulerManagerProcessorResumeJobUpdate{handler:handler}) + self210.AddToProcessorMap("abortJobUpdate", &auroraSchedulerManagerProcessorAbortJobUpdate{handler:handler}) + self210.AddToProcessorMap("rollbackJobUpdate", &auroraSchedulerManagerProcessorRollbackJobUpdate{handler:handler}) + self210.AddToProcessorMap("pulseJobUpdate", &auroraSchedulerManagerProcessorPulseJobUpdate{handler:handler}) + return self210 +} + +type auroraSchedulerManagerProcessorCreateJob struct { + handler AuroraSchedulerManager +} + +func (p *auroraSchedulerManagerProcessorCreateJob) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraSchedulerManagerCreateJobArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "createJob", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraSchedulerManagerCreateJobResult{} + var retval *Response + if retval, err2 = p.handler.CreateJob(ctx, args.Description); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing createJob: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "createJob", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "createJob", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraSchedulerManagerProcessorScheduleCronJob struct { + handler AuroraSchedulerManager +} + +func (p *auroraSchedulerManagerProcessorScheduleCronJob) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraSchedulerManagerScheduleCronJobArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "scheduleCronJob", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraSchedulerManagerScheduleCronJobResult{} + var retval *Response + if retval, err2 = p.handler.ScheduleCronJob(ctx, args.Description); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing scheduleCronJob: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "scheduleCronJob", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "scheduleCronJob", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraSchedulerManagerProcessorDescheduleCronJob struct { + handler AuroraSchedulerManager +} + +func (p *auroraSchedulerManagerProcessorDescheduleCronJob) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraSchedulerManagerDescheduleCronJobArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "descheduleCronJob", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraSchedulerManagerDescheduleCronJobResult{} + var retval *Response + if retval, err2 = p.handler.DescheduleCronJob(ctx, args.Job); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing descheduleCronJob: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "descheduleCronJob", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "descheduleCronJob", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraSchedulerManagerProcessorStartCronJob struct { + handler AuroraSchedulerManager +} + +func (p *auroraSchedulerManagerProcessorStartCronJob) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraSchedulerManagerStartCronJobArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "startCronJob", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraSchedulerManagerStartCronJobResult{} + var retval *Response + if retval, err2 = p.handler.StartCronJob(ctx, args.Job); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing startCronJob: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "startCronJob", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "startCronJob", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraSchedulerManagerProcessorRestartShards struct { + handler AuroraSchedulerManager +} + +func (p *auroraSchedulerManagerProcessorRestartShards) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraSchedulerManagerRestartShardsArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "restartShards", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraSchedulerManagerRestartShardsResult{} + var retval *Response + if retval, err2 = p.handler.RestartShards(ctx, args.Job, args.ShardIds); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing restartShards: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "restartShards", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "restartShards", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraSchedulerManagerProcessorKillTasks struct { + handler AuroraSchedulerManager +} + +func (p *auroraSchedulerManagerProcessorKillTasks) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraSchedulerManagerKillTasksArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "killTasks", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraSchedulerManagerKillTasksResult{} + var retval *Response + if retval, err2 = p.handler.KillTasks(ctx, args.Job, args.Instances, args.Message); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing killTasks: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "killTasks", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "killTasks", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraSchedulerManagerProcessorAddInstances struct { + handler AuroraSchedulerManager +} + +func (p *auroraSchedulerManagerProcessorAddInstances) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraSchedulerManagerAddInstancesArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "addInstances", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraSchedulerManagerAddInstancesResult{} + var retval *Response + if retval, err2 = p.handler.AddInstances(ctx, args.Key, args.Count); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing addInstances: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "addInstances", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "addInstances", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraSchedulerManagerProcessorReplaceCronTemplate struct { + handler AuroraSchedulerManager +} + +func (p *auroraSchedulerManagerProcessorReplaceCronTemplate) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraSchedulerManagerReplaceCronTemplateArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "replaceCronTemplate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraSchedulerManagerReplaceCronTemplateResult{} + var retval *Response + if retval, err2 = p.handler.ReplaceCronTemplate(ctx, args.Config); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing replaceCronTemplate: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "replaceCronTemplate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "replaceCronTemplate", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraSchedulerManagerProcessorStartJobUpdate struct { + handler AuroraSchedulerManager +} + +func (p *auroraSchedulerManagerProcessorStartJobUpdate) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraSchedulerManagerStartJobUpdateArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "startJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraSchedulerManagerStartJobUpdateResult{} + var retval *Response + if retval, err2 = p.handler.StartJobUpdate(ctx, args.Request, args.Message); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing startJobUpdate: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "startJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "startJobUpdate", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraSchedulerManagerProcessorPauseJobUpdate struct { + handler AuroraSchedulerManager +} + +func (p *auroraSchedulerManagerProcessorPauseJobUpdate) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraSchedulerManagerPauseJobUpdateArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "pauseJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraSchedulerManagerPauseJobUpdateResult{} + var retval *Response + if retval, err2 = p.handler.PauseJobUpdate(ctx, args.Key, args.Message); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing pauseJobUpdate: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "pauseJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "pauseJobUpdate", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraSchedulerManagerProcessorResumeJobUpdate struct { + handler AuroraSchedulerManager +} + +func (p *auroraSchedulerManagerProcessorResumeJobUpdate) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraSchedulerManagerResumeJobUpdateArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "resumeJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraSchedulerManagerResumeJobUpdateResult{} + var retval *Response + if retval, err2 = p.handler.ResumeJobUpdate(ctx, args.Key, args.Message); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing resumeJobUpdate: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "resumeJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "resumeJobUpdate", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraSchedulerManagerProcessorAbortJobUpdate struct { + handler AuroraSchedulerManager +} + +func (p *auroraSchedulerManagerProcessorAbortJobUpdate) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraSchedulerManagerAbortJobUpdateArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "abortJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraSchedulerManagerAbortJobUpdateResult{} + var retval *Response + if retval, err2 = p.handler.AbortJobUpdate(ctx, args.Key, args.Message); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing abortJobUpdate: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "abortJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "abortJobUpdate", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraSchedulerManagerProcessorRollbackJobUpdate struct { + handler AuroraSchedulerManager +} + +func (p *auroraSchedulerManagerProcessorRollbackJobUpdate) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraSchedulerManagerRollbackJobUpdateArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "rollbackJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraSchedulerManagerRollbackJobUpdateResult{} + var retval *Response + if retval, err2 = p.handler.RollbackJobUpdate(ctx, args.Key, args.Message); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing rollbackJobUpdate: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "rollbackJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "rollbackJobUpdate", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraSchedulerManagerProcessorPulseJobUpdate struct { + handler AuroraSchedulerManager +} + +func (p *auroraSchedulerManagerProcessorPulseJobUpdate) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraSchedulerManagerPulseJobUpdateArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "pulseJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraSchedulerManagerPulseJobUpdateResult{} + var retval *Response + if retval, err2 = p.handler.PulseJobUpdate(ctx, args.Key); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing pulseJobUpdate: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "pulseJobUpdate", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "pulseJobUpdate", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + + +// HELPER FUNCTIONS AND STRUCTURES + +// Attributes: +// - Description +type AuroraSchedulerManagerCreateJobArgs struct { + Description *JobConfiguration `thrift:"description,1" db:"description" json:"description"` +} + +func NewAuroraSchedulerManagerCreateJobArgs() *AuroraSchedulerManagerCreateJobArgs { + return &AuroraSchedulerManagerCreateJobArgs{} +} + +var AuroraSchedulerManagerCreateJobArgs_Description_DEFAULT *JobConfiguration +func (p *AuroraSchedulerManagerCreateJobArgs) GetDescription() *JobConfiguration { + if !p.IsSetDescription() { + return AuroraSchedulerManagerCreateJobArgs_Description_DEFAULT + } +return p.Description +} +func (p *AuroraSchedulerManagerCreateJobArgs) IsSetDescription() bool { + return p.Description != nil +} + +func (p *AuroraSchedulerManagerCreateJobArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerCreateJobArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Description = &JobConfiguration{} + if err := p.Description.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Description), err) + } + return nil +} + +func (p *AuroraSchedulerManagerCreateJobArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "createJob_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerCreateJobArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "description", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:description: ", p), err) } + if err := p.Description.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Description), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:description: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerCreateJobArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerCreateJobArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraSchedulerManagerCreateJobResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraSchedulerManagerCreateJobResult() *AuroraSchedulerManagerCreateJobResult { + return &AuroraSchedulerManagerCreateJobResult{} +} + +var AuroraSchedulerManagerCreateJobResult_Success_DEFAULT *Response +func (p *AuroraSchedulerManagerCreateJobResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraSchedulerManagerCreateJobResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraSchedulerManagerCreateJobResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraSchedulerManagerCreateJobResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerCreateJobResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraSchedulerManagerCreateJobResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "createJob_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerCreateJobResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraSchedulerManagerCreateJobResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerCreateJobResult(%+v)", *p) +} + +// Attributes: +// - Description +type AuroraSchedulerManagerScheduleCronJobArgs struct { + Description *JobConfiguration `thrift:"description,1" db:"description" json:"description"` +} + +func NewAuroraSchedulerManagerScheduleCronJobArgs() *AuroraSchedulerManagerScheduleCronJobArgs { + return &AuroraSchedulerManagerScheduleCronJobArgs{} +} + +var AuroraSchedulerManagerScheduleCronJobArgs_Description_DEFAULT *JobConfiguration +func (p *AuroraSchedulerManagerScheduleCronJobArgs) GetDescription() *JobConfiguration { + if !p.IsSetDescription() { + return AuroraSchedulerManagerScheduleCronJobArgs_Description_DEFAULT + } +return p.Description +} +func (p *AuroraSchedulerManagerScheduleCronJobArgs) IsSetDescription() bool { + return p.Description != nil +} + +func (p *AuroraSchedulerManagerScheduleCronJobArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerScheduleCronJobArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Description = &JobConfiguration{} + if err := p.Description.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Description), err) + } + return nil +} + +func (p *AuroraSchedulerManagerScheduleCronJobArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "scheduleCronJob_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerScheduleCronJobArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "description", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:description: ", p), err) } + if err := p.Description.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Description), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:description: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerScheduleCronJobArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerScheduleCronJobArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraSchedulerManagerScheduleCronJobResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraSchedulerManagerScheduleCronJobResult() *AuroraSchedulerManagerScheduleCronJobResult { + return &AuroraSchedulerManagerScheduleCronJobResult{} +} + +var AuroraSchedulerManagerScheduleCronJobResult_Success_DEFAULT *Response +func (p *AuroraSchedulerManagerScheduleCronJobResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraSchedulerManagerScheduleCronJobResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraSchedulerManagerScheduleCronJobResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraSchedulerManagerScheduleCronJobResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerScheduleCronJobResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraSchedulerManagerScheduleCronJobResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "scheduleCronJob_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerScheduleCronJobResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraSchedulerManagerScheduleCronJobResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerScheduleCronJobResult(%+v)", *p) +} + +// Attributes: +// - Job +type AuroraSchedulerManagerDescheduleCronJobArgs struct { + // unused fields # 1 to 3 + Job *JobKey `thrift:"job,4" db:"job" json:"job"` +} + +func NewAuroraSchedulerManagerDescheduleCronJobArgs() *AuroraSchedulerManagerDescheduleCronJobArgs { + return &AuroraSchedulerManagerDescheduleCronJobArgs{} +} + +var AuroraSchedulerManagerDescheduleCronJobArgs_Job_DEFAULT *JobKey +func (p *AuroraSchedulerManagerDescheduleCronJobArgs) GetJob() *JobKey { + if !p.IsSetJob() { + return AuroraSchedulerManagerDescheduleCronJobArgs_Job_DEFAULT + } +return p.Job +} +func (p *AuroraSchedulerManagerDescheduleCronJobArgs) IsSetJob() bool { + return p.Job != nil +} + +func (p *AuroraSchedulerManagerDescheduleCronJobArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 4: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerDescheduleCronJobArgs) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + p.Job = &JobKey{} + if err := p.Job.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) + } + return nil +} + +func (p *AuroraSchedulerManagerDescheduleCronJobArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "descheduleCronJob_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField4(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerDescheduleCronJobArgs) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "job", thrift.STRUCT, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:job: ", p), err) } + if err := p.Job.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:job: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerDescheduleCronJobArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerDescheduleCronJobArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraSchedulerManagerDescheduleCronJobResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraSchedulerManagerDescheduleCronJobResult() *AuroraSchedulerManagerDescheduleCronJobResult { + return &AuroraSchedulerManagerDescheduleCronJobResult{} +} + +var AuroraSchedulerManagerDescheduleCronJobResult_Success_DEFAULT *Response +func (p *AuroraSchedulerManagerDescheduleCronJobResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraSchedulerManagerDescheduleCronJobResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraSchedulerManagerDescheduleCronJobResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraSchedulerManagerDescheduleCronJobResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerDescheduleCronJobResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraSchedulerManagerDescheduleCronJobResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "descheduleCronJob_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerDescheduleCronJobResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraSchedulerManagerDescheduleCronJobResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerDescheduleCronJobResult(%+v)", *p) +} + +// Attributes: +// - Job +type AuroraSchedulerManagerStartCronJobArgs struct { + // unused fields # 1 to 3 + Job *JobKey `thrift:"job,4" db:"job" json:"job"` +} + +func NewAuroraSchedulerManagerStartCronJobArgs() *AuroraSchedulerManagerStartCronJobArgs { + return &AuroraSchedulerManagerStartCronJobArgs{} +} + +var AuroraSchedulerManagerStartCronJobArgs_Job_DEFAULT *JobKey +func (p *AuroraSchedulerManagerStartCronJobArgs) GetJob() *JobKey { + if !p.IsSetJob() { + return AuroraSchedulerManagerStartCronJobArgs_Job_DEFAULT + } +return p.Job +} +func (p *AuroraSchedulerManagerStartCronJobArgs) IsSetJob() bool { + return p.Job != nil +} + +func (p *AuroraSchedulerManagerStartCronJobArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 4: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerStartCronJobArgs) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + p.Job = &JobKey{} + if err := p.Job.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) + } + return nil +} + +func (p *AuroraSchedulerManagerStartCronJobArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "startCronJob_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField4(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerStartCronJobArgs) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "job", thrift.STRUCT, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:job: ", p), err) } + if err := p.Job.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:job: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerStartCronJobArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerStartCronJobArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraSchedulerManagerStartCronJobResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraSchedulerManagerStartCronJobResult() *AuroraSchedulerManagerStartCronJobResult { + return &AuroraSchedulerManagerStartCronJobResult{} +} + +var AuroraSchedulerManagerStartCronJobResult_Success_DEFAULT *Response +func (p *AuroraSchedulerManagerStartCronJobResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraSchedulerManagerStartCronJobResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraSchedulerManagerStartCronJobResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraSchedulerManagerStartCronJobResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerStartCronJobResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraSchedulerManagerStartCronJobResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "startCronJob_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerStartCronJobResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraSchedulerManagerStartCronJobResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerStartCronJobResult(%+v)", *p) +} + +// Attributes: +// - Job +// - ShardIds +type AuroraSchedulerManagerRestartShardsArgs struct { + // unused fields # 1 to 2 + ShardIds []int32 `thrift:"shardIds,3" db:"shardIds" json:"shardIds"` + // unused field # 4 + Job *JobKey `thrift:"job,5" db:"job" json:"job"` +} + +func NewAuroraSchedulerManagerRestartShardsArgs() *AuroraSchedulerManagerRestartShardsArgs { + return &AuroraSchedulerManagerRestartShardsArgs{} +} + +var AuroraSchedulerManagerRestartShardsArgs_Job_DEFAULT *JobKey +func (p *AuroraSchedulerManagerRestartShardsArgs) GetJob() *JobKey { + if !p.IsSetJob() { + return AuroraSchedulerManagerRestartShardsArgs_Job_DEFAULT + } +return p.Job +} + +func (p *AuroraSchedulerManagerRestartShardsArgs) GetShardIds() []int32 { + return p.ShardIds +} +func (p *AuroraSchedulerManagerRestartShardsArgs) IsSetJob() bool { + return p.Job != nil +} + +func (p *AuroraSchedulerManagerRestartShardsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 5: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField5(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.SET { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerRestartShardsArgs) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + p.Job = &JobKey{} + if err := p.Job.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) + } + return nil +} + +func (p *AuroraSchedulerManagerRestartShardsArgs) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]int32, 0, size) + p.ShardIds = tSet + for i := 0; i < size; i ++ { +var _elem211 int32 + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _elem211 = v +} + p.ShardIds = append(p.ShardIds, _elem211) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *AuroraSchedulerManagerRestartShardsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "restartShards_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerRestartShardsArgs) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "shardIds", thrift.SET, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:shardIds: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.I32, len(p.ShardIds)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("AuroraSchedulerManagerRestartShardsArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraSchedulerManagerRestartShardsResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraSchedulerManagerRestartShardsResult() *AuroraSchedulerManagerRestartShardsResult { + return &AuroraSchedulerManagerRestartShardsResult{} +} + +var AuroraSchedulerManagerRestartShardsResult_Success_DEFAULT *Response +func (p *AuroraSchedulerManagerRestartShardsResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraSchedulerManagerRestartShardsResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraSchedulerManagerRestartShardsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraSchedulerManagerRestartShardsResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerRestartShardsResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraSchedulerManagerRestartShardsResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "restartShards_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerRestartShardsResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraSchedulerManagerRestartShardsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerRestartShardsResult(%+v)", *p) +} + +// Attributes: +// - Job +// - Instances +// - Message +type AuroraSchedulerManagerKillTasksArgs struct { + // unused fields # 1 to 3 + Job *JobKey `thrift:"job,4" db:"job" json:"job"` + Instances []int32 `thrift:"instances,5" db:"instances" json:"instances"` + Message string `thrift:"message,6" db:"message" json:"message"` +} + +func NewAuroraSchedulerManagerKillTasksArgs() *AuroraSchedulerManagerKillTasksArgs { + return &AuroraSchedulerManagerKillTasksArgs{} +} + +var AuroraSchedulerManagerKillTasksArgs_Job_DEFAULT *JobKey +func (p *AuroraSchedulerManagerKillTasksArgs) GetJob() *JobKey { + if !p.IsSetJob() { + return AuroraSchedulerManagerKillTasksArgs_Job_DEFAULT + } +return p.Job +} + +func (p *AuroraSchedulerManagerKillTasksArgs) GetInstances() []int32 { + return p.Instances +} + +func (p *AuroraSchedulerManagerKillTasksArgs) GetMessage() string { + return p.Message +} +func (p *AuroraSchedulerManagerKillTasksArgs) IsSetJob() bool { + return p.Job != nil +} + +func (p *AuroraSchedulerManagerKillTasksArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 4: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 5: + if fieldTypeId == thrift.SET { + if err := p.ReadField5(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 6: + if fieldTypeId == thrift.STRING { + if err := p.ReadField6(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerKillTasksArgs) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + p.Job = &JobKey{} + if err := p.Job.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) + } + return nil +} + +func (p *AuroraSchedulerManagerKillTasksArgs) ReadField5(ctx context.Context, iprot thrift.TProtocol) error { + _, size, err := iprot.ReadSetBegin(ctx) + if err != nil { + return thrift.PrependError("error reading set begin: ", err) + } + tSet := make([]int32, 0, size) + p.Instances = tSet + for i := 0; i < size; i ++ { +var _elem212 int32 + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 0: ", err) +} else { + _elem212 = v +} + p.Instances = append(p.Instances, _elem212) + } + if err := iprot.ReadSetEnd(ctx); err != nil { + return thrift.PrependError("error reading set end: ", err) + } + return nil +} + +func (p *AuroraSchedulerManagerKillTasksArgs) ReadField6(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 6: ", err) +} else { + p.Message = v +} + return nil +} + +func (p *AuroraSchedulerManagerKillTasksArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "killTasks_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField4(ctx, oprot); err != nil { return err } + if err := p.writeField5(ctx, oprot); err != nil { return err } + if err := p.writeField6(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerKillTasksArgs) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "job", thrift.STRUCT, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:job: ", p), err) } + if err := p.Job.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:job: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerKillTasksArgs) writeField5(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "instances", thrift.SET, 5); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:instances: ", p), err) } + if err := oprot.WriteSetBegin(ctx, thrift.I32, len(p.Instances)); err != nil { + return thrift.PrependError("error writing set begin: ", err) + } + for i := 0; i" + } + return fmt.Sprintf("AuroraSchedulerManagerKillTasksArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraSchedulerManagerKillTasksResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraSchedulerManagerKillTasksResult() *AuroraSchedulerManagerKillTasksResult { + return &AuroraSchedulerManagerKillTasksResult{} +} + +var AuroraSchedulerManagerKillTasksResult_Success_DEFAULT *Response +func (p *AuroraSchedulerManagerKillTasksResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraSchedulerManagerKillTasksResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraSchedulerManagerKillTasksResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraSchedulerManagerKillTasksResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerKillTasksResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraSchedulerManagerKillTasksResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "killTasks_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerKillTasksResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraSchedulerManagerKillTasksResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerKillTasksResult(%+v)", *p) +} + +// Attributes: +// - Key +// - Count +type AuroraSchedulerManagerAddInstancesArgs struct { + // unused fields # 1 to 2 + Key *InstanceKey `thrift:"key,3" db:"key" json:"key"` + Count int32 `thrift:"count,4" db:"count" json:"count"` +} + +func NewAuroraSchedulerManagerAddInstancesArgs() *AuroraSchedulerManagerAddInstancesArgs { + return &AuroraSchedulerManagerAddInstancesArgs{} +} + +var AuroraSchedulerManagerAddInstancesArgs_Key_DEFAULT *InstanceKey +func (p *AuroraSchedulerManagerAddInstancesArgs) GetKey() *InstanceKey { + if !p.IsSetKey() { + return AuroraSchedulerManagerAddInstancesArgs_Key_DEFAULT + } +return p.Key +} + +func (p *AuroraSchedulerManagerAddInstancesArgs) GetCount() int32 { + return p.Count +} +func (p *AuroraSchedulerManagerAddInstancesArgs) IsSetKey() bool { + return p.Key != nil +} + +func (p *AuroraSchedulerManagerAddInstancesArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 3: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 4: + if fieldTypeId == thrift.I32 { + if err := p.ReadField4(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerAddInstancesArgs) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + p.Key = &InstanceKey{} + if err := p.Key.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) + } + return nil +} + +func (p *AuroraSchedulerManagerAddInstancesArgs) ReadField4(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 4: ", err) +} else { + p.Count = v +} + return nil +} + +func (p *AuroraSchedulerManagerAddInstancesArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "addInstances_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField3(ctx, oprot); err != nil { return err } + if err := p.writeField4(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerAddInstancesArgs) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:key: ", p), err) } + if err := p.Key.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:key: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerAddInstancesArgs) writeField4(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "count", thrift.I32, 4); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:count: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.Count)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.count (4) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 4:count: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerAddInstancesArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerAddInstancesArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraSchedulerManagerAddInstancesResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraSchedulerManagerAddInstancesResult() *AuroraSchedulerManagerAddInstancesResult { + return &AuroraSchedulerManagerAddInstancesResult{} +} + +var AuroraSchedulerManagerAddInstancesResult_Success_DEFAULT *Response +func (p *AuroraSchedulerManagerAddInstancesResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraSchedulerManagerAddInstancesResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraSchedulerManagerAddInstancesResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraSchedulerManagerAddInstancesResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerAddInstancesResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraSchedulerManagerAddInstancesResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "addInstances_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerAddInstancesResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraSchedulerManagerAddInstancesResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerAddInstancesResult(%+v)", *p) +} + +// Attributes: +// - Config +type AuroraSchedulerManagerReplaceCronTemplateArgs struct { + Config *JobConfiguration `thrift:"config,1" db:"config" json:"config"` +} + +func NewAuroraSchedulerManagerReplaceCronTemplateArgs() *AuroraSchedulerManagerReplaceCronTemplateArgs { + return &AuroraSchedulerManagerReplaceCronTemplateArgs{} +} + +var AuroraSchedulerManagerReplaceCronTemplateArgs_Config_DEFAULT *JobConfiguration +func (p *AuroraSchedulerManagerReplaceCronTemplateArgs) GetConfig() *JobConfiguration { + if !p.IsSetConfig() { + return AuroraSchedulerManagerReplaceCronTemplateArgs_Config_DEFAULT + } +return p.Config +} +func (p *AuroraSchedulerManagerReplaceCronTemplateArgs) IsSetConfig() bool { + return p.Config != nil +} + +func (p *AuroraSchedulerManagerReplaceCronTemplateArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerReplaceCronTemplateArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Config = &JobConfiguration{} + if err := p.Config.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Config), err) + } + return nil +} + +func (p *AuroraSchedulerManagerReplaceCronTemplateArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "replaceCronTemplate_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerReplaceCronTemplateArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "config", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:config: ", p), err) } + if err := p.Config.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Config), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:config: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerReplaceCronTemplateArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerReplaceCronTemplateArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraSchedulerManagerReplaceCronTemplateResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraSchedulerManagerReplaceCronTemplateResult() *AuroraSchedulerManagerReplaceCronTemplateResult { + return &AuroraSchedulerManagerReplaceCronTemplateResult{} +} + +var AuroraSchedulerManagerReplaceCronTemplateResult_Success_DEFAULT *Response +func (p *AuroraSchedulerManagerReplaceCronTemplateResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraSchedulerManagerReplaceCronTemplateResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraSchedulerManagerReplaceCronTemplateResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraSchedulerManagerReplaceCronTemplateResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerReplaceCronTemplateResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraSchedulerManagerReplaceCronTemplateResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "replaceCronTemplate_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerReplaceCronTemplateResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraSchedulerManagerReplaceCronTemplateResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerReplaceCronTemplateResult(%+v)", *p) +} + +// Attributes: +// - Request: A description of how to change the job. +// - Message: A user-specified message to include with the induced job update state change. +type AuroraSchedulerManagerStartJobUpdateArgs struct { + Request *JobUpdateRequest `thrift:"request,1" db:"request" json:"request"` + // unused field # 2 + Message string `thrift:"message,3" db:"message" json:"message"` +} + +func NewAuroraSchedulerManagerStartJobUpdateArgs() *AuroraSchedulerManagerStartJobUpdateArgs { + return &AuroraSchedulerManagerStartJobUpdateArgs{} +} + +var AuroraSchedulerManagerStartJobUpdateArgs_Request_DEFAULT *JobUpdateRequest +func (p *AuroraSchedulerManagerStartJobUpdateArgs) GetRequest() *JobUpdateRequest { + if !p.IsSetRequest() { + return AuroraSchedulerManagerStartJobUpdateArgs_Request_DEFAULT + } +return p.Request +} + +func (p *AuroraSchedulerManagerStartJobUpdateArgs) GetMessage() string { + return p.Message +} +func (p *AuroraSchedulerManagerStartJobUpdateArgs) IsSetRequest() bool { + return p.Request != nil +} + +func (p *AuroraSchedulerManagerStartJobUpdateArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRING { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerStartJobUpdateArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Request = &JobUpdateRequest{} + if err := p.Request.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Request), err) + } + return nil +} + +func (p *AuroraSchedulerManagerStartJobUpdateArgs) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.Message = v +} + return nil +} + +func (p *AuroraSchedulerManagerStartJobUpdateArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "startJobUpdate_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerStartJobUpdateArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "request", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:request: ", p), err) } + if err := p.Request.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Request), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:request: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerStartJobUpdateArgs) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "message", thrift.STRING, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:message: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Message)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.message (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:message: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerStartJobUpdateArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerStartJobUpdateArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraSchedulerManagerStartJobUpdateResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraSchedulerManagerStartJobUpdateResult() *AuroraSchedulerManagerStartJobUpdateResult { + return &AuroraSchedulerManagerStartJobUpdateResult{} +} + +var AuroraSchedulerManagerStartJobUpdateResult_Success_DEFAULT *Response +func (p *AuroraSchedulerManagerStartJobUpdateResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraSchedulerManagerStartJobUpdateResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraSchedulerManagerStartJobUpdateResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraSchedulerManagerStartJobUpdateResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerStartJobUpdateResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraSchedulerManagerStartJobUpdateResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "startJobUpdate_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerStartJobUpdateResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraSchedulerManagerStartJobUpdateResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerStartJobUpdateResult(%+v)", *p) +} + +// Attributes: +// - Key: The update to pause. +// - Message: A user-specified message to include with the induced job update state change. +type AuroraSchedulerManagerPauseJobUpdateArgs struct { + Key *JobUpdateKey `thrift:"key,1" db:"key" json:"key"` + // unused field # 2 + Message string `thrift:"message,3" db:"message" json:"message"` +} + +func NewAuroraSchedulerManagerPauseJobUpdateArgs() *AuroraSchedulerManagerPauseJobUpdateArgs { + return &AuroraSchedulerManagerPauseJobUpdateArgs{} +} + +var AuroraSchedulerManagerPauseJobUpdateArgs_Key_DEFAULT *JobUpdateKey +func (p *AuroraSchedulerManagerPauseJobUpdateArgs) GetKey() *JobUpdateKey { + if !p.IsSetKey() { + return AuroraSchedulerManagerPauseJobUpdateArgs_Key_DEFAULT + } +return p.Key +} + +func (p *AuroraSchedulerManagerPauseJobUpdateArgs) GetMessage() string { + return p.Message +} +func (p *AuroraSchedulerManagerPauseJobUpdateArgs) IsSetKey() bool { + return p.Key != nil +} + +func (p *AuroraSchedulerManagerPauseJobUpdateArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRING { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerPauseJobUpdateArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Key = &JobUpdateKey{} + if err := p.Key.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) + } + return nil +} + +func (p *AuroraSchedulerManagerPauseJobUpdateArgs) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.Message = v +} + return nil +} + +func (p *AuroraSchedulerManagerPauseJobUpdateArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "pauseJobUpdate_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerPauseJobUpdateArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } + if err := p.Key.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerPauseJobUpdateArgs) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "message", thrift.STRING, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:message: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Message)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.message (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:message: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerPauseJobUpdateArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerPauseJobUpdateArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraSchedulerManagerPauseJobUpdateResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraSchedulerManagerPauseJobUpdateResult() *AuroraSchedulerManagerPauseJobUpdateResult { + return &AuroraSchedulerManagerPauseJobUpdateResult{} +} + +var AuroraSchedulerManagerPauseJobUpdateResult_Success_DEFAULT *Response +func (p *AuroraSchedulerManagerPauseJobUpdateResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraSchedulerManagerPauseJobUpdateResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraSchedulerManagerPauseJobUpdateResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraSchedulerManagerPauseJobUpdateResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerPauseJobUpdateResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraSchedulerManagerPauseJobUpdateResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "pauseJobUpdate_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerPauseJobUpdateResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraSchedulerManagerPauseJobUpdateResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerPauseJobUpdateResult(%+v)", *p) +} + +// Attributes: +// - Key: The update to resume. +// - Message: A user-specified message to include with the induced job update state change. +type AuroraSchedulerManagerResumeJobUpdateArgs struct { + Key *JobUpdateKey `thrift:"key,1" db:"key" json:"key"` + // unused field # 2 + Message string `thrift:"message,3" db:"message" json:"message"` +} + +func NewAuroraSchedulerManagerResumeJobUpdateArgs() *AuroraSchedulerManagerResumeJobUpdateArgs { + return &AuroraSchedulerManagerResumeJobUpdateArgs{} +} + +var AuroraSchedulerManagerResumeJobUpdateArgs_Key_DEFAULT *JobUpdateKey +func (p *AuroraSchedulerManagerResumeJobUpdateArgs) GetKey() *JobUpdateKey { + if !p.IsSetKey() { + return AuroraSchedulerManagerResumeJobUpdateArgs_Key_DEFAULT + } +return p.Key +} + +func (p *AuroraSchedulerManagerResumeJobUpdateArgs) GetMessage() string { + return p.Message +} +func (p *AuroraSchedulerManagerResumeJobUpdateArgs) IsSetKey() bool { + return p.Key != nil +} + +func (p *AuroraSchedulerManagerResumeJobUpdateArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRING { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerResumeJobUpdateArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Key = &JobUpdateKey{} + if err := p.Key.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) + } + return nil +} + +func (p *AuroraSchedulerManagerResumeJobUpdateArgs) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.Message = v +} + return nil +} + +func (p *AuroraSchedulerManagerResumeJobUpdateArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "resumeJobUpdate_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerResumeJobUpdateArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } + if err := p.Key.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerResumeJobUpdateArgs) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "message", thrift.STRING, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:message: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Message)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.message (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:message: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerResumeJobUpdateArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerResumeJobUpdateArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraSchedulerManagerResumeJobUpdateResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraSchedulerManagerResumeJobUpdateResult() *AuroraSchedulerManagerResumeJobUpdateResult { + return &AuroraSchedulerManagerResumeJobUpdateResult{} +} + +var AuroraSchedulerManagerResumeJobUpdateResult_Success_DEFAULT *Response +func (p *AuroraSchedulerManagerResumeJobUpdateResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraSchedulerManagerResumeJobUpdateResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraSchedulerManagerResumeJobUpdateResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraSchedulerManagerResumeJobUpdateResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerResumeJobUpdateResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraSchedulerManagerResumeJobUpdateResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "resumeJobUpdate_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerResumeJobUpdateResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraSchedulerManagerResumeJobUpdateResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerResumeJobUpdateResult(%+v)", *p) +} + +// Attributes: +// - Key: The update to abort. +// - Message: A user-specified message to include with the induced job update state change. +type AuroraSchedulerManagerAbortJobUpdateArgs struct { + Key *JobUpdateKey `thrift:"key,1" db:"key" json:"key"` + // unused field # 2 + Message string `thrift:"message,3" db:"message" json:"message"` +} + +func NewAuroraSchedulerManagerAbortJobUpdateArgs() *AuroraSchedulerManagerAbortJobUpdateArgs { + return &AuroraSchedulerManagerAbortJobUpdateArgs{} +} + +var AuroraSchedulerManagerAbortJobUpdateArgs_Key_DEFAULT *JobUpdateKey +func (p *AuroraSchedulerManagerAbortJobUpdateArgs) GetKey() *JobUpdateKey { + if !p.IsSetKey() { + return AuroraSchedulerManagerAbortJobUpdateArgs_Key_DEFAULT + } +return p.Key +} + +func (p *AuroraSchedulerManagerAbortJobUpdateArgs) GetMessage() string { + return p.Message +} +func (p *AuroraSchedulerManagerAbortJobUpdateArgs) IsSetKey() bool { + return p.Key != nil +} + +func (p *AuroraSchedulerManagerAbortJobUpdateArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.STRING { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerAbortJobUpdateArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Key = &JobUpdateKey{} + if err := p.Key.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) + } + return nil +} + +func (p *AuroraSchedulerManagerAbortJobUpdateArgs) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.Message = v +} + return nil +} + +func (p *AuroraSchedulerManagerAbortJobUpdateArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "abortJobUpdate_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerAbortJobUpdateArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } + if err := p.Key.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerAbortJobUpdateArgs) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "message", thrift.STRING, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:message: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Message)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.message (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:message: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerAbortJobUpdateArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerAbortJobUpdateArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraSchedulerManagerAbortJobUpdateResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraSchedulerManagerAbortJobUpdateResult() *AuroraSchedulerManagerAbortJobUpdateResult { + return &AuroraSchedulerManagerAbortJobUpdateResult{} +} + +var AuroraSchedulerManagerAbortJobUpdateResult_Success_DEFAULT *Response +func (p *AuroraSchedulerManagerAbortJobUpdateResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraSchedulerManagerAbortJobUpdateResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraSchedulerManagerAbortJobUpdateResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraSchedulerManagerAbortJobUpdateResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerAbortJobUpdateResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraSchedulerManagerAbortJobUpdateResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "abortJobUpdate_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerAbortJobUpdateResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraSchedulerManagerAbortJobUpdateResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerAbortJobUpdateResult(%+v)", *p) +} + +// Attributes: +// - Key: The update to rollback. +// - Message: A user-specified message to include with the induced job update state change. +type AuroraSchedulerManagerRollbackJobUpdateArgs struct { + Key *JobUpdateKey `thrift:"key,1" db:"key" json:"key"` + Message string `thrift:"message,2" db:"message" json:"message"` +} + +func NewAuroraSchedulerManagerRollbackJobUpdateArgs() *AuroraSchedulerManagerRollbackJobUpdateArgs { + return &AuroraSchedulerManagerRollbackJobUpdateArgs{} +} + +var AuroraSchedulerManagerRollbackJobUpdateArgs_Key_DEFAULT *JobUpdateKey +func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) GetKey() *JobUpdateKey { + if !p.IsSetKey() { + return AuroraSchedulerManagerRollbackJobUpdateArgs_Key_DEFAULT + } +return p.Key +} + +func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) GetMessage() string { + return p.Message +} +func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) IsSetKey() bool { + return p.Key != nil +} + +func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRING { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Key = &JobUpdateKey{} + if err := p.Key.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) + } + return nil +} + +func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + p.Message = v +} + return nil +} + +func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "rollbackJobUpdate_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } + if err := p.Key.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "message", thrift.STRING, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:message: ", p), err) } + if err := oprot.WriteString(ctx, string(p.Message)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.message (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:message: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerRollbackJobUpdateArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraSchedulerManagerRollbackJobUpdateResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraSchedulerManagerRollbackJobUpdateResult() *AuroraSchedulerManagerRollbackJobUpdateResult { + return &AuroraSchedulerManagerRollbackJobUpdateResult{} +} + +var AuroraSchedulerManagerRollbackJobUpdateResult_Success_DEFAULT *Response +func (p *AuroraSchedulerManagerRollbackJobUpdateResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraSchedulerManagerRollbackJobUpdateResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraSchedulerManagerRollbackJobUpdateResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraSchedulerManagerRollbackJobUpdateResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerRollbackJobUpdateResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraSchedulerManagerRollbackJobUpdateResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "rollbackJobUpdate_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerRollbackJobUpdateResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraSchedulerManagerRollbackJobUpdateResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerRollbackJobUpdateResult(%+v)", *p) +} + +// Attributes: +// - Key +type AuroraSchedulerManagerPulseJobUpdateArgs struct { + Key *JobUpdateKey `thrift:"key,1" db:"key" json:"key"` +} + +func NewAuroraSchedulerManagerPulseJobUpdateArgs() *AuroraSchedulerManagerPulseJobUpdateArgs { + return &AuroraSchedulerManagerPulseJobUpdateArgs{} +} + +var AuroraSchedulerManagerPulseJobUpdateArgs_Key_DEFAULT *JobUpdateKey +func (p *AuroraSchedulerManagerPulseJobUpdateArgs) GetKey() *JobUpdateKey { + if !p.IsSetKey() { + return AuroraSchedulerManagerPulseJobUpdateArgs_Key_DEFAULT + } +return p.Key +} +func (p *AuroraSchedulerManagerPulseJobUpdateArgs) IsSetKey() bool { + return p.Key != nil +} + +func (p *AuroraSchedulerManagerPulseJobUpdateArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerPulseJobUpdateArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Key = &JobUpdateKey{} + if err := p.Key.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) + } + return nil +} + +func (p *AuroraSchedulerManagerPulseJobUpdateArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "pulseJobUpdate_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerPulseJobUpdateArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "key", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) } + if err := p.Key.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) } + return err +} + +func (p *AuroraSchedulerManagerPulseJobUpdateArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerPulseJobUpdateArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraSchedulerManagerPulseJobUpdateResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraSchedulerManagerPulseJobUpdateResult() *AuroraSchedulerManagerPulseJobUpdateResult { + return &AuroraSchedulerManagerPulseJobUpdateResult{} +} + +var AuroraSchedulerManagerPulseJobUpdateResult_Success_DEFAULT *Response +func (p *AuroraSchedulerManagerPulseJobUpdateResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraSchedulerManagerPulseJobUpdateResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraSchedulerManagerPulseJobUpdateResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraSchedulerManagerPulseJobUpdateResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraSchedulerManagerPulseJobUpdateResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraSchedulerManagerPulseJobUpdateResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "pulseJobUpdate_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraSchedulerManagerPulseJobUpdateResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraSchedulerManagerPulseJobUpdateResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraSchedulerManagerPulseJobUpdateResult(%+v)", *p) +} + + +type AuroraAdmin interface { +AuroraSchedulerManager + + // Assign quota to a user. This will overwrite any pre-existing quota for the user. + // + // Parameters: + // - OwnerRole + // - Quota + SetQuota(ctx context.Context, ownerRole string, quota *ResourceAggregate) (r *Response, err error) + // Forces a task into a specific state. This does not guarantee the task will enter the given + // state, as the task must still transition within the bounds of the state machine. However, + // it attempts to enter that state via the state machine. + // + // Parameters: + // - TaskId + // - Status + ForceTaskState(ctx context.Context, taskId string, status ScheduleStatus) (r *Response, err error) + // Immediately writes a storage snapshot to disk. + PerformBackup(ctx context.Context) (r *Response, err error) + // Lists backups that are available for recovery. + ListBackups(ctx context.Context) (r *Response, err error) + // Loads a backup to an in-memory storage. This must precede all other recovery operations. + // + // Parameters: + // - BackupId + StageRecovery(ctx context.Context, backupId string) (r *Response, err error) + // Queries for tasks in a staged recovery. + // + // Parameters: + // - Query + QueryRecovery(ctx context.Context, query *TaskQuery) (r *Response, err error) + // Deletes tasks from a staged recovery. + // + // Parameters: + // - Query + DeleteRecoveryTasks(ctx context.Context, query *TaskQuery) (r *Response, err error) + // Commits a staged recovery, completely replacing the previous storage state. + CommitRecovery(ctx context.Context) (r *Response, err error) + // Unloads (aborts) a staged recovery. + UnloadRecovery(ctx context.Context) (r *Response, err error) + // Put the given hosts into maintenance mode. + // + // Parameters: + // - Hosts + StartMaintenance(ctx context.Context, hosts *Hosts) (r *Response, err error) + // Ask scheduler to begin moving tasks scheduled on given hosts. + // + // Parameters: + // - Hosts + DrainHosts(ctx context.Context, hosts *Hosts) (r *Response, err error) + // Retrieve the current maintenance states for a group of hosts. + // + // Parameters: + // - Hosts + MaintenanceStatus(ctx context.Context, hosts *Hosts) (r *Response, err error) + // Set the given hosts back into serving mode. + // + // Parameters: + // - Hosts + EndMaintenance(ctx context.Context, hosts *Hosts) (r *Response, err error) + // Ask scheduler to put hosts into DRAINING mode and move scheduled tasks off of the hosts + // such that its SLA requirements are satisfied. Use defaultSlaPolicy if it is not set for a task. + // + // + // Parameters: + // - Hosts + // - DefaultSlaPolicy + // - TimeoutSecs + SlaDrainHosts(ctx context.Context, hosts *Hosts, defaultSlaPolicy *SlaPolicy, timeoutSecs int64) (r *Response, err error) + // Start a storage snapshot and block until it completes. + Snapshot(ctx context.Context) (r *Response, err error) + // Tell scheduler to trigger an explicit task reconciliation with the given settings. + // + // Parameters: + // - Settings + TriggerExplicitTaskReconciliation(ctx context.Context, settings *ExplicitReconciliationSettings) (r *Response, err error) + // Tell scheduler to trigger an implicit task reconciliation. + TriggerImplicitTaskReconciliation(ctx context.Context) (r *Response, err error) + // Force prune any (terminal) tasks that match the query. If no statuses are supplied with the + // query, it will default to all terminal task states. If statuses are supplied, they must be + // terminal states. + // + // Parameters: + // - Query + PruneTasks(ctx context.Context, query *TaskQuery) (r *Response, err error) +} + +type AuroraAdminClient struct { + *AuroraSchedulerManagerClient +} + +func NewAuroraAdminClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *AuroraAdminClient { + return &AuroraAdminClient{AuroraSchedulerManagerClient: NewAuroraSchedulerManagerClientFactory(t, f)}} + +func NewAuroraAdminClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *AuroraAdminClient { + return &AuroraAdminClient{AuroraSchedulerManagerClient: NewAuroraSchedulerManagerClientProtocol(t, iprot, oprot)} +} + +func NewAuroraAdminClient(c thrift.TClient) *AuroraAdminClient { + return &AuroraAdminClient{ + AuroraSchedulerManagerClient: NewAuroraSchedulerManagerClient(c), + } +} + +// Assign quota to a user. This will overwrite any pre-existing quota for the user. +// +// Parameters: +// - OwnerRole +// - Quota +func (p *AuroraAdminClient) SetQuota(ctx context.Context, ownerRole string, quota *ResourceAggregate) (r *Response, err error) { + var _args367 AuroraAdminSetQuotaArgs + _args367.OwnerRole = ownerRole + _args367.Quota = quota + var _result368 AuroraAdminSetQuotaResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "setQuota", &_args367, &_result368) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result368.GetSuccess(), nil +} + +// Forces a task into a specific state. This does not guarantee the task will enter the given +// state, as the task must still transition within the bounds of the state machine. However, +// it attempts to enter that state via the state machine. +// +// Parameters: +// - TaskId +// - Status +func (p *AuroraAdminClient) ForceTaskState(ctx context.Context, taskId string, status ScheduleStatus) (r *Response, err error) { + var _args369 AuroraAdminForceTaskStateArgs + _args369.TaskId = taskId + _args369.Status = status + var _result370 AuroraAdminForceTaskStateResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "forceTaskState", &_args369, &_result370) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result370.GetSuccess(), nil +} + +// Immediately writes a storage snapshot to disk. +func (p *AuroraAdminClient) PerformBackup(ctx context.Context) (r *Response, err error) { + var _args371 AuroraAdminPerformBackupArgs + var _result372 AuroraAdminPerformBackupResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "performBackup", &_args371, &_result372) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result372.GetSuccess(), nil +} + +// Lists backups that are available for recovery. +func (p *AuroraAdminClient) ListBackups(ctx context.Context) (r *Response, err error) { + var _args373 AuroraAdminListBackupsArgs + var _result374 AuroraAdminListBackupsResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "listBackups", &_args373, &_result374) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result374.GetSuccess(), nil +} + +// Loads a backup to an in-memory storage. This must precede all other recovery operations. +// +// Parameters: +// - BackupId +func (p *AuroraAdminClient) StageRecovery(ctx context.Context, backupId string) (r *Response, err error) { + var _args375 AuroraAdminStageRecoveryArgs + _args375.BackupId = backupId + var _result376 AuroraAdminStageRecoveryResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "stageRecovery", &_args375, &_result376) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result376.GetSuccess(), nil +} + +// Queries for tasks in a staged recovery. +// +// Parameters: +// - Query +func (p *AuroraAdminClient) QueryRecovery(ctx context.Context, query *TaskQuery) (r *Response, err error) { + var _args377 AuroraAdminQueryRecoveryArgs + _args377.Query = query + var _result378 AuroraAdminQueryRecoveryResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "queryRecovery", &_args377, &_result378) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result378.GetSuccess(), nil +} + +// Deletes tasks from a staged recovery. +// +// Parameters: +// - Query +func (p *AuroraAdminClient) DeleteRecoveryTasks(ctx context.Context, query *TaskQuery) (r *Response, err error) { + var _args379 AuroraAdminDeleteRecoveryTasksArgs + _args379.Query = query + var _result380 AuroraAdminDeleteRecoveryTasksResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "deleteRecoveryTasks", &_args379, &_result380) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result380.GetSuccess(), nil +} + +// Commits a staged recovery, completely replacing the previous storage state. +func (p *AuroraAdminClient) CommitRecovery(ctx context.Context) (r *Response, err error) { + var _args381 AuroraAdminCommitRecoveryArgs + var _result382 AuroraAdminCommitRecoveryResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "commitRecovery", &_args381, &_result382) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result382.GetSuccess(), nil +} + +// Unloads (aborts) a staged recovery. +func (p *AuroraAdminClient) UnloadRecovery(ctx context.Context) (r *Response, err error) { + var _args383 AuroraAdminUnloadRecoveryArgs + var _result384 AuroraAdminUnloadRecoveryResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "unloadRecovery", &_args383, &_result384) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result384.GetSuccess(), nil +} + +// Put the given hosts into maintenance mode. +// +// Parameters: +// - Hosts +func (p *AuroraAdminClient) StartMaintenance(ctx context.Context, hosts *Hosts) (r *Response, err error) { + var _args385 AuroraAdminStartMaintenanceArgs + _args385.Hosts = hosts + var _result386 AuroraAdminStartMaintenanceResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "startMaintenance", &_args385, &_result386) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result386.GetSuccess(), nil +} + +// Ask scheduler to begin moving tasks scheduled on given hosts. +// +// Parameters: +// - Hosts +func (p *AuroraAdminClient) DrainHosts(ctx context.Context, hosts *Hosts) (r *Response, err error) { + var _args387 AuroraAdminDrainHostsArgs + _args387.Hosts = hosts + var _result388 AuroraAdminDrainHostsResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "drainHosts", &_args387, &_result388) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result388.GetSuccess(), nil +} + +// Retrieve the current maintenance states for a group of hosts. +// +// Parameters: +// - Hosts +func (p *AuroraAdminClient) MaintenanceStatus(ctx context.Context, hosts *Hosts) (r *Response, err error) { + var _args389 AuroraAdminMaintenanceStatusArgs + _args389.Hosts = hosts + var _result390 AuroraAdminMaintenanceStatusResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "maintenanceStatus", &_args389, &_result390) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result390.GetSuccess(), nil +} + +// Set the given hosts back into serving mode. +// +// Parameters: +// - Hosts +func (p *AuroraAdminClient) EndMaintenance(ctx context.Context, hosts *Hosts) (r *Response, err error) { + var _args391 AuroraAdminEndMaintenanceArgs + _args391.Hosts = hosts + var _result392 AuroraAdminEndMaintenanceResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "endMaintenance", &_args391, &_result392) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result392.GetSuccess(), nil +} + +// Ask scheduler to put hosts into DRAINING mode and move scheduled tasks off of the hosts +// such that its SLA requirements are satisfied. Use defaultSlaPolicy if it is not set for a task. +// +// +// Parameters: +// - Hosts +// - DefaultSlaPolicy +// - TimeoutSecs +func (p *AuroraAdminClient) SlaDrainHosts(ctx context.Context, hosts *Hosts, defaultSlaPolicy *SlaPolicy, timeoutSecs int64) (r *Response, err error) { + var _args393 AuroraAdminSlaDrainHostsArgs + _args393.Hosts = hosts + _args393.DefaultSlaPolicy = defaultSlaPolicy + _args393.TimeoutSecs = timeoutSecs + var _result394 AuroraAdminSlaDrainHostsResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "slaDrainHosts", &_args393, &_result394) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result394.GetSuccess(), nil +} + +// Start a storage snapshot and block until it completes. +func (p *AuroraAdminClient) Snapshot(ctx context.Context) (r *Response, err error) { + var _args395 AuroraAdminSnapshotArgs + var _result396 AuroraAdminSnapshotResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "snapshot", &_args395, &_result396) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result396.GetSuccess(), nil +} + +// Tell scheduler to trigger an explicit task reconciliation with the given settings. +// +// Parameters: +// - Settings +func (p *AuroraAdminClient) TriggerExplicitTaskReconciliation(ctx context.Context, settings *ExplicitReconciliationSettings) (r *Response, err error) { + var _args397 AuroraAdminTriggerExplicitTaskReconciliationArgs + _args397.Settings = settings + var _result398 AuroraAdminTriggerExplicitTaskReconciliationResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "triggerExplicitTaskReconciliation", &_args397, &_result398) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result398.GetSuccess(), nil +} + +// Tell scheduler to trigger an implicit task reconciliation. +func (p *AuroraAdminClient) TriggerImplicitTaskReconciliation(ctx context.Context) (r *Response, err error) { + var _args399 AuroraAdminTriggerImplicitTaskReconciliationArgs + var _result400 AuroraAdminTriggerImplicitTaskReconciliationResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "triggerImplicitTaskReconciliation", &_args399, &_result400) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result400.GetSuccess(), nil +} + +// Force prune any (terminal) tasks that match the query. If no statuses are supplied with the +// query, it will default to all terminal task states. If statuses are supplied, they must be +// terminal states. +// +// Parameters: +// - Query +func (p *AuroraAdminClient) PruneTasks(ctx context.Context, query *TaskQuery) (r *Response, err error) { + var _args401 AuroraAdminPruneTasksArgs + _args401.Query = query + var _result402 AuroraAdminPruneTasksResult + var meta thrift.ResponseMeta + meta, err = p.Client_().Call(ctx, "pruneTasks", &_args401, &_result402) + p.SetLastResponseMeta_(meta) + if err != nil { + return + } + return _result402.GetSuccess(), nil +} + +type AuroraAdminProcessor struct { + *AuroraSchedulerManagerProcessor +} + +func NewAuroraAdminProcessor(handler AuroraAdmin) *AuroraAdminProcessor { + self403 := &AuroraAdminProcessor{NewAuroraSchedulerManagerProcessor(handler)} + self403.AddToProcessorMap("setQuota", &auroraAdminProcessorSetQuota{handler:handler}) + self403.AddToProcessorMap("forceTaskState", &auroraAdminProcessorForceTaskState{handler:handler}) + self403.AddToProcessorMap("performBackup", &auroraAdminProcessorPerformBackup{handler:handler}) + self403.AddToProcessorMap("listBackups", &auroraAdminProcessorListBackups{handler:handler}) + self403.AddToProcessorMap("stageRecovery", &auroraAdminProcessorStageRecovery{handler:handler}) + self403.AddToProcessorMap("queryRecovery", &auroraAdminProcessorQueryRecovery{handler:handler}) + self403.AddToProcessorMap("deleteRecoveryTasks", &auroraAdminProcessorDeleteRecoveryTasks{handler:handler}) + self403.AddToProcessorMap("commitRecovery", &auroraAdminProcessorCommitRecovery{handler:handler}) + self403.AddToProcessorMap("unloadRecovery", &auroraAdminProcessorUnloadRecovery{handler:handler}) + self403.AddToProcessorMap("startMaintenance", &auroraAdminProcessorStartMaintenance{handler:handler}) + self403.AddToProcessorMap("drainHosts", &auroraAdminProcessorDrainHosts{handler:handler}) + self403.AddToProcessorMap("maintenanceStatus", &auroraAdminProcessorMaintenanceStatus{handler:handler}) + self403.AddToProcessorMap("endMaintenance", &auroraAdminProcessorEndMaintenance{handler:handler}) + self403.AddToProcessorMap("slaDrainHosts", &auroraAdminProcessorSlaDrainHosts{handler:handler}) + self403.AddToProcessorMap("snapshot", &auroraAdminProcessorSnapshot{handler:handler}) + self403.AddToProcessorMap("triggerExplicitTaskReconciliation", &auroraAdminProcessorTriggerExplicitTaskReconciliation{handler:handler}) + self403.AddToProcessorMap("triggerImplicitTaskReconciliation", &auroraAdminProcessorTriggerImplicitTaskReconciliation{handler:handler}) + self403.AddToProcessorMap("pruneTasks", &auroraAdminProcessorPruneTasks{handler:handler}) + return self403 +} + +type auroraAdminProcessorSetQuota struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorSetQuota) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminSetQuotaArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "setQuota", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminSetQuotaResult{} + var retval *Response + if retval, err2 = p.handler.SetQuota(ctx, args.OwnerRole, args.Quota); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing setQuota: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "setQuota", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "setQuota", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraAdminProcessorForceTaskState struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorForceTaskState) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminForceTaskStateArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "forceTaskState", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminForceTaskStateResult{} + var retval *Response + if retval, err2 = p.handler.ForceTaskState(ctx, args.TaskId, args.Status); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing forceTaskState: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "forceTaskState", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "forceTaskState", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraAdminProcessorPerformBackup struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorPerformBackup) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminPerformBackupArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "performBackup", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminPerformBackupResult{} + var retval *Response + if retval, err2 = p.handler.PerformBackup(ctx); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing performBackup: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "performBackup", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "performBackup", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraAdminProcessorListBackups struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorListBackups) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminListBackupsArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "listBackups", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminListBackupsResult{} + var retval *Response + if retval, err2 = p.handler.ListBackups(ctx); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing listBackups: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "listBackups", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "listBackups", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraAdminProcessorStageRecovery struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorStageRecovery) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminStageRecoveryArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "stageRecovery", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminStageRecoveryResult{} + var retval *Response + if retval, err2 = p.handler.StageRecovery(ctx, args.BackupId); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing stageRecovery: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "stageRecovery", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "stageRecovery", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraAdminProcessorQueryRecovery struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorQueryRecovery) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminQueryRecoveryArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "queryRecovery", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminQueryRecoveryResult{} + var retval *Response + if retval, err2 = p.handler.QueryRecovery(ctx, args.Query); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing queryRecovery: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "queryRecovery", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "queryRecovery", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraAdminProcessorDeleteRecoveryTasks struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorDeleteRecoveryTasks) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminDeleteRecoveryTasksArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "deleteRecoveryTasks", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminDeleteRecoveryTasksResult{} + var retval *Response + if retval, err2 = p.handler.DeleteRecoveryTasks(ctx, args.Query); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing deleteRecoveryTasks: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "deleteRecoveryTasks", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "deleteRecoveryTasks", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraAdminProcessorCommitRecovery struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorCommitRecovery) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminCommitRecoveryArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "commitRecovery", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminCommitRecoveryResult{} + var retval *Response + if retval, err2 = p.handler.CommitRecovery(ctx); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing commitRecovery: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "commitRecovery", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "commitRecovery", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraAdminProcessorUnloadRecovery struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorUnloadRecovery) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminUnloadRecoveryArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "unloadRecovery", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminUnloadRecoveryResult{} + var retval *Response + if retval, err2 = p.handler.UnloadRecovery(ctx); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing unloadRecovery: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "unloadRecovery", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "unloadRecovery", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraAdminProcessorStartMaintenance struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorStartMaintenance) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminStartMaintenanceArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "startMaintenance", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminStartMaintenanceResult{} + var retval *Response + if retval, err2 = p.handler.StartMaintenance(ctx, args.Hosts); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing startMaintenance: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "startMaintenance", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "startMaintenance", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraAdminProcessorDrainHosts struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorDrainHosts) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminDrainHostsArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "drainHosts", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminDrainHostsResult{} + var retval *Response + if retval, err2 = p.handler.DrainHosts(ctx, args.Hosts); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing drainHosts: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "drainHosts", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "drainHosts", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraAdminProcessorMaintenanceStatus struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorMaintenanceStatus) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminMaintenanceStatusArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "maintenanceStatus", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminMaintenanceStatusResult{} + var retval *Response + if retval, err2 = p.handler.MaintenanceStatus(ctx, args.Hosts); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing maintenanceStatus: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "maintenanceStatus", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "maintenanceStatus", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraAdminProcessorEndMaintenance struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorEndMaintenance) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminEndMaintenanceArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "endMaintenance", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminEndMaintenanceResult{} + var retval *Response + if retval, err2 = p.handler.EndMaintenance(ctx, args.Hosts); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing endMaintenance: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "endMaintenance", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "endMaintenance", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraAdminProcessorSlaDrainHosts struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorSlaDrainHosts) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminSlaDrainHostsArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "slaDrainHosts", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminSlaDrainHostsResult{} + var retval *Response + if retval, err2 = p.handler.SlaDrainHosts(ctx, args.Hosts, args.DefaultSlaPolicy, args.TimeoutSecs); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing slaDrainHosts: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "slaDrainHosts", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "slaDrainHosts", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraAdminProcessorSnapshot struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorSnapshot) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminSnapshotArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "snapshot", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminSnapshotResult{} + var retval *Response + if retval, err2 = p.handler.Snapshot(ctx); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing snapshot: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "snapshot", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "snapshot", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraAdminProcessorTriggerExplicitTaskReconciliation struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorTriggerExplicitTaskReconciliation) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminTriggerExplicitTaskReconciliationArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "triggerExplicitTaskReconciliation", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminTriggerExplicitTaskReconciliationResult{} + var retval *Response + if retval, err2 = p.handler.TriggerExplicitTaskReconciliation(ctx, args.Settings); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing triggerExplicitTaskReconciliation: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "triggerExplicitTaskReconciliation", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "triggerExplicitTaskReconciliation", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraAdminProcessorTriggerImplicitTaskReconciliation struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorTriggerImplicitTaskReconciliation) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminTriggerImplicitTaskReconciliationArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "triggerImplicitTaskReconciliation", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminTriggerImplicitTaskReconciliationResult{} + var retval *Response + if retval, err2 = p.handler.TriggerImplicitTaskReconciliation(ctx); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing triggerImplicitTaskReconciliation: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "triggerImplicitTaskReconciliation", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "triggerImplicitTaskReconciliation", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + +type auroraAdminProcessorPruneTasks struct { + handler AuroraAdmin +} + +func (p *auroraAdminProcessorPruneTasks) Process(ctx context.Context, seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { + args := AuroraAdminPruneTasksArgs{} + var err2 error + if err2 = args.Read(ctx, iprot); err2 != nil { + iprot.ReadMessageEnd(ctx) + x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err2.Error()) + oprot.WriteMessageBegin(ctx, "pruneTasks", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return false, thrift.WrapTException(err2) + } + iprot.ReadMessageEnd(ctx) + + tickerCancel := func() {} + // Start a goroutine to do server side connectivity check. + if thrift.ServerConnectivityCheckInterval > 0 { + var cancel context.CancelFunc + ctx, cancel = context.WithCancel(ctx) + defer cancel() + var tickerCtx context.Context + tickerCtx, tickerCancel = context.WithCancel(context.Background()) + defer tickerCancel() + go func(ctx context.Context, cancel context.CancelFunc) { + ticker := time.NewTicker(thrift.ServerConnectivityCheckInterval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + if !iprot.Transport().IsOpen() { + cancel() + return + } + } + } + }(tickerCtx, cancel) + } + + result := AuroraAdminPruneTasksResult{} + var retval *Response + if retval, err2 = p.handler.PruneTasks(ctx, args.Query); err2 != nil { + tickerCancel() + if err2 == thrift.ErrAbandonRequest { + return false, thrift.WrapTException(err2) + } + x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing pruneTasks: " + err2.Error()) + oprot.WriteMessageBegin(ctx, "pruneTasks", thrift.EXCEPTION, seqId) + x.Write(ctx, oprot) + oprot.WriteMessageEnd(ctx) + oprot.Flush(ctx) + return true, thrift.WrapTException(err2) + } else { + result.Success = retval + } + tickerCancel() + if err2 = oprot.WriteMessageBegin(ctx, "pruneTasks", thrift.REPLY, seqId); err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = result.Write(ctx, oprot); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.WriteMessageEnd(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err2 = oprot.Flush(ctx); err == nil && err2 != nil { + err = thrift.WrapTException(err2) + } + if err != nil { + return + } + return true, err +} + + +// HELPER FUNCTIONS AND STRUCTURES + +// Attributes: +// - OwnerRole +// - Quota +type AuroraAdminSetQuotaArgs struct { + OwnerRole string `thrift:"ownerRole,1" db:"ownerRole" json:"ownerRole"` + Quota *ResourceAggregate `thrift:"quota,2" db:"quota" json:"quota"` +} + +func NewAuroraAdminSetQuotaArgs() *AuroraAdminSetQuotaArgs { + return &AuroraAdminSetQuotaArgs{} +} + + +func (p *AuroraAdminSetQuotaArgs) GetOwnerRole() string { + return p.OwnerRole +} +var AuroraAdminSetQuotaArgs_Quota_DEFAULT *ResourceAggregate +func (p *AuroraAdminSetQuotaArgs) GetQuota() *ResourceAggregate { + if !p.IsSetQuota() { + return AuroraAdminSetQuotaArgs_Quota_DEFAULT + } +return p.Quota +} +func (p *AuroraAdminSetQuotaArgs) IsSetQuota() bool { + return p.Quota != nil +} + +func (p *AuroraAdminSetQuotaArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminSetQuotaArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.OwnerRole = v +} + return nil +} + +func (p *AuroraAdminSetQuotaArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.Quota = &ResourceAggregate{} + if err := p.Quota.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Quota), err) + } + return nil +} + +func (p *AuroraAdminSetQuotaArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "setQuota_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminSetQuotaArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "ownerRole", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ownerRole: ", p), err) } + if err := oprot.WriteString(ctx, string(p.OwnerRole)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.ownerRole (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ownerRole: ", p), err) } + return err +} + +func (p *AuroraAdminSetQuotaArgs) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "quota", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:quota: ", p), err) } + if err := p.Quota.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Quota), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:quota: ", p), err) } + return err +} + +func (p *AuroraAdminSetQuotaArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminSetQuotaArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminSetQuotaResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminSetQuotaResult() *AuroraAdminSetQuotaResult { + return &AuroraAdminSetQuotaResult{} +} + +var AuroraAdminSetQuotaResult_Success_DEFAULT *Response +func (p *AuroraAdminSetQuotaResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminSetQuotaResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminSetQuotaResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminSetQuotaResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminSetQuotaResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminSetQuotaResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "setQuota_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminSetQuotaResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminSetQuotaResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminSetQuotaResult(%+v)", *p) +} + +// Attributes: +// - TaskId +// - Status +type AuroraAdminForceTaskStateArgs struct { + TaskId string `thrift:"taskId,1" db:"taskId" json:"taskId"` + Status ScheduleStatus `thrift:"status,2" db:"status" json:"status"` +} + +func NewAuroraAdminForceTaskStateArgs() *AuroraAdminForceTaskStateArgs { + return &AuroraAdminForceTaskStateArgs{} +} + + +func (p *AuroraAdminForceTaskStateArgs) GetTaskId() string { + return p.TaskId +} + +func (p *AuroraAdminForceTaskStateArgs) GetStatus() ScheduleStatus { + return p.Status +} +func (p *AuroraAdminForceTaskStateArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.I32 { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminForceTaskStateArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.TaskId = v +} + return nil +} + +func (p *AuroraAdminForceTaskStateArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI32(ctx); err != nil { + return thrift.PrependError("error reading field 2: ", err) +} else { + temp := ScheduleStatus(v) + p.Status = temp +} + return nil +} + +func (p *AuroraAdminForceTaskStateArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "forceTaskState_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminForceTaskStateArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "taskId", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:taskId: ", p), err) } + if err := oprot.WriteString(ctx, string(p.TaskId)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.taskId (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:taskId: ", p), err) } + return err +} + +func (p *AuroraAdminForceTaskStateArgs) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "status", thrift.I32, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:status: ", p), err) } + if err := oprot.WriteI32(ctx, int32(p.Status)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.status (2) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:status: ", p), err) } + return err +} + +func (p *AuroraAdminForceTaskStateArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminForceTaskStateArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminForceTaskStateResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminForceTaskStateResult() *AuroraAdminForceTaskStateResult { + return &AuroraAdminForceTaskStateResult{} +} + +var AuroraAdminForceTaskStateResult_Success_DEFAULT *Response +func (p *AuroraAdminForceTaskStateResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminForceTaskStateResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminForceTaskStateResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminForceTaskStateResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminForceTaskStateResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminForceTaskStateResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "forceTaskState_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminForceTaskStateResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminForceTaskStateResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminForceTaskStateResult(%+v)", *p) +} + +type AuroraAdminPerformBackupArgs struct { +} + +func NewAuroraAdminPerformBackupArgs() *AuroraAdminPerformBackupArgs { + return &AuroraAdminPerformBackupArgs{} +} + +func (p *AuroraAdminPerformBackupArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminPerformBackupArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "performBackup_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminPerformBackupArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminPerformBackupArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminPerformBackupResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminPerformBackupResult() *AuroraAdminPerformBackupResult { + return &AuroraAdminPerformBackupResult{} +} + +var AuroraAdminPerformBackupResult_Success_DEFAULT *Response +func (p *AuroraAdminPerformBackupResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminPerformBackupResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminPerformBackupResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminPerformBackupResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminPerformBackupResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminPerformBackupResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "performBackup_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminPerformBackupResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminPerformBackupResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminPerformBackupResult(%+v)", *p) +} + +type AuroraAdminListBackupsArgs struct { +} + +func NewAuroraAdminListBackupsArgs() *AuroraAdminListBackupsArgs { + return &AuroraAdminListBackupsArgs{} +} + +func (p *AuroraAdminListBackupsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminListBackupsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "listBackups_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminListBackupsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminListBackupsArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminListBackupsResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminListBackupsResult() *AuroraAdminListBackupsResult { + return &AuroraAdminListBackupsResult{} +} + +var AuroraAdminListBackupsResult_Success_DEFAULT *Response +func (p *AuroraAdminListBackupsResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminListBackupsResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminListBackupsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminListBackupsResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminListBackupsResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminListBackupsResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "listBackups_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminListBackupsResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminListBackupsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminListBackupsResult(%+v)", *p) +} + +// Attributes: +// - BackupId +type AuroraAdminStageRecoveryArgs struct { + BackupId string `thrift:"backupId,1" db:"backupId" json:"backupId"` +} + +func NewAuroraAdminStageRecoveryArgs() *AuroraAdminStageRecoveryArgs { + return &AuroraAdminStageRecoveryArgs{} +} + + +func (p *AuroraAdminStageRecoveryArgs) GetBackupId() string { + return p.BackupId +} +func (p *AuroraAdminStageRecoveryArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRING { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminStageRecoveryArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadString(ctx); err != nil { + return thrift.PrependError("error reading field 1: ", err) +} else { + p.BackupId = v +} + return nil +} + +func (p *AuroraAdminStageRecoveryArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "stageRecovery_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminStageRecoveryArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "backupId", thrift.STRING, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:backupId: ", p), err) } + if err := oprot.WriteString(ctx, string(p.BackupId)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.backupId (1) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:backupId: ", p), err) } + return err +} + +func (p *AuroraAdminStageRecoveryArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminStageRecoveryArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminStageRecoveryResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminStageRecoveryResult() *AuroraAdminStageRecoveryResult { + return &AuroraAdminStageRecoveryResult{} +} + +var AuroraAdminStageRecoveryResult_Success_DEFAULT *Response +func (p *AuroraAdminStageRecoveryResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminStageRecoveryResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminStageRecoveryResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminStageRecoveryResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminStageRecoveryResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminStageRecoveryResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "stageRecovery_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminStageRecoveryResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminStageRecoveryResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminStageRecoveryResult(%+v)", *p) +} + +// Attributes: +// - Query +type AuroraAdminQueryRecoveryArgs struct { + Query *TaskQuery `thrift:"query,1" db:"query" json:"query"` +} + +func NewAuroraAdminQueryRecoveryArgs() *AuroraAdminQueryRecoveryArgs { + return &AuroraAdminQueryRecoveryArgs{} +} + +var AuroraAdminQueryRecoveryArgs_Query_DEFAULT *TaskQuery +func (p *AuroraAdminQueryRecoveryArgs) GetQuery() *TaskQuery { + if !p.IsSetQuery() { + return AuroraAdminQueryRecoveryArgs_Query_DEFAULT + } +return p.Query +} +func (p *AuroraAdminQueryRecoveryArgs) IsSetQuery() bool { + return p.Query != nil +} + +func (p *AuroraAdminQueryRecoveryArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminQueryRecoveryArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Query = &TaskQuery{} + if err := p.Query.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) + } + return nil +} + +func (p *AuroraAdminQueryRecoveryArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "queryRecovery_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminQueryRecoveryArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "query", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:query: ", p), err) } + if err := p.Query.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:query: ", p), err) } + return err +} + +func (p *AuroraAdminQueryRecoveryArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminQueryRecoveryArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminQueryRecoveryResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminQueryRecoveryResult() *AuroraAdminQueryRecoveryResult { + return &AuroraAdminQueryRecoveryResult{} +} + +var AuroraAdminQueryRecoveryResult_Success_DEFAULT *Response +func (p *AuroraAdminQueryRecoveryResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminQueryRecoveryResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminQueryRecoveryResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminQueryRecoveryResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminQueryRecoveryResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminQueryRecoveryResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "queryRecovery_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminQueryRecoveryResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminQueryRecoveryResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminQueryRecoveryResult(%+v)", *p) +} + +// Attributes: +// - Query +type AuroraAdminDeleteRecoveryTasksArgs struct { + Query *TaskQuery `thrift:"query,1" db:"query" json:"query"` +} + +func NewAuroraAdminDeleteRecoveryTasksArgs() *AuroraAdminDeleteRecoveryTasksArgs { + return &AuroraAdminDeleteRecoveryTasksArgs{} +} + +var AuroraAdminDeleteRecoveryTasksArgs_Query_DEFAULT *TaskQuery +func (p *AuroraAdminDeleteRecoveryTasksArgs) GetQuery() *TaskQuery { + if !p.IsSetQuery() { + return AuroraAdminDeleteRecoveryTasksArgs_Query_DEFAULT + } +return p.Query +} +func (p *AuroraAdminDeleteRecoveryTasksArgs) IsSetQuery() bool { + return p.Query != nil +} + +func (p *AuroraAdminDeleteRecoveryTasksArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminDeleteRecoveryTasksArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Query = &TaskQuery{} + if err := p.Query.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) + } + return nil +} + +func (p *AuroraAdminDeleteRecoveryTasksArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "deleteRecoveryTasks_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminDeleteRecoveryTasksArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "query", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:query: ", p), err) } + if err := p.Query.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:query: ", p), err) } + return err +} + +func (p *AuroraAdminDeleteRecoveryTasksArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminDeleteRecoveryTasksArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminDeleteRecoveryTasksResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminDeleteRecoveryTasksResult() *AuroraAdminDeleteRecoveryTasksResult { + return &AuroraAdminDeleteRecoveryTasksResult{} +} + +var AuroraAdminDeleteRecoveryTasksResult_Success_DEFAULT *Response +func (p *AuroraAdminDeleteRecoveryTasksResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminDeleteRecoveryTasksResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminDeleteRecoveryTasksResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminDeleteRecoveryTasksResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminDeleteRecoveryTasksResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminDeleteRecoveryTasksResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "deleteRecoveryTasks_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminDeleteRecoveryTasksResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminDeleteRecoveryTasksResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminDeleteRecoveryTasksResult(%+v)", *p) +} + +type AuroraAdminCommitRecoveryArgs struct { +} + +func NewAuroraAdminCommitRecoveryArgs() *AuroraAdminCommitRecoveryArgs { + return &AuroraAdminCommitRecoveryArgs{} +} + +func (p *AuroraAdminCommitRecoveryArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminCommitRecoveryArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "commitRecovery_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminCommitRecoveryArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminCommitRecoveryArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminCommitRecoveryResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminCommitRecoveryResult() *AuroraAdminCommitRecoveryResult { + return &AuroraAdminCommitRecoveryResult{} +} + +var AuroraAdminCommitRecoveryResult_Success_DEFAULT *Response +func (p *AuroraAdminCommitRecoveryResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminCommitRecoveryResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminCommitRecoveryResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminCommitRecoveryResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminCommitRecoveryResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminCommitRecoveryResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "commitRecovery_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminCommitRecoveryResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminCommitRecoveryResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminCommitRecoveryResult(%+v)", *p) +} + +type AuroraAdminUnloadRecoveryArgs struct { +} + +func NewAuroraAdminUnloadRecoveryArgs() *AuroraAdminUnloadRecoveryArgs { + return &AuroraAdminUnloadRecoveryArgs{} +} + +func (p *AuroraAdminUnloadRecoveryArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminUnloadRecoveryArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "unloadRecovery_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminUnloadRecoveryArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminUnloadRecoveryArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminUnloadRecoveryResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminUnloadRecoveryResult() *AuroraAdminUnloadRecoveryResult { + return &AuroraAdminUnloadRecoveryResult{} +} + +var AuroraAdminUnloadRecoveryResult_Success_DEFAULT *Response +func (p *AuroraAdminUnloadRecoveryResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminUnloadRecoveryResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminUnloadRecoveryResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminUnloadRecoveryResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminUnloadRecoveryResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminUnloadRecoveryResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "unloadRecovery_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminUnloadRecoveryResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminUnloadRecoveryResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminUnloadRecoveryResult(%+v)", *p) +} + +// Attributes: +// - Hosts +type AuroraAdminStartMaintenanceArgs struct { + Hosts *Hosts `thrift:"hosts,1" db:"hosts" json:"hosts"` +} + +func NewAuroraAdminStartMaintenanceArgs() *AuroraAdminStartMaintenanceArgs { + return &AuroraAdminStartMaintenanceArgs{} +} + +var AuroraAdminStartMaintenanceArgs_Hosts_DEFAULT *Hosts +func (p *AuroraAdminStartMaintenanceArgs) GetHosts() *Hosts { + if !p.IsSetHosts() { + return AuroraAdminStartMaintenanceArgs_Hosts_DEFAULT + } +return p.Hosts +} +func (p *AuroraAdminStartMaintenanceArgs) IsSetHosts() bool { + return p.Hosts != nil +} + +func (p *AuroraAdminStartMaintenanceArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminStartMaintenanceArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Hosts = &Hosts{} + if err := p.Hosts.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Hosts), err) + } + return nil +} + +func (p *AuroraAdminStartMaintenanceArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "startMaintenance_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminStartMaintenanceArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "hosts", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:hosts: ", p), err) } + if err := p.Hosts.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Hosts), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:hosts: ", p), err) } + return err +} + +func (p *AuroraAdminStartMaintenanceArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminStartMaintenanceArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminStartMaintenanceResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminStartMaintenanceResult() *AuroraAdminStartMaintenanceResult { + return &AuroraAdminStartMaintenanceResult{} +} + +var AuroraAdminStartMaintenanceResult_Success_DEFAULT *Response +func (p *AuroraAdminStartMaintenanceResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminStartMaintenanceResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminStartMaintenanceResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminStartMaintenanceResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminStartMaintenanceResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminStartMaintenanceResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "startMaintenance_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminStartMaintenanceResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminStartMaintenanceResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminStartMaintenanceResult(%+v)", *p) +} + +// Attributes: +// - Hosts +type AuroraAdminDrainHostsArgs struct { + Hosts *Hosts `thrift:"hosts,1" db:"hosts" json:"hosts"` +} + +func NewAuroraAdminDrainHostsArgs() *AuroraAdminDrainHostsArgs { + return &AuroraAdminDrainHostsArgs{} +} + +var AuroraAdminDrainHostsArgs_Hosts_DEFAULT *Hosts +func (p *AuroraAdminDrainHostsArgs) GetHosts() *Hosts { + if !p.IsSetHosts() { + return AuroraAdminDrainHostsArgs_Hosts_DEFAULT + } +return p.Hosts +} +func (p *AuroraAdminDrainHostsArgs) IsSetHosts() bool { + return p.Hosts != nil +} + +func (p *AuroraAdminDrainHostsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminDrainHostsArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Hosts = &Hosts{} + if err := p.Hosts.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Hosts), err) + } + return nil +} + +func (p *AuroraAdminDrainHostsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "drainHosts_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminDrainHostsArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "hosts", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:hosts: ", p), err) } + if err := p.Hosts.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Hosts), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:hosts: ", p), err) } + return err +} + +func (p *AuroraAdminDrainHostsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminDrainHostsArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminDrainHostsResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminDrainHostsResult() *AuroraAdminDrainHostsResult { + return &AuroraAdminDrainHostsResult{} +} + +var AuroraAdminDrainHostsResult_Success_DEFAULT *Response +func (p *AuroraAdminDrainHostsResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminDrainHostsResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminDrainHostsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminDrainHostsResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminDrainHostsResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminDrainHostsResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "drainHosts_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminDrainHostsResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminDrainHostsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminDrainHostsResult(%+v)", *p) +} + +// Attributes: +// - Hosts +type AuroraAdminMaintenanceStatusArgs struct { + Hosts *Hosts `thrift:"hosts,1" db:"hosts" json:"hosts"` +} + +func NewAuroraAdminMaintenanceStatusArgs() *AuroraAdminMaintenanceStatusArgs { + return &AuroraAdminMaintenanceStatusArgs{} +} + +var AuroraAdminMaintenanceStatusArgs_Hosts_DEFAULT *Hosts +func (p *AuroraAdminMaintenanceStatusArgs) GetHosts() *Hosts { + if !p.IsSetHosts() { + return AuroraAdminMaintenanceStatusArgs_Hosts_DEFAULT + } +return p.Hosts +} +func (p *AuroraAdminMaintenanceStatusArgs) IsSetHosts() bool { + return p.Hosts != nil +} + +func (p *AuroraAdminMaintenanceStatusArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminMaintenanceStatusArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Hosts = &Hosts{} + if err := p.Hosts.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Hosts), err) + } + return nil +} + +func (p *AuroraAdminMaintenanceStatusArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "maintenanceStatus_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminMaintenanceStatusArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "hosts", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:hosts: ", p), err) } + if err := p.Hosts.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Hosts), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:hosts: ", p), err) } + return err +} + +func (p *AuroraAdminMaintenanceStatusArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminMaintenanceStatusArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminMaintenanceStatusResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminMaintenanceStatusResult() *AuroraAdminMaintenanceStatusResult { + return &AuroraAdminMaintenanceStatusResult{} +} + +var AuroraAdminMaintenanceStatusResult_Success_DEFAULT *Response +func (p *AuroraAdminMaintenanceStatusResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminMaintenanceStatusResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminMaintenanceStatusResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminMaintenanceStatusResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminMaintenanceStatusResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminMaintenanceStatusResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "maintenanceStatus_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminMaintenanceStatusResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminMaintenanceStatusResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminMaintenanceStatusResult(%+v)", *p) +} + +// Attributes: +// - Hosts +type AuroraAdminEndMaintenanceArgs struct { + Hosts *Hosts `thrift:"hosts,1" db:"hosts" json:"hosts"` +} + +func NewAuroraAdminEndMaintenanceArgs() *AuroraAdminEndMaintenanceArgs { + return &AuroraAdminEndMaintenanceArgs{} +} + +var AuroraAdminEndMaintenanceArgs_Hosts_DEFAULT *Hosts +func (p *AuroraAdminEndMaintenanceArgs) GetHosts() *Hosts { + if !p.IsSetHosts() { + return AuroraAdminEndMaintenanceArgs_Hosts_DEFAULT + } +return p.Hosts +} +func (p *AuroraAdminEndMaintenanceArgs) IsSetHosts() bool { + return p.Hosts != nil +} + +func (p *AuroraAdminEndMaintenanceArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminEndMaintenanceArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Hosts = &Hosts{} + if err := p.Hosts.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Hosts), err) + } + return nil +} + +func (p *AuroraAdminEndMaintenanceArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "endMaintenance_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminEndMaintenanceArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "hosts", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:hosts: ", p), err) } + if err := p.Hosts.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Hosts), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:hosts: ", p), err) } + return err +} + +func (p *AuroraAdminEndMaintenanceArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminEndMaintenanceArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminEndMaintenanceResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminEndMaintenanceResult() *AuroraAdminEndMaintenanceResult { + return &AuroraAdminEndMaintenanceResult{} +} + +var AuroraAdminEndMaintenanceResult_Success_DEFAULT *Response +func (p *AuroraAdminEndMaintenanceResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminEndMaintenanceResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminEndMaintenanceResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminEndMaintenanceResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminEndMaintenanceResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminEndMaintenanceResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "endMaintenance_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminEndMaintenanceResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminEndMaintenanceResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminEndMaintenanceResult(%+v)", *p) +} + +// Attributes: +// - Hosts +// - DefaultSlaPolicy +// - TimeoutSecs +type AuroraAdminSlaDrainHostsArgs struct { + Hosts *Hosts `thrift:"hosts,1" db:"hosts" json:"hosts"` + DefaultSlaPolicy *SlaPolicy `thrift:"defaultSlaPolicy,2" db:"defaultSlaPolicy" json:"defaultSlaPolicy"` + TimeoutSecs int64 `thrift:"timeoutSecs,3" db:"timeoutSecs" json:"timeoutSecs"` +} + +func NewAuroraAdminSlaDrainHostsArgs() *AuroraAdminSlaDrainHostsArgs { + return &AuroraAdminSlaDrainHostsArgs{} +} + +var AuroraAdminSlaDrainHostsArgs_Hosts_DEFAULT *Hosts +func (p *AuroraAdminSlaDrainHostsArgs) GetHosts() *Hosts { + if !p.IsSetHosts() { + return AuroraAdminSlaDrainHostsArgs_Hosts_DEFAULT + } +return p.Hosts +} +var AuroraAdminSlaDrainHostsArgs_DefaultSlaPolicy_DEFAULT *SlaPolicy +func (p *AuroraAdminSlaDrainHostsArgs) GetDefaultSlaPolicy() *SlaPolicy { + if !p.IsSetDefaultSlaPolicy() { + return AuroraAdminSlaDrainHostsArgs_DefaultSlaPolicy_DEFAULT + } +return p.DefaultSlaPolicy +} + +func (p *AuroraAdminSlaDrainHostsArgs) GetTimeoutSecs() int64 { + return p.TimeoutSecs +} +func (p *AuroraAdminSlaDrainHostsArgs) IsSetHosts() bool { + return p.Hosts != nil +} + +func (p *AuroraAdminSlaDrainHostsArgs) IsSetDefaultSlaPolicy() bool { + return p.DefaultSlaPolicy != nil +} + +func (p *AuroraAdminSlaDrainHostsArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 2: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField2(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + case 3: + if fieldTypeId == thrift.I64 { + if err := p.ReadField3(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminSlaDrainHostsArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Hosts = &Hosts{} + if err := p.Hosts.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Hosts), err) + } + return nil +} + +func (p *AuroraAdminSlaDrainHostsArgs) ReadField2(ctx context.Context, iprot thrift.TProtocol) error { + p.DefaultSlaPolicy = &SlaPolicy{} + if err := p.DefaultSlaPolicy.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.DefaultSlaPolicy), err) + } + return nil +} + +func (p *AuroraAdminSlaDrainHostsArgs) ReadField3(ctx context.Context, iprot thrift.TProtocol) error { + if v, err := iprot.ReadI64(ctx); err != nil { + return thrift.PrependError("error reading field 3: ", err) +} else { + p.TimeoutSecs = v +} + return nil +} + +func (p *AuroraAdminSlaDrainHostsArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "slaDrainHosts_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + if err := p.writeField2(ctx, oprot); err != nil { return err } + if err := p.writeField3(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminSlaDrainHostsArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "hosts", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:hosts: ", p), err) } + if err := p.Hosts.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Hosts), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:hosts: ", p), err) } + return err +} + +func (p *AuroraAdminSlaDrainHostsArgs) writeField2(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "defaultSlaPolicy", thrift.STRUCT, 2); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:defaultSlaPolicy: ", p), err) } + if err := p.DefaultSlaPolicy.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.DefaultSlaPolicy), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 2:defaultSlaPolicy: ", p), err) } + return err +} + +func (p *AuroraAdminSlaDrainHostsArgs) writeField3(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "timeoutSecs", thrift.I64, 3); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:timeoutSecs: ", p), err) } + if err := oprot.WriteI64(ctx, int64(p.TimeoutSecs)); err != nil { + return thrift.PrependError(fmt.Sprintf("%T.timeoutSecs (3) field write error: ", p), err) } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 3:timeoutSecs: ", p), err) } + return err +} + +func (p *AuroraAdminSlaDrainHostsArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminSlaDrainHostsArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminSlaDrainHostsResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminSlaDrainHostsResult() *AuroraAdminSlaDrainHostsResult { + return &AuroraAdminSlaDrainHostsResult{} +} + +var AuroraAdminSlaDrainHostsResult_Success_DEFAULT *Response +func (p *AuroraAdminSlaDrainHostsResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminSlaDrainHostsResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminSlaDrainHostsResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminSlaDrainHostsResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminSlaDrainHostsResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminSlaDrainHostsResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "slaDrainHosts_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminSlaDrainHostsResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminSlaDrainHostsResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminSlaDrainHostsResult(%+v)", *p) +} + +type AuroraAdminSnapshotArgs struct { +} + +func NewAuroraAdminSnapshotArgs() *AuroraAdminSnapshotArgs { + return &AuroraAdminSnapshotArgs{} +} + +func (p *AuroraAdminSnapshotArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminSnapshotArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "snapshot_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminSnapshotArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminSnapshotArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminSnapshotResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminSnapshotResult() *AuroraAdminSnapshotResult { + return &AuroraAdminSnapshotResult{} +} + +var AuroraAdminSnapshotResult_Success_DEFAULT *Response +func (p *AuroraAdminSnapshotResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminSnapshotResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminSnapshotResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminSnapshotResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminSnapshotResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminSnapshotResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "snapshot_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminSnapshotResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminSnapshotResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminSnapshotResult(%+v)", *p) +} + +// Attributes: +// - Settings +type AuroraAdminTriggerExplicitTaskReconciliationArgs struct { + Settings *ExplicitReconciliationSettings `thrift:"settings,1" db:"settings" json:"settings"` +} + +func NewAuroraAdminTriggerExplicitTaskReconciliationArgs() *AuroraAdminTriggerExplicitTaskReconciliationArgs { + return &AuroraAdminTriggerExplicitTaskReconciliationArgs{} +} + +var AuroraAdminTriggerExplicitTaskReconciliationArgs_Settings_DEFAULT *ExplicitReconciliationSettings +func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) GetSettings() *ExplicitReconciliationSettings { + if !p.IsSetSettings() { + return AuroraAdminTriggerExplicitTaskReconciliationArgs_Settings_DEFAULT + } +return p.Settings +} +func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) IsSetSettings() bool { + return p.Settings != nil +} + +func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Settings = &ExplicitReconciliationSettings{} + if err := p.Settings.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Settings), err) + } + return nil +} + +func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "triggerExplicitTaskReconciliation_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "settings", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:settings: ", p), err) } + if err := p.Settings.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Settings), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:settings: ", p), err) } + return err +} + +func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminTriggerExplicitTaskReconciliationArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminTriggerExplicitTaskReconciliationResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminTriggerExplicitTaskReconciliationResult() *AuroraAdminTriggerExplicitTaskReconciliationResult { + return &AuroraAdminTriggerExplicitTaskReconciliationResult{} +} + +var AuroraAdminTriggerExplicitTaskReconciliationResult_Success_DEFAULT *Response +func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminTriggerExplicitTaskReconciliationResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "triggerExplicitTaskReconciliation_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminTriggerExplicitTaskReconciliationResult(%+v)", *p) +} + +type AuroraAdminTriggerImplicitTaskReconciliationArgs struct { +} + +func NewAuroraAdminTriggerImplicitTaskReconciliationArgs() *AuroraAdminTriggerImplicitTaskReconciliationArgs { + return &AuroraAdminTriggerImplicitTaskReconciliationArgs{} +} + +func (p *AuroraAdminTriggerImplicitTaskReconciliationArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminTriggerImplicitTaskReconciliationArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "triggerImplicitTaskReconciliation_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminTriggerImplicitTaskReconciliationArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminTriggerImplicitTaskReconciliationArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminTriggerImplicitTaskReconciliationResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminTriggerImplicitTaskReconciliationResult() *AuroraAdminTriggerImplicitTaskReconciliationResult { + return &AuroraAdminTriggerImplicitTaskReconciliationResult{} +} + +var AuroraAdminTriggerImplicitTaskReconciliationResult_Success_DEFAULT *Response +func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminTriggerImplicitTaskReconciliationResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "triggerImplicitTaskReconciliation_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminTriggerImplicitTaskReconciliationResult(%+v)", *p) +} + +// Attributes: +// - Query +type AuroraAdminPruneTasksArgs struct { + Query *TaskQuery `thrift:"query,1" db:"query" json:"query"` +} + +func NewAuroraAdminPruneTasksArgs() *AuroraAdminPruneTasksArgs { + return &AuroraAdminPruneTasksArgs{} +} + +var AuroraAdminPruneTasksArgs_Query_DEFAULT *TaskQuery +func (p *AuroraAdminPruneTasksArgs) GetQuery() *TaskQuery { + if !p.IsSetQuery() { + return AuroraAdminPruneTasksArgs_Query_DEFAULT + } +return p.Query +} +func (p *AuroraAdminPruneTasksArgs) IsSetQuery() bool { + return p.Query != nil +} + +func (p *AuroraAdminPruneTasksArgs) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 1: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField1(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminPruneTasksArgs) ReadField1(ctx context.Context, iprot thrift.TProtocol) error { + p.Query = &TaskQuery{} + if err := p.Query.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) + } + return nil +} + +func (p *AuroraAdminPruneTasksArgs) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "pruneTasks_args"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField1(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminPruneTasksArgs) writeField1(ctx context.Context, oprot thrift.TProtocol) (err error) { + if err := oprot.WriteFieldBegin(ctx, "query", thrift.STRUCT, 1); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:query: ", p), err) } + if err := p.Query.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 1:query: ", p), err) } + return err +} + +func (p *AuroraAdminPruneTasksArgs) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminPruneTasksArgs(%+v)", *p) +} + +// Attributes: +// - Success +type AuroraAdminPruneTasksResult struct { + Success *Response `thrift:"success,0" db:"success" json:"success,omitempty"` +} + +func NewAuroraAdminPruneTasksResult() *AuroraAdminPruneTasksResult { + return &AuroraAdminPruneTasksResult{} +} + +var AuroraAdminPruneTasksResult_Success_DEFAULT *Response +func (p *AuroraAdminPruneTasksResult) GetSuccess() *Response { + if !p.IsSetSuccess() { + return AuroraAdminPruneTasksResult_Success_DEFAULT + } +return p.Success +} +func (p *AuroraAdminPruneTasksResult) IsSetSuccess() bool { + return p.Success != nil +} + +func (p *AuroraAdminPruneTasksResult) Read(ctx context.Context, iprot thrift.TProtocol) error { + if _, err := iprot.ReadStructBegin(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) + } + + + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin(ctx) + if err != nil { + return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == thrift.STOP { break; } + switch fieldId { + case 0: + if fieldTypeId == thrift.STRUCT { + if err := p.ReadField0(ctx, iprot); err != nil { + return err + } + } else { + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + default: + if err := iprot.Skip(ctx, fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(ctx); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *AuroraAdminPruneTasksResult) ReadField0(ctx context.Context, iprot thrift.TProtocol) error { + p.Success = &Response{} + if err := p.Success.Read(ctx, iprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) + } + return nil +} + +func (p *AuroraAdminPruneTasksResult) Write(ctx context.Context, oprot thrift.TProtocol) error { + if err := oprot.WriteStructBegin(ctx, "pruneTasks_result"); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) } + if p != nil { + if err := p.writeField0(ctx, oprot); err != nil { return err } + } + if err := oprot.WriteFieldStop(ctx); err != nil { + return thrift.PrependError("write field stop error: ", err) } + if err := oprot.WriteStructEnd(ctx); err != nil { + return thrift.PrependError("write struct stop error: ", err) } + return nil +} + +func (p *AuroraAdminPruneTasksResult) writeField0(ctx context.Context, oprot thrift.TProtocol) (err error) { + if p.IsSetSuccess() { + if err := oprot.WriteFieldBegin(ctx, "success", thrift.STRUCT, 0); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) } + if err := p.Success.Write(ctx, oprot); err != nil { + return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) + } + if err := oprot.WriteFieldEnd(ctx); err != nil { + return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) } + } + return err +} + +func (p *AuroraAdminPruneTasksResult) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("AuroraAdminPruneTasksResult(%+v)", *p) +} + + diff --git a/gen-go/apache/aurora/aurora_admin-remote/aurora_admin-remote.go b/gen-go/apache/aurora/aurora_admin-remote/aurora_admin-remote.go index cb052fe..d2d4441 100755 --- a/gen-go/apache/aurora/aurora_admin-remote/aurora_admin-remote.go +++ b/gen-go/apache/aurora/aurora_admin-remote/aurora_admin-remote.go @@ -1,1118 +1,1198 @@ -// Autogenerated by Thrift Compiler (0.9.3) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT. package main import ( - "apache/aurora" + "context" "flag" "fmt" - "git.apache.org/thrift.git/lib/go/thrift" "math" "net" "net/url" "os" "strconv" "strings" + "github.com/apache/thrift/lib/go/thrift" + "apache/aurora" ) +var _ = aurora.GoUnusedProtection__ + func Usage() { - fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:") - flag.PrintDefaults() - fmt.Fprintln(os.Stderr, "\nFunctions:") - fmt.Fprintln(os.Stderr, " Response setQuota(string ownerRole, ResourceAggregate quota)") - fmt.Fprintln(os.Stderr, " Response forceTaskState(string taskId, ScheduleStatus status)") - fmt.Fprintln(os.Stderr, " Response performBackup()") - fmt.Fprintln(os.Stderr, " Response listBackups()") - fmt.Fprintln(os.Stderr, " Response stageRecovery(string backupId)") - fmt.Fprintln(os.Stderr, " Response queryRecovery(TaskQuery query)") - fmt.Fprintln(os.Stderr, " Response deleteRecoveryTasks(TaskQuery query)") - fmt.Fprintln(os.Stderr, " Response commitRecovery()") - fmt.Fprintln(os.Stderr, " Response unloadRecovery()") - fmt.Fprintln(os.Stderr, " Response startMaintenance(Hosts hosts)") - fmt.Fprintln(os.Stderr, " Response drainHosts(Hosts hosts)") - fmt.Fprintln(os.Stderr, " Response maintenanceStatus(Hosts hosts)") - fmt.Fprintln(os.Stderr, " Response endMaintenance(Hosts hosts)") - fmt.Fprintln(os.Stderr, " Response snapshot()") - fmt.Fprintln(os.Stderr, " Response rewriteConfigs(RewriteConfigsRequest request)") - fmt.Fprintln(os.Stderr, " Response triggerExplicitTaskReconciliation(ExplicitReconciliationSettings settings)") - fmt.Fprintln(os.Stderr, " Response triggerImplicitTaskReconciliation()") - fmt.Fprintln(os.Stderr, " Response createJob(JobConfiguration description)") - fmt.Fprintln(os.Stderr, " Response scheduleCronJob(JobConfiguration description)") - fmt.Fprintln(os.Stderr, " Response descheduleCronJob(JobKey job)") - fmt.Fprintln(os.Stderr, " Response startCronJob(JobKey job)") - fmt.Fprintln(os.Stderr, " Response restartShards(JobKey job, shardIds)") - fmt.Fprintln(os.Stderr, " Response killTasks(JobKey job, instances)") - fmt.Fprintln(os.Stderr, " Response addInstances(InstanceKey key, i32 count)") - fmt.Fprintln(os.Stderr, " Response replaceCronTemplate(JobConfiguration config)") - fmt.Fprintln(os.Stderr, " Response startJobUpdate(JobUpdateRequest request, string message)") - fmt.Fprintln(os.Stderr, " Response pauseJobUpdate(JobUpdateKey key, string message)") - fmt.Fprintln(os.Stderr, " Response resumeJobUpdate(JobUpdateKey key, string message)") - fmt.Fprintln(os.Stderr, " Response abortJobUpdate(JobUpdateKey key, string message)") - fmt.Fprintln(os.Stderr, " Response rollbackJobUpdate(JobUpdateKey key, string message)") - fmt.Fprintln(os.Stderr, " Response pulseJobUpdate(JobUpdateKey key)") - fmt.Fprintln(os.Stderr, " Response getRoleSummary()") - fmt.Fprintln(os.Stderr, " Response getJobSummary(string role)") - fmt.Fprintln(os.Stderr, " Response getTasksStatus(TaskQuery query)") - fmt.Fprintln(os.Stderr, " Response getTasksWithoutConfigs(TaskQuery query)") - fmt.Fprintln(os.Stderr, " Response getPendingReason(TaskQuery query)") - fmt.Fprintln(os.Stderr, " Response getConfigSummary(JobKey job)") - fmt.Fprintln(os.Stderr, " Response getJobs(string ownerRole)") - fmt.Fprintln(os.Stderr, " Response getQuota(string ownerRole)") - fmt.Fprintln(os.Stderr, " Response populateJobConfig(JobConfiguration description)") - fmt.Fprintln(os.Stderr, " Response getJobUpdateSummaries(JobUpdateQuery jobUpdateQuery)") - fmt.Fprintln(os.Stderr, " Response getJobUpdateDetails(JobUpdateQuery query)") - fmt.Fprintln(os.Stderr, " Response getJobUpdateDiff(JobUpdateRequest request)") - fmt.Fprintln(os.Stderr, " Response getTierConfigs()") - fmt.Fprintln(os.Stderr) - os.Exit(0) + fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:") + flag.PrintDefaults() + fmt.Fprintln(os.Stderr, "\nFunctions:") + fmt.Fprintln(os.Stderr, " Response setQuota(string ownerRole, ResourceAggregate quota)") + fmt.Fprintln(os.Stderr, " Response forceTaskState(string taskId, ScheduleStatus status)") + fmt.Fprintln(os.Stderr, " Response performBackup()") + fmt.Fprintln(os.Stderr, " Response listBackups()") + fmt.Fprintln(os.Stderr, " Response stageRecovery(string backupId)") + fmt.Fprintln(os.Stderr, " Response queryRecovery(TaskQuery query)") + fmt.Fprintln(os.Stderr, " Response deleteRecoveryTasks(TaskQuery query)") + fmt.Fprintln(os.Stderr, " Response commitRecovery()") + fmt.Fprintln(os.Stderr, " Response unloadRecovery()") + fmt.Fprintln(os.Stderr, " Response startMaintenance(Hosts hosts)") + fmt.Fprintln(os.Stderr, " Response drainHosts(Hosts hosts)") + fmt.Fprintln(os.Stderr, " Response maintenanceStatus(Hosts hosts)") + fmt.Fprintln(os.Stderr, " Response endMaintenance(Hosts hosts)") + fmt.Fprintln(os.Stderr, " Response slaDrainHosts(Hosts hosts, SlaPolicy defaultSlaPolicy, i64 timeoutSecs)") + fmt.Fprintln(os.Stderr, " Response snapshot()") + fmt.Fprintln(os.Stderr, " Response triggerExplicitTaskReconciliation(ExplicitReconciliationSettings settings)") + fmt.Fprintln(os.Stderr, " Response triggerImplicitTaskReconciliation()") + fmt.Fprintln(os.Stderr, " Response pruneTasks(TaskQuery query)") + fmt.Fprintln(os.Stderr, " Response createJob(JobConfiguration description)") + fmt.Fprintln(os.Stderr, " Response scheduleCronJob(JobConfiguration description)") + fmt.Fprintln(os.Stderr, " Response descheduleCronJob(JobKey job)") + fmt.Fprintln(os.Stderr, " Response startCronJob(JobKey job)") + fmt.Fprintln(os.Stderr, " Response restartShards(JobKey job, shardIds)") + fmt.Fprintln(os.Stderr, " Response killTasks(JobKey job, instances, string message)") + fmt.Fprintln(os.Stderr, " Response addInstances(InstanceKey key, i32 count)") + fmt.Fprintln(os.Stderr, " Response replaceCronTemplate(JobConfiguration config)") + fmt.Fprintln(os.Stderr, " Response startJobUpdate(JobUpdateRequest request, string message)") + fmt.Fprintln(os.Stderr, " Response pauseJobUpdate(JobUpdateKey key, string message)") + fmt.Fprintln(os.Stderr, " Response resumeJobUpdate(JobUpdateKey key, string message)") + fmt.Fprintln(os.Stderr, " Response abortJobUpdate(JobUpdateKey key, string message)") + fmt.Fprintln(os.Stderr, " Response rollbackJobUpdate(JobUpdateKey key, string message)") + fmt.Fprintln(os.Stderr, " Response pulseJobUpdate(JobUpdateKey key)") + fmt.Fprintln(os.Stderr, " Response getRoleSummary()") + fmt.Fprintln(os.Stderr, " Response getJobSummary(string role)") + fmt.Fprintln(os.Stderr, " Response getTasksStatus(TaskQuery query)") + fmt.Fprintln(os.Stderr, " Response getTasksWithoutConfigs(TaskQuery query)") + fmt.Fprintln(os.Stderr, " Response getPendingReason(TaskQuery query)") + fmt.Fprintln(os.Stderr, " Response getConfigSummary(JobKey job)") + fmt.Fprintln(os.Stderr, " Response getJobs(string ownerRole)") + fmt.Fprintln(os.Stderr, " Response getQuota(string ownerRole)") + fmt.Fprintln(os.Stderr, " Response populateJobConfig(JobConfiguration description)") + fmt.Fprintln(os.Stderr, " Response getJobUpdateSummaries(JobUpdateQuery jobUpdateQuery)") + fmt.Fprintln(os.Stderr, " Response getJobUpdateDetails(JobUpdateQuery query)") + fmt.Fprintln(os.Stderr, " Response getJobUpdateDiff(JobUpdateRequest request)") + fmt.Fprintln(os.Stderr, " Response getTierConfigs()") + fmt.Fprintln(os.Stderr) + os.Exit(0) +} + +type httpHeaders map[string]string + +func (h httpHeaders) String() string { + var m map[string]string = h + return fmt.Sprintf("%s", m) +} + +func (h httpHeaders) Set(value string) error { + parts := strings.Split(value, ": ") + if len(parts) != 2 { + return fmt.Errorf("header should be of format 'Key: Value'") + } + h[parts[0]] = parts[1] + return nil } func main() { - flag.Usage = Usage - var host string - var port int - var protocol string - var urlString string - var framed bool - var useHttp bool - var parsedUrl url.URL - var trans thrift.TTransport - _ = strconv.Atoi - _ = math.Abs - flag.Usage = Usage - flag.StringVar(&host, "h", "localhost", "Specify host and port") - flag.IntVar(&port, "p", 9090, "Specify port") - flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") - flag.StringVar(&urlString, "u", "", "Specify the url") - flag.BoolVar(&framed, "framed", false, "Use framed transport") - flag.BoolVar(&useHttp, "http", false, "Use http") - flag.Parse() - - if len(urlString) > 0 { - parsedUrl, err := url.Parse(urlString) - if err != nil { - fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) - flag.Usage() - } - host = parsedUrl.Host - useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" - } else if useHttp { - _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) - if err != nil { - fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) - flag.Usage() - } - } - - cmd := flag.Arg(0) - var err error - if useHttp { - trans, err = thrift.NewTHttpClient(parsedUrl.String()) - } else { - portStr := fmt.Sprint(port) - if strings.Contains(host, ":") { - host, portStr, err = net.SplitHostPort(host) - if err != nil { - fmt.Fprintln(os.Stderr, "error with host:", err) - os.Exit(1) - } - } - trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) - if err != nil { - fmt.Fprintln(os.Stderr, "error resolving address:", err) - os.Exit(1) - } - if framed { - trans = thrift.NewTFramedTransport(trans) - } - } - if err != nil { - fmt.Fprintln(os.Stderr, "Error creating transport", err) - os.Exit(1) - } - defer trans.Close() - var protocolFactory thrift.TProtocolFactory - switch protocol { - case "compact": - protocolFactory = thrift.NewTCompactProtocolFactory() - break - case "simplejson": - protocolFactory = thrift.NewTSimpleJSONProtocolFactory() - break - case "json": - protocolFactory = thrift.NewTJSONProtocolFactory() - break - case "binary", "": - protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() - break - default: - fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) - Usage() - os.Exit(1) - } - client := aurora.NewAuroraAdminClientFactory(trans, protocolFactory) - if err := trans.Open(); err != nil { - fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) - os.Exit(1) - } - - switch cmd { - case "setQuota": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "SetQuota requires 2 args") - flag.Usage() - } - argvalue0 := flag.Arg(1) - value0 := argvalue0 - arg352 := flag.Arg(2) - mbTrans353 := thrift.NewTMemoryBufferLen(len(arg352)) - defer mbTrans353.Close() - _, err354 := mbTrans353.WriteString(arg352) - if err354 != nil { - Usage() - return - } - factory355 := thrift.NewTSimpleJSONProtocolFactory() - jsProt356 := factory355.GetProtocol(mbTrans353) - argvalue1 := aurora.NewResourceAggregate() - err357 := argvalue1.Read(jsProt356) - if err357 != nil { - Usage() - return - } - value1 := argvalue1 - fmt.Print(client.SetQuota(value0, value1)) - fmt.Print("\n") - break - case "forceTaskState": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "ForceTaskState requires 2 args") - flag.Usage() - } - argvalue0 := flag.Arg(1) - value0 := argvalue0 - tmp1, err := (strconv.Atoi(flag.Arg(2))) - if err != nil { - Usage() - return - } - argvalue1 := aurora.ScheduleStatus(tmp1) - value1 := argvalue1 - fmt.Print(client.ForceTaskState(value0, value1)) - fmt.Print("\n") - break - case "performBackup": - if flag.NArg()-1 != 0 { - fmt.Fprintln(os.Stderr, "PerformBackup requires 0 args") - flag.Usage() - } - fmt.Print(client.PerformBackup()) - fmt.Print("\n") - break - case "listBackups": - if flag.NArg()-1 != 0 { - fmt.Fprintln(os.Stderr, "ListBackups requires 0 args") - flag.Usage() - } - fmt.Print(client.ListBackups()) - fmt.Print("\n") - break - case "stageRecovery": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "StageRecovery requires 1 args") - flag.Usage() - } - argvalue0 := flag.Arg(1) - value0 := argvalue0 - fmt.Print(client.StageRecovery(value0)) - fmt.Print("\n") - break - case "queryRecovery": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "QueryRecovery requires 1 args") - flag.Usage() - } - arg360 := flag.Arg(1) - mbTrans361 := thrift.NewTMemoryBufferLen(len(arg360)) - defer mbTrans361.Close() - _, err362 := mbTrans361.WriteString(arg360) - if err362 != nil { - Usage() - return - } - factory363 := thrift.NewTSimpleJSONProtocolFactory() - jsProt364 := factory363.GetProtocol(mbTrans361) - argvalue0 := aurora.NewTaskQuery() - err365 := argvalue0.Read(jsProt364) - if err365 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.QueryRecovery(value0)) - fmt.Print("\n") - break - case "deleteRecoveryTasks": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "DeleteRecoveryTasks requires 1 args") - flag.Usage() - } - arg366 := flag.Arg(1) - mbTrans367 := thrift.NewTMemoryBufferLen(len(arg366)) - defer mbTrans367.Close() - _, err368 := mbTrans367.WriteString(arg366) - if err368 != nil { - Usage() - return - } - factory369 := thrift.NewTSimpleJSONProtocolFactory() - jsProt370 := factory369.GetProtocol(mbTrans367) - argvalue0 := aurora.NewTaskQuery() - err371 := argvalue0.Read(jsProt370) - if err371 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.DeleteRecoveryTasks(value0)) - fmt.Print("\n") - break - case "commitRecovery": - if flag.NArg()-1 != 0 { - fmt.Fprintln(os.Stderr, "CommitRecovery requires 0 args") - flag.Usage() - } - fmt.Print(client.CommitRecovery()) - fmt.Print("\n") - break - case "unloadRecovery": - if flag.NArg()-1 != 0 { - fmt.Fprintln(os.Stderr, "UnloadRecovery requires 0 args") - flag.Usage() - } - fmt.Print(client.UnloadRecovery()) - fmt.Print("\n") - break - case "startMaintenance": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "StartMaintenance requires 1 args") - flag.Usage() - } - arg372 := flag.Arg(1) - mbTrans373 := thrift.NewTMemoryBufferLen(len(arg372)) - defer mbTrans373.Close() - _, err374 := mbTrans373.WriteString(arg372) - if err374 != nil { - Usage() - return - } - factory375 := thrift.NewTSimpleJSONProtocolFactory() - jsProt376 := factory375.GetProtocol(mbTrans373) - argvalue0 := aurora.NewHosts() - err377 := argvalue0.Read(jsProt376) - if err377 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.StartMaintenance(value0)) - fmt.Print("\n") - break - case "drainHosts": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "DrainHosts requires 1 args") - flag.Usage() - } - arg378 := flag.Arg(1) - mbTrans379 := thrift.NewTMemoryBufferLen(len(arg378)) - defer mbTrans379.Close() - _, err380 := mbTrans379.WriteString(arg378) - if err380 != nil { - Usage() - return - } - factory381 := thrift.NewTSimpleJSONProtocolFactory() - jsProt382 := factory381.GetProtocol(mbTrans379) - argvalue0 := aurora.NewHosts() - err383 := argvalue0.Read(jsProt382) - if err383 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.DrainHosts(value0)) - fmt.Print("\n") - break - case "maintenanceStatus": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "MaintenanceStatus requires 1 args") - flag.Usage() - } - arg384 := flag.Arg(1) - mbTrans385 := thrift.NewTMemoryBufferLen(len(arg384)) - defer mbTrans385.Close() - _, err386 := mbTrans385.WriteString(arg384) - if err386 != nil { - Usage() - return - } - factory387 := thrift.NewTSimpleJSONProtocolFactory() - jsProt388 := factory387.GetProtocol(mbTrans385) - argvalue0 := aurora.NewHosts() - err389 := argvalue0.Read(jsProt388) - if err389 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.MaintenanceStatus(value0)) - fmt.Print("\n") - break - case "endMaintenance": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "EndMaintenance requires 1 args") - flag.Usage() - } - arg390 := flag.Arg(1) - mbTrans391 := thrift.NewTMemoryBufferLen(len(arg390)) - defer mbTrans391.Close() - _, err392 := mbTrans391.WriteString(arg390) - if err392 != nil { - Usage() - return - } - factory393 := thrift.NewTSimpleJSONProtocolFactory() - jsProt394 := factory393.GetProtocol(mbTrans391) - argvalue0 := aurora.NewHosts() - err395 := argvalue0.Read(jsProt394) - if err395 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.EndMaintenance(value0)) - fmt.Print("\n") - break - case "snapshot": - if flag.NArg()-1 != 0 { - fmt.Fprintln(os.Stderr, "Snapshot requires 0 args") - flag.Usage() - } - fmt.Print(client.Snapshot()) - fmt.Print("\n") - break - case "rewriteConfigs": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "RewriteConfigs requires 1 args") - flag.Usage() - } - arg396 := flag.Arg(1) - mbTrans397 := thrift.NewTMemoryBufferLen(len(arg396)) - defer mbTrans397.Close() - _, err398 := mbTrans397.WriteString(arg396) - if err398 != nil { - Usage() - return - } - factory399 := thrift.NewTSimpleJSONProtocolFactory() - jsProt400 := factory399.GetProtocol(mbTrans397) - argvalue0 := aurora.NewRewriteConfigsRequest() - err401 := argvalue0.Read(jsProt400) - if err401 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.RewriteConfigs(value0)) - fmt.Print("\n") - break - case "triggerExplicitTaskReconciliation": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "TriggerExplicitTaskReconciliation requires 1 args") - flag.Usage() - } - arg402 := flag.Arg(1) - mbTrans403 := thrift.NewTMemoryBufferLen(len(arg402)) - defer mbTrans403.Close() - _, err404 := mbTrans403.WriteString(arg402) - if err404 != nil { - Usage() - return - } - factory405 := thrift.NewTSimpleJSONProtocolFactory() - jsProt406 := factory405.GetProtocol(mbTrans403) - argvalue0 := aurora.NewExplicitReconciliationSettings() - err407 := argvalue0.Read(jsProt406) - if err407 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.TriggerExplicitTaskReconciliation(value0)) - fmt.Print("\n") - break - case "triggerImplicitTaskReconciliation": - if flag.NArg()-1 != 0 { - fmt.Fprintln(os.Stderr, "TriggerImplicitTaskReconciliation requires 0 args") - flag.Usage() - } - fmt.Print(client.TriggerImplicitTaskReconciliation()) - fmt.Print("\n") - break - case "createJob": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "CreateJob requires 1 args") - flag.Usage() - } - arg408 := flag.Arg(1) - mbTrans409 := thrift.NewTMemoryBufferLen(len(arg408)) - defer mbTrans409.Close() - _, err410 := mbTrans409.WriteString(arg408) - if err410 != nil { - Usage() - return - } - factory411 := thrift.NewTSimpleJSONProtocolFactory() - jsProt412 := factory411.GetProtocol(mbTrans409) - argvalue0 := aurora.NewJobConfiguration() - err413 := argvalue0.Read(jsProt412) - if err413 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.CreateJob(value0)) - fmt.Print("\n") - break - case "scheduleCronJob": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "ScheduleCronJob requires 1 args") - flag.Usage() - } - arg414 := flag.Arg(1) - mbTrans415 := thrift.NewTMemoryBufferLen(len(arg414)) - defer mbTrans415.Close() - _, err416 := mbTrans415.WriteString(arg414) - if err416 != nil { - Usage() - return - } - factory417 := thrift.NewTSimpleJSONProtocolFactory() - jsProt418 := factory417.GetProtocol(mbTrans415) - argvalue0 := aurora.NewJobConfiguration() - err419 := argvalue0.Read(jsProt418) - if err419 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.ScheduleCronJob(value0)) - fmt.Print("\n") - break - case "descheduleCronJob": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "DescheduleCronJob requires 1 args") - flag.Usage() - } - arg420 := flag.Arg(1) - mbTrans421 := thrift.NewTMemoryBufferLen(len(arg420)) - defer mbTrans421.Close() - _, err422 := mbTrans421.WriteString(arg420) - if err422 != nil { - Usage() - return - } - factory423 := thrift.NewTSimpleJSONProtocolFactory() - jsProt424 := factory423.GetProtocol(mbTrans421) - argvalue0 := aurora.NewJobKey() - err425 := argvalue0.Read(jsProt424) - if err425 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.DescheduleCronJob(value0)) - fmt.Print("\n") - break - case "startCronJob": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "StartCronJob requires 1 args") - flag.Usage() - } - arg426 := flag.Arg(1) - mbTrans427 := thrift.NewTMemoryBufferLen(len(arg426)) - defer mbTrans427.Close() - _, err428 := mbTrans427.WriteString(arg426) - if err428 != nil { - Usage() - return - } - factory429 := thrift.NewTSimpleJSONProtocolFactory() - jsProt430 := factory429.GetProtocol(mbTrans427) - argvalue0 := aurora.NewJobKey() - err431 := argvalue0.Read(jsProt430) - if err431 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.StartCronJob(value0)) - fmt.Print("\n") - break - case "restartShards": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "RestartShards requires 2 args") - flag.Usage() - } - arg432 := flag.Arg(1) - mbTrans433 := thrift.NewTMemoryBufferLen(len(arg432)) - defer mbTrans433.Close() - _, err434 := mbTrans433.WriteString(arg432) - if err434 != nil { - Usage() - return - } - factory435 := thrift.NewTSimpleJSONProtocolFactory() - jsProt436 := factory435.GetProtocol(mbTrans433) - argvalue0 := aurora.NewJobKey() - err437 := argvalue0.Read(jsProt436) - if err437 != nil { - Usage() - return - } - value0 := argvalue0 - arg438 := flag.Arg(2) - mbTrans439 := thrift.NewTMemoryBufferLen(len(arg438)) - defer mbTrans439.Close() - _, err440 := mbTrans439.WriteString(arg438) - if err440 != nil { - Usage() - return - } - factory441 := thrift.NewTSimpleJSONProtocolFactory() - jsProt442 := factory441.GetProtocol(mbTrans439) - containerStruct1 := aurora.NewAuroraAdminRestartShardsArgs() - err443 := containerStruct1.ReadField2(jsProt442) - if err443 != nil { - Usage() - return - } - argvalue1 := containerStruct1.ShardIds - value1 := argvalue1 - fmt.Print(client.RestartShards(value0, value1)) - fmt.Print("\n") - break - case "killTasks": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "KillTasks requires 2 args") - flag.Usage() - } - arg444 := flag.Arg(1) - mbTrans445 := thrift.NewTMemoryBufferLen(len(arg444)) - defer mbTrans445.Close() - _, err446 := mbTrans445.WriteString(arg444) - if err446 != nil { - Usage() - return - } - factory447 := thrift.NewTSimpleJSONProtocolFactory() - jsProt448 := factory447.GetProtocol(mbTrans445) - argvalue0 := aurora.NewJobKey() - err449 := argvalue0.Read(jsProt448) - if err449 != nil { - Usage() - return - } - value0 := argvalue0 - arg450 := flag.Arg(2) - mbTrans451 := thrift.NewTMemoryBufferLen(len(arg450)) - defer mbTrans451.Close() - _, err452 := mbTrans451.WriteString(arg450) - if err452 != nil { - Usage() - return - } - factory453 := thrift.NewTSimpleJSONProtocolFactory() - jsProt454 := factory453.GetProtocol(mbTrans451) - containerStruct1 := aurora.NewAuroraAdminKillTasksArgs() - err455 := containerStruct1.ReadField2(jsProt454) - if err455 != nil { - Usage() - return - } - argvalue1 := containerStruct1.Instances - value1 := argvalue1 - fmt.Print(client.KillTasks(value0, value1)) - fmt.Print("\n") - break - case "addInstances": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "AddInstances requires 2 args") - flag.Usage() - } - arg456 := flag.Arg(1) - mbTrans457 := thrift.NewTMemoryBufferLen(len(arg456)) - defer mbTrans457.Close() - _, err458 := mbTrans457.WriteString(arg456) - if err458 != nil { - Usage() - return - } - factory459 := thrift.NewTSimpleJSONProtocolFactory() - jsProt460 := factory459.GetProtocol(mbTrans457) - argvalue0 := aurora.NewInstanceKey() - err461 := argvalue0.Read(jsProt460) - if err461 != nil { - Usage() - return - } - value0 := argvalue0 - tmp1, err462 := (strconv.Atoi(flag.Arg(2))) - if err462 != nil { - Usage() - return - } - argvalue1 := int32(tmp1) - value1 := argvalue1 - fmt.Print(client.AddInstances(value0, value1)) - fmt.Print("\n") - break - case "replaceCronTemplate": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "ReplaceCronTemplate requires 1 args") - flag.Usage() - } - arg463 := flag.Arg(1) - mbTrans464 := thrift.NewTMemoryBufferLen(len(arg463)) - defer mbTrans464.Close() - _, err465 := mbTrans464.WriteString(arg463) - if err465 != nil { - Usage() - return - } - factory466 := thrift.NewTSimpleJSONProtocolFactory() - jsProt467 := factory466.GetProtocol(mbTrans464) - argvalue0 := aurora.NewJobConfiguration() - err468 := argvalue0.Read(jsProt467) - if err468 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.ReplaceCronTemplate(value0)) - fmt.Print("\n") - break - case "startJobUpdate": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "StartJobUpdate requires 2 args") - flag.Usage() - } - arg469 := flag.Arg(1) - mbTrans470 := thrift.NewTMemoryBufferLen(len(arg469)) - defer mbTrans470.Close() - _, err471 := mbTrans470.WriteString(arg469) - if err471 != nil { - Usage() - return - } - factory472 := thrift.NewTSimpleJSONProtocolFactory() - jsProt473 := factory472.GetProtocol(mbTrans470) - argvalue0 := aurora.NewJobUpdateRequest() - err474 := argvalue0.Read(jsProt473) - if err474 != nil { - Usage() - return - } - value0 := argvalue0 - argvalue1 := flag.Arg(2) - value1 := argvalue1 - fmt.Print(client.StartJobUpdate(value0, value1)) - fmt.Print("\n") - break - case "pauseJobUpdate": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "PauseJobUpdate requires 2 args") - flag.Usage() - } - arg476 := flag.Arg(1) - mbTrans477 := thrift.NewTMemoryBufferLen(len(arg476)) - defer mbTrans477.Close() - _, err478 := mbTrans477.WriteString(arg476) - if err478 != nil { - Usage() - return - } - factory479 := thrift.NewTSimpleJSONProtocolFactory() - jsProt480 := factory479.GetProtocol(mbTrans477) - argvalue0 := aurora.NewJobUpdateKey() - err481 := argvalue0.Read(jsProt480) - if err481 != nil { - Usage() - return - } - value0 := argvalue0 - argvalue1 := flag.Arg(2) - value1 := argvalue1 - fmt.Print(client.PauseJobUpdate(value0, value1)) - fmt.Print("\n") - break - case "resumeJobUpdate": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "ResumeJobUpdate requires 2 args") - flag.Usage() - } - arg483 := flag.Arg(1) - mbTrans484 := thrift.NewTMemoryBufferLen(len(arg483)) - defer mbTrans484.Close() - _, err485 := mbTrans484.WriteString(arg483) - if err485 != nil { - Usage() - return - } - factory486 := thrift.NewTSimpleJSONProtocolFactory() - jsProt487 := factory486.GetProtocol(mbTrans484) - argvalue0 := aurora.NewJobUpdateKey() - err488 := argvalue0.Read(jsProt487) - if err488 != nil { - Usage() - return - } - value0 := argvalue0 - argvalue1 := flag.Arg(2) - value1 := argvalue1 - fmt.Print(client.ResumeJobUpdate(value0, value1)) - fmt.Print("\n") - break - case "abortJobUpdate": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "AbortJobUpdate requires 2 args") - flag.Usage() - } - arg490 := flag.Arg(1) - mbTrans491 := thrift.NewTMemoryBufferLen(len(arg490)) - defer mbTrans491.Close() - _, err492 := mbTrans491.WriteString(arg490) - if err492 != nil { - Usage() - return - } - factory493 := thrift.NewTSimpleJSONProtocolFactory() - jsProt494 := factory493.GetProtocol(mbTrans491) - argvalue0 := aurora.NewJobUpdateKey() - err495 := argvalue0.Read(jsProt494) - if err495 != nil { - Usage() - return - } - value0 := argvalue0 - argvalue1 := flag.Arg(2) - value1 := argvalue1 - fmt.Print(client.AbortJobUpdate(value0, value1)) - fmt.Print("\n") - break - case "rollbackJobUpdate": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "RollbackJobUpdate requires 2 args") - flag.Usage() - } - arg497 := flag.Arg(1) - mbTrans498 := thrift.NewTMemoryBufferLen(len(arg497)) - defer mbTrans498.Close() - _, err499 := mbTrans498.WriteString(arg497) - if err499 != nil { - Usage() - return - } - factory500 := thrift.NewTSimpleJSONProtocolFactory() - jsProt501 := factory500.GetProtocol(mbTrans498) - argvalue0 := aurora.NewJobUpdateKey() - err502 := argvalue0.Read(jsProt501) - if err502 != nil { - Usage() - return - } - value0 := argvalue0 - argvalue1 := flag.Arg(2) - value1 := argvalue1 - fmt.Print(client.RollbackJobUpdate(value0, value1)) - fmt.Print("\n") - break - case "pulseJobUpdate": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "PulseJobUpdate requires 1 args") - flag.Usage() - } - arg504 := flag.Arg(1) - mbTrans505 := thrift.NewTMemoryBufferLen(len(arg504)) - defer mbTrans505.Close() - _, err506 := mbTrans505.WriteString(arg504) - if err506 != nil { - Usage() - return - } - factory507 := thrift.NewTSimpleJSONProtocolFactory() - jsProt508 := factory507.GetProtocol(mbTrans505) - argvalue0 := aurora.NewJobUpdateKey() - err509 := argvalue0.Read(jsProt508) - if err509 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.PulseJobUpdate(value0)) - fmt.Print("\n") - break - case "getRoleSummary": - if flag.NArg()-1 != 0 { - fmt.Fprintln(os.Stderr, "GetRoleSummary requires 0 args") - flag.Usage() - } - fmt.Print(client.GetRoleSummary()) - fmt.Print("\n") - break - case "getJobSummary": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetJobSummary requires 1 args") - flag.Usage() - } - argvalue0 := flag.Arg(1) - value0 := argvalue0 - fmt.Print(client.GetJobSummary(value0)) - fmt.Print("\n") - break - case "getTasksStatus": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetTasksStatus requires 1 args") - flag.Usage() - } - arg511 := flag.Arg(1) - mbTrans512 := thrift.NewTMemoryBufferLen(len(arg511)) - defer mbTrans512.Close() - _, err513 := mbTrans512.WriteString(arg511) - if err513 != nil { - Usage() - return - } - factory514 := thrift.NewTSimpleJSONProtocolFactory() - jsProt515 := factory514.GetProtocol(mbTrans512) - argvalue0 := aurora.NewTaskQuery() - err516 := argvalue0.Read(jsProt515) - if err516 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetTasksStatus(value0)) - fmt.Print("\n") - break - case "getTasksWithoutConfigs": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetTasksWithoutConfigs requires 1 args") - flag.Usage() - } - arg517 := flag.Arg(1) - mbTrans518 := thrift.NewTMemoryBufferLen(len(arg517)) - defer mbTrans518.Close() - _, err519 := mbTrans518.WriteString(arg517) - if err519 != nil { - Usage() - return - } - factory520 := thrift.NewTSimpleJSONProtocolFactory() - jsProt521 := factory520.GetProtocol(mbTrans518) - argvalue0 := aurora.NewTaskQuery() - err522 := argvalue0.Read(jsProt521) - if err522 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetTasksWithoutConfigs(value0)) - fmt.Print("\n") - break - case "getPendingReason": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetPendingReason requires 1 args") - flag.Usage() - } - arg523 := flag.Arg(1) - mbTrans524 := thrift.NewTMemoryBufferLen(len(arg523)) - defer mbTrans524.Close() - _, err525 := mbTrans524.WriteString(arg523) - if err525 != nil { - Usage() - return - } - factory526 := thrift.NewTSimpleJSONProtocolFactory() - jsProt527 := factory526.GetProtocol(mbTrans524) - argvalue0 := aurora.NewTaskQuery() - err528 := argvalue0.Read(jsProt527) - if err528 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetPendingReason(value0)) - fmt.Print("\n") - break - case "getConfigSummary": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetConfigSummary requires 1 args") - flag.Usage() - } - arg529 := flag.Arg(1) - mbTrans530 := thrift.NewTMemoryBufferLen(len(arg529)) - defer mbTrans530.Close() - _, err531 := mbTrans530.WriteString(arg529) - if err531 != nil { - Usage() - return - } - factory532 := thrift.NewTSimpleJSONProtocolFactory() - jsProt533 := factory532.GetProtocol(mbTrans530) - argvalue0 := aurora.NewJobKey() - err534 := argvalue0.Read(jsProt533) - if err534 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetConfigSummary(value0)) - fmt.Print("\n") - break - case "getJobs": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetJobs requires 1 args") - flag.Usage() - } - argvalue0 := flag.Arg(1) - value0 := argvalue0 - fmt.Print(client.GetJobs(value0)) - fmt.Print("\n") - break - case "getQuota": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetQuota requires 1 args") - flag.Usage() - } - argvalue0 := flag.Arg(1) - value0 := argvalue0 - fmt.Print(client.GetQuota(value0)) - fmt.Print("\n") - break - case "populateJobConfig": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "PopulateJobConfig requires 1 args") - flag.Usage() - } - arg537 := flag.Arg(1) - mbTrans538 := thrift.NewTMemoryBufferLen(len(arg537)) - defer mbTrans538.Close() - _, err539 := mbTrans538.WriteString(arg537) - if err539 != nil { - Usage() - return - } - factory540 := thrift.NewTSimpleJSONProtocolFactory() - jsProt541 := factory540.GetProtocol(mbTrans538) - argvalue0 := aurora.NewJobConfiguration() - err542 := argvalue0.Read(jsProt541) - if err542 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.PopulateJobConfig(value0)) - fmt.Print("\n") - break - case "getJobUpdateSummaries": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetJobUpdateSummaries requires 1 args") - flag.Usage() - } - arg543 := flag.Arg(1) - mbTrans544 := thrift.NewTMemoryBufferLen(len(arg543)) - defer mbTrans544.Close() - _, err545 := mbTrans544.WriteString(arg543) - if err545 != nil { - Usage() - return - } - factory546 := thrift.NewTSimpleJSONProtocolFactory() - jsProt547 := factory546.GetProtocol(mbTrans544) - argvalue0 := aurora.NewJobUpdateQuery() - err548 := argvalue0.Read(jsProt547) - if err548 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetJobUpdateSummaries(value0)) - fmt.Print("\n") - break - case "getJobUpdateDetails": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetJobUpdateDetails requires 1 args") - flag.Usage() - } - arg549 := flag.Arg(1) - mbTrans550 := thrift.NewTMemoryBufferLen(len(arg549)) - defer mbTrans550.Close() - _, err551 := mbTrans550.WriteString(arg549) - if err551 != nil { - Usage() - return - } - factory552 := thrift.NewTSimpleJSONProtocolFactory() - jsProt553 := factory552.GetProtocol(mbTrans550) - argvalue0 := aurora.NewJobUpdateQuery() - err554 := argvalue0.Read(jsProt553) - if err554 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetJobUpdateDetails(value0)) - fmt.Print("\n") - break - case "getJobUpdateDiff": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetJobUpdateDiff requires 1 args") - flag.Usage() - } - arg555 := flag.Arg(1) - mbTrans556 := thrift.NewTMemoryBufferLen(len(arg555)) - defer mbTrans556.Close() - _, err557 := mbTrans556.WriteString(arg555) - if err557 != nil { - Usage() - return - } - factory558 := thrift.NewTSimpleJSONProtocolFactory() - jsProt559 := factory558.GetProtocol(mbTrans556) - argvalue0 := aurora.NewJobUpdateRequest() - err560 := argvalue0.Read(jsProt559) - if err560 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetJobUpdateDiff(value0)) - fmt.Print("\n") - break - case "getTierConfigs": - if flag.NArg()-1 != 0 { - fmt.Fprintln(os.Stderr, "GetTierConfigs requires 0 args") - flag.Usage() - } - fmt.Print(client.GetTierConfigs()) - fmt.Print("\n") - break - case "": - Usage() - break - default: - fmt.Fprintln(os.Stderr, "Invalid function ", cmd) - } + flag.Usage = Usage + var host string + var port int + var protocol string + var urlString string + var framed bool + var useHttp bool + headers := make(httpHeaders) + var parsedUrl *url.URL + var trans thrift.TTransport + _ = strconv.Atoi + _ = math.Abs + flag.Usage = Usage + flag.StringVar(&host, "h", "localhost", "Specify host and port") + flag.IntVar(&port, "p", 9090, "Specify port") + flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") + flag.StringVar(&urlString, "u", "", "Specify the url") + flag.BoolVar(&framed, "framed", false, "Use framed transport") + flag.BoolVar(&useHttp, "http", false, "Use http") + flag.Var(headers, "H", "Headers to set on the http(s) request (e.g. -H \"Key: Value\")") + flag.Parse() + + if len(urlString) > 0 { + var err error + parsedUrl, err = url.Parse(urlString) + if err != nil { + fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) + flag.Usage() + } + host = parsedUrl.Host + useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" || parsedUrl.Scheme == "https" + } else if useHttp { + _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) + if err != nil { + fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) + flag.Usage() + } + } + + cmd := flag.Arg(0) + var err error + if useHttp { + trans, err = thrift.NewTHttpClient(parsedUrl.String()) + if len(headers) > 0 { + httptrans := trans.(*thrift.THttpClient) + for key, value := range headers { + httptrans.SetHeader(key, value) + } + } + } else { + portStr := fmt.Sprint(port) + if strings.Contains(host, ":") { + host, portStr, err = net.SplitHostPort(host) + if err != nil { + fmt.Fprintln(os.Stderr, "error with host:", err) + os.Exit(1) + } + } + trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) + if err != nil { + fmt.Fprintln(os.Stderr, "error resolving address:", err) + os.Exit(1) + } + if framed { + trans = thrift.NewTFramedTransport(trans) + } + } + if err != nil { + fmt.Fprintln(os.Stderr, "Error creating transport", err) + os.Exit(1) + } + defer trans.Close() + var protocolFactory thrift.TProtocolFactory + switch protocol { + case "compact": + protocolFactory = thrift.NewTCompactProtocolFactory() + break + case "simplejson": + protocolFactory = thrift.NewTSimpleJSONProtocolFactory() + break + case "json": + protocolFactory = thrift.NewTJSONProtocolFactory() + break + case "binary", "": + protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() + break + default: + fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) + Usage() + os.Exit(1) + } + iprot := protocolFactory.GetProtocol(trans) + oprot := protocolFactory.GetProtocol(trans) + client := aurora.NewAuroraAdminClient(thrift.NewTStandardClient(iprot, oprot)) + if err := trans.Open(); err != nil { + fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) + os.Exit(1) + } + + switch cmd { + case "setQuota": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "SetQuota requires 2 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + arg405 := flag.Arg(2) + mbTrans406 := thrift.NewTMemoryBufferLen(len(arg405)) + defer mbTrans406.Close() + _, err407 := mbTrans406.WriteString(arg405) + if err407 != nil { + Usage() + return + } + factory408 := thrift.NewTJSONProtocolFactory() + jsProt409 := factory408.GetProtocol(mbTrans406) + argvalue1 := aurora.NewResourceAggregate() + err410 := argvalue1.Read(context.Background(), jsProt409) + if err410 != nil { + Usage() + return + } + value1 := argvalue1 + fmt.Print(client.SetQuota(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "forceTaskState": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "ForceTaskState requires 2 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + tmp1, err := (strconv.Atoi(flag.Arg(2))) + if err != nil { + Usage() + return + } + argvalue1 := aurora.ScheduleStatus(tmp1) + value1 := argvalue1 + fmt.Print(client.ForceTaskState(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "performBackup": + if flag.NArg() - 1 != 0 { + fmt.Fprintln(os.Stderr, "PerformBackup requires 0 args") + flag.Usage() + } + fmt.Print(client.PerformBackup(context.Background())) + fmt.Print("\n") + break + case "listBackups": + if flag.NArg() - 1 != 0 { + fmt.Fprintln(os.Stderr, "ListBackups requires 0 args") + flag.Usage() + } + fmt.Print(client.ListBackups(context.Background())) + fmt.Print("\n") + break + case "stageRecovery": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "StageRecovery requires 1 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + fmt.Print(client.StageRecovery(context.Background(), value0)) + fmt.Print("\n") + break + case "queryRecovery": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "QueryRecovery requires 1 args") + flag.Usage() + } + arg413 := flag.Arg(1) + mbTrans414 := thrift.NewTMemoryBufferLen(len(arg413)) + defer mbTrans414.Close() + _, err415 := mbTrans414.WriteString(arg413) + if err415 != nil { + Usage() + return + } + factory416 := thrift.NewTJSONProtocolFactory() + jsProt417 := factory416.GetProtocol(mbTrans414) + argvalue0 := aurora.NewTaskQuery() + err418 := argvalue0.Read(context.Background(), jsProt417) + if err418 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.QueryRecovery(context.Background(), value0)) + fmt.Print("\n") + break + case "deleteRecoveryTasks": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "DeleteRecoveryTasks requires 1 args") + flag.Usage() + } + arg419 := flag.Arg(1) + mbTrans420 := thrift.NewTMemoryBufferLen(len(arg419)) + defer mbTrans420.Close() + _, err421 := mbTrans420.WriteString(arg419) + if err421 != nil { + Usage() + return + } + factory422 := thrift.NewTJSONProtocolFactory() + jsProt423 := factory422.GetProtocol(mbTrans420) + argvalue0 := aurora.NewTaskQuery() + err424 := argvalue0.Read(context.Background(), jsProt423) + if err424 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.DeleteRecoveryTasks(context.Background(), value0)) + fmt.Print("\n") + break + case "commitRecovery": + if flag.NArg() - 1 != 0 { + fmt.Fprintln(os.Stderr, "CommitRecovery requires 0 args") + flag.Usage() + } + fmt.Print(client.CommitRecovery(context.Background())) + fmt.Print("\n") + break + case "unloadRecovery": + if flag.NArg() - 1 != 0 { + fmt.Fprintln(os.Stderr, "UnloadRecovery requires 0 args") + flag.Usage() + } + fmt.Print(client.UnloadRecovery(context.Background())) + fmt.Print("\n") + break + case "startMaintenance": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "StartMaintenance requires 1 args") + flag.Usage() + } + arg425 := flag.Arg(1) + mbTrans426 := thrift.NewTMemoryBufferLen(len(arg425)) + defer mbTrans426.Close() + _, err427 := mbTrans426.WriteString(arg425) + if err427 != nil { + Usage() + return + } + factory428 := thrift.NewTJSONProtocolFactory() + jsProt429 := factory428.GetProtocol(mbTrans426) + argvalue0 := aurora.NewHosts() + err430 := argvalue0.Read(context.Background(), jsProt429) + if err430 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.StartMaintenance(context.Background(), value0)) + fmt.Print("\n") + break + case "drainHosts": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "DrainHosts requires 1 args") + flag.Usage() + } + arg431 := flag.Arg(1) + mbTrans432 := thrift.NewTMemoryBufferLen(len(arg431)) + defer mbTrans432.Close() + _, err433 := mbTrans432.WriteString(arg431) + if err433 != nil { + Usage() + return + } + factory434 := thrift.NewTJSONProtocolFactory() + jsProt435 := factory434.GetProtocol(mbTrans432) + argvalue0 := aurora.NewHosts() + err436 := argvalue0.Read(context.Background(), jsProt435) + if err436 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.DrainHosts(context.Background(), value0)) + fmt.Print("\n") + break + case "maintenanceStatus": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "MaintenanceStatus requires 1 args") + flag.Usage() + } + arg437 := flag.Arg(1) + mbTrans438 := thrift.NewTMemoryBufferLen(len(arg437)) + defer mbTrans438.Close() + _, err439 := mbTrans438.WriteString(arg437) + if err439 != nil { + Usage() + return + } + factory440 := thrift.NewTJSONProtocolFactory() + jsProt441 := factory440.GetProtocol(mbTrans438) + argvalue0 := aurora.NewHosts() + err442 := argvalue0.Read(context.Background(), jsProt441) + if err442 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.MaintenanceStatus(context.Background(), value0)) + fmt.Print("\n") + break + case "endMaintenance": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "EndMaintenance requires 1 args") + flag.Usage() + } + arg443 := flag.Arg(1) + mbTrans444 := thrift.NewTMemoryBufferLen(len(arg443)) + defer mbTrans444.Close() + _, err445 := mbTrans444.WriteString(arg443) + if err445 != nil { + Usage() + return + } + factory446 := thrift.NewTJSONProtocolFactory() + jsProt447 := factory446.GetProtocol(mbTrans444) + argvalue0 := aurora.NewHosts() + err448 := argvalue0.Read(context.Background(), jsProt447) + if err448 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.EndMaintenance(context.Background(), value0)) + fmt.Print("\n") + break + case "slaDrainHosts": + if flag.NArg() - 1 != 3 { + fmt.Fprintln(os.Stderr, "SlaDrainHosts requires 3 args") + flag.Usage() + } + arg449 := flag.Arg(1) + mbTrans450 := thrift.NewTMemoryBufferLen(len(arg449)) + defer mbTrans450.Close() + _, err451 := mbTrans450.WriteString(arg449) + if err451 != nil { + Usage() + return + } + factory452 := thrift.NewTJSONProtocolFactory() + jsProt453 := factory452.GetProtocol(mbTrans450) + argvalue0 := aurora.NewHosts() + err454 := argvalue0.Read(context.Background(), jsProt453) + if err454 != nil { + Usage() + return + } + value0 := argvalue0 + arg455 := flag.Arg(2) + mbTrans456 := thrift.NewTMemoryBufferLen(len(arg455)) + defer mbTrans456.Close() + _, err457 := mbTrans456.WriteString(arg455) + if err457 != nil { + Usage() + return + } + factory458 := thrift.NewTJSONProtocolFactory() + jsProt459 := factory458.GetProtocol(mbTrans456) + argvalue1 := aurora.NewSlaPolicy() + err460 := argvalue1.Read(context.Background(), jsProt459) + if err460 != nil { + Usage() + return + } + value1 := argvalue1 + argvalue2, err461 := (strconv.ParseInt(flag.Arg(3), 10, 64)) + if err461 != nil { + Usage() + return + } + value2 := argvalue2 + fmt.Print(client.SlaDrainHosts(context.Background(), value0, value1, value2)) + fmt.Print("\n") + break + case "snapshot": + if flag.NArg() - 1 != 0 { + fmt.Fprintln(os.Stderr, "Snapshot requires 0 args") + flag.Usage() + } + fmt.Print(client.Snapshot(context.Background())) + fmt.Print("\n") + break + case "triggerExplicitTaskReconciliation": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "TriggerExplicitTaskReconciliation requires 1 args") + flag.Usage() + } + arg462 := flag.Arg(1) + mbTrans463 := thrift.NewTMemoryBufferLen(len(arg462)) + defer mbTrans463.Close() + _, err464 := mbTrans463.WriteString(arg462) + if err464 != nil { + Usage() + return + } + factory465 := thrift.NewTJSONProtocolFactory() + jsProt466 := factory465.GetProtocol(mbTrans463) + argvalue0 := aurora.NewExplicitReconciliationSettings() + err467 := argvalue0.Read(context.Background(), jsProt466) + if err467 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.TriggerExplicitTaskReconciliation(context.Background(), value0)) + fmt.Print("\n") + break + case "triggerImplicitTaskReconciliation": + if flag.NArg() - 1 != 0 { + fmt.Fprintln(os.Stderr, "TriggerImplicitTaskReconciliation requires 0 args") + flag.Usage() + } + fmt.Print(client.TriggerImplicitTaskReconciliation(context.Background())) + fmt.Print("\n") + break + case "pruneTasks": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "PruneTasks requires 1 args") + flag.Usage() + } + arg468 := flag.Arg(1) + mbTrans469 := thrift.NewTMemoryBufferLen(len(arg468)) + defer mbTrans469.Close() + _, err470 := mbTrans469.WriteString(arg468) + if err470 != nil { + Usage() + return + } + factory471 := thrift.NewTJSONProtocolFactory() + jsProt472 := factory471.GetProtocol(mbTrans469) + argvalue0 := aurora.NewTaskQuery() + err473 := argvalue0.Read(context.Background(), jsProt472) + if err473 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.PruneTasks(context.Background(), value0)) + fmt.Print("\n") + break + case "createJob": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "CreateJob requires 1 args") + flag.Usage() + } + arg474 := flag.Arg(1) + mbTrans475 := thrift.NewTMemoryBufferLen(len(arg474)) + defer mbTrans475.Close() + _, err476 := mbTrans475.WriteString(arg474) + if err476 != nil { + Usage() + return + } + factory477 := thrift.NewTJSONProtocolFactory() + jsProt478 := factory477.GetProtocol(mbTrans475) + argvalue0 := aurora.NewJobConfiguration() + err479 := argvalue0.Read(context.Background(), jsProt478) + if err479 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.CreateJob(context.Background(), value0)) + fmt.Print("\n") + break + case "scheduleCronJob": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "ScheduleCronJob requires 1 args") + flag.Usage() + } + arg480 := flag.Arg(1) + mbTrans481 := thrift.NewTMemoryBufferLen(len(arg480)) + defer mbTrans481.Close() + _, err482 := mbTrans481.WriteString(arg480) + if err482 != nil { + Usage() + return + } + factory483 := thrift.NewTJSONProtocolFactory() + jsProt484 := factory483.GetProtocol(mbTrans481) + argvalue0 := aurora.NewJobConfiguration() + err485 := argvalue0.Read(context.Background(), jsProt484) + if err485 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.ScheduleCronJob(context.Background(), value0)) + fmt.Print("\n") + break + case "descheduleCronJob": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "DescheduleCronJob requires 1 args") + flag.Usage() + } + arg486 := flag.Arg(1) + mbTrans487 := thrift.NewTMemoryBufferLen(len(arg486)) + defer mbTrans487.Close() + _, err488 := mbTrans487.WriteString(arg486) + if err488 != nil { + Usage() + return + } + factory489 := thrift.NewTJSONProtocolFactory() + jsProt490 := factory489.GetProtocol(mbTrans487) + argvalue0 := aurora.NewJobKey() + err491 := argvalue0.Read(context.Background(), jsProt490) + if err491 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.DescheduleCronJob(context.Background(), value0)) + fmt.Print("\n") + break + case "startCronJob": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "StartCronJob requires 1 args") + flag.Usage() + } + arg492 := flag.Arg(1) + mbTrans493 := thrift.NewTMemoryBufferLen(len(arg492)) + defer mbTrans493.Close() + _, err494 := mbTrans493.WriteString(arg492) + if err494 != nil { + Usage() + return + } + factory495 := thrift.NewTJSONProtocolFactory() + jsProt496 := factory495.GetProtocol(mbTrans493) + argvalue0 := aurora.NewJobKey() + err497 := argvalue0.Read(context.Background(), jsProt496) + if err497 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.StartCronJob(context.Background(), value0)) + fmt.Print("\n") + break + case "restartShards": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "RestartShards requires 2 args") + flag.Usage() + } + arg498 := flag.Arg(1) + mbTrans499 := thrift.NewTMemoryBufferLen(len(arg498)) + defer mbTrans499.Close() + _, err500 := mbTrans499.WriteString(arg498) + if err500 != nil { + Usage() + return + } + factory501 := thrift.NewTJSONProtocolFactory() + jsProt502 := factory501.GetProtocol(mbTrans499) + argvalue0 := aurora.NewJobKey() + err503 := argvalue0.Read(context.Background(), jsProt502) + if err503 != nil { + Usage() + return + } + value0 := argvalue0 + arg504 := flag.Arg(2) + mbTrans505 := thrift.NewTMemoryBufferLen(len(arg504)) + defer mbTrans505.Close() + _, err506 := mbTrans505.WriteString(arg504) + if err506 != nil { + Usage() + return + } + factory507 := thrift.NewTJSONProtocolFactory() + jsProt508 := factory507.GetProtocol(mbTrans505) + containerStruct1 := aurora.NewAuroraSchedulerManagerRestartShardsArgs() + err509 := containerStruct1.ReadField2(context.Background(), jsProt508) + if err509 != nil { + Usage() + return + } + argvalue1 := containerStruct1.ShardIds + value1 := argvalue1 + fmt.Print(client.RestartShards(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "killTasks": + if flag.NArg() - 1 != 3 { + fmt.Fprintln(os.Stderr, "KillTasks requires 3 args") + flag.Usage() + } + arg510 := flag.Arg(1) + mbTrans511 := thrift.NewTMemoryBufferLen(len(arg510)) + defer mbTrans511.Close() + _, err512 := mbTrans511.WriteString(arg510) + if err512 != nil { + Usage() + return + } + factory513 := thrift.NewTJSONProtocolFactory() + jsProt514 := factory513.GetProtocol(mbTrans511) + argvalue0 := aurora.NewJobKey() + err515 := argvalue0.Read(context.Background(), jsProt514) + if err515 != nil { + Usage() + return + } + value0 := argvalue0 + arg516 := flag.Arg(2) + mbTrans517 := thrift.NewTMemoryBufferLen(len(arg516)) + defer mbTrans517.Close() + _, err518 := mbTrans517.WriteString(arg516) + if err518 != nil { + Usage() + return + } + factory519 := thrift.NewTJSONProtocolFactory() + jsProt520 := factory519.GetProtocol(mbTrans517) + containerStruct1 := aurora.NewAuroraSchedulerManagerKillTasksArgs() + err521 := containerStruct1.ReadField2(context.Background(), jsProt520) + if err521 != nil { + Usage() + return + } + argvalue1 := containerStruct1.Instances + value1 := argvalue1 + argvalue2 := flag.Arg(3) + value2 := argvalue2 + fmt.Print(client.KillTasks(context.Background(), value0, value1, value2)) + fmt.Print("\n") + break + case "addInstances": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "AddInstances requires 2 args") + flag.Usage() + } + arg523 := flag.Arg(1) + mbTrans524 := thrift.NewTMemoryBufferLen(len(arg523)) + defer mbTrans524.Close() + _, err525 := mbTrans524.WriteString(arg523) + if err525 != nil { + Usage() + return + } + factory526 := thrift.NewTJSONProtocolFactory() + jsProt527 := factory526.GetProtocol(mbTrans524) + argvalue0 := aurora.NewInstanceKey() + err528 := argvalue0.Read(context.Background(), jsProt527) + if err528 != nil { + Usage() + return + } + value0 := argvalue0 + tmp1, err529 := (strconv.Atoi(flag.Arg(2))) + if err529 != nil { + Usage() + return + } + argvalue1 := int32(tmp1) + value1 := argvalue1 + fmt.Print(client.AddInstances(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "replaceCronTemplate": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "ReplaceCronTemplate requires 1 args") + flag.Usage() + } + arg530 := flag.Arg(1) + mbTrans531 := thrift.NewTMemoryBufferLen(len(arg530)) + defer mbTrans531.Close() + _, err532 := mbTrans531.WriteString(arg530) + if err532 != nil { + Usage() + return + } + factory533 := thrift.NewTJSONProtocolFactory() + jsProt534 := factory533.GetProtocol(mbTrans531) + argvalue0 := aurora.NewJobConfiguration() + err535 := argvalue0.Read(context.Background(), jsProt534) + if err535 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.ReplaceCronTemplate(context.Background(), value0)) + fmt.Print("\n") + break + case "startJobUpdate": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "StartJobUpdate requires 2 args") + flag.Usage() + } + arg536 := flag.Arg(1) + mbTrans537 := thrift.NewTMemoryBufferLen(len(arg536)) + defer mbTrans537.Close() + _, err538 := mbTrans537.WriteString(arg536) + if err538 != nil { + Usage() + return + } + factory539 := thrift.NewTJSONProtocolFactory() + jsProt540 := factory539.GetProtocol(mbTrans537) + argvalue0 := aurora.NewJobUpdateRequest() + err541 := argvalue0.Read(context.Background(), jsProt540) + if err541 != nil { + Usage() + return + } + value0 := argvalue0 + argvalue1 := flag.Arg(2) + value1 := argvalue1 + fmt.Print(client.StartJobUpdate(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "pauseJobUpdate": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "PauseJobUpdate requires 2 args") + flag.Usage() + } + arg543 := flag.Arg(1) + mbTrans544 := thrift.NewTMemoryBufferLen(len(arg543)) + defer mbTrans544.Close() + _, err545 := mbTrans544.WriteString(arg543) + if err545 != nil { + Usage() + return + } + factory546 := thrift.NewTJSONProtocolFactory() + jsProt547 := factory546.GetProtocol(mbTrans544) + argvalue0 := aurora.NewJobUpdateKey() + err548 := argvalue0.Read(context.Background(), jsProt547) + if err548 != nil { + Usage() + return + } + value0 := argvalue0 + argvalue1 := flag.Arg(2) + value1 := argvalue1 + fmt.Print(client.PauseJobUpdate(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "resumeJobUpdate": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "ResumeJobUpdate requires 2 args") + flag.Usage() + } + arg550 := flag.Arg(1) + mbTrans551 := thrift.NewTMemoryBufferLen(len(arg550)) + defer mbTrans551.Close() + _, err552 := mbTrans551.WriteString(arg550) + if err552 != nil { + Usage() + return + } + factory553 := thrift.NewTJSONProtocolFactory() + jsProt554 := factory553.GetProtocol(mbTrans551) + argvalue0 := aurora.NewJobUpdateKey() + err555 := argvalue0.Read(context.Background(), jsProt554) + if err555 != nil { + Usage() + return + } + value0 := argvalue0 + argvalue1 := flag.Arg(2) + value1 := argvalue1 + fmt.Print(client.ResumeJobUpdate(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "abortJobUpdate": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "AbortJobUpdate requires 2 args") + flag.Usage() + } + arg557 := flag.Arg(1) + mbTrans558 := thrift.NewTMemoryBufferLen(len(arg557)) + defer mbTrans558.Close() + _, err559 := mbTrans558.WriteString(arg557) + if err559 != nil { + Usage() + return + } + factory560 := thrift.NewTJSONProtocolFactory() + jsProt561 := factory560.GetProtocol(mbTrans558) + argvalue0 := aurora.NewJobUpdateKey() + err562 := argvalue0.Read(context.Background(), jsProt561) + if err562 != nil { + Usage() + return + } + value0 := argvalue0 + argvalue1 := flag.Arg(2) + value1 := argvalue1 + fmt.Print(client.AbortJobUpdate(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "rollbackJobUpdate": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "RollbackJobUpdate requires 2 args") + flag.Usage() + } + arg564 := flag.Arg(1) + mbTrans565 := thrift.NewTMemoryBufferLen(len(arg564)) + defer mbTrans565.Close() + _, err566 := mbTrans565.WriteString(arg564) + if err566 != nil { + Usage() + return + } + factory567 := thrift.NewTJSONProtocolFactory() + jsProt568 := factory567.GetProtocol(mbTrans565) + argvalue0 := aurora.NewJobUpdateKey() + err569 := argvalue0.Read(context.Background(), jsProt568) + if err569 != nil { + Usage() + return + } + value0 := argvalue0 + argvalue1 := flag.Arg(2) + value1 := argvalue1 + fmt.Print(client.RollbackJobUpdate(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "pulseJobUpdate": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "PulseJobUpdate requires 1 args") + flag.Usage() + } + arg571 := flag.Arg(1) + mbTrans572 := thrift.NewTMemoryBufferLen(len(arg571)) + defer mbTrans572.Close() + _, err573 := mbTrans572.WriteString(arg571) + if err573 != nil { + Usage() + return + } + factory574 := thrift.NewTJSONProtocolFactory() + jsProt575 := factory574.GetProtocol(mbTrans572) + argvalue0 := aurora.NewJobUpdateKey() + err576 := argvalue0.Read(context.Background(), jsProt575) + if err576 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.PulseJobUpdate(context.Background(), value0)) + fmt.Print("\n") + break + case "getRoleSummary": + if flag.NArg() - 1 != 0 { + fmt.Fprintln(os.Stderr, "GetRoleSummary requires 0 args") + flag.Usage() + } + fmt.Print(client.GetRoleSummary(context.Background())) + fmt.Print("\n") + break + case "getJobSummary": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetJobSummary requires 1 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + fmt.Print(client.GetJobSummary(context.Background(), value0)) + fmt.Print("\n") + break + case "getTasksStatus": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetTasksStatus requires 1 args") + flag.Usage() + } + arg578 := flag.Arg(1) + mbTrans579 := thrift.NewTMemoryBufferLen(len(arg578)) + defer mbTrans579.Close() + _, err580 := mbTrans579.WriteString(arg578) + if err580 != nil { + Usage() + return + } + factory581 := thrift.NewTJSONProtocolFactory() + jsProt582 := factory581.GetProtocol(mbTrans579) + argvalue0 := aurora.NewTaskQuery() + err583 := argvalue0.Read(context.Background(), jsProt582) + if err583 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetTasksStatus(context.Background(), value0)) + fmt.Print("\n") + break + case "getTasksWithoutConfigs": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetTasksWithoutConfigs requires 1 args") + flag.Usage() + } + arg584 := flag.Arg(1) + mbTrans585 := thrift.NewTMemoryBufferLen(len(arg584)) + defer mbTrans585.Close() + _, err586 := mbTrans585.WriteString(arg584) + if err586 != nil { + Usage() + return + } + factory587 := thrift.NewTJSONProtocolFactory() + jsProt588 := factory587.GetProtocol(mbTrans585) + argvalue0 := aurora.NewTaskQuery() + err589 := argvalue0.Read(context.Background(), jsProt588) + if err589 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetTasksWithoutConfigs(context.Background(), value0)) + fmt.Print("\n") + break + case "getPendingReason": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetPendingReason requires 1 args") + flag.Usage() + } + arg590 := flag.Arg(1) + mbTrans591 := thrift.NewTMemoryBufferLen(len(arg590)) + defer mbTrans591.Close() + _, err592 := mbTrans591.WriteString(arg590) + if err592 != nil { + Usage() + return + } + factory593 := thrift.NewTJSONProtocolFactory() + jsProt594 := factory593.GetProtocol(mbTrans591) + argvalue0 := aurora.NewTaskQuery() + err595 := argvalue0.Read(context.Background(), jsProt594) + if err595 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetPendingReason(context.Background(), value0)) + fmt.Print("\n") + break + case "getConfigSummary": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetConfigSummary requires 1 args") + flag.Usage() + } + arg596 := flag.Arg(1) + mbTrans597 := thrift.NewTMemoryBufferLen(len(arg596)) + defer mbTrans597.Close() + _, err598 := mbTrans597.WriteString(arg596) + if err598 != nil { + Usage() + return + } + factory599 := thrift.NewTJSONProtocolFactory() + jsProt600 := factory599.GetProtocol(mbTrans597) + argvalue0 := aurora.NewJobKey() + err601 := argvalue0.Read(context.Background(), jsProt600) + if err601 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetConfigSummary(context.Background(), value0)) + fmt.Print("\n") + break + case "getJobs": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetJobs requires 1 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + fmt.Print(client.GetJobs(context.Background(), value0)) + fmt.Print("\n") + break + case "getQuota": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetQuota requires 1 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + fmt.Print(client.GetQuota(context.Background(), value0)) + fmt.Print("\n") + break + case "populateJobConfig": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "PopulateJobConfig requires 1 args") + flag.Usage() + } + arg604 := flag.Arg(1) + mbTrans605 := thrift.NewTMemoryBufferLen(len(arg604)) + defer mbTrans605.Close() + _, err606 := mbTrans605.WriteString(arg604) + if err606 != nil { + Usage() + return + } + factory607 := thrift.NewTJSONProtocolFactory() + jsProt608 := factory607.GetProtocol(mbTrans605) + argvalue0 := aurora.NewJobConfiguration() + err609 := argvalue0.Read(context.Background(), jsProt608) + if err609 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.PopulateJobConfig(context.Background(), value0)) + fmt.Print("\n") + break + case "getJobUpdateSummaries": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetJobUpdateSummaries requires 1 args") + flag.Usage() + } + arg610 := flag.Arg(1) + mbTrans611 := thrift.NewTMemoryBufferLen(len(arg610)) + defer mbTrans611.Close() + _, err612 := mbTrans611.WriteString(arg610) + if err612 != nil { + Usage() + return + } + factory613 := thrift.NewTJSONProtocolFactory() + jsProt614 := factory613.GetProtocol(mbTrans611) + argvalue0 := aurora.NewJobUpdateQuery() + err615 := argvalue0.Read(context.Background(), jsProt614) + if err615 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetJobUpdateSummaries(context.Background(), value0)) + fmt.Print("\n") + break + case "getJobUpdateDetails": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetJobUpdateDetails requires 1 args") + flag.Usage() + } + arg616 := flag.Arg(1) + mbTrans617 := thrift.NewTMemoryBufferLen(len(arg616)) + defer mbTrans617.Close() + _, err618 := mbTrans617.WriteString(arg616) + if err618 != nil { + Usage() + return + } + factory619 := thrift.NewTJSONProtocolFactory() + jsProt620 := factory619.GetProtocol(mbTrans617) + argvalue0 := aurora.NewJobUpdateQuery() + err621 := argvalue0.Read(context.Background(), jsProt620) + if err621 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetJobUpdateDetails(context.Background(), value0)) + fmt.Print("\n") + break + case "getJobUpdateDiff": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetJobUpdateDiff requires 1 args") + flag.Usage() + } + arg622 := flag.Arg(1) + mbTrans623 := thrift.NewTMemoryBufferLen(len(arg622)) + defer mbTrans623.Close() + _, err624 := mbTrans623.WriteString(arg622) + if err624 != nil { + Usage() + return + } + factory625 := thrift.NewTJSONProtocolFactory() + jsProt626 := factory625.GetProtocol(mbTrans623) + argvalue0 := aurora.NewJobUpdateRequest() + err627 := argvalue0.Read(context.Background(), jsProt626) + if err627 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetJobUpdateDiff(context.Background(), value0)) + fmt.Print("\n") + break + case "getTierConfigs": + if flag.NArg() - 1 != 0 { + fmt.Fprintln(os.Stderr, "GetTierConfigs requires 0 args") + flag.Usage() + } + fmt.Print(client.GetTierConfigs(context.Background())) + fmt.Print("\n") + break + case "": + Usage() + break + default: + fmt.Fprintln(os.Stderr, "Invalid function ", cmd) + } } diff --git a/gen-go/apache/aurora/aurora_scheduler_manager-remote/aurora_scheduler_manager-remote.go b/gen-go/apache/aurora/aurora_scheduler_manager-remote/aurora_scheduler_manager-remote.go index f5fc45c..b4715d5 100755 --- a/gen-go/apache/aurora/aurora_scheduler_manager-remote/aurora_scheduler_manager-remote.go +++ b/gen-go/apache/aurora/aurora_scheduler_manager-remote/aurora_scheduler_manager-remote.go @@ -1,799 +1,830 @@ -// Autogenerated by Thrift Compiler (0.9.3) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT. package main import ( - "apache/aurora" + "context" "flag" "fmt" - "git.apache.org/thrift.git/lib/go/thrift" "math" "net" "net/url" "os" "strconv" "strings" + "github.com/apache/thrift/lib/go/thrift" + "apache/aurora" ) +var _ = aurora.GoUnusedProtection__ + func Usage() { - fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:") - flag.PrintDefaults() - fmt.Fprintln(os.Stderr, "\nFunctions:") - fmt.Fprintln(os.Stderr, " Response createJob(JobConfiguration description)") - fmt.Fprintln(os.Stderr, " Response scheduleCronJob(JobConfiguration description)") - fmt.Fprintln(os.Stderr, " Response descheduleCronJob(JobKey job)") - fmt.Fprintln(os.Stderr, " Response startCronJob(JobKey job)") - fmt.Fprintln(os.Stderr, " Response restartShards(JobKey job, shardIds)") - fmt.Fprintln(os.Stderr, " Response killTasks(JobKey job, instances)") - fmt.Fprintln(os.Stderr, " Response addInstances(InstanceKey key, i32 count)") - fmt.Fprintln(os.Stderr, " Response replaceCronTemplate(JobConfiguration config)") - fmt.Fprintln(os.Stderr, " Response startJobUpdate(JobUpdateRequest request, string message)") - fmt.Fprintln(os.Stderr, " Response pauseJobUpdate(JobUpdateKey key, string message)") - fmt.Fprintln(os.Stderr, " Response resumeJobUpdate(JobUpdateKey key, string message)") - fmt.Fprintln(os.Stderr, " Response abortJobUpdate(JobUpdateKey key, string message)") - fmt.Fprintln(os.Stderr, " Response rollbackJobUpdate(JobUpdateKey key, string message)") - fmt.Fprintln(os.Stderr, " Response pulseJobUpdate(JobUpdateKey key)") - fmt.Fprintln(os.Stderr, " Response getRoleSummary()") - fmt.Fprintln(os.Stderr, " Response getJobSummary(string role)") - fmt.Fprintln(os.Stderr, " Response getTasksStatus(TaskQuery query)") - fmt.Fprintln(os.Stderr, " Response getTasksWithoutConfigs(TaskQuery query)") - fmt.Fprintln(os.Stderr, " Response getPendingReason(TaskQuery query)") - fmt.Fprintln(os.Stderr, " Response getConfigSummary(JobKey job)") - fmt.Fprintln(os.Stderr, " Response getJobs(string ownerRole)") - fmt.Fprintln(os.Stderr, " Response getQuota(string ownerRole)") - fmt.Fprintln(os.Stderr, " Response populateJobConfig(JobConfiguration description)") - fmt.Fprintln(os.Stderr, " Response getJobUpdateSummaries(JobUpdateQuery jobUpdateQuery)") - fmt.Fprintln(os.Stderr, " Response getJobUpdateDetails(JobUpdateQuery query)") - fmt.Fprintln(os.Stderr, " Response getJobUpdateDiff(JobUpdateRequest request)") - fmt.Fprintln(os.Stderr, " Response getTierConfigs()") - fmt.Fprintln(os.Stderr) - os.Exit(0) + fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:") + flag.PrintDefaults() + fmt.Fprintln(os.Stderr, "\nFunctions:") + fmt.Fprintln(os.Stderr, " Response createJob(JobConfiguration description)") + fmt.Fprintln(os.Stderr, " Response scheduleCronJob(JobConfiguration description)") + fmt.Fprintln(os.Stderr, " Response descheduleCronJob(JobKey job)") + fmt.Fprintln(os.Stderr, " Response startCronJob(JobKey job)") + fmt.Fprintln(os.Stderr, " Response restartShards(JobKey job, shardIds)") + fmt.Fprintln(os.Stderr, " Response killTasks(JobKey job, instances, string message)") + fmt.Fprintln(os.Stderr, " Response addInstances(InstanceKey key, i32 count)") + fmt.Fprintln(os.Stderr, " Response replaceCronTemplate(JobConfiguration config)") + fmt.Fprintln(os.Stderr, " Response startJobUpdate(JobUpdateRequest request, string message)") + fmt.Fprintln(os.Stderr, " Response pauseJobUpdate(JobUpdateKey key, string message)") + fmt.Fprintln(os.Stderr, " Response resumeJobUpdate(JobUpdateKey key, string message)") + fmt.Fprintln(os.Stderr, " Response abortJobUpdate(JobUpdateKey key, string message)") + fmt.Fprintln(os.Stderr, " Response rollbackJobUpdate(JobUpdateKey key, string message)") + fmt.Fprintln(os.Stderr, " Response pulseJobUpdate(JobUpdateKey key)") + fmt.Fprintln(os.Stderr, " Response getRoleSummary()") + fmt.Fprintln(os.Stderr, " Response getJobSummary(string role)") + fmt.Fprintln(os.Stderr, " Response getTasksStatus(TaskQuery query)") + fmt.Fprintln(os.Stderr, " Response getTasksWithoutConfigs(TaskQuery query)") + fmt.Fprintln(os.Stderr, " Response getPendingReason(TaskQuery query)") + fmt.Fprintln(os.Stderr, " Response getConfigSummary(JobKey job)") + fmt.Fprintln(os.Stderr, " Response getJobs(string ownerRole)") + fmt.Fprintln(os.Stderr, " Response getQuota(string ownerRole)") + fmt.Fprintln(os.Stderr, " Response populateJobConfig(JobConfiguration description)") + fmt.Fprintln(os.Stderr, " Response getJobUpdateSummaries(JobUpdateQuery jobUpdateQuery)") + fmt.Fprintln(os.Stderr, " Response getJobUpdateDetails(JobUpdateQuery query)") + fmt.Fprintln(os.Stderr, " Response getJobUpdateDiff(JobUpdateRequest request)") + fmt.Fprintln(os.Stderr, " Response getTierConfigs()") + fmt.Fprintln(os.Stderr) + os.Exit(0) +} + +type httpHeaders map[string]string + +func (h httpHeaders) String() string { + var m map[string]string = h + return fmt.Sprintf("%s", m) +} + +func (h httpHeaders) Set(value string) error { + parts := strings.Split(value, ": ") + if len(parts) != 2 { + return fmt.Errorf("header should be of format 'Key: Value'") + } + h[parts[0]] = parts[1] + return nil } func main() { - flag.Usage = Usage - var host string - var port int - var protocol string - var urlString string - var framed bool - var useHttp bool - var parsedUrl url.URL - var trans thrift.TTransport - _ = strconv.Atoi - _ = math.Abs - flag.Usage = Usage - flag.StringVar(&host, "h", "localhost", "Specify host and port") - flag.IntVar(&port, "p", 9090, "Specify port") - flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") - flag.StringVar(&urlString, "u", "", "Specify the url") - flag.BoolVar(&framed, "framed", false, "Use framed transport") - flag.BoolVar(&useHttp, "http", false, "Use http") - flag.Parse() - - if len(urlString) > 0 { - parsedUrl, err := url.Parse(urlString) - if err != nil { - fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) - flag.Usage() - } - host = parsedUrl.Host - useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" - } else if useHttp { - _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) - if err != nil { - fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) - flag.Usage() - } - } - - cmd := flag.Arg(0) - var err error - if useHttp { - trans, err = thrift.NewTHttpClient(parsedUrl.String()) - } else { - portStr := fmt.Sprint(port) - if strings.Contains(host, ":") { - host, portStr, err = net.SplitHostPort(host) - if err != nil { - fmt.Fprintln(os.Stderr, "error with host:", err) - os.Exit(1) - } - } - trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) - if err != nil { - fmt.Fprintln(os.Stderr, "error resolving address:", err) - os.Exit(1) - } - if framed { - trans = thrift.NewTFramedTransport(trans) - } - } - if err != nil { - fmt.Fprintln(os.Stderr, "Error creating transport", err) - os.Exit(1) - } - defer trans.Close() - var protocolFactory thrift.TProtocolFactory - switch protocol { - case "compact": - protocolFactory = thrift.NewTCompactProtocolFactory() - break - case "simplejson": - protocolFactory = thrift.NewTSimpleJSONProtocolFactory() - break - case "json": - protocolFactory = thrift.NewTJSONProtocolFactory() - break - case "binary", "": - protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() - break - default: - fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) - Usage() - os.Exit(1) - } - client := aurora.NewAuroraSchedulerManagerClientFactory(trans, protocolFactory) - if err := trans.Open(); err != nil { - fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) - os.Exit(1) - } - - switch cmd { - case "createJob": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "CreateJob requires 1 args") - flag.Usage() - } - arg163 := flag.Arg(1) - mbTrans164 := thrift.NewTMemoryBufferLen(len(arg163)) - defer mbTrans164.Close() - _, err165 := mbTrans164.WriteString(arg163) - if err165 != nil { - Usage() - return - } - factory166 := thrift.NewTSimpleJSONProtocolFactory() - jsProt167 := factory166.GetProtocol(mbTrans164) - argvalue0 := aurora.NewJobConfiguration() - err168 := argvalue0.Read(jsProt167) - if err168 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.CreateJob(value0)) - fmt.Print("\n") - break - case "scheduleCronJob": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "ScheduleCronJob requires 1 args") - flag.Usage() - } - arg169 := flag.Arg(1) - mbTrans170 := thrift.NewTMemoryBufferLen(len(arg169)) - defer mbTrans170.Close() - _, err171 := mbTrans170.WriteString(arg169) - if err171 != nil { - Usage() - return - } - factory172 := thrift.NewTSimpleJSONProtocolFactory() - jsProt173 := factory172.GetProtocol(mbTrans170) - argvalue0 := aurora.NewJobConfiguration() - err174 := argvalue0.Read(jsProt173) - if err174 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.ScheduleCronJob(value0)) - fmt.Print("\n") - break - case "descheduleCronJob": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "DescheduleCronJob requires 1 args") - flag.Usage() - } - arg175 := flag.Arg(1) - mbTrans176 := thrift.NewTMemoryBufferLen(len(arg175)) - defer mbTrans176.Close() - _, err177 := mbTrans176.WriteString(arg175) - if err177 != nil { - Usage() - return - } - factory178 := thrift.NewTSimpleJSONProtocolFactory() - jsProt179 := factory178.GetProtocol(mbTrans176) - argvalue0 := aurora.NewJobKey() - err180 := argvalue0.Read(jsProt179) - if err180 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.DescheduleCronJob(value0)) - fmt.Print("\n") - break - case "startCronJob": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "StartCronJob requires 1 args") - flag.Usage() - } - arg181 := flag.Arg(1) - mbTrans182 := thrift.NewTMemoryBufferLen(len(arg181)) - defer mbTrans182.Close() - _, err183 := mbTrans182.WriteString(arg181) - if err183 != nil { - Usage() - return - } - factory184 := thrift.NewTSimpleJSONProtocolFactory() - jsProt185 := factory184.GetProtocol(mbTrans182) - argvalue0 := aurora.NewJobKey() - err186 := argvalue0.Read(jsProt185) - if err186 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.StartCronJob(value0)) - fmt.Print("\n") - break - case "restartShards": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "RestartShards requires 2 args") - flag.Usage() - } - arg187 := flag.Arg(1) - mbTrans188 := thrift.NewTMemoryBufferLen(len(arg187)) - defer mbTrans188.Close() - _, err189 := mbTrans188.WriteString(arg187) - if err189 != nil { - Usage() - return - } - factory190 := thrift.NewTSimpleJSONProtocolFactory() - jsProt191 := factory190.GetProtocol(mbTrans188) - argvalue0 := aurora.NewJobKey() - err192 := argvalue0.Read(jsProt191) - if err192 != nil { - Usage() - return - } - value0 := argvalue0 - arg193 := flag.Arg(2) - mbTrans194 := thrift.NewTMemoryBufferLen(len(arg193)) - defer mbTrans194.Close() - _, err195 := mbTrans194.WriteString(arg193) - if err195 != nil { - Usage() - return - } - factory196 := thrift.NewTSimpleJSONProtocolFactory() - jsProt197 := factory196.GetProtocol(mbTrans194) - containerStruct1 := aurora.NewAuroraSchedulerManagerRestartShardsArgs() - err198 := containerStruct1.ReadField2(jsProt197) - if err198 != nil { - Usage() - return - } - argvalue1 := containerStruct1.ShardIds - value1 := argvalue1 - fmt.Print(client.RestartShards(value0, value1)) - fmt.Print("\n") - break - case "killTasks": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "KillTasks requires 2 args") - flag.Usage() - } - arg199 := flag.Arg(1) - mbTrans200 := thrift.NewTMemoryBufferLen(len(arg199)) - defer mbTrans200.Close() - _, err201 := mbTrans200.WriteString(arg199) - if err201 != nil { - Usage() - return - } - factory202 := thrift.NewTSimpleJSONProtocolFactory() - jsProt203 := factory202.GetProtocol(mbTrans200) - argvalue0 := aurora.NewJobKey() - err204 := argvalue0.Read(jsProt203) - if err204 != nil { - Usage() - return - } - value0 := argvalue0 - arg205 := flag.Arg(2) - mbTrans206 := thrift.NewTMemoryBufferLen(len(arg205)) - defer mbTrans206.Close() - _, err207 := mbTrans206.WriteString(arg205) - if err207 != nil { - Usage() - return - } - factory208 := thrift.NewTSimpleJSONProtocolFactory() - jsProt209 := factory208.GetProtocol(mbTrans206) - containerStruct1 := aurora.NewAuroraSchedulerManagerKillTasksArgs() - err210 := containerStruct1.ReadField2(jsProt209) - if err210 != nil { - Usage() - return - } - argvalue1 := containerStruct1.Instances - value1 := argvalue1 - fmt.Print(client.KillTasks(value0, value1)) - fmt.Print("\n") - break - case "addInstances": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "AddInstances requires 2 args") - flag.Usage() - } - arg211 := flag.Arg(1) - mbTrans212 := thrift.NewTMemoryBufferLen(len(arg211)) - defer mbTrans212.Close() - _, err213 := mbTrans212.WriteString(arg211) - if err213 != nil { - Usage() - return - } - factory214 := thrift.NewTSimpleJSONProtocolFactory() - jsProt215 := factory214.GetProtocol(mbTrans212) - argvalue0 := aurora.NewInstanceKey() - err216 := argvalue0.Read(jsProt215) - if err216 != nil { - Usage() - return - } - value0 := argvalue0 - tmp1, err217 := (strconv.Atoi(flag.Arg(2))) - if err217 != nil { - Usage() - return - } - argvalue1 := int32(tmp1) - value1 := argvalue1 - fmt.Print(client.AddInstances(value0, value1)) - fmt.Print("\n") - break - case "replaceCronTemplate": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "ReplaceCronTemplate requires 1 args") - flag.Usage() - } - arg218 := flag.Arg(1) - mbTrans219 := thrift.NewTMemoryBufferLen(len(arg218)) - defer mbTrans219.Close() - _, err220 := mbTrans219.WriteString(arg218) - if err220 != nil { - Usage() - return - } - factory221 := thrift.NewTSimpleJSONProtocolFactory() - jsProt222 := factory221.GetProtocol(mbTrans219) - argvalue0 := aurora.NewJobConfiguration() - err223 := argvalue0.Read(jsProt222) - if err223 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.ReplaceCronTemplate(value0)) - fmt.Print("\n") - break - case "startJobUpdate": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "StartJobUpdate requires 2 args") - flag.Usage() - } - arg224 := flag.Arg(1) - mbTrans225 := thrift.NewTMemoryBufferLen(len(arg224)) - defer mbTrans225.Close() - _, err226 := mbTrans225.WriteString(arg224) - if err226 != nil { - Usage() - return - } - factory227 := thrift.NewTSimpleJSONProtocolFactory() - jsProt228 := factory227.GetProtocol(mbTrans225) - argvalue0 := aurora.NewJobUpdateRequest() - err229 := argvalue0.Read(jsProt228) - if err229 != nil { - Usage() - return - } - value0 := argvalue0 - argvalue1 := flag.Arg(2) - value1 := argvalue1 - fmt.Print(client.StartJobUpdate(value0, value1)) - fmt.Print("\n") - break - case "pauseJobUpdate": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "PauseJobUpdate requires 2 args") - flag.Usage() - } - arg231 := flag.Arg(1) - mbTrans232 := thrift.NewTMemoryBufferLen(len(arg231)) - defer mbTrans232.Close() - _, err233 := mbTrans232.WriteString(arg231) - if err233 != nil { - Usage() - return - } - factory234 := thrift.NewTSimpleJSONProtocolFactory() - jsProt235 := factory234.GetProtocol(mbTrans232) - argvalue0 := aurora.NewJobUpdateKey() - err236 := argvalue0.Read(jsProt235) - if err236 != nil { - Usage() - return - } - value0 := argvalue0 - argvalue1 := flag.Arg(2) - value1 := argvalue1 - fmt.Print(client.PauseJobUpdate(value0, value1)) - fmt.Print("\n") - break - case "resumeJobUpdate": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "ResumeJobUpdate requires 2 args") - flag.Usage() - } - arg238 := flag.Arg(1) - mbTrans239 := thrift.NewTMemoryBufferLen(len(arg238)) - defer mbTrans239.Close() - _, err240 := mbTrans239.WriteString(arg238) - if err240 != nil { - Usage() - return - } - factory241 := thrift.NewTSimpleJSONProtocolFactory() - jsProt242 := factory241.GetProtocol(mbTrans239) - argvalue0 := aurora.NewJobUpdateKey() - err243 := argvalue0.Read(jsProt242) - if err243 != nil { - Usage() - return - } - value0 := argvalue0 - argvalue1 := flag.Arg(2) - value1 := argvalue1 - fmt.Print(client.ResumeJobUpdate(value0, value1)) - fmt.Print("\n") - break - case "abortJobUpdate": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "AbortJobUpdate requires 2 args") - flag.Usage() - } - arg245 := flag.Arg(1) - mbTrans246 := thrift.NewTMemoryBufferLen(len(arg245)) - defer mbTrans246.Close() - _, err247 := mbTrans246.WriteString(arg245) - if err247 != nil { - Usage() - return - } - factory248 := thrift.NewTSimpleJSONProtocolFactory() - jsProt249 := factory248.GetProtocol(mbTrans246) - argvalue0 := aurora.NewJobUpdateKey() - err250 := argvalue0.Read(jsProt249) - if err250 != nil { - Usage() - return - } - value0 := argvalue0 - argvalue1 := flag.Arg(2) - value1 := argvalue1 - fmt.Print(client.AbortJobUpdate(value0, value1)) - fmt.Print("\n") - break - case "rollbackJobUpdate": - if flag.NArg()-1 != 2 { - fmt.Fprintln(os.Stderr, "RollbackJobUpdate requires 2 args") - flag.Usage() - } - arg252 := flag.Arg(1) - mbTrans253 := thrift.NewTMemoryBufferLen(len(arg252)) - defer mbTrans253.Close() - _, err254 := mbTrans253.WriteString(arg252) - if err254 != nil { - Usage() - return - } - factory255 := thrift.NewTSimpleJSONProtocolFactory() - jsProt256 := factory255.GetProtocol(mbTrans253) - argvalue0 := aurora.NewJobUpdateKey() - err257 := argvalue0.Read(jsProt256) - if err257 != nil { - Usage() - return - } - value0 := argvalue0 - argvalue1 := flag.Arg(2) - value1 := argvalue1 - fmt.Print(client.RollbackJobUpdate(value0, value1)) - fmt.Print("\n") - break - case "pulseJobUpdate": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "PulseJobUpdate requires 1 args") - flag.Usage() - } - arg259 := flag.Arg(1) - mbTrans260 := thrift.NewTMemoryBufferLen(len(arg259)) - defer mbTrans260.Close() - _, err261 := mbTrans260.WriteString(arg259) - if err261 != nil { - Usage() - return - } - factory262 := thrift.NewTSimpleJSONProtocolFactory() - jsProt263 := factory262.GetProtocol(mbTrans260) - argvalue0 := aurora.NewJobUpdateKey() - err264 := argvalue0.Read(jsProt263) - if err264 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.PulseJobUpdate(value0)) - fmt.Print("\n") - break - case "getRoleSummary": - if flag.NArg()-1 != 0 { - fmt.Fprintln(os.Stderr, "GetRoleSummary requires 0 args") - flag.Usage() - } - fmt.Print(client.GetRoleSummary()) - fmt.Print("\n") - break - case "getJobSummary": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetJobSummary requires 1 args") - flag.Usage() - } - argvalue0 := flag.Arg(1) - value0 := argvalue0 - fmt.Print(client.GetJobSummary(value0)) - fmt.Print("\n") - break - case "getTasksStatus": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetTasksStatus requires 1 args") - flag.Usage() - } - arg266 := flag.Arg(1) - mbTrans267 := thrift.NewTMemoryBufferLen(len(arg266)) - defer mbTrans267.Close() - _, err268 := mbTrans267.WriteString(arg266) - if err268 != nil { - Usage() - return - } - factory269 := thrift.NewTSimpleJSONProtocolFactory() - jsProt270 := factory269.GetProtocol(mbTrans267) - argvalue0 := aurora.NewTaskQuery() - err271 := argvalue0.Read(jsProt270) - if err271 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetTasksStatus(value0)) - fmt.Print("\n") - break - case "getTasksWithoutConfigs": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetTasksWithoutConfigs requires 1 args") - flag.Usage() - } - arg272 := flag.Arg(1) - mbTrans273 := thrift.NewTMemoryBufferLen(len(arg272)) - defer mbTrans273.Close() - _, err274 := mbTrans273.WriteString(arg272) - if err274 != nil { - Usage() - return - } - factory275 := thrift.NewTSimpleJSONProtocolFactory() - jsProt276 := factory275.GetProtocol(mbTrans273) - argvalue0 := aurora.NewTaskQuery() - err277 := argvalue0.Read(jsProt276) - if err277 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetTasksWithoutConfigs(value0)) - fmt.Print("\n") - break - case "getPendingReason": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetPendingReason requires 1 args") - flag.Usage() - } - arg278 := flag.Arg(1) - mbTrans279 := thrift.NewTMemoryBufferLen(len(arg278)) - defer mbTrans279.Close() - _, err280 := mbTrans279.WriteString(arg278) - if err280 != nil { - Usage() - return - } - factory281 := thrift.NewTSimpleJSONProtocolFactory() - jsProt282 := factory281.GetProtocol(mbTrans279) - argvalue0 := aurora.NewTaskQuery() - err283 := argvalue0.Read(jsProt282) - if err283 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetPendingReason(value0)) - fmt.Print("\n") - break - case "getConfigSummary": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetConfigSummary requires 1 args") - flag.Usage() - } - arg284 := flag.Arg(1) - mbTrans285 := thrift.NewTMemoryBufferLen(len(arg284)) - defer mbTrans285.Close() - _, err286 := mbTrans285.WriteString(arg284) - if err286 != nil { - Usage() - return - } - factory287 := thrift.NewTSimpleJSONProtocolFactory() - jsProt288 := factory287.GetProtocol(mbTrans285) - argvalue0 := aurora.NewJobKey() - err289 := argvalue0.Read(jsProt288) - if err289 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetConfigSummary(value0)) - fmt.Print("\n") - break - case "getJobs": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetJobs requires 1 args") - flag.Usage() - } - argvalue0 := flag.Arg(1) - value0 := argvalue0 - fmt.Print(client.GetJobs(value0)) - fmt.Print("\n") - break - case "getQuota": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetQuota requires 1 args") - flag.Usage() - } - argvalue0 := flag.Arg(1) - value0 := argvalue0 - fmt.Print(client.GetQuota(value0)) - fmt.Print("\n") - break - case "populateJobConfig": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "PopulateJobConfig requires 1 args") - flag.Usage() - } - arg292 := flag.Arg(1) - mbTrans293 := thrift.NewTMemoryBufferLen(len(arg292)) - defer mbTrans293.Close() - _, err294 := mbTrans293.WriteString(arg292) - if err294 != nil { - Usage() - return - } - factory295 := thrift.NewTSimpleJSONProtocolFactory() - jsProt296 := factory295.GetProtocol(mbTrans293) - argvalue0 := aurora.NewJobConfiguration() - err297 := argvalue0.Read(jsProt296) - if err297 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.PopulateJobConfig(value0)) - fmt.Print("\n") - break - case "getJobUpdateSummaries": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetJobUpdateSummaries requires 1 args") - flag.Usage() - } - arg298 := flag.Arg(1) - mbTrans299 := thrift.NewTMemoryBufferLen(len(arg298)) - defer mbTrans299.Close() - _, err300 := mbTrans299.WriteString(arg298) - if err300 != nil { - Usage() - return - } - factory301 := thrift.NewTSimpleJSONProtocolFactory() - jsProt302 := factory301.GetProtocol(mbTrans299) - argvalue0 := aurora.NewJobUpdateQuery() - err303 := argvalue0.Read(jsProt302) - if err303 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetJobUpdateSummaries(value0)) - fmt.Print("\n") - break - case "getJobUpdateDetails": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetJobUpdateDetails requires 1 args") - flag.Usage() - } - arg304 := flag.Arg(1) - mbTrans305 := thrift.NewTMemoryBufferLen(len(arg304)) - defer mbTrans305.Close() - _, err306 := mbTrans305.WriteString(arg304) - if err306 != nil { - Usage() - return - } - factory307 := thrift.NewTSimpleJSONProtocolFactory() - jsProt308 := factory307.GetProtocol(mbTrans305) - argvalue0 := aurora.NewJobUpdateQuery() - err309 := argvalue0.Read(jsProt308) - if err309 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetJobUpdateDetails(value0)) - fmt.Print("\n") - break - case "getJobUpdateDiff": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetJobUpdateDiff requires 1 args") - flag.Usage() - } - arg310 := flag.Arg(1) - mbTrans311 := thrift.NewTMemoryBufferLen(len(arg310)) - defer mbTrans311.Close() - _, err312 := mbTrans311.WriteString(arg310) - if err312 != nil { - Usage() - return - } - factory313 := thrift.NewTSimpleJSONProtocolFactory() - jsProt314 := factory313.GetProtocol(mbTrans311) - argvalue0 := aurora.NewJobUpdateRequest() - err315 := argvalue0.Read(jsProt314) - if err315 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetJobUpdateDiff(value0)) - fmt.Print("\n") - break - case "getTierConfigs": - if flag.NArg()-1 != 0 { - fmt.Fprintln(os.Stderr, "GetTierConfigs requires 0 args") - flag.Usage() - } - fmt.Print(client.GetTierConfigs()) - fmt.Print("\n") - break - case "": - Usage() - break - default: - fmt.Fprintln(os.Stderr, "Invalid function ", cmd) - } + flag.Usage = Usage + var host string + var port int + var protocol string + var urlString string + var framed bool + var useHttp bool + headers := make(httpHeaders) + var parsedUrl *url.URL + var trans thrift.TTransport + _ = strconv.Atoi + _ = math.Abs + flag.Usage = Usage + flag.StringVar(&host, "h", "localhost", "Specify host and port") + flag.IntVar(&port, "p", 9090, "Specify port") + flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") + flag.StringVar(&urlString, "u", "", "Specify the url") + flag.BoolVar(&framed, "framed", false, "Use framed transport") + flag.BoolVar(&useHttp, "http", false, "Use http") + flag.Var(headers, "H", "Headers to set on the http(s) request (e.g. -H \"Key: Value\")") + flag.Parse() + + if len(urlString) > 0 { + var err error + parsedUrl, err = url.Parse(urlString) + if err != nil { + fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) + flag.Usage() + } + host = parsedUrl.Host + useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" || parsedUrl.Scheme == "https" + } else if useHttp { + _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) + if err != nil { + fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) + flag.Usage() + } + } + + cmd := flag.Arg(0) + var err error + if useHttp { + trans, err = thrift.NewTHttpClient(parsedUrl.String()) + if len(headers) > 0 { + httptrans := trans.(*thrift.THttpClient) + for key, value := range headers { + httptrans.SetHeader(key, value) + } + } + } else { + portStr := fmt.Sprint(port) + if strings.Contains(host, ":") { + host, portStr, err = net.SplitHostPort(host) + if err != nil { + fmt.Fprintln(os.Stderr, "error with host:", err) + os.Exit(1) + } + } + trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) + if err != nil { + fmt.Fprintln(os.Stderr, "error resolving address:", err) + os.Exit(1) + } + if framed { + trans = thrift.NewTFramedTransport(trans) + } + } + if err != nil { + fmt.Fprintln(os.Stderr, "Error creating transport", err) + os.Exit(1) + } + defer trans.Close() + var protocolFactory thrift.TProtocolFactory + switch protocol { + case "compact": + protocolFactory = thrift.NewTCompactProtocolFactory() + break + case "simplejson": + protocolFactory = thrift.NewTSimpleJSONProtocolFactory() + break + case "json": + protocolFactory = thrift.NewTJSONProtocolFactory() + break + case "binary", "": + protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() + break + default: + fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) + Usage() + os.Exit(1) + } + iprot := protocolFactory.GetProtocol(trans) + oprot := protocolFactory.GetProtocol(trans) + client := aurora.NewAuroraSchedulerManagerClient(thrift.NewTStandardClient(iprot, oprot)) + if err := trans.Open(); err != nil { + fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) + os.Exit(1) + } + + switch cmd { + case "createJob": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "CreateJob requires 1 args") + flag.Usage() + } + arg213 := flag.Arg(1) + mbTrans214 := thrift.NewTMemoryBufferLen(len(arg213)) + defer mbTrans214.Close() + _, err215 := mbTrans214.WriteString(arg213) + if err215 != nil { + Usage() + return + } + factory216 := thrift.NewTJSONProtocolFactory() + jsProt217 := factory216.GetProtocol(mbTrans214) + argvalue0 := aurora.NewJobConfiguration() + err218 := argvalue0.Read(context.Background(), jsProt217) + if err218 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.CreateJob(context.Background(), value0)) + fmt.Print("\n") + break + case "scheduleCronJob": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "ScheduleCronJob requires 1 args") + flag.Usage() + } + arg219 := flag.Arg(1) + mbTrans220 := thrift.NewTMemoryBufferLen(len(arg219)) + defer mbTrans220.Close() + _, err221 := mbTrans220.WriteString(arg219) + if err221 != nil { + Usage() + return + } + factory222 := thrift.NewTJSONProtocolFactory() + jsProt223 := factory222.GetProtocol(mbTrans220) + argvalue0 := aurora.NewJobConfiguration() + err224 := argvalue0.Read(context.Background(), jsProt223) + if err224 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.ScheduleCronJob(context.Background(), value0)) + fmt.Print("\n") + break + case "descheduleCronJob": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "DescheduleCronJob requires 1 args") + flag.Usage() + } + arg225 := flag.Arg(1) + mbTrans226 := thrift.NewTMemoryBufferLen(len(arg225)) + defer mbTrans226.Close() + _, err227 := mbTrans226.WriteString(arg225) + if err227 != nil { + Usage() + return + } + factory228 := thrift.NewTJSONProtocolFactory() + jsProt229 := factory228.GetProtocol(mbTrans226) + argvalue0 := aurora.NewJobKey() + err230 := argvalue0.Read(context.Background(), jsProt229) + if err230 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.DescheduleCronJob(context.Background(), value0)) + fmt.Print("\n") + break + case "startCronJob": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "StartCronJob requires 1 args") + flag.Usage() + } + arg231 := flag.Arg(1) + mbTrans232 := thrift.NewTMemoryBufferLen(len(arg231)) + defer mbTrans232.Close() + _, err233 := mbTrans232.WriteString(arg231) + if err233 != nil { + Usage() + return + } + factory234 := thrift.NewTJSONProtocolFactory() + jsProt235 := factory234.GetProtocol(mbTrans232) + argvalue0 := aurora.NewJobKey() + err236 := argvalue0.Read(context.Background(), jsProt235) + if err236 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.StartCronJob(context.Background(), value0)) + fmt.Print("\n") + break + case "restartShards": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "RestartShards requires 2 args") + flag.Usage() + } + arg237 := flag.Arg(1) + mbTrans238 := thrift.NewTMemoryBufferLen(len(arg237)) + defer mbTrans238.Close() + _, err239 := mbTrans238.WriteString(arg237) + if err239 != nil { + Usage() + return + } + factory240 := thrift.NewTJSONProtocolFactory() + jsProt241 := factory240.GetProtocol(mbTrans238) + argvalue0 := aurora.NewJobKey() + err242 := argvalue0.Read(context.Background(), jsProt241) + if err242 != nil { + Usage() + return + } + value0 := argvalue0 + arg243 := flag.Arg(2) + mbTrans244 := thrift.NewTMemoryBufferLen(len(arg243)) + defer mbTrans244.Close() + _, err245 := mbTrans244.WriteString(arg243) + if err245 != nil { + Usage() + return + } + factory246 := thrift.NewTJSONProtocolFactory() + jsProt247 := factory246.GetProtocol(mbTrans244) + containerStruct1 := aurora.NewAuroraSchedulerManagerRestartShardsArgs() + err248 := containerStruct1.ReadField2(context.Background(), jsProt247) + if err248 != nil { + Usage() + return + } + argvalue1 := containerStruct1.ShardIds + value1 := argvalue1 + fmt.Print(client.RestartShards(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "killTasks": + if flag.NArg() - 1 != 3 { + fmt.Fprintln(os.Stderr, "KillTasks requires 3 args") + flag.Usage() + } + arg249 := flag.Arg(1) + mbTrans250 := thrift.NewTMemoryBufferLen(len(arg249)) + defer mbTrans250.Close() + _, err251 := mbTrans250.WriteString(arg249) + if err251 != nil { + Usage() + return + } + factory252 := thrift.NewTJSONProtocolFactory() + jsProt253 := factory252.GetProtocol(mbTrans250) + argvalue0 := aurora.NewJobKey() + err254 := argvalue0.Read(context.Background(), jsProt253) + if err254 != nil { + Usage() + return + } + value0 := argvalue0 + arg255 := flag.Arg(2) + mbTrans256 := thrift.NewTMemoryBufferLen(len(arg255)) + defer mbTrans256.Close() + _, err257 := mbTrans256.WriteString(arg255) + if err257 != nil { + Usage() + return + } + factory258 := thrift.NewTJSONProtocolFactory() + jsProt259 := factory258.GetProtocol(mbTrans256) + containerStruct1 := aurora.NewAuroraSchedulerManagerKillTasksArgs() + err260 := containerStruct1.ReadField2(context.Background(), jsProt259) + if err260 != nil { + Usage() + return + } + argvalue1 := containerStruct1.Instances + value1 := argvalue1 + argvalue2 := flag.Arg(3) + value2 := argvalue2 + fmt.Print(client.KillTasks(context.Background(), value0, value1, value2)) + fmt.Print("\n") + break + case "addInstances": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "AddInstances requires 2 args") + flag.Usage() + } + arg262 := flag.Arg(1) + mbTrans263 := thrift.NewTMemoryBufferLen(len(arg262)) + defer mbTrans263.Close() + _, err264 := mbTrans263.WriteString(arg262) + if err264 != nil { + Usage() + return + } + factory265 := thrift.NewTJSONProtocolFactory() + jsProt266 := factory265.GetProtocol(mbTrans263) + argvalue0 := aurora.NewInstanceKey() + err267 := argvalue0.Read(context.Background(), jsProt266) + if err267 != nil { + Usage() + return + } + value0 := argvalue0 + tmp1, err268 := (strconv.Atoi(flag.Arg(2))) + if err268 != nil { + Usage() + return + } + argvalue1 := int32(tmp1) + value1 := argvalue1 + fmt.Print(client.AddInstances(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "replaceCronTemplate": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "ReplaceCronTemplate requires 1 args") + flag.Usage() + } + arg269 := flag.Arg(1) + mbTrans270 := thrift.NewTMemoryBufferLen(len(arg269)) + defer mbTrans270.Close() + _, err271 := mbTrans270.WriteString(arg269) + if err271 != nil { + Usage() + return + } + factory272 := thrift.NewTJSONProtocolFactory() + jsProt273 := factory272.GetProtocol(mbTrans270) + argvalue0 := aurora.NewJobConfiguration() + err274 := argvalue0.Read(context.Background(), jsProt273) + if err274 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.ReplaceCronTemplate(context.Background(), value0)) + fmt.Print("\n") + break + case "startJobUpdate": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "StartJobUpdate requires 2 args") + flag.Usage() + } + arg275 := flag.Arg(1) + mbTrans276 := thrift.NewTMemoryBufferLen(len(arg275)) + defer mbTrans276.Close() + _, err277 := mbTrans276.WriteString(arg275) + if err277 != nil { + Usage() + return + } + factory278 := thrift.NewTJSONProtocolFactory() + jsProt279 := factory278.GetProtocol(mbTrans276) + argvalue0 := aurora.NewJobUpdateRequest() + err280 := argvalue0.Read(context.Background(), jsProt279) + if err280 != nil { + Usage() + return + } + value0 := argvalue0 + argvalue1 := flag.Arg(2) + value1 := argvalue1 + fmt.Print(client.StartJobUpdate(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "pauseJobUpdate": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "PauseJobUpdate requires 2 args") + flag.Usage() + } + arg282 := flag.Arg(1) + mbTrans283 := thrift.NewTMemoryBufferLen(len(arg282)) + defer mbTrans283.Close() + _, err284 := mbTrans283.WriteString(arg282) + if err284 != nil { + Usage() + return + } + factory285 := thrift.NewTJSONProtocolFactory() + jsProt286 := factory285.GetProtocol(mbTrans283) + argvalue0 := aurora.NewJobUpdateKey() + err287 := argvalue0.Read(context.Background(), jsProt286) + if err287 != nil { + Usage() + return + } + value0 := argvalue0 + argvalue1 := flag.Arg(2) + value1 := argvalue1 + fmt.Print(client.PauseJobUpdate(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "resumeJobUpdate": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "ResumeJobUpdate requires 2 args") + flag.Usage() + } + arg289 := flag.Arg(1) + mbTrans290 := thrift.NewTMemoryBufferLen(len(arg289)) + defer mbTrans290.Close() + _, err291 := mbTrans290.WriteString(arg289) + if err291 != nil { + Usage() + return + } + factory292 := thrift.NewTJSONProtocolFactory() + jsProt293 := factory292.GetProtocol(mbTrans290) + argvalue0 := aurora.NewJobUpdateKey() + err294 := argvalue0.Read(context.Background(), jsProt293) + if err294 != nil { + Usage() + return + } + value0 := argvalue0 + argvalue1 := flag.Arg(2) + value1 := argvalue1 + fmt.Print(client.ResumeJobUpdate(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "abortJobUpdate": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "AbortJobUpdate requires 2 args") + flag.Usage() + } + arg296 := flag.Arg(1) + mbTrans297 := thrift.NewTMemoryBufferLen(len(arg296)) + defer mbTrans297.Close() + _, err298 := mbTrans297.WriteString(arg296) + if err298 != nil { + Usage() + return + } + factory299 := thrift.NewTJSONProtocolFactory() + jsProt300 := factory299.GetProtocol(mbTrans297) + argvalue0 := aurora.NewJobUpdateKey() + err301 := argvalue0.Read(context.Background(), jsProt300) + if err301 != nil { + Usage() + return + } + value0 := argvalue0 + argvalue1 := flag.Arg(2) + value1 := argvalue1 + fmt.Print(client.AbortJobUpdate(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "rollbackJobUpdate": + if flag.NArg() - 1 != 2 { + fmt.Fprintln(os.Stderr, "RollbackJobUpdate requires 2 args") + flag.Usage() + } + arg303 := flag.Arg(1) + mbTrans304 := thrift.NewTMemoryBufferLen(len(arg303)) + defer mbTrans304.Close() + _, err305 := mbTrans304.WriteString(arg303) + if err305 != nil { + Usage() + return + } + factory306 := thrift.NewTJSONProtocolFactory() + jsProt307 := factory306.GetProtocol(mbTrans304) + argvalue0 := aurora.NewJobUpdateKey() + err308 := argvalue0.Read(context.Background(), jsProt307) + if err308 != nil { + Usage() + return + } + value0 := argvalue0 + argvalue1 := flag.Arg(2) + value1 := argvalue1 + fmt.Print(client.RollbackJobUpdate(context.Background(), value0, value1)) + fmt.Print("\n") + break + case "pulseJobUpdate": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "PulseJobUpdate requires 1 args") + flag.Usage() + } + arg310 := flag.Arg(1) + mbTrans311 := thrift.NewTMemoryBufferLen(len(arg310)) + defer mbTrans311.Close() + _, err312 := mbTrans311.WriteString(arg310) + if err312 != nil { + Usage() + return + } + factory313 := thrift.NewTJSONProtocolFactory() + jsProt314 := factory313.GetProtocol(mbTrans311) + argvalue0 := aurora.NewJobUpdateKey() + err315 := argvalue0.Read(context.Background(), jsProt314) + if err315 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.PulseJobUpdate(context.Background(), value0)) + fmt.Print("\n") + break + case "getRoleSummary": + if flag.NArg() - 1 != 0 { + fmt.Fprintln(os.Stderr, "GetRoleSummary requires 0 args") + flag.Usage() + } + fmt.Print(client.GetRoleSummary(context.Background())) + fmt.Print("\n") + break + case "getJobSummary": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetJobSummary requires 1 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + fmt.Print(client.GetJobSummary(context.Background(), value0)) + fmt.Print("\n") + break + case "getTasksStatus": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetTasksStatus requires 1 args") + flag.Usage() + } + arg317 := flag.Arg(1) + mbTrans318 := thrift.NewTMemoryBufferLen(len(arg317)) + defer mbTrans318.Close() + _, err319 := mbTrans318.WriteString(arg317) + if err319 != nil { + Usage() + return + } + factory320 := thrift.NewTJSONProtocolFactory() + jsProt321 := factory320.GetProtocol(mbTrans318) + argvalue0 := aurora.NewTaskQuery() + err322 := argvalue0.Read(context.Background(), jsProt321) + if err322 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetTasksStatus(context.Background(), value0)) + fmt.Print("\n") + break + case "getTasksWithoutConfigs": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetTasksWithoutConfigs requires 1 args") + flag.Usage() + } + arg323 := flag.Arg(1) + mbTrans324 := thrift.NewTMemoryBufferLen(len(arg323)) + defer mbTrans324.Close() + _, err325 := mbTrans324.WriteString(arg323) + if err325 != nil { + Usage() + return + } + factory326 := thrift.NewTJSONProtocolFactory() + jsProt327 := factory326.GetProtocol(mbTrans324) + argvalue0 := aurora.NewTaskQuery() + err328 := argvalue0.Read(context.Background(), jsProt327) + if err328 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetTasksWithoutConfigs(context.Background(), value0)) + fmt.Print("\n") + break + case "getPendingReason": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetPendingReason requires 1 args") + flag.Usage() + } + arg329 := flag.Arg(1) + mbTrans330 := thrift.NewTMemoryBufferLen(len(arg329)) + defer mbTrans330.Close() + _, err331 := mbTrans330.WriteString(arg329) + if err331 != nil { + Usage() + return + } + factory332 := thrift.NewTJSONProtocolFactory() + jsProt333 := factory332.GetProtocol(mbTrans330) + argvalue0 := aurora.NewTaskQuery() + err334 := argvalue0.Read(context.Background(), jsProt333) + if err334 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetPendingReason(context.Background(), value0)) + fmt.Print("\n") + break + case "getConfigSummary": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetConfigSummary requires 1 args") + flag.Usage() + } + arg335 := flag.Arg(1) + mbTrans336 := thrift.NewTMemoryBufferLen(len(arg335)) + defer mbTrans336.Close() + _, err337 := mbTrans336.WriteString(arg335) + if err337 != nil { + Usage() + return + } + factory338 := thrift.NewTJSONProtocolFactory() + jsProt339 := factory338.GetProtocol(mbTrans336) + argvalue0 := aurora.NewJobKey() + err340 := argvalue0.Read(context.Background(), jsProt339) + if err340 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetConfigSummary(context.Background(), value0)) + fmt.Print("\n") + break + case "getJobs": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetJobs requires 1 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + fmt.Print(client.GetJobs(context.Background(), value0)) + fmt.Print("\n") + break + case "getQuota": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetQuota requires 1 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + fmt.Print(client.GetQuota(context.Background(), value0)) + fmt.Print("\n") + break + case "populateJobConfig": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "PopulateJobConfig requires 1 args") + flag.Usage() + } + arg343 := flag.Arg(1) + mbTrans344 := thrift.NewTMemoryBufferLen(len(arg343)) + defer mbTrans344.Close() + _, err345 := mbTrans344.WriteString(arg343) + if err345 != nil { + Usage() + return + } + factory346 := thrift.NewTJSONProtocolFactory() + jsProt347 := factory346.GetProtocol(mbTrans344) + argvalue0 := aurora.NewJobConfiguration() + err348 := argvalue0.Read(context.Background(), jsProt347) + if err348 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.PopulateJobConfig(context.Background(), value0)) + fmt.Print("\n") + break + case "getJobUpdateSummaries": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetJobUpdateSummaries requires 1 args") + flag.Usage() + } + arg349 := flag.Arg(1) + mbTrans350 := thrift.NewTMemoryBufferLen(len(arg349)) + defer mbTrans350.Close() + _, err351 := mbTrans350.WriteString(arg349) + if err351 != nil { + Usage() + return + } + factory352 := thrift.NewTJSONProtocolFactory() + jsProt353 := factory352.GetProtocol(mbTrans350) + argvalue0 := aurora.NewJobUpdateQuery() + err354 := argvalue0.Read(context.Background(), jsProt353) + if err354 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetJobUpdateSummaries(context.Background(), value0)) + fmt.Print("\n") + break + case "getJobUpdateDetails": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetJobUpdateDetails requires 1 args") + flag.Usage() + } + arg355 := flag.Arg(1) + mbTrans356 := thrift.NewTMemoryBufferLen(len(arg355)) + defer mbTrans356.Close() + _, err357 := mbTrans356.WriteString(arg355) + if err357 != nil { + Usage() + return + } + factory358 := thrift.NewTJSONProtocolFactory() + jsProt359 := factory358.GetProtocol(mbTrans356) + argvalue0 := aurora.NewJobUpdateQuery() + err360 := argvalue0.Read(context.Background(), jsProt359) + if err360 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetJobUpdateDetails(context.Background(), value0)) + fmt.Print("\n") + break + case "getJobUpdateDiff": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetJobUpdateDiff requires 1 args") + flag.Usage() + } + arg361 := flag.Arg(1) + mbTrans362 := thrift.NewTMemoryBufferLen(len(arg361)) + defer mbTrans362.Close() + _, err363 := mbTrans362.WriteString(arg361) + if err363 != nil { + Usage() + return + } + factory364 := thrift.NewTJSONProtocolFactory() + jsProt365 := factory364.GetProtocol(mbTrans362) + argvalue0 := aurora.NewJobUpdateRequest() + err366 := argvalue0.Read(context.Background(), jsProt365) + if err366 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetJobUpdateDiff(context.Background(), value0)) + fmt.Print("\n") + break + case "getTierConfigs": + if flag.NArg() - 1 != 0 { + fmt.Fprintln(os.Stderr, "GetTierConfigs requires 0 args") + flag.Usage() + } + fmt.Print(client.GetTierConfigs(context.Background())) + fmt.Print("\n") + break + case "": + Usage() + break + default: + fmt.Fprintln(os.Stderr, "Invalid function ", cmd) + } } diff --git a/gen-go/apache/aurora/auroraadmin.go b/gen-go/apache/aurora/auroraadmin.go deleted file mode 100644 index 8f29940..0000000 --- a/gen-go/apache/aurora/auroraadmin.go +++ /dev/null @@ -1,5453 +0,0 @@ -// Autogenerated by Thrift Compiler (0.9.3) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -package aurora - -import ( - "bytes" - "fmt" - "git.apache.org/thrift.git/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = bytes.Equal - -type AuroraAdmin interface { - AuroraSchedulerManager - - // Assign quota to a user. This will overwrite any pre-existing quota for the user. - // - // Parameters: - // - OwnerRole - // - Quota - SetQuota(ownerRole string, quota *ResourceAggregate) (r *Response, err error) - // Forces a task into a specific state. This does not guarantee the task will enter the given - // state, as the task must still transition within the bounds of the state machine. However, - // it attempts to enter that state via the state machine. - // - // Parameters: - // - TaskId - // - Status - ForceTaskState(taskId string, status ScheduleStatus) (r *Response, err error) - // Immediately writes a storage snapshot to disk. - PerformBackup() (r *Response, err error) - // Lists backups that are available for recovery. - ListBackups() (r *Response, err error) - // Loads a backup to an in-memory storage. This must precede all other recovery operations. - // - // Parameters: - // - BackupId - StageRecovery(backupId string) (r *Response, err error) - // Queries for tasks in a staged recovery. - // - // Parameters: - // - Query - QueryRecovery(query *TaskQuery) (r *Response, err error) - // Deletes tasks from a staged recovery. - // - // Parameters: - // - Query - DeleteRecoveryTasks(query *TaskQuery) (r *Response, err error) - // Commits a staged recovery, completely replacing the previous storage state. - CommitRecovery() (r *Response, err error) - // Unloads (aborts) a staged recovery. - UnloadRecovery() (r *Response, err error) - // Put the given hosts into maintenance mode. - // - // Parameters: - // - Hosts - StartMaintenance(hosts *Hosts) (r *Response, err error) - // Ask scheduler to begin moving tasks scheduled on given hosts. - // - // Parameters: - // - Hosts - DrainHosts(hosts *Hosts) (r *Response, err error) - // Retrieve the current maintenance states for a group of hosts. - // - // Parameters: - // - Hosts - MaintenanceStatus(hosts *Hosts) (r *Response, err error) - // Set the given hosts back into serving mode. - // - // Parameters: - // - Hosts - EndMaintenance(hosts *Hosts) (r *Response, err error) - // Start a storage snapshot and block until it completes. - Snapshot() (r *Response, err error) - // Forcibly rewrites the stored definition of user configurations. This is intended to be used - // in a controlled setting, primarily to migrate pieces of configurations that are opaque to the - // scheduler (e.g. executorConfig). - // The scheduler may do some validation of the rewritten configurations, but it is important - // that the caller take care to provide valid input and alter only necessary fields. - // - // Parameters: - // - Request - RewriteConfigs(request *RewriteConfigsRequest) (r *Response, err error) - // Tell scheduler to trigger an explicit task reconciliation with the given settings. - // - // Parameters: - // - Settings - TriggerExplicitTaskReconciliation(settings *ExplicitReconciliationSettings) (r *Response, err error) - // Tell scheduler to trigger an implicit task reconciliation. - TriggerImplicitTaskReconciliation() (r *Response, err error) -} - -type AuroraAdminClient struct { - *AuroraSchedulerManagerClient -} - -func NewAuroraAdminClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *AuroraAdminClient { - return &AuroraAdminClient{AuroraSchedulerManagerClient: NewAuroraSchedulerManagerClientFactory(t, f)} -} - -func NewAuroraAdminClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *AuroraAdminClient { - return &AuroraAdminClient{AuroraSchedulerManagerClient: NewAuroraSchedulerManagerClientProtocol(t, iprot, oprot)} -} - -// Assign quota to a user. This will overwrite any pre-existing quota for the user. -// -// Parameters: -// - OwnerRole -// - Quota -func (p *AuroraAdminClient) SetQuota(ownerRole string, quota *ResourceAggregate) (r *Response, err error) { - if err = p.sendSetQuota(ownerRole, quota); err != nil { - return - } - return p.recvSetQuota() -} - -func (p *AuroraAdminClient) sendSetQuota(ownerRole string, quota *ResourceAggregate) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("setQuota", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraAdminSetQuotaArgs{ - OwnerRole: ownerRole, - Quota: quota, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraAdminClient) recvSetQuota() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "setQuota" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "setQuota failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "setQuota failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error316 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error317 error - error317, err = error316.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error317 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "setQuota failed: invalid message type") - return - } - result := AuroraAdminSetQuotaResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Forces a task into a specific state. This does not guarantee the task will enter the given -// state, as the task must still transition within the bounds of the state machine. However, -// it attempts to enter that state via the state machine. -// -// Parameters: -// - TaskId -// - Status -func (p *AuroraAdminClient) ForceTaskState(taskId string, status ScheduleStatus) (r *Response, err error) { - if err = p.sendForceTaskState(taskId, status); err != nil { - return - } - return p.recvForceTaskState() -} - -func (p *AuroraAdminClient) sendForceTaskState(taskId string, status ScheduleStatus) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("forceTaskState", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraAdminForceTaskStateArgs{ - TaskId: taskId, - Status: status, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraAdminClient) recvForceTaskState() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "forceTaskState" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "forceTaskState failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "forceTaskState failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error318 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error319 error - error319, err = error318.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error319 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "forceTaskState failed: invalid message type") - return - } - result := AuroraAdminForceTaskStateResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Immediately writes a storage snapshot to disk. -func (p *AuroraAdminClient) PerformBackup() (r *Response, err error) { - if err = p.sendPerformBackup(); err != nil { - return - } - return p.recvPerformBackup() -} - -func (p *AuroraAdminClient) sendPerformBackup() (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("performBackup", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraAdminPerformBackupArgs{} - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraAdminClient) recvPerformBackup() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "performBackup" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "performBackup failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "performBackup failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error320 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error321 error - error321, err = error320.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error321 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "performBackup failed: invalid message type") - return - } - result := AuroraAdminPerformBackupResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Lists backups that are available for recovery. -func (p *AuroraAdminClient) ListBackups() (r *Response, err error) { - if err = p.sendListBackups(); err != nil { - return - } - return p.recvListBackups() -} - -func (p *AuroraAdminClient) sendListBackups() (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("listBackups", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraAdminListBackupsArgs{} - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraAdminClient) recvListBackups() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "listBackups" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "listBackups failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "listBackups failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error322 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error323 error - error323, err = error322.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error323 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "listBackups failed: invalid message type") - return - } - result := AuroraAdminListBackupsResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Loads a backup to an in-memory storage. This must precede all other recovery operations. -// -// Parameters: -// - BackupId -func (p *AuroraAdminClient) StageRecovery(backupId string) (r *Response, err error) { - if err = p.sendStageRecovery(backupId); err != nil { - return - } - return p.recvStageRecovery() -} - -func (p *AuroraAdminClient) sendStageRecovery(backupId string) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("stageRecovery", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraAdminStageRecoveryArgs{ - BackupId: backupId, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraAdminClient) recvStageRecovery() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "stageRecovery" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "stageRecovery failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "stageRecovery failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error324 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error325 error - error325, err = error324.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error325 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "stageRecovery failed: invalid message type") - return - } - result := AuroraAdminStageRecoveryResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Queries for tasks in a staged recovery. -// -// Parameters: -// - Query -func (p *AuroraAdminClient) QueryRecovery(query *TaskQuery) (r *Response, err error) { - if err = p.sendQueryRecovery(query); err != nil { - return - } - return p.recvQueryRecovery() -} - -func (p *AuroraAdminClient) sendQueryRecovery(query *TaskQuery) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("queryRecovery", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraAdminQueryRecoveryArgs{ - Query: query, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraAdminClient) recvQueryRecovery() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "queryRecovery" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "queryRecovery failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "queryRecovery failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error326 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error327 error - error327, err = error326.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error327 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "queryRecovery failed: invalid message type") - return - } - result := AuroraAdminQueryRecoveryResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Deletes tasks from a staged recovery. -// -// Parameters: -// - Query -func (p *AuroraAdminClient) DeleteRecoveryTasks(query *TaskQuery) (r *Response, err error) { - if err = p.sendDeleteRecoveryTasks(query); err != nil { - return - } - return p.recvDeleteRecoveryTasks() -} - -func (p *AuroraAdminClient) sendDeleteRecoveryTasks(query *TaskQuery) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("deleteRecoveryTasks", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraAdminDeleteRecoveryTasksArgs{ - Query: query, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraAdminClient) recvDeleteRecoveryTasks() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "deleteRecoveryTasks" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "deleteRecoveryTasks failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "deleteRecoveryTasks failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error328 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error329 error - error329, err = error328.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error329 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "deleteRecoveryTasks failed: invalid message type") - return - } - result := AuroraAdminDeleteRecoveryTasksResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Commits a staged recovery, completely replacing the previous storage state. -func (p *AuroraAdminClient) CommitRecovery() (r *Response, err error) { - if err = p.sendCommitRecovery(); err != nil { - return - } - return p.recvCommitRecovery() -} - -func (p *AuroraAdminClient) sendCommitRecovery() (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("commitRecovery", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraAdminCommitRecoveryArgs{} - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraAdminClient) recvCommitRecovery() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "commitRecovery" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "commitRecovery failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "commitRecovery failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error330 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error331 error - error331, err = error330.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error331 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "commitRecovery failed: invalid message type") - return - } - result := AuroraAdminCommitRecoveryResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Unloads (aborts) a staged recovery. -func (p *AuroraAdminClient) UnloadRecovery() (r *Response, err error) { - if err = p.sendUnloadRecovery(); err != nil { - return - } - return p.recvUnloadRecovery() -} - -func (p *AuroraAdminClient) sendUnloadRecovery() (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("unloadRecovery", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraAdminUnloadRecoveryArgs{} - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraAdminClient) recvUnloadRecovery() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "unloadRecovery" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "unloadRecovery failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "unloadRecovery failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error332 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error333 error - error333, err = error332.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error333 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "unloadRecovery failed: invalid message type") - return - } - result := AuroraAdminUnloadRecoveryResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Put the given hosts into maintenance mode. -// -// Parameters: -// - Hosts -func (p *AuroraAdminClient) StartMaintenance(hosts *Hosts) (r *Response, err error) { - if err = p.sendStartMaintenance(hosts); err != nil { - return - } - return p.recvStartMaintenance() -} - -func (p *AuroraAdminClient) sendStartMaintenance(hosts *Hosts) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("startMaintenance", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraAdminStartMaintenanceArgs{ - Hosts: hosts, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraAdminClient) recvStartMaintenance() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "startMaintenance" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "startMaintenance failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "startMaintenance failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error334 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error335 error - error335, err = error334.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error335 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "startMaintenance failed: invalid message type") - return - } - result := AuroraAdminStartMaintenanceResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Ask scheduler to begin moving tasks scheduled on given hosts. -// -// Parameters: -// - Hosts -func (p *AuroraAdminClient) DrainHosts(hosts *Hosts) (r *Response, err error) { - if err = p.sendDrainHosts(hosts); err != nil { - return - } - return p.recvDrainHosts() -} - -func (p *AuroraAdminClient) sendDrainHosts(hosts *Hosts) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("drainHosts", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraAdminDrainHostsArgs{ - Hosts: hosts, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraAdminClient) recvDrainHosts() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "drainHosts" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "drainHosts failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "drainHosts failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error336 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error337 error - error337, err = error336.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error337 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "drainHosts failed: invalid message type") - return - } - result := AuroraAdminDrainHostsResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Retrieve the current maintenance states for a group of hosts. -// -// Parameters: -// - Hosts -func (p *AuroraAdminClient) MaintenanceStatus(hosts *Hosts) (r *Response, err error) { - if err = p.sendMaintenanceStatus(hosts); err != nil { - return - } - return p.recvMaintenanceStatus() -} - -func (p *AuroraAdminClient) sendMaintenanceStatus(hosts *Hosts) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("maintenanceStatus", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraAdminMaintenanceStatusArgs{ - Hosts: hosts, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraAdminClient) recvMaintenanceStatus() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "maintenanceStatus" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "maintenanceStatus failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "maintenanceStatus failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error338 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error339 error - error339, err = error338.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error339 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "maintenanceStatus failed: invalid message type") - return - } - result := AuroraAdminMaintenanceStatusResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Set the given hosts back into serving mode. -// -// Parameters: -// - Hosts -func (p *AuroraAdminClient) EndMaintenance(hosts *Hosts) (r *Response, err error) { - if err = p.sendEndMaintenance(hosts); err != nil { - return - } - return p.recvEndMaintenance() -} - -func (p *AuroraAdminClient) sendEndMaintenance(hosts *Hosts) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("endMaintenance", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraAdminEndMaintenanceArgs{ - Hosts: hosts, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraAdminClient) recvEndMaintenance() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "endMaintenance" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "endMaintenance failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "endMaintenance failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error340 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error341 error - error341, err = error340.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error341 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "endMaintenance failed: invalid message type") - return - } - result := AuroraAdminEndMaintenanceResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Start a storage snapshot and block until it completes. -func (p *AuroraAdminClient) Snapshot() (r *Response, err error) { - if err = p.sendSnapshot(); err != nil { - return - } - return p.recvSnapshot() -} - -func (p *AuroraAdminClient) sendSnapshot() (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("snapshot", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraAdminSnapshotArgs{} - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraAdminClient) recvSnapshot() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "snapshot" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "snapshot failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "snapshot failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error342 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error343 error - error343, err = error342.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error343 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "snapshot failed: invalid message type") - return - } - result := AuroraAdminSnapshotResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Forcibly rewrites the stored definition of user configurations. This is intended to be used -// in a controlled setting, primarily to migrate pieces of configurations that are opaque to the -// scheduler (e.g. executorConfig). -// The scheduler may do some validation of the rewritten configurations, but it is important -// that the caller take care to provide valid input and alter only necessary fields. -// -// Parameters: -// - Request -func (p *AuroraAdminClient) RewriteConfigs(request *RewriteConfigsRequest) (r *Response, err error) { - if err = p.sendRewriteConfigs(request); err != nil { - return - } - return p.recvRewriteConfigs() -} - -func (p *AuroraAdminClient) sendRewriteConfigs(request *RewriteConfigsRequest) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("rewriteConfigs", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraAdminRewriteConfigsArgs{ - Request: request, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraAdminClient) recvRewriteConfigs() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "rewriteConfigs" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "rewriteConfigs failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "rewriteConfigs failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error344 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error345 error - error345, err = error344.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error345 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "rewriteConfigs failed: invalid message type") - return - } - result := AuroraAdminRewriteConfigsResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Tell scheduler to trigger an explicit task reconciliation with the given settings. -// -// Parameters: -// - Settings -func (p *AuroraAdminClient) TriggerExplicitTaskReconciliation(settings *ExplicitReconciliationSettings) (r *Response, err error) { - if err = p.sendTriggerExplicitTaskReconciliation(settings); err != nil { - return - } - return p.recvTriggerExplicitTaskReconciliation() -} - -func (p *AuroraAdminClient) sendTriggerExplicitTaskReconciliation(settings *ExplicitReconciliationSettings) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("triggerExplicitTaskReconciliation", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraAdminTriggerExplicitTaskReconciliationArgs{ - Settings: settings, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraAdminClient) recvTriggerExplicitTaskReconciliation() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "triggerExplicitTaskReconciliation" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "triggerExplicitTaskReconciliation failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "triggerExplicitTaskReconciliation failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error346 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error347 error - error347, err = error346.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error347 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "triggerExplicitTaskReconciliation failed: invalid message type") - return - } - result := AuroraAdminTriggerExplicitTaskReconciliationResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Tell scheduler to trigger an implicit task reconciliation. -func (p *AuroraAdminClient) TriggerImplicitTaskReconciliation() (r *Response, err error) { - if err = p.sendTriggerImplicitTaskReconciliation(); err != nil { - return - } - return p.recvTriggerImplicitTaskReconciliation() -} - -func (p *AuroraAdminClient) sendTriggerImplicitTaskReconciliation() (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("triggerImplicitTaskReconciliation", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraAdminTriggerImplicitTaskReconciliationArgs{} - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraAdminClient) recvTriggerImplicitTaskReconciliation() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "triggerImplicitTaskReconciliation" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "triggerImplicitTaskReconciliation failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "triggerImplicitTaskReconciliation failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error348 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error349 error - error349, err = error348.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error349 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "triggerImplicitTaskReconciliation failed: invalid message type") - return - } - result := AuroraAdminTriggerImplicitTaskReconciliationResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -type AuroraAdminProcessor struct { - *AuroraSchedulerManagerProcessor -} - -func NewAuroraAdminProcessor(handler AuroraAdmin) *AuroraAdminProcessor { - self350 := &AuroraAdminProcessor{NewAuroraSchedulerManagerProcessor(handler)} - self350.AddToProcessorMap("setQuota", &auroraAdminProcessorSetQuota{handler: handler}) - self350.AddToProcessorMap("forceTaskState", &auroraAdminProcessorForceTaskState{handler: handler}) - self350.AddToProcessorMap("performBackup", &auroraAdminProcessorPerformBackup{handler: handler}) - self350.AddToProcessorMap("listBackups", &auroraAdminProcessorListBackups{handler: handler}) - self350.AddToProcessorMap("stageRecovery", &auroraAdminProcessorStageRecovery{handler: handler}) - self350.AddToProcessorMap("queryRecovery", &auroraAdminProcessorQueryRecovery{handler: handler}) - self350.AddToProcessorMap("deleteRecoveryTasks", &auroraAdminProcessorDeleteRecoveryTasks{handler: handler}) - self350.AddToProcessorMap("commitRecovery", &auroraAdminProcessorCommitRecovery{handler: handler}) - self350.AddToProcessorMap("unloadRecovery", &auroraAdminProcessorUnloadRecovery{handler: handler}) - self350.AddToProcessorMap("startMaintenance", &auroraAdminProcessorStartMaintenance{handler: handler}) - self350.AddToProcessorMap("drainHosts", &auroraAdminProcessorDrainHosts{handler: handler}) - self350.AddToProcessorMap("maintenanceStatus", &auroraAdminProcessorMaintenanceStatus{handler: handler}) - self350.AddToProcessorMap("endMaintenance", &auroraAdminProcessorEndMaintenance{handler: handler}) - self350.AddToProcessorMap("snapshot", &auroraAdminProcessorSnapshot{handler: handler}) - self350.AddToProcessorMap("rewriteConfigs", &auroraAdminProcessorRewriteConfigs{handler: handler}) - self350.AddToProcessorMap("triggerExplicitTaskReconciliation", &auroraAdminProcessorTriggerExplicitTaskReconciliation{handler: handler}) - self350.AddToProcessorMap("triggerImplicitTaskReconciliation", &auroraAdminProcessorTriggerImplicitTaskReconciliation{handler: handler}) - return self350 -} - -type auroraAdminProcessorSetQuota struct { - handler AuroraAdmin -} - -func (p *auroraAdminProcessorSetQuota) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraAdminSetQuotaArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("setQuota", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraAdminSetQuotaResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.SetQuota(args.OwnerRole, args.Quota); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing setQuota: "+err2.Error()) - oprot.WriteMessageBegin("setQuota", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("setQuota", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraAdminProcessorForceTaskState struct { - handler AuroraAdmin -} - -func (p *auroraAdminProcessorForceTaskState) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraAdminForceTaskStateArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("forceTaskState", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraAdminForceTaskStateResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.ForceTaskState(args.TaskId, args.Status); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing forceTaskState: "+err2.Error()) - oprot.WriteMessageBegin("forceTaskState", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("forceTaskState", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraAdminProcessorPerformBackup struct { - handler AuroraAdmin -} - -func (p *auroraAdminProcessorPerformBackup) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraAdminPerformBackupArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("performBackup", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraAdminPerformBackupResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.PerformBackup(); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing performBackup: "+err2.Error()) - oprot.WriteMessageBegin("performBackup", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("performBackup", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraAdminProcessorListBackups struct { - handler AuroraAdmin -} - -func (p *auroraAdminProcessorListBackups) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraAdminListBackupsArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("listBackups", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraAdminListBackupsResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.ListBackups(); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing listBackups: "+err2.Error()) - oprot.WriteMessageBegin("listBackups", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("listBackups", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraAdminProcessorStageRecovery struct { - handler AuroraAdmin -} - -func (p *auroraAdminProcessorStageRecovery) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraAdminStageRecoveryArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("stageRecovery", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraAdminStageRecoveryResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.StageRecovery(args.BackupId); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing stageRecovery: "+err2.Error()) - oprot.WriteMessageBegin("stageRecovery", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("stageRecovery", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraAdminProcessorQueryRecovery struct { - handler AuroraAdmin -} - -func (p *auroraAdminProcessorQueryRecovery) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraAdminQueryRecoveryArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("queryRecovery", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraAdminQueryRecoveryResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.QueryRecovery(args.Query); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing queryRecovery: "+err2.Error()) - oprot.WriteMessageBegin("queryRecovery", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("queryRecovery", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraAdminProcessorDeleteRecoveryTasks struct { - handler AuroraAdmin -} - -func (p *auroraAdminProcessorDeleteRecoveryTasks) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraAdminDeleteRecoveryTasksArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("deleteRecoveryTasks", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraAdminDeleteRecoveryTasksResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.DeleteRecoveryTasks(args.Query); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing deleteRecoveryTasks: "+err2.Error()) - oprot.WriteMessageBegin("deleteRecoveryTasks", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("deleteRecoveryTasks", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraAdminProcessorCommitRecovery struct { - handler AuroraAdmin -} - -func (p *auroraAdminProcessorCommitRecovery) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraAdminCommitRecoveryArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("commitRecovery", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraAdminCommitRecoveryResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.CommitRecovery(); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing commitRecovery: "+err2.Error()) - oprot.WriteMessageBegin("commitRecovery", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("commitRecovery", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraAdminProcessorUnloadRecovery struct { - handler AuroraAdmin -} - -func (p *auroraAdminProcessorUnloadRecovery) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraAdminUnloadRecoveryArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("unloadRecovery", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraAdminUnloadRecoveryResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.UnloadRecovery(); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing unloadRecovery: "+err2.Error()) - oprot.WriteMessageBegin("unloadRecovery", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("unloadRecovery", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraAdminProcessorStartMaintenance struct { - handler AuroraAdmin -} - -func (p *auroraAdminProcessorStartMaintenance) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraAdminStartMaintenanceArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("startMaintenance", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraAdminStartMaintenanceResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.StartMaintenance(args.Hosts); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing startMaintenance: "+err2.Error()) - oprot.WriteMessageBegin("startMaintenance", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("startMaintenance", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraAdminProcessorDrainHosts struct { - handler AuroraAdmin -} - -func (p *auroraAdminProcessorDrainHosts) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraAdminDrainHostsArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("drainHosts", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraAdminDrainHostsResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.DrainHosts(args.Hosts); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing drainHosts: "+err2.Error()) - oprot.WriteMessageBegin("drainHosts", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("drainHosts", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraAdminProcessorMaintenanceStatus struct { - handler AuroraAdmin -} - -func (p *auroraAdminProcessorMaintenanceStatus) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraAdminMaintenanceStatusArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("maintenanceStatus", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraAdminMaintenanceStatusResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.MaintenanceStatus(args.Hosts); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing maintenanceStatus: "+err2.Error()) - oprot.WriteMessageBegin("maintenanceStatus", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("maintenanceStatus", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraAdminProcessorEndMaintenance struct { - handler AuroraAdmin -} - -func (p *auroraAdminProcessorEndMaintenance) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraAdminEndMaintenanceArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("endMaintenance", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraAdminEndMaintenanceResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.EndMaintenance(args.Hosts); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing endMaintenance: "+err2.Error()) - oprot.WriteMessageBegin("endMaintenance", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("endMaintenance", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraAdminProcessorSnapshot struct { - handler AuroraAdmin -} - -func (p *auroraAdminProcessorSnapshot) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraAdminSnapshotArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("snapshot", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraAdminSnapshotResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.Snapshot(); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing snapshot: "+err2.Error()) - oprot.WriteMessageBegin("snapshot", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("snapshot", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraAdminProcessorRewriteConfigs struct { - handler AuroraAdmin -} - -func (p *auroraAdminProcessorRewriteConfigs) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraAdminRewriteConfigsArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("rewriteConfigs", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraAdminRewriteConfigsResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.RewriteConfigs(args.Request); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing rewriteConfigs: "+err2.Error()) - oprot.WriteMessageBegin("rewriteConfigs", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("rewriteConfigs", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraAdminProcessorTriggerExplicitTaskReconciliation struct { - handler AuroraAdmin -} - -func (p *auroraAdminProcessorTriggerExplicitTaskReconciliation) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraAdminTriggerExplicitTaskReconciliationArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("triggerExplicitTaskReconciliation", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraAdminTriggerExplicitTaskReconciliationResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.TriggerExplicitTaskReconciliation(args.Settings); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing triggerExplicitTaskReconciliation: "+err2.Error()) - oprot.WriteMessageBegin("triggerExplicitTaskReconciliation", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("triggerExplicitTaskReconciliation", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraAdminProcessorTriggerImplicitTaskReconciliation struct { - handler AuroraAdmin -} - -func (p *auroraAdminProcessorTriggerImplicitTaskReconciliation) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraAdminTriggerImplicitTaskReconciliationArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("triggerImplicitTaskReconciliation", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraAdminTriggerImplicitTaskReconciliationResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.TriggerImplicitTaskReconciliation(); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing triggerImplicitTaskReconciliation: "+err2.Error()) - oprot.WriteMessageBegin("triggerImplicitTaskReconciliation", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("triggerImplicitTaskReconciliation", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -// HELPER FUNCTIONS AND STRUCTURES - -// Attributes: -// - OwnerRole -// - Quota -type AuroraAdminSetQuotaArgs struct { - OwnerRole string `thrift:"ownerRole,1" json:"ownerRole"` - Quota *ResourceAggregate `thrift:"quota,2" json:"quota"` -} - -func NewAuroraAdminSetQuotaArgs() *AuroraAdminSetQuotaArgs { - return &AuroraAdminSetQuotaArgs{} -} - -func (p *AuroraAdminSetQuotaArgs) GetOwnerRole() string { - return p.OwnerRole -} - -var AuroraAdminSetQuotaArgs_Quota_DEFAULT *ResourceAggregate - -func (p *AuroraAdminSetQuotaArgs) GetQuota() *ResourceAggregate { - if !p.IsSetQuota() { - return AuroraAdminSetQuotaArgs_Quota_DEFAULT - } - return p.Quota -} -func (p *AuroraAdminSetQuotaArgs) IsSetQuota() bool { - return p.Quota != nil -} - -func (p *AuroraAdminSetQuotaArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminSetQuotaArgs) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.OwnerRole = v - } - return nil -} - -func (p *AuroraAdminSetQuotaArgs) readField2(iprot thrift.TProtocol) error { - p.Quota = &ResourceAggregate{} - if err := p.Quota.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Quota), err) - } - return nil -} - -func (p *AuroraAdminSetQuotaArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("setQuota_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminSetQuotaArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("ownerRole", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ownerRole: ", p), err) - } - if err := oprot.WriteString(string(p.OwnerRole)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.ownerRole (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ownerRole: ", p), err) - } - return err -} - -func (p *AuroraAdminSetQuotaArgs) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("quota", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:quota: ", p), err) - } - if err := p.Quota.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Quota), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:quota: ", p), err) - } - return err -} - -func (p *AuroraAdminSetQuotaArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminSetQuotaArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraAdminSetQuotaResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraAdminSetQuotaResult() *AuroraAdminSetQuotaResult { - return &AuroraAdminSetQuotaResult{} -} - -var AuroraAdminSetQuotaResult_Success_DEFAULT *Response - -func (p *AuroraAdminSetQuotaResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraAdminSetQuotaResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraAdminSetQuotaResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraAdminSetQuotaResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminSetQuotaResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraAdminSetQuotaResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("setQuota_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminSetQuotaResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraAdminSetQuotaResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminSetQuotaResult(%+v)", *p) -} - -// Attributes: -// - TaskId -// - Status -type AuroraAdminForceTaskStateArgs struct { - TaskId string `thrift:"taskId,1" json:"taskId"` - Status ScheduleStatus `thrift:"status,2" json:"status"` -} - -func NewAuroraAdminForceTaskStateArgs() *AuroraAdminForceTaskStateArgs { - return &AuroraAdminForceTaskStateArgs{} -} - -func (p *AuroraAdminForceTaskStateArgs) GetTaskId() string { - return p.TaskId -} - -func (p *AuroraAdminForceTaskStateArgs) GetStatus() ScheduleStatus { - return p.Status -} -func (p *AuroraAdminForceTaskStateArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminForceTaskStateArgs) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.TaskId = v - } - return nil -} - -func (p *AuroraAdminForceTaskStateArgs) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := ScheduleStatus(v) - p.Status = temp - } - return nil -} - -func (p *AuroraAdminForceTaskStateArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("forceTaskState_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminForceTaskStateArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("taskId", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:taskId: ", p), err) - } - if err := oprot.WriteString(string(p.TaskId)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.taskId (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:taskId: ", p), err) - } - return err -} - -func (p *AuroraAdminForceTaskStateArgs) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("status", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:status: ", p), err) - } - if err := oprot.WriteI32(int32(p.Status)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.status (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:status: ", p), err) - } - return err -} - -func (p *AuroraAdminForceTaskStateArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminForceTaskStateArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraAdminForceTaskStateResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraAdminForceTaskStateResult() *AuroraAdminForceTaskStateResult { - return &AuroraAdminForceTaskStateResult{} -} - -var AuroraAdminForceTaskStateResult_Success_DEFAULT *Response - -func (p *AuroraAdminForceTaskStateResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraAdminForceTaskStateResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraAdminForceTaskStateResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraAdminForceTaskStateResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminForceTaskStateResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraAdminForceTaskStateResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("forceTaskState_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminForceTaskStateResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraAdminForceTaskStateResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminForceTaskStateResult(%+v)", *p) -} - -type AuroraAdminPerformBackupArgs struct { -} - -func NewAuroraAdminPerformBackupArgs() *AuroraAdminPerformBackupArgs { - return &AuroraAdminPerformBackupArgs{} -} - -func (p *AuroraAdminPerformBackupArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminPerformBackupArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("performBackup_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminPerformBackupArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminPerformBackupArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraAdminPerformBackupResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraAdminPerformBackupResult() *AuroraAdminPerformBackupResult { - return &AuroraAdminPerformBackupResult{} -} - -var AuroraAdminPerformBackupResult_Success_DEFAULT *Response - -func (p *AuroraAdminPerformBackupResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraAdminPerformBackupResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraAdminPerformBackupResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraAdminPerformBackupResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminPerformBackupResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraAdminPerformBackupResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("performBackup_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminPerformBackupResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraAdminPerformBackupResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminPerformBackupResult(%+v)", *p) -} - -type AuroraAdminListBackupsArgs struct { -} - -func NewAuroraAdminListBackupsArgs() *AuroraAdminListBackupsArgs { - return &AuroraAdminListBackupsArgs{} -} - -func (p *AuroraAdminListBackupsArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminListBackupsArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("listBackups_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminListBackupsArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminListBackupsArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraAdminListBackupsResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraAdminListBackupsResult() *AuroraAdminListBackupsResult { - return &AuroraAdminListBackupsResult{} -} - -var AuroraAdminListBackupsResult_Success_DEFAULT *Response - -func (p *AuroraAdminListBackupsResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraAdminListBackupsResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraAdminListBackupsResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraAdminListBackupsResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminListBackupsResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraAdminListBackupsResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("listBackups_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminListBackupsResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraAdminListBackupsResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminListBackupsResult(%+v)", *p) -} - -// Attributes: -// - BackupId -type AuroraAdminStageRecoveryArgs struct { - BackupId string `thrift:"backupId,1" json:"backupId"` -} - -func NewAuroraAdminStageRecoveryArgs() *AuroraAdminStageRecoveryArgs { - return &AuroraAdminStageRecoveryArgs{} -} - -func (p *AuroraAdminStageRecoveryArgs) GetBackupId() string { - return p.BackupId -} -func (p *AuroraAdminStageRecoveryArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminStageRecoveryArgs) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.BackupId = v - } - return nil -} - -func (p *AuroraAdminStageRecoveryArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("stageRecovery_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminStageRecoveryArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("backupId", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:backupId: ", p), err) - } - if err := oprot.WriteString(string(p.BackupId)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.backupId (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:backupId: ", p), err) - } - return err -} - -func (p *AuroraAdminStageRecoveryArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminStageRecoveryArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraAdminStageRecoveryResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraAdminStageRecoveryResult() *AuroraAdminStageRecoveryResult { - return &AuroraAdminStageRecoveryResult{} -} - -var AuroraAdminStageRecoveryResult_Success_DEFAULT *Response - -func (p *AuroraAdminStageRecoveryResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraAdminStageRecoveryResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraAdminStageRecoveryResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraAdminStageRecoveryResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminStageRecoveryResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraAdminStageRecoveryResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("stageRecovery_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminStageRecoveryResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraAdminStageRecoveryResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminStageRecoveryResult(%+v)", *p) -} - -// Attributes: -// - Query -type AuroraAdminQueryRecoveryArgs struct { - Query *TaskQuery `thrift:"query,1" json:"query"` -} - -func NewAuroraAdminQueryRecoveryArgs() *AuroraAdminQueryRecoveryArgs { - return &AuroraAdminQueryRecoveryArgs{} -} - -var AuroraAdminQueryRecoveryArgs_Query_DEFAULT *TaskQuery - -func (p *AuroraAdminQueryRecoveryArgs) GetQuery() *TaskQuery { - if !p.IsSetQuery() { - return AuroraAdminQueryRecoveryArgs_Query_DEFAULT - } - return p.Query -} -func (p *AuroraAdminQueryRecoveryArgs) IsSetQuery() bool { - return p.Query != nil -} - -func (p *AuroraAdminQueryRecoveryArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminQueryRecoveryArgs) readField1(iprot thrift.TProtocol) error { - p.Query = &TaskQuery{} - if err := p.Query.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) - } - return nil -} - -func (p *AuroraAdminQueryRecoveryArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("queryRecovery_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminQueryRecoveryArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("query", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:query: ", p), err) - } - if err := p.Query.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:query: ", p), err) - } - return err -} - -func (p *AuroraAdminQueryRecoveryArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminQueryRecoveryArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraAdminQueryRecoveryResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraAdminQueryRecoveryResult() *AuroraAdminQueryRecoveryResult { - return &AuroraAdminQueryRecoveryResult{} -} - -var AuroraAdminQueryRecoveryResult_Success_DEFAULT *Response - -func (p *AuroraAdminQueryRecoveryResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraAdminQueryRecoveryResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraAdminQueryRecoveryResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraAdminQueryRecoveryResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminQueryRecoveryResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraAdminQueryRecoveryResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("queryRecovery_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminQueryRecoveryResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraAdminQueryRecoveryResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminQueryRecoveryResult(%+v)", *p) -} - -// Attributes: -// - Query -type AuroraAdminDeleteRecoveryTasksArgs struct { - Query *TaskQuery `thrift:"query,1" json:"query"` -} - -func NewAuroraAdminDeleteRecoveryTasksArgs() *AuroraAdminDeleteRecoveryTasksArgs { - return &AuroraAdminDeleteRecoveryTasksArgs{} -} - -var AuroraAdminDeleteRecoveryTasksArgs_Query_DEFAULT *TaskQuery - -func (p *AuroraAdminDeleteRecoveryTasksArgs) GetQuery() *TaskQuery { - if !p.IsSetQuery() { - return AuroraAdminDeleteRecoveryTasksArgs_Query_DEFAULT - } - return p.Query -} -func (p *AuroraAdminDeleteRecoveryTasksArgs) IsSetQuery() bool { - return p.Query != nil -} - -func (p *AuroraAdminDeleteRecoveryTasksArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminDeleteRecoveryTasksArgs) readField1(iprot thrift.TProtocol) error { - p.Query = &TaskQuery{} - if err := p.Query.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) - } - return nil -} - -func (p *AuroraAdminDeleteRecoveryTasksArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("deleteRecoveryTasks_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminDeleteRecoveryTasksArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("query", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:query: ", p), err) - } - if err := p.Query.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:query: ", p), err) - } - return err -} - -func (p *AuroraAdminDeleteRecoveryTasksArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminDeleteRecoveryTasksArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraAdminDeleteRecoveryTasksResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraAdminDeleteRecoveryTasksResult() *AuroraAdminDeleteRecoveryTasksResult { - return &AuroraAdminDeleteRecoveryTasksResult{} -} - -var AuroraAdminDeleteRecoveryTasksResult_Success_DEFAULT *Response - -func (p *AuroraAdminDeleteRecoveryTasksResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraAdminDeleteRecoveryTasksResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraAdminDeleteRecoveryTasksResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraAdminDeleteRecoveryTasksResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminDeleteRecoveryTasksResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraAdminDeleteRecoveryTasksResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("deleteRecoveryTasks_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminDeleteRecoveryTasksResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraAdminDeleteRecoveryTasksResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminDeleteRecoveryTasksResult(%+v)", *p) -} - -type AuroraAdminCommitRecoveryArgs struct { -} - -func NewAuroraAdminCommitRecoveryArgs() *AuroraAdminCommitRecoveryArgs { - return &AuroraAdminCommitRecoveryArgs{} -} - -func (p *AuroraAdminCommitRecoveryArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminCommitRecoveryArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("commitRecovery_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminCommitRecoveryArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminCommitRecoveryArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraAdminCommitRecoveryResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraAdminCommitRecoveryResult() *AuroraAdminCommitRecoveryResult { - return &AuroraAdminCommitRecoveryResult{} -} - -var AuroraAdminCommitRecoveryResult_Success_DEFAULT *Response - -func (p *AuroraAdminCommitRecoveryResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraAdminCommitRecoveryResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraAdminCommitRecoveryResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraAdminCommitRecoveryResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminCommitRecoveryResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraAdminCommitRecoveryResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("commitRecovery_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminCommitRecoveryResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraAdminCommitRecoveryResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminCommitRecoveryResult(%+v)", *p) -} - -type AuroraAdminUnloadRecoveryArgs struct { -} - -func NewAuroraAdminUnloadRecoveryArgs() *AuroraAdminUnloadRecoveryArgs { - return &AuroraAdminUnloadRecoveryArgs{} -} - -func (p *AuroraAdminUnloadRecoveryArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminUnloadRecoveryArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("unloadRecovery_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminUnloadRecoveryArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminUnloadRecoveryArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraAdminUnloadRecoveryResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraAdminUnloadRecoveryResult() *AuroraAdminUnloadRecoveryResult { - return &AuroraAdminUnloadRecoveryResult{} -} - -var AuroraAdminUnloadRecoveryResult_Success_DEFAULT *Response - -func (p *AuroraAdminUnloadRecoveryResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraAdminUnloadRecoveryResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraAdminUnloadRecoveryResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraAdminUnloadRecoveryResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminUnloadRecoveryResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraAdminUnloadRecoveryResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("unloadRecovery_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminUnloadRecoveryResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraAdminUnloadRecoveryResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminUnloadRecoveryResult(%+v)", *p) -} - -// Attributes: -// - Hosts -type AuroraAdminStartMaintenanceArgs struct { - Hosts *Hosts `thrift:"hosts,1" json:"hosts"` -} - -func NewAuroraAdminStartMaintenanceArgs() *AuroraAdminStartMaintenanceArgs { - return &AuroraAdminStartMaintenanceArgs{} -} - -var AuroraAdminStartMaintenanceArgs_Hosts_DEFAULT *Hosts - -func (p *AuroraAdminStartMaintenanceArgs) GetHosts() *Hosts { - if !p.IsSetHosts() { - return AuroraAdminStartMaintenanceArgs_Hosts_DEFAULT - } - return p.Hosts -} -func (p *AuroraAdminStartMaintenanceArgs) IsSetHosts() bool { - return p.Hosts != nil -} - -func (p *AuroraAdminStartMaintenanceArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminStartMaintenanceArgs) readField1(iprot thrift.TProtocol) error { - p.Hosts = &Hosts{} - if err := p.Hosts.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Hosts), err) - } - return nil -} - -func (p *AuroraAdminStartMaintenanceArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("startMaintenance_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminStartMaintenanceArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("hosts", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:hosts: ", p), err) - } - if err := p.Hosts.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Hosts), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:hosts: ", p), err) - } - return err -} - -func (p *AuroraAdminStartMaintenanceArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminStartMaintenanceArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraAdminStartMaintenanceResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraAdminStartMaintenanceResult() *AuroraAdminStartMaintenanceResult { - return &AuroraAdminStartMaintenanceResult{} -} - -var AuroraAdminStartMaintenanceResult_Success_DEFAULT *Response - -func (p *AuroraAdminStartMaintenanceResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraAdminStartMaintenanceResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraAdminStartMaintenanceResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraAdminStartMaintenanceResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminStartMaintenanceResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraAdminStartMaintenanceResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("startMaintenance_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminStartMaintenanceResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraAdminStartMaintenanceResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminStartMaintenanceResult(%+v)", *p) -} - -// Attributes: -// - Hosts -type AuroraAdminDrainHostsArgs struct { - Hosts *Hosts `thrift:"hosts,1" json:"hosts"` -} - -func NewAuroraAdminDrainHostsArgs() *AuroraAdminDrainHostsArgs { - return &AuroraAdminDrainHostsArgs{} -} - -var AuroraAdminDrainHostsArgs_Hosts_DEFAULT *Hosts - -func (p *AuroraAdminDrainHostsArgs) GetHosts() *Hosts { - if !p.IsSetHosts() { - return AuroraAdminDrainHostsArgs_Hosts_DEFAULT - } - return p.Hosts -} -func (p *AuroraAdminDrainHostsArgs) IsSetHosts() bool { - return p.Hosts != nil -} - -func (p *AuroraAdminDrainHostsArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminDrainHostsArgs) readField1(iprot thrift.TProtocol) error { - p.Hosts = &Hosts{} - if err := p.Hosts.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Hosts), err) - } - return nil -} - -func (p *AuroraAdminDrainHostsArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("drainHosts_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminDrainHostsArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("hosts", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:hosts: ", p), err) - } - if err := p.Hosts.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Hosts), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:hosts: ", p), err) - } - return err -} - -func (p *AuroraAdminDrainHostsArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminDrainHostsArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraAdminDrainHostsResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraAdminDrainHostsResult() *AuroraAdminDrainHostsResult { - return &AuroraAdminDrainHostsResult{} -} - -var AuroraAdminDrainHostsResult_Success_DEFAULT *Response - -func (p *AuroraAdminDrainHostsResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraAdminDrainHostsResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraAdminDrainHostsResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraAdminDrainHostsResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminDrainHostsResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraAdminDrainHostsResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("drainHosts_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminDrainHostsResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraAdminDrainHostsResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminDrainHostsResult(%+v)", *p) -} - -// Attributes: -// - Hosts -type AuroraAdminMaintenanceStatusArgs struct { - Hosts *Hosts `thrift:"hosts,1" json:"hosts"` -} - -func NewAuroraAdminMaintenanceStatusArgs() *AuroraAdminMaintenanceStatusArgs { - return &AuroraAdminMaintenanceStatusArgs{} -} - -var AuroraAdminMaintenanceStatusArgs_Hosts_DEFAULT *Hosts - -func (p *AuroraAdminMaintenanceStatusArgs) GetHosts() *Hosts { - if !p.IsSetHosts() { - return AuroraAdminMaintenanceStatusArgs_Hosts_DEFAULT - } - return p.Hosts -} -func (p *AuroraAdminMaintenanceStatusArgs) IsSetHosts() bool { - return p.Hosts != nil -} - -func (p *AuroraAdminMaintenanceStatusArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminMaintenanceStatusArgs) readField1(iprot thrift.TProtocol) error { - p.Hosts = &Hosts{} - if err := p.Hosts.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Hosts), err) - } - return nil -} - -func (p *AuroraAdminMaintenanceStatusArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("maintenanceStatus_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminMaintenanceStatusArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("hosts", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:hosts: ", p), err) - } - if err := p.Hosts.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Hosts), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:hosts: ", p), err) - } - return err -} - -func (p *AuroraAdminMaintenanceStatusArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminMaintenanceStatusArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraAdminMaintenanceStatusResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraAdminMaintenanceStatusResult() *AuroraAdminMaintenanceStatusResult { - return &AuroraAdminMaintenanceStatusResult{} -} - -var AuroraAdminMaintenanceStatusResult_Success_DEFAULT *Response - -func (p *AuroraAdminMaintenanceStatusResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraAdminMaintenanceStatusResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraAdminMaintenanceStatusResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraAdminMaintenanceStatusResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminMaintenanceStatusResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraAdminMaintenanceStatusResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("maintenanceStatus_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminMaintenanceStatusResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraAdminMaintenanceStatusResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminMaintenanceStatusResult(%+v)", *p) -} - -// Attributes: -// - Hosts -type AuroraAdminEndMaintenanceArgs struct { - Hosts *Hosts `thrift:"hosts,1" json:"hosts"` -} - -func NewAuroraAdminEndMaintenanceArgs() *AuroraAdminEndMaintenanceArgs { - return &AuroraAdminEndMaintenanceArgs{} -} - -var AuroraAdminEndMaintenanceArgs_Hosts_DEFAULT *Hosts - -func (p *AuroraAdminEndMaintenanceArgs) GetHosts() *Hosts { - if !p.IsSetHosts() { - return AuroraAdminEndMaintenanceArgs_Hosts_DEFAULT - } - return p.Hosts -} -func (p *AuroraAdminEndMaintenanceArgs) IsSetHosts() bool { - return p.Hosts != nil -} - -func (p *AuroraAdminEndMaintenanceArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminEndMaintenanceArgs) readField1(iprot thrift.TProtocol) error { - p.Hosts = &Hosts{} - if err := p.Hosts.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Hosts), err) - } - return nil -} - -func (p *AuroraAdminEndMaintenanceArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("endMaintenance_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminEndMaintenanceArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("hosts", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:hosts: ", p), err) - } - if err := p.Hosts.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Hosts), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:hosts: ", p), err) - } - return err -} - -func (p *AuroraAdminEndMaintenanceArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminEndMaintenanceArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraAdminEndMaintenanceResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraAdminEndMaintenanceResult() *AuroraAdminEndMaintenanceResult { - return &AuroraAdminEndMaintenanceResult{} -} - -var AuroraAdminEndMaintenanceResult_Success_DEFAULT *Response - -func (p *AuroraAdminEndMaintenanceResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraAdminEndMaintenanceResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraAdminEndMaintenanceResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraAdminEndMaintenanceResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminEndMaintenanceResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraAdminEndMaintenanceResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("endMaintenance_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminEndMaintenanceResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraAdminEndMaintenanceResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminEndMaintenanceResult(%+v)", *p) -} - -type AuroraAdminSnapshotArgs struct { -} - -func NewAuroraAdminSnapshotArgs() *AuroraAdminSnapshotArgs { - return &AuroraAdminSnapshotArgs{} -} - -func (p *AuroraAdminSnapshotArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminSnapshotArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("snapshot_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminSnapshotArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminSnapshotArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraAdminSnapshotResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraAdminSnapshotResult() *AuroraAdminSnapshotResult { - return &AuroraAdminSnapshotResult{} -} - -var AuroraAdminSnapshotResult_Success_DEFAULT *Response - -func (p *AuroraAdminSnapshotResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraAdminSnapshotResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraAdminSnapshotResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraAdminSnapshotResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminSnapshotResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraAdminSnapshotResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("snapshot_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminSnapshotResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraAdminSnapshotResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminSnapshotResult(%+v)", *p) -} - -// Attributes: -// - Request -type AuroraAdminRewriteConfigsArgs struct { - Request *RewriteConfigsRequest `thrift:"request,1" json:"request"` -} - -func NewAuroraAdminRewriteConfigsArgs() *AuroraAdminRewriteConfigsArgs { - return &AuroraAdminRewriteConfigsArgs{} -} - -var AuroraAdminRewriteConfigsArgs_Request_DEFAULT *RewriteConfigsRequest - -func (p *AuroraAdminRewriteConfigsArgs) GetRequest() *RewriteConfigsRequest { - if !p.IsSetRequest() { - return AuroraAdminRewriteConfigsArgs_Request_DEFAULT - } - return p.Request -} -func (p *AuroraAdminRewriteConfigsArgs) IsSetRequest() bool { - return p.Request != nil -} - -func (p *AuroraAdminRewriteConfigsArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminRewriteConfigsArgs) readField1(iprot thrift.TProtocol) error { - p.Request = &RewriteConfigsRequest{} - if err := p.Request.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Request), err) - } - return nil -} - -func (p *AuroraAdminRewriteConfigsArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("rewriteConfigs_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminRewriteConfigsArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:request: ", p), err) - } - if err := p.Request.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Request), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:request: ", p), err) - } - return err -} - -func (p *AuroraAdminRewriteConfigsArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminRewriteConfigsArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraAdminRewriteConfigsResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraAdminRewriteConfigsResult() *AuroraAdminRewriteConfigsResult { - return &AuroraAdminRewriteConfigsResult{} -} - -var AuroraAdminRewriteConfigsResult_Success_DEFAULT *Response - -func (p *AuroraAdminRewriteConfigsResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraAdminRewriteConfigsResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraAdminRewriteConfigsResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraAdminRewriteConfigsResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminRewriteConfigsResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraAdminRewriteConfigsResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("rewriteConfigs_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminRewriteConfigsResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraAdminRewriteConfigsResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminRewriteConfigsResult(%+v)", *p) -} - -// Attributes: -// - Settings -type AuroraAdminTriggerExplicitTaskReconciliationArgs struct { - Settings *ExplicitReconciliationSettings `thrift:"settings,1" json:"settings"` -} - -func NewAuroraAdminTriggerExplicitTaskReconciliationArgs() *AuroraAdminTriggerExplicitTaskReconciliationArgs { - return &AuroraAdminTriggerExplicitTaskReconciliationArgs{} -} - -var AuroraAdminTriggerExplicitTaskReconciliationArgs_Settings_DEFAULT *ExplicitReconciliationSettings - -func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) GetSettings() *ExplicitReconciliationSettings { - if !p.IsSetSettings() { - return AuroraAdminTriggerExplicitTaskReconciliationArgs_Settings_DEFAULT - } - return p.Settings -} -func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) IsSetSettings() bool { - return p.Settings != nil -} - -func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) readField1(iprot thrift.TProtocol) error { - p.Settings = &ExplicitReconciliationSettings{} - if err := p.Settings.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Settings), err) - } - return nil -} - -func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("triggerExplicitTaskReconciliation_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("settings", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:settings: ", p), err) - } - if err := p.Settings.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Settings), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:settings: ", p), err) - } - return err -} - -func (p *AuroraAdminTriggerExplicitTaskReconciliationArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminTriggerExplicitTaskReconciliationArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraAdminTriggerExplicitTaskReconciliationResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraAdminTriggerExplicitTaskReconciliationResult() *AuroraAdminTriggerExplicitTaskReconciliationResult { - return &AuroraAdminTriggerExplicitTaskReconciliationResult{} -} - -var AuroraAdminTriggerExplicitTaskReconciliationResult_Success_DEFAULT *Response - -func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraAdminTriggerExplicitTaskReconciliationResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("triggerExplicitTaskReconciliation_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraAdminTriggerExplicitTaskReconciliationResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminTriggerExplicitTaskReconciliationResult(%+v)", *p) -} - -type AuroraAdminTriggerImplicitTaskReconciliationArgs struct { -} - -func NewAuroraAdminTriggerImplicitTaskReconciliationArgs() *AuroraAdminTriggerImplicitTaskReconciliationArgs { - return &AuroraAdminTriggerImplicitTaskReconciliationArgs{} -} - -func (p *AuroraAdminTriggerImplicitTaskReconciliationArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminTriggerImplicitTaskReconciliationArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("triggerImplicitTaskReconciliation_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminTriggerImplicitTaskReconciliationArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminTriggerImplicitTaskReconciliationArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraAdminTriggerImplicitTaskReconciliationResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraAdminTriggerImplicitTaskReconciliationResult() *AuroraAdminTriggerImplicitTaskReconciliationResult { - return &AuroraAdminTriggerImplicitTaskReconciliationResult{} -} - -var AuroraAdminTriggerImplicitTaskReconciliationResult_Success_DEFAULT *Response - -func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraAdminTriggerImplicitTaskReconciliationResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("triggerImplicitTaskReconciliation_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraAdminTriggerImplicitTaskReconciliationResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraAdminTriggerImplicitTaskReconciliationResult(%+v)", *p) -} diff --git a/gen-go/apache/aurora/auroraschedulermanager.go b/gen-go/apache/aurora/auroraschedulermanager.go deleted file mode 100644 index 26865dc..0000000 --- a/gen-go/apache/aurora/auroraschedulermanager.go +++ /dev/null @@ -1,5077 +0,0 @@ -// Autogenerated by Thrift Compiler (0.9.3) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -package aurora - -import ( - "bytes" - "fmt" - "git.apache.org/thrift.git/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = bytes.Equal - -type AuroraSchedulerManager interface { - ReadOnlyScheduler - - // Creates a new job. The request will be denied if a job with the provided name already exists - // in the cluster. - // - // Parameters: - // - Description - CreateJob(description *JobConfiguration) (r *Response, err error) - // Enters a job into the cron schedule, without actually starting the job. - // If the job is already present in the schedule, this will update the schedule entry with the new - // configuration. - // - // Parameters: - // - Description - ScheduleCronJob(description *JobConfiguration) (r *Response, err error) - // Removes a job from the cron schedule. The request will be denied if the job was not previously - // scheduled with scheduleCronJob. - // - // Parameters: - // - Job - DescheduleCronJob(job *JobKey) (r *Response, err error) - // Starts a cron job immediately. The request will be denied if the specified job does not - // exist for the role account, or the job is not a cron job. - // - // Parameters: - // - Job - StartCronJob(job *JobKey) (r *Response, err error) - // Restarts a batch of shards. - // - // Parameters: - // - Job - // - ShardIds - RestartShards(job *JobKey, shardIds map[int32]bool) (r *Response, err error) - // Initiates a kill on tasks. - // - // Parameters: - // - Job - // - Instances - KillTasks(job *JobKey, instances map[int32]bool) (r *Response, err error) - // Adds new instances with the TaskConfig of the existing instance pointed by the key. - // - // Parameters: - // - Key - // - Count - AddInstances(key *InstanceKey, count int32) (r *Response, err error) - // Replaces the template (configuration) for the existing cron job. - // The cron job template (configuration) must exist for the call to succeed. - // - // Parameters: - // - Config - ReplaceCronTemplate(config *JobConfiguration) (r *Response, err error) - // Starts update of the existing service job. - // - // Parameters: - // - Request: A description of how to change the job. - // - Message: A user-specified message to include with the induced job update state change. - StartJobUpdate(request *JobUpdateRequest, message string) (r *Response, err error) - // Pauses the specified job update. Can be resumed by resumeUpdate call. - // - // Parameters: - // - Key: The update to pause. - // - Message: A user-specified message to include with the induced job update state change. - PauseJobUpdate(key *JobUpdateKey, message string) (r *Response, err error) - // Resumes progress of a previously paused job update. - // - // Parameters: - // - Key: The update to resume. - // - Message: A user-specified message to include with the induced job update state change. - ResumeJobUpdate(key *JobUpdateKey, message string) (r *Response, err error) - // Permanently aborts the job update. Does not remove the update history. - // - // Parameters: - // - Key: The update to abort. - // - Message: A user-specified message to include with the induced job update state change. - AbortJobUpdate(key *JobUpdateKey, message string) (r *Response, err error) - // Rollbacks the specified active job update to the initial state. - // - // Parameters: - // - Key: The update to rollback. - // - Message: A user-specified message to include with the induced job update state change. - RollbackJobUpdate(key *JobUpdateKey, message string) (r *Response, err error) - // Allows progress of the job update in case blockIfNoPulsesAfterMs is specified in - // JobUpdateSettings. Unblocks progress if the update was previously blocked. - // Responds with ResponseCode.INVALID_REQUEST in case an unknown update key is specified. - // - // Parameters: - // - Key - PulseJobUpdate(key *JobUpdateKey) (r *Response, err error) -} - -type AuroraSchedulerManagerClient struct { - *ReadOnlySchedulerClient -} - -func NewAuroraSchedulerManagerClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *AuroraSchedulerManagerClient { - return &AuroraSchedulerManagerClient{ReadOnlySchedulerClient: NewReadOnlySchedulerClientFactory(t, f)} -} - -func NewAuroraSchedulerManagerClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *AuroraSchedulerManagerClient { - return &AuroraSchedulerManagerClient{ReadOnlySchedulerClient: NewReadOnlySchedulerClientProtocol(t, iprot, oprot)} -} - -// Creates a new job. The request will be denied if a job with the provided name already exists -// in the cluster. -// -// Parameters: -// - Description -func (p *AuroraSchedulerManagerClient) CreateJob(description *JobConfiguration) (r *Response, err error) { - if err = p.sendCreateJob(description); err != nil { - return - } - return p.recvCreateJob() -} - -func (p *AuroraSchedulerManagerClient) sendCreateJob(description *JobConfiguration) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("createJob", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraSchedulerManagerCreateJobArgs{ - Description: description, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraSchedulerManagerClient) recvCreateJob() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "createJob" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "createJob failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "createJob failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error132 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error133 error - error133, err = error132.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error133 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "createJob failed: invalid message type") - return - } - result := AuroraSchedulerManagerCreateJobResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Enters a job into the cron schedule, without actually starting the job. -// If the job is already present in the schedule, this will update the schedule entry with the new -// configuration. -// -// Parameters: -// - Description -func (p *AuroraSchedulerManagerClient) ScheduleCronJob(description *JobConfiguration) (r *Response, err error) { - if err = p.sendScheduleCronJob(description); err != nil { - return - } - return p.recvScheduleCronJob() -} - -func (p *AuroraSchedulerManagerClient) sendScheduleCronJob(description *JobConfiguration) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("scheduleCronJob", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraSchedulerManagerScheduleCronJobArgs{ - Description: description, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraSchedulerManagerClient) recvScheduleCronJob() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "scheduleCronJob" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "scheduleCronJob failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "scheduleCronJob failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error134 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error135 error - error135, err = error134.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error135 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "scheduleCronJob failed: invalid message type") - return - } - result := AuroraSchedulerManagerScheduleCronJobResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Removes a job from the cron schedule. The request will be denied if the job was not previously -// scheduled with scheduleCronJob. -// -// Parameters: -// - Job -func (p *AuroraSchedulerManagerClient) DescheduleCronJob(job *JobKey) (r *Response, err error) { - if err = p.sendDescheduleCronJob(job); err != nil { - return - } - return p.recvDescheduleCronJob() -} - -func (p *AuroraSchedulerManagerClient) sendDescheduleCronJob(job *JobKey) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("descheduleCronJob", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraSchedulerManagerDescheduleCronJobArgs{ - Job: job, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraSchedulerManagerClient) recvDescheduleCronJob() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "descheduleCronJob" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "descheduleCronJob failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "descheduleCronJob failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error136 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error137 error - error137, err = error136.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error137 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "descheduleCronJob failed: invalid message type") - return - } - result := AuroraSchedulerManagerDescheduleCronJobResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Starts a cron job immediately. The request will be denied if the specified job does not -// exist for the role account, or the job is not a cron job. -// -// Parameters: -// - Job -func (p *AuroraSchedulerManagerClient) StartCronJob(job *JobKey) (r *Response, err error) { - if err = p.sendStartCronJob(job); err != nil { - return - } - return p.recvStartCronJob() -} - -func (p *AuroraSchedulerManagerClient) sendStartCronJob(job *JobKey) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("startCronJob", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraSchedulerManagerStartCronJobArgs{ - Job: job, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraSchedulerManagerClient) recvStartCronJob() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "startCronJob" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "startCronJob failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "startCronJob failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error138 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error139 error - error139, err = error138.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error139 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "startCronJob failed: invalid message type") - return - } - result := AuroraSchedulerManagerStartCronJobResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Restarts a batch of shards. -// -// Parameters: -// - Job -// - ShardIds -func (p *AuroraSchedulerManagerClient) RestartShards(job *JobKey, shardIds map[int32]bool) (r *Response, err error) { - if err = p.sendRestartShards(job, shardIds); err != nil { - return - } - return p.recvRestartShards() -} - -func (p *AuroraSchedulerManagerClient) sendRestartShards(job *JobKey, shardIds map[int32]bool) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("restartShards", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraSchedulerManagerRestartShardsArgs{ - Job: job, - ShardIds: shardIds, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraSchedulerManagerClient) recvRestartShards() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "restartShards" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "restartShards failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "restartShards failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error140 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error141 error - error141, err = error140.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error141 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "restartShards failed: invalid message type") - return - } - result := AuroraSchedulerManagerRestartShardsResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Initiates a kill on tasks. -// -// Parameters: -// - Job -// - Instances -func (p *AuroraSchedulerManagerClient) KillTasks(job *JobKey, instances map[int32]bool) (r *Response, err error) { - if err = p.sendKillTasks(job, instances); err != nil { - return - } - return p.recvKillTasks() -} - -func (p *AuroraSchedulerManagerClient) sendKillTasks(job *JobKey, instances map[int32]bool) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("killTasks", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraSchedulerManagerKillTasksArgs{ - Job: job, - Instances: instances, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraSchedulerManagerClient) recvKillTasks() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "killTasks" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "killTasks failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "killTasks failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error142 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error143 error - error143, err = error142.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error143 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "killTasks failed: invalid message type") - return - } - result := AuroraSchedulerManagerKillTasksResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Adds new instances with the TaskConfig of the existing instance pointed by the key. -// -// Parameters: -// - Key -// - Count -func (p *AuroraSchedulerManagerClient) AddInstances(key *InstanceKey, count int32) (r *Response, err error) { - if err = p.sendAddInstances(key, count); err != nil { - return - } - return p.recvAddInstances() -} - -func (p *AuroraSchedulerManagerClient) sendAddInstances(key *InstanceKey, count int32) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("addInstances", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraSchedulerManagerAddInstancesArgs{ - Key: key, - Count: count, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraSchedulerManagerClient) recvAddInstances() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "addInstances" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "addInstances failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "addInstances failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error144 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error145 error - error145, err = error144.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error145 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "addInstances failed: invalid message type") - return - } - result := AuroraSchedulerManagerAddInstancesResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Replaces the template (configuration) for the existing cron job. -// The cron job template (configuration) must exist for the call to succeed. -// -// Parameters: -// - Config -func (p *AuroraSchedulerManagerClient) ReplaceCronTemplate(config *JobConfiguration) (r *Response, err error) { - if err = p.sendReplaceCronTemplate(config); err != nil { - return - } - return p.recvReplaceCronTemplate() -} - -func (p *AuroraSchedulerManagerClient) sendReplaceCronTemplate(config *JobConfiguration) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("replaceCronTemplate", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraSchedulerManagerReplaceCronTemplateArgs{ - Config: config, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraSchedulerManagerClient) recvReplaceCronTemplate() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "replaceCronTemplate" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "replaceCronTemplate failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "replaceCronTemplate failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error146 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error147 error - error147, err = error146.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error147 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "replaceCronTemplate failed: invalid message type") - return - } - result := AuroraSchedulerManagerReplaceCronTemplateResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Starts update of the existing service job. -// -// Parameters: -// - Request: A description of how to change the job. -// - Message: A user-specified message to include with the induced job update state change. -func (p *AuroraSchedulerManagerClient) StartJobUpdate(request *JobUpdateRequest, message string) (r *Response, err error) { - if err = p.sendStartJobUpdate(request, message); err != nil { - return - } - return p.recvStartJobUpdate() -} - -func (p *AuroraSchedulerManagerClient) sendStartJobUpdate(request *JobUpdateRequest, message string) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("startJobUpdate", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraSchedulerManagerStartJobUpdateArgs{ - Request: request, - Message: message, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraSchedulerManagerClient) recvStartJobUpdate() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "startJobUpdate" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "startJobUpdate failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "startJobUpdate failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error148 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error149 error - error149, err = error148.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error149 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "startJobUpdate failed: invalid message type") - return - } - result := AuroraSchedulerManagerStartJobUpdateResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Pauses the specified job update. Can be resumed by resumeUpdate call. -// -// Parameters: -// - Key: The update to pause. -// - Message: A user-specified message to include with the induced job update state change. -func (p *AuroraSchedulerManagerClient) PauseJobUpdate(key *JobUpdateKey, message string) (r *Response, err error) { - if err = p.sendPauseJobUpdate(key, message); err != nil { - return - } - return p.recvPauseJobUpdate() -} - -func (p *AuroraSchedulerManagerClient) sendPauseJobUpdate(key *JobUpdateKey, message string) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("pauseJobUpdate", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraSchedulerManagerPauseJobUpdateArgs{ - Key: key, - Message: message, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraSchedulerManagerClient) recvPauseJobUpdate() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "pauseJobUpdate" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "pauseJobUpdate failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "pauseJobUpdate failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error150 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error151 error - error151, err = error150.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error151 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "pauseJobUpdate failed: invalid message type") - return - } - result := AuroraSchedulerManagerPauseJobUpdateResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Resumes progress of a previously paused job update. -// -// Parameters: -// - Key: The update to resume. -// - Message: A user-specified message to include with the induced job update state change. -func (p *AuroraSchedulerManagerClient) ResumeJobUpdate(key *JobUpdateKey, message string) (r *Response, err error) { - if err = p.sendResumeJobUpdate(key, message); err != nil { - return - } - return p.recvResumeJobUpdate() -} - -func (p *AuroraSchedulerManagerClient) sendResumeJobUpdate(key *JobUpdateKey, message string) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("resumeJobUpdate", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraSchedulerManagerResumeJobUpdateArgs{ - Key: key, - Message: message, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraSchedulerManagerClient) recvResumeJobUpdate() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "resumeJobUpdate" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "resumeJobUpdate failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "resumeJobUpdate failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error152 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error153 error - error153, err = error152.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error153 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "resumeJobUpdate failed: invalid message type") - return - } - result := AuroraSchedulerManagerResumeJobUpdateResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Permanently aborts the job update. Does not remove the update history. -// -// Parameters: -// - Key: The update to abort. -// - Message: A user-specified message to include with the induced job update state change. -func (p *AuroraSchedulerManagerClient) AbortJobUpdate(key *JobUpdateKey, message string) (r *Response, err error) { - if err = p.sendAbortJobUpdate(key, message); err != nil { - return - } - return p.recvAbortJobUpdate() -} - -func (p *AuroraSchedulerManagerClient) sendAbortJobUpdate(key *JobUpdateKey, message string) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("abortJobUpdate", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraSchedulerManagerAbortJobUpdateArgs{ - Key: key, - Message: message, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraSchedulerManagerClient) recvAbortJobUpdate() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "abortJobUpdate" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "abortJobUpdate failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "abortJobUpdate failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error154 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error155 error - error155, err = error154.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error155 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "abortJobUpdate failed: invalid message type") - return - } - result := AuroraSchedulerManagerAbortJobUpdateResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Rollbacks the specified active job update to the initial state. -// -// Parameters: -// - Key: The update to rollback. -// - Message: A user-specified message to include with the induced job update state change. -func (p *AuroraSchedulerManagerClient) RollbackJobUpdate(key *JobUpdateKey, message string) (r *Response, err error) { - if err = p.sendRollbackJobUpdate(key, message); err != nil { - return - } - return p.recvRollbackJobUpdate() -} - -func (p *AuroraSchedulerManagerClient) sendRollbackJobUpdate(key *JobUpdateKey, message string) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("rollbackJobUpdate", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraSchedulerManagerRollbackJobUpdateArgs{ - Key: key, - Message: message, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraSchedulerManagerClient) recvRollbackJobUpdate() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "rollbackJobUpdate" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "rollbackJobUpdate failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "rollbackJobUpdate failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error156 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error157 error - error157, err = error156.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error157 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "rollbackJobUpdate failed: invalid message type") - return - } - result := AuroraSchedulerManagerRollbackJobUpdateResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Allows progress of the job update in case blockIfNoPulsesAfterMs is specified in -// JobUpdateSettings. Unblocks progress if the update was previously blocked. -// Responds with ResponseCode.INVALID_REQUEST in case an unknown update key is specified. -// -// Parameters: -// - Key -func (p *AuroraSchedulerManagerClient) PulseJobUpdate(key *JobUpdateKey) (r *Response, err error) { - if err = p.sendPulseJobUpdate(key); err != nil { - return - } - return p.recvPulseJobUpdate() -} - -func (p *AuroraSchedulerManagerClient) sendPulseJobUpdate(key *JobUpdateKey) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("pulseJobUpdate", thrift.CALL, p.SeqId); err != nil { - return - } - args := AuroraSchedulerManagerPulseJobUpdateArgs{ - Key: key, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *AuroraSchedulerManagerClient) recvPulseJobUpdate() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "pulseJobUpdate" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "pulseJobUpdate failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "pulseJobUpdate failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error158 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error159 error - error159, err = error158.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error159 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "pulseJobUpdate failed: invalid message type") - return - } - result := AuroraSchedulerManagerPulseJobUpdateResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -type AuroraSchedulerManagerProcessor struct { - *ReadOnlySchedulerProcessor -} - -func NewAuroraSchedulerManagerProcessor(handler AuroraSchedulerManager) *AuroraSchedulerManagerProcessor { - self160 := &AuroraSchedulerManagerProcessor{NewReadOnlySchedulerProcessor(handler)} - self160.AddToProcessorMap("createJob", &auroraSchedulerManagerProcessorCreateJob{handler: handler}) - self160.AddToProcessorMap("scheduleCronJob", &auroraSchedulerManagerProcessorScheduleCronJob{handler: handler}) - self160.AddToProcessorMap("descheduleCronJob", &auroraSchedulerManagerProcessorDescheduleCronJob{handler: handler}) - self160.AddToProcessorMap("startCronJob", &auroraSchedulerManagerProcessorStartCronJob{handler: handler}) - self160.AddToProcessorMap("restartShards", &auroraSchedulerManagerProcessorRestartShards{handler: handler}) - self160.AddToProcessorMap("killTasks", &auroraSchedulerManagerProcessorKillTasks{handler: handler}) - self160.AddToProcessorMap("addInstances", &auroraSchedulerManagerProcessorAddInstances{handler: handler}) - self160.AddToProcessorMap("replaceCronTemplate", &auroraSchedulerManagerProcessorReplaceCronTemplate{handler: handler}) - self160.AddToProcessorMap("startJobUpdate", &auroraSchedulerManagerProcessorStartJobUpdate{handler: handler}) - self160.AddToProcessorMap("pauseJobUpdate", &auroraSchedulerManagerProcessorPauseJobUpdate{handler: handler}) - self160.AddToProcessorMap("resumeJobUpdate", &auroraSchedulerManagerProcessorResumeJobUpdate{handler: handler}) - self160.AddToProcessorMap("abortJobUpdate", &auroraSchedulerManagerProcessorAbortJobUpdate{handler: handler}) - self160.AddToProcessorMap("rollbackJobUpdate", &auroraSchedulerManagerProcessorRollbackJobUpdate{handler: handler}) - self160.AddToProcessorMap("pulseJobUpdate", &auroraSchedulerManagerProcessorPulseJobUpdate{handler: handler}) - return self160 -} - -type auroraSchedulerManagerProcessorCreateJob struct { - handler AuroraSchedulerManager -} - -func (p *auroraSchedulerManagerProcessorCreateJob) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraSchedulerManagerCreateJobArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("createJob", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraSchedulerManagerCreateJobResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.CreateJob(args.Description); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing createJob: "+err2.Error()) - oprot.WriteMessageBegin("createJob", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("createJob", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraSchedulerManagerProcessorScheduleCronJob struct { - handler AuroraSchedulerManager -} - -func (p *auroraSchedulerManagerProcessorScheduleCronJob) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraSchedulerManagerScheduleCronJobArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("scheduleCronJob", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraSchedulerManagerScheduleCronJobResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.ScheduleCronJob(args.Description); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing scheduleCronJob: "+err2.Error()) - oprot.WriteMessageBegin("scheduleCronJob", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("scheduleCronJob", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraSchedulerManagerProcessorDescheduleCronJob struct { - handler AuroraSchedulerManager -} - -func (p *auroraSchedulerManagerProcessorDescheduleCronJob) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraSchedulerManagerDescheduleCronJobArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("descheduleCronJob", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraSchedulerManagerDescheduleCronJobResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.DescheduleCronJob(args.Job); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing descheduleCronJob: "+err2.Error()) - oprot.WriteMessageBegin("descheduleCronJob", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("descheduleCronJob", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraSchedulerManagerProcessorStartCronJob struct { - handler AuroraSchedulerManager -} - -func (p *auroraSchedulerManagerProcessorStartCronJob) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraSchedulerManagerStartCronJobArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("startCronJob", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraSchedulerManagerStartCronJobResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.StartCronJob(args.Job); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing startCronJob: "+err2.Error()) - oprot.WriteMessageBegin("startCronJob", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("startCronJob", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraSchedulerManagerProcessorRestartShards struct { - handler AuroraSchedulerManager -} - -func (p *auroraSchedulerManagerProcessorRestartShards) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraSchedulerManagerRestartShardsArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("restartShards", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraSchedulerManagerRestartShardsResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.RestartShards(args.Job, args.ShardIds); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing restartShards: "+err2.Error()) - oprot.WriteMessageBegin("restartShards", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("restartShards", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraSchedulerManagerProcessorKillTasks struct { - handler AuroraSchedulerManager -} - -func (p *auroraSchedulerManagerProcessorKillTasks) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraSchedulerManagerKillTasksArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("killTasks", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraSchedulerManagerKillTasksResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.KillTasks(args.Job, args.Instances); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing killTasks: "+err2.Error()) - oprot.WriteMessageBegin("killTasks", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("killTasks", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraSchedulerManagerProcessorAddInstances struct { - handler AuroraSchedulerManager -} - -func (p *auroraSchedulerManagerProcessorAddInstances) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraSchedulerManagerAddInstancesArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("addInstances", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraSchedulerManagerAddInstancesResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.AddInstances(args.Key, args.Count); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing addInstances: "+err2.Error()) - oprot.WriteMessageBegin("addInstances", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("addInstances", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraSchedulerManagerProcessorReplaceCronTemplate struct { - handler AuroraSchedulerManager -} - -func (p *auroraSchedulerManagerProcessorReplaceCronTemplate) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraSchedulerManagerReplaceCronTemplateArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("replaceCronTemplate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraSchedulerManagerReplaceCronTemplateResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.ReplaceCronTemplate(args.Config); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing replaceCronTemplate: "+err2.Error()) - oprot.WriteMessageBegin("replaceCronTemplate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("replaceCronTemplate", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraSchedulerManagerProcessorStartJobUpdate struct { - handler AuroraSchedulerManager -} - -func (p *auroraSchedulerManagerProcessorStartJobUpdate) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraSchedulerManagerStartJobUpdateArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("startJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraSchedulerManagerStartJobUpdateResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.StartJobUpdate(args.Request, args.Message); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing startJobUpdate: "+err2.Error()) - oprot.WriteMessageBegin("startJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("startJobUpdate", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraSchedulerManagerProcessorPauseJobUpdate struct { - handler AuroraSchedulerManager -} - -func (p *auroraSchedulerManagerProcessorPauseJobUpdate) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraSchedulerManagerPauseJobUpdateArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("pauseJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraSchedulerManagerPauseJobUpdateResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.PauseJobUpdate(args.Key, args.Message); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing pauseJobUpdate: "+err2.Error()) - oprot.WriteMessageBegin("pauseJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("pauseJobUpdate", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraSchedulerManagerProcessorResumeJobUpdate struct { - handler AuroraSchedulerManager -} - -func (p *auroraSchedulerManagerProcessorResumeJobUpdate) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraSchedulerManagerResumeJobUpdateArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("resumeJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraSchedulerManagerResumeJobUpdateResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.ResumeJobUpdate(args.Key, args.Message); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing resumeJobUpdate: "+err2.Error()) - oprot.WriteMessageBegin("resumeJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("resumeJobUpdate", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraSchedulerManagerProcessorAbortJobUpdate struct { - handler AuroraSchedulerManager -} - -func (p *auroraSchedulerManagerProcessorAbortJobUpdate) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraSchedulerManagerAbortJobUpdateArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("abortJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraSchedulerManagerAbortJobUpdateResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.AbortJobUpdate(args.Key, args.Message); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing abortJobUpdate: "+err2.Error()) - oprot.WriteMessageBegin("abortJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("abortJobUpdate", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraSchedulerManagerProcessorRollbackJobUpdate struct { - handler AuroraSchedulerManager -} - -func (p *auroraSchedulerManagerProcessorRollbackJobUpdate) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraSchedulerManagerRollbackJobUpdateArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("rollbackJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraSchedulerManagerRollbackJobUpdateResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.RollbackJobUpdate(args.Key, args.Message); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing rollbackJobUpdate: "+err2.Error()) - oprot.WriteMessageBegin("rollbackJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("rollbackJobUpdate", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type auroraSchedulerManagerProcessorPulseJobUpdate struct { - handler AuroraSchedulerManager -} - -func (p *auroraSchedulerManagerProcessorPulseJobUpdate) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := AuroraSchedulerManagerPulseJobUpdateArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("pulseJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := AuroraSchedulerManagerPulseJobUpdateResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.PulseJobUpdate(args.Key); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing pulseJobUpdate: "+err2.Error()) - oprot.WriteMessageBegin("pulseJobUpdate", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("pulseJobUpdate", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -// HELPER FUNCTIONS AND STRUCTURES - -// Attributes: -// - Description -type AuroraSchedulerManagerCreateJobArgs struct { - Description *JobConfiguration `thrift:"description,1" json:"description"` -} - -func NewAuroraSchedulerManagerCreateJobArgs() *AuroraSchedulerManagerCreateJobArgs { - return &AuroraSchedulerManagerCreateJobArgs{} -} - -var AuroraSchedulerManagerCreateJobArgs_Description_DEFAULT *JobConfiguration - -func (p *AuroraSchedulerManagerCreateJobArgs) GetDescription() *JobConfiguration { - if !p.IsSetDescription() { - return AuroraSchedulerManagerCreateJobArgs_Description_DEFAULT - } - return p.Description -} -func (p *AuroraSchedulerManagerCreateJobArgs) IsSetDescription() bool { - return p.Description != nil -} - -func (p *AuroraSchedulerManagerCreateJobArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerCreateJobArgs) readField1(iprot thrift.TProtocol) error { - p.Description = &JobConfiguration{} - if err := p.Description.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Description), err) - } - return nil -} - -func (p *AuroraSchedulerManagerCreateJobArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("createJob_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerCreateJobArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("description", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:description: ", p), err) - } - if err := p.Description.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Description), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:description: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerCreateJobArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerCreateJobArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraSchedulerManagerCreateJobResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraSchedulerManagerCreateJobResult() *AuroraSchedulerManagerCreateJobResult { - return &AuroraSchedulerManagerCreateJobResult{} -} - -var AuroraSchedulerManagerCreateJobResult_Success_DEFAULT *Response - -func (p *AuroraSchedulerManagerCreateJobResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraSchedulerManagerCreateJobResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraSchedulerManagerCreateJobResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraSchedulerManagerCreateJobResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerCreateJobResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraSchedulerManagerCreateJobResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("createJob_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerCreateJobResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraSchedulerManagerCreateJobResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerCreateJobResult(%+v)", *p) -} - -// Attributes: -// - Description -type AuroraSchedulerManagerScheduleCronJobArgs struct { - Description *JobConfiguration `thrift:"description,1" json:"description"` -} - -func NewAuroraSchedulerManagerScheduleCronJobArgs() *AuroraSchedulerManagerScheduleCronJobArgs { - return &AuroraSchedulerManagerScheduleCronJobArgs{} -} - -var AuroraSchedulerManagerScheduleCronJobArgs_Description_DEFAULT *JobConfiguration - -func (p *AuroraSchedulerManagerScheduleCronJobArgs) GetDescription() *JobConfiguration { - if !p.IsSetDescription() { - return AuroraSchedulerManagerScheduleCronJobArgs_Description_DEFAULT - } - return p.Description -} -func (p *AuroraSchedulerManagerScheduleCronJobArgs) IsSetDescription() bool { - return p.Description != nil -} - -func (p *AuroraSchedulerManagerScheduleCronJobArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerScheduleCronJobArgs) readField1(iprot thrift.TProtocol) error { - p.Description = &JobConfiguration{} - if err := p.Description.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Description), err) - } - return nil -} - -func (p *AuroraSchedulerManagerScheduleCronJobArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("scheduleCronJob_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerScheduleCronJobArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("description", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:description: ", p), err) - } - if err := p.Description.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Description), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:description: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerScheduleCronJobArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerScheduleCronJobArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraSchedulerManagerScheduleCronJobResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraSchedulerManagerScheduleCronJobResult() *AuroraSchedulerManagerScheduleCronJobResult { - return &AuroraSchedulerManagerScheduleCronJobResult{} -} - -var AuroraSchedulerManagerScheduleCronJobResult_Success_DEFAULT *Response - -func (p *AuroraSchedulerManagerScheduleCronJobResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraSchedulerManagerScheduleCronJobResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraSchedulerManagerScheduleCronJobResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraSchedulerManagerScheduleCronJobResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerScheduleCronJobResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraSchedulerManagerScheduleCronJobResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("scheduleCronJob_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerScheduleCronJobResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraSchedulerManagerScheduleCronJobResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerScheduleCronJobResult(%+v)", *p) -} - -// Attributes: -// - Job -type AuroraSchedulerManagerDescheduleCronJobArgs struct { - // unused fields # 1 to 3 - Job *JobKey `thrift:"job,4" json:"job"` -} - -func NewAuroraSchedulerManagerDescheduleCronJobArgs() *AuroraSchedulerManagerDescheduleCronJobArgs { - return &AuroraSchedulerManagerDescheduleCronJobArgs{} -} - -var AuroraSchedulerManagerDescheduleCronJobArgs_Job_DEFAULT *JobKey - -func (p *AuroraSchedulerManagerDescheduleCronJobArgs) GetJob() *JobKey { - if !p.IsSetJob() { - return AuroraSchedulerManagerDescheduleCronJobArgs_Job_DEFAULT - } - return p.Job -} -func (p *AuroraSchedulerManagerDescheduleCronJobArgs) IsSetJob() bool { - return p.Job != nil -} - -func (p *AuroraSchedulerManagerDescheduleCronJobArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerDescheduleCronJobArgs) readField4(iprot thrift.TProtocol) error { - p.Job = &JobKey{} - if err := p.Job.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) - } - return nil -} - -func (p *AuroraSchedulerManagerDescheduleCronJobArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("descheduleCronJob_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerDescheduleCronJobArgs) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("job", thrift.STRUCT, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:job: ", p), err) - } - if err := p.Job.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:job: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerDescheduleCronJobArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerDescheduleCronJobArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraSchedulerManagerDescheduleCronJobResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraSchedulerManagerDescheduleCronJobResult() *AuroraSchedulerManagerDescheduleCronJobResult { - return &AuroraSchedulerManagerDescheduleCronJobResult{} -} - -var AuroraSchedulerManagerDescheduleCronJobResult_Success_DEFAULT *Response - -func (p *AuroraSchedulerManagerDescheduleCronJobResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraSchedulerManagerDescheduleCronJobResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraSchedulerManagerDescheduleCronJobResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraSchedulerManagerDescheduleCronJobResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerDescheduleCronJobResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraSchedulerManagerDescheduleCronJobResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("descheduleCronJob_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerDescheduleCronJobResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraSchedulerManagerDescheduleCronJobResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerDescheduleCronJobResult(%+v)", *p) -} - -// Attributes: -// - Job -type AuroraSchedulerManagerStartCronJobArgs struct { - // unused fields # 1 to 3 - Job *JobKey `thrift:"job,4" json:"job"` -} - -func NewAuroraSchedulerManagerStartCronJobArgs() *AuroraSchedulerManagerStartCronJobArgs { - return &AuroraSchedulerManagerStartCronJobArgs{} -} - -var AuroraSchedulerManagerStartCronJobArgs_Job_DEFAULT *JobKey - -func (p *AuroraSchedulerManagerStartCronJobArgs) GetJob() *JobKey { - if !p.IsSetJob() { - return AuroraSchedulerManagerStartCronJobArgs_Job_DEFAULT - } - return p.Job -} -func (p *AuroraSchedulerManagerStartCronJobArgs) IsSetJob() bool { - return p.Job != nil -} - -func (p *AuroraSchedulerManagerStartCronJobArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerStartCronJobArgs) readField4(iprot thrift.TProtocol) error { - p.Job = &JobKey{} - if err := p.Job.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) - } - return nil -} - -func (p *AuroraSchedulerManagerStartCronJobArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("startCronJob_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerStartCronJobArgs) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("job", thrift.STRUCT, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:job: ", p), err) - } - if err := p.Job.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:job: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerStartCronJobArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerStartCronJobArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraSchedulerManagerStartCronJobResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraSchedulerManagerStartCronJobResult() *AuroraSchedulerManagerStartCronJobResult { - return &AuroraSchedulerManagerStartCronJobResult{} -} - -var AuroraSchedulerManagerStartCronJobResult_Success_DEFAULT *Response - -func (p *AuroraSchedulerManagerStartCronJobResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraSchedulerManagerStartCronJobResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraSchedulerManagerStartCronJobResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraSchedulerManagerStartCronJobResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerStartCronJobResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraSchedulerManagerStartCronJobResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("startCronJob_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerStartCronJobResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraSchedulerManagerStartCronJobResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerStartCronJobResult(%+v)", *p) -} - -// Attributes: -// - Job -// - ShardIds -type AuroraSchedulerManagerRestartShardsArgs struct { - // unused fields # 1 to 2 - ShardIds map[int32]bool `thrift:"shardIds,3" json:"shardIds"` - // unused field # 4 - Job *JobKey `thrift:"job,5" json:"job"` -} - -func NewAuroraSchedulerManagerRestartShardsArgs() *AuroraSchedulerManagerRestartShardsArgs { - return &AuroraSchedulerManagerRestartShardsArgs{} -} - -var AuroraSchedulerManagerRestartShardsArgs_Job_DEFAULT *JobKey - -func (p *AuroraSchedulerManagerRestartShardsArgs) GetJob() *JobKey { - if !p.IsSetJob() { - return AuroraSchedulerManagerRestartShardsArgs_Job_DEFAULT - } - return p.Job -} - -func (p *AuroraSchedulerManagerRestartShardsArgs) GetShardIds() map[int32]bool { - return p.ShardIds -} -func (p *AuroraSchedulerManagerRestartShardsArgs) IsSetJob() bool { - return p.Job != nil -} - -func (p *AuroraSchedulerManagerRestartShardsArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 5: - if err := p.readField5(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerRestartShardsArgs) readField5(iprot thrift.TProtocol) error { - p.Job = &JobKey{} - if err := p.Job.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) - } - return nil -} - -func (p *AuroraSchedulerManagerRestartShardsArgs) readField3(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[int32]bool, size) - p.ShardIds = tSet - for i := 0; i < size; i++ { - var _elem161 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem161 = v - } - p.ShardIds[_elem161] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerRestartShardsArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("restartShards_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField5(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerRestartShardsArgs) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("shardIds", thrift.SET, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:shardIds: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.I32, len(p.ShardIds)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.ShardIds { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:shardIds: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerRestartShardsArgs) writeField5(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("job", thrift.STRUCT, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:job: ", p), err) - } - if err := p.Job.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:job: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerRestartShardsArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerRestartShardsArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraSchedulerManagerRestartShardsResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraSchedulerManagerRestartShardsResult() *AuroraSchedulerManagerRestartShardsResult { - return &AuroraSchedulerManagerRestartShardsResult{} -} - -var AuroraSchedulerManagerRestartShardsResult_Success_DEFAULT *Response - -func (p *AuroraSchedulerManagerRestartShardsResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraSchedulerManagerRestartShardsResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraSchedulerManagerRestartShardsResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraSchedulerManagerRestartShardsResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerRestartShardsResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraSchedulerManagerRestartShardsResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("restartShards_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerRestartShardsResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraSchedulerManagerRestartShardsResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerRestartShardsResult(%+v)", *p) -} - -// Attributes: -// - Job -// - Instances -type AuroraSchedulerManagerKillTasksArgs struct { - // unused fields # 1 to 3 - Job *JobKey `thrift:"job,4" json:"job"` - Instances map[int32]bool `thrift:"instances,5" json:"instances"` -} - -func NewAuroraSchedulerManagerKillTasksArgs() *AuroraSchedulerManagerKillTasksArgs { - return &AuroraSchedulerManagerKillTasksArgs{} -} - -var AuroraSchedulerManagerKillTasksArgs_Job_DEFAULT *JobKey - -func (p *AuroraSchedulerManagerKillTasksArgs) GetJob() *JobKey { - if !p.IsSetJob() { - return AuroraSchedulerManagerKillTasksArgs_Job_DEFAULT - } - return p.Job -} - -func (p *AuroraSchedulerManagerKillTasksArgs) GetInstances() map[int32]bool { - return p.Instances -} -func (p *AuroraSchedulerManagerKillTasksArgs) IsSetJob() bool { - return p.Job != nil -} - -func (p *AuroraSchedulerManagerKillTasksArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - case 5: - if err := p.readField5(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerKillTasksArgs) readField4(iprot thrift.TProtocol) error { - p.Job = &JobKey{} - if err := p.Job.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) - } - return nil -} - -func (p *AuroraSchedulerManagerKillTasksArgs) readField5(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[int32]bool, size) - p.Instances = tSet - for i := 0; i < size; i++ { - var _elem162 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem162 = v - } - p.Instances[_elem162] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerKillTasksArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("killTasks_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := p.writeField5(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerKillTasksArgs) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("job", thrift.STRUCT, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:job: ", p), err) - } - if err := p.Job.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:job: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerKillTasksArgs) writeField5(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instances", thrift.SET, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:instances: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.I32, len(p.Instances)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Instances { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:instances: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerKillTasksArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerKillTasksArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraSchedulerManagerKillTasksResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraSchedulerManagerKillTasksResult() *AuroraSchedulerManagerKillTasksResult { - return &AuroraSchedulerManagerKillTasksResult{} -} - -var AuroraSchedulerManagerKillTasksResult_Success_DEFAULT *Response - -func (p *AuroraSchedulerManagerKillTasksResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraSchedulerManagerKillTasksResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraSchedulerManagerKillTasksResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraSchedulerManagerKillTasksResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerKillTasksResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraSchedulerManagerKillTasksResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("killTasks_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerKillTasksResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraSchedulerManagerKillTasksResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerKillTasksResult(%+v)", *p) -} - -// Attributes: -// - Key -// - Count -type AuroraSchedulerManagerAddInstancesArgs struct { - // unused fields # 1 to 2 - Key *InstanceKey `thrift:"key,3" json:"key"` - Count int32 `thrift:"count,4" json:"count"` -} - -func NewAuroraSchedulerManagerAddInstancesArgs() *AuroraSchedulerManagerAddInstancesArgs { - return &AuroraSchedulerManagerAddInstancesArgs{} -} - -var AuroraSchedulerManagerAddInstancesArgs_Key_DEFAULT *InstanceKey - -func (p *AuroraSchedulerManagerAddInstancesArgs) GetKey() *InstanceKey { - if !p.IsSetKey() { - return AuroraSchedulerManagerAddInstancesArgs_Key_DEFAULT - } - return p.Key -} - -func (p *AuroraSchedulerManagerAddInstancesArgs) GetCount() int32 { - return p.Count -} -func (p *AuroraSchedulerManagerAddInstancesArgs) IsSetKey() bool { - return p.Key != nil -} - -func (p *AuroraSchedulerManagerAddInstancesArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerAddInstancesArgs) readField3(iprot thrift.TProtocol) error { - p.Key = &InstanceKey{} - if err := p.Key.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) - } - return nil -} - -func (p *AuroraSchedulerManagerAddInstancesArgs) readField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.Count = v - } - return nil -} - -func (p *AuroraSchedulerManagerAddInstancesArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("addInstances_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerAddInstancesArgs) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:key: ", p), err) - } - if err := p.Key.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:key: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerAddInstancesArgs) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("count", thrift.I32, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:count: ", p), err) - } - if err := oprot.WriteI32(int32(p.Count)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.count (4) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:count: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerAddInstancesArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerAddInstancesArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraSchedulerManagerAddInstancesResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraSchedulerManagerAddInstancesResult() *AuroraSchedulerManagerAddInstancesResult { - return &AuroraSchedulerManagerAddInstancesResult{} -} - -var AuroraSchedulerManagerAddInstancesResult_Success_DEFAULT *Response - -func (p *AuroraSchedulerManagerAddInstancesResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraSchedulerManagerAddInstancesResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraSchedulerManagerAddInstancesResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraSchedulerManagerAddInstancesResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerAddInstancesResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraSchedulerManagerAddInstancesResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("addInstances_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerAddInstancesResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraSchedulerManagerAddInstancesResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerAddInstancesResult(%+v)", *p) -} - -// Attributes: -// - Config -type AuroraSchedulerManagerReplaceCronTemplateArgs struct { - Config *JobConfiguration `thrift:"config,1" json:"config"` -} - -func NewAuroraSchedulerManagerReplaceCronTemplateArgs() *AuroraSchedulerManagerReplaceCronTemplateArgs { - return &AuroraSchedulerManagerReplaceCronTemplateArgs{} -} - -var AuroraSchedulerManagerReplaceCronTemplateArgs_Config_DEFAULT *JobConfiguration - -func (p *AuroraSchedulerManagerReplaceCronTemplateArgs) GetConfig() *JobConfiguration { - if !p.IsSetConfig() { - return AuroraSchedulerManagerReplaceCronTemplateArgs_Config_DEFAULT - } - return p.Config -} -func (p *AuroraSchedulerManagerReplaceCronTemplateArgs) IsSetConfig() bool { - return p.Config != nil -} - -func (p *AuroraSchedulerManagerReplaceCronTemplateArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerReplaceCronTemplateArgs) readField1(iprot thrift.TProtocol) error { - p.Config = &JobConfiguration{} - if err := p.Config.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Config), err) - } - return nil -} - -func (p *AuroraSchedulerManagerReplaceCronTemplateArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("replaceCronTemplate_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerReplaceCronTemplateArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("config", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:config: ", p), err) - } - if err := p.Config.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Config), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:config: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerReplaceCronTemplateArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerReplaceCronTemplateArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraSchedulerManagerReplaceCronTemplateResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraSchedulerManagerReplaceCronTemplateResult() *AuroraSchedulerManagerReplaceCronTemplateResult { - return &AuroraSchedulerManagerReplaceCronTemplateResult{} -} - -var AuroraSchedulerManagerReplaceCronTemplateResult_Success_DEFAULT *Response - -func (p *AuroraSchedulerManagerReplaceCronTemplateResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraSchedulerManagerReplaceCronTemplateResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraSchedulerManagerReplaceCronTemplateResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraSchedulerManagerReplaceCronTemplateResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerReplaceCronTemplateResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraSchedulerManagerReplaceCronTemplateResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("replaceCronTemplate_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerReplaceCronTemplateResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraSchedulerManagerReplaceCronTemplateResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerReplaceCronTemplateResult(%+v)", *p) -} - -// Attributes: -// - Request: A description of how to change the job. -// - Message: A user-specified message to include with the induced job update state change. -type AuroraSchedulerManagerStartJobUpdateArgs struct { - Request *JobUpdateRequest `thrift:"request,1" json:"request"` - // unused field # 2 - Message string `thrift:"message,3" json:"message"` -} - -func NewAuroraSchedulerManagerStartJobUpdateArgs() *AuroraSchedulerManagerStartJobUpdateArgs { - return &AuroraSchedulerManagerStartJobUpdateArgs{} -} - -var AuroraSchedulerManagerStartJobUpdateArgs_Request_DEFAULT *JobUpdateRequest - -func (p *AuroraSchedulerManagerStartJobUpdateArgs) GetRequest() *JobUpdateRequest { - if !p.IsSetRequest() { - return AuroraSchedulerManagerStartJobUpdateArgs_Request_DEFAULT - } - return p.Request -} - -func (p *AuroraSchedulerManagerStartJobUpdateArgs) GetMessage() string { - return p.Message -} -func (p *AuroraSchedulerManagerStartJobUpdateArgs) IsSetRequest() bool { - return p.Request != nil -} - -func (p *AuroraSchedulerManagerStartJobUpdateArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerStartJobUpdateArgs) readField1(iprot thrift.TProtocol) error { - p.Request = &JobUpdateRequest{} - if err := p.Request.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Request), err) - } - return nil -} - -func (p *AuroraSchedulerManagerStartJobUpdateArgs) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.Message = v - } - return nil -} - -func (p *AuroraSchedulerManagerStartJobUpdateArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("startJobUpdate_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerStartJobUpdateArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:request: ", p), err) - } - if err := p.Request.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Request), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:request: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerStartJobUpdateArgs) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:message: ", p), err) - } - if err := oprot.WriteString(string(p.Message)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.message (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:message: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerStartJobUpdateArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerStartJobUpdateArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraSchedulerManagerStartJobUpdateResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraSchedulerManagerStartJobUpdateResult() *AuroraSchedulerManagerStartJobUpdateResult { - return &AuroraSchedulerManagerStartJobUpdateResult{} -} - -var AuroraSchedulerManagerStartJobUpdateResult_Success_DEFAULT *Response - -func (p *AuroraSchedulerManagerStartJobUpdateResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraSchedulerManagerStartJobUpdateResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraSchedulerManagerStartJobUpdateResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraSchedulerManagerStartJobUpdateResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerStartJobUpdateResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraSchedulerManagerStartJobUpdateResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("startJobUpdate_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerStartJobUpdateResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraSchedulerManagerStartJobUpdateResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerStartJobUpdateResult(%+v)", *p) -} - -// Attributes: -// - Key: The update to pause. -// - Message: A user-specified message to include with the induced job update state change. -type AuroraSchedulerManagerPauseJobUpdateArgs struct { - Key *JobUpdateKey `thrift:"key,1" json:"key"` - // unused field # 2 - Message string `thrift:"message,3" json:"message"` -} - -func NewAuroraSchedulerManagerPauseJobUpdateArgs() *AuroraSchedulerManagerPauseJobUpdateArgs { - return &AuroraSchedulerManagerPauseJobUpdateArgs{} -} - -var AuroraSchedulerManagerPauseJobUpdateArgs_Key_DEFAULT *JobUpdateKey - -func (p *AuroraSchedulerManagerPauseJobUpdateArgs) GetKey() *JobUpdateKey { - if !p.IsSetKey() { - return AuroraSchedulerManagerPauseJobUpdateArgs_Key_DEFAULT - } - return p.Key -} - -func (p *AuroraSchedulerManagerPauseJobUpdateArgs) GetMessage() string { - return p.Message -} -func (p *AuroraSchedulerManagerPauseJobUpdateArgs) IsSetKey() bool { - return p.Key != nil -} - -func (p *AuroraSchedulerManagerPauseJobUpdateArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerPauseJobUpdateArgs) readField1(iprot thrift.TProtocol) error { - p.Key = &JobUpdateKey{} - if err := p.Key.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) - } - return nil -} - -func (p *AuroraSchedulerManagerPauseJobUpdateArgs) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.Message = v - } - return nil -} - -func (p *AuroraSchedulerManagerPauseJobUpdateArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("pauseJobUpdate_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerPauseJobUpdateArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) - } - if err := p.Key.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerPauseJobUpdateArgs) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:message: ", p), err) - } - if err := oprot.WriteString(string(p.Message)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.message (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:message: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerPauseJobUpdateArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerPauseJobUpdateArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraSchedulerManagerPauseJobUpdateResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraSchedulerManagerPauseJobUpdateResult() *AuroraSchedulerManagerPauseJobUpdateResult { - return &AuroraSchedulerManagerPauseJobUpdateResult{} -} - -var AuroraSchedulerManagerPauseJobUpdateResult_Success_DEFAULT *Response - -func (p *AuroraSchedulerManagerPauseJobUpdateResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraSchedulerManagerPauseJobUpdateResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraSchedulerManagerPauseJobUpdateResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraSchedulerManagerPauseJobUpdateResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerPauseJobUpdateResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraSchedulerManagerPauseJobUpdateResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("pauseJobUpdate_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerPauseJobUpdateResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraSchedulerManagerPauseJobUpdateResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerPauseJobUpdateResult(%+v)", *p) -} - -// Attributes: -// - Key: The update to resume. -// - Message: A user-specified message to include with the induced job update state change. -type AuroraSchedulerManagerResumeJobUpdateArgs struct { - Key *JobUpdateKey `thrift:"key,1" json:"key"` - // unused field # 2 - Message string `thrift:"message,3" json:"message"` -} - -func NewAuroraSchedulerManagerResumeJobUpdateArgs() *AuroraSchedulerManagerResumeJobUpdateArgs { - return &AuroraSchedulerManagerResumeJobUpdateArgs{} -} - -var AuroraSchedulerManagerResumeJobUpdateArgs_Key_DEFAULT *JobUpdateKey - -func (p *AuroraSchedulerManagerResumeJobUpdateArgs) GetKey() *JobUpdateKey { - if !p.IsSetKey() { - return AuroraSchedulerManagerResumeJobUpdateArgs_Key_DEFAULT - } - return p.Key -} - -func (p *AuroraSchedulerManagerResumeJobUpdateArgs) GetMessage() string { - return p.Message -} -func (p *AuroraSchedulerManagerResumeJobUpdateArgs) IsSetKey() bool { - return p.Key != nil -} - -func (p *AuroraSchedulerManagerResumeJobUpdateArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerResumeJobUpdateArgs) readField1(iprot thrift.TProtocol) error { - p.Key = &JobUpdateKey{} - if err := p.Key.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) - } - return nil -} - -func (p *AuroraSchedulerManagerResumeJobUpdateArgs) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.Message = v - } - return nil -} - -func (p *AuroraSchedulerManagerResumeJobUpdateArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("resumeJobUpdate_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerResumeJobUpdateArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) - } - if err := p.Key.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerResumeJobUpdateArgs) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:message: ", p), err) - } - if err := oprot.WriteString(string(p.Message)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.message (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:message: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerResumeJobUpdateArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerResumeJobUpdateArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraSchedulerManagerResumeJobUpdateResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraSchedulerManagerResumeJobUpdateResult() *AuroraSchedulerManagerResumeJobUpdateResult { - return &AuroraSchedulerManagerResumeJobUpdateResult{} -} - -var AuroraSchedulerManagerResumeJobUpdateResult_Success_DEFAULT *Response - -func (p *AuroraSchedulerManagerResumeJobUpdateResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraSchedulerManagerResumeJobUpdateResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraSchedulerManagerResumeJobUpdateResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraSchedulerManagerResumeJobUpdateResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerResumeJobUpdateResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraSchedulerManagerResumeJobUpdateResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("resumeJobUpdate_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerResumeJobUpdateResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraSchedulerManagerResumeJobUpdateResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerResumeJobUpdateResult(%+v)", *p) -} - -// Attributes: -// - Key: The update to abort. -// - Message: A user-specified message to include with the induced job update state change. -type AuroraSchedulerManagerAbortJobUpdateArgs struct { - Key *JobUpdateKey `thrift:"key,1" json:"key"` - // unused field # 2 - Message string `thrift:"message,3" json:"message"` -} - -func NewAuroraSchedulerManagerAbortJobUpdateArgs() *AuroraSchedulerManagerAbortJobUpdateArgs { - return &AuroraSchedulerManagerAbortJobUpdateArgs{} -} - -var AuroraSchedulerManagerAbortJobUpdateArgs_Key_DEFAULT *JobUpdateKey - -func (p *AuroraSchedulerManagerAbortJobUpdateArgs) GetKey() *JobUpdateKey { - if !p.IsSetKey() { - return AuroraSchedulerManagerAbortJobUpdateArgs_Key_DEFAULT - } - return p.Key -} - -func (p *AuroraSchedulerManagerAbortJobUpdateArgs) GetMessage() string { - return p.Message -} -func (p *AuroraSchedulerManagerAbortJobUpdateArgs) IsSetKey() bool { - return p.Key != nil -} - -func (p *AuroraSchedulerManagerAbortJobUpdateArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerAbortJobUpdateArgs) readField1(iprot thrift.TProtocol) error { - p.Key = &JobUpdateKey{} - if err := p.Key.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) - } - return nil -} - -func (p *AuroraSchedulerManagerAbortJobUpdateArgs) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.Message = v - } - return nil -} - -func (p *AuroraSchedulerManagerAbortJobUpdateArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("abortJobUpdate_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerAbortJobUpdateArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) - } - if err := p.Key.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerAbortJobUpdateArgs) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:message: ", p), err) - } - if err := oprot.WriteString(string(p.Message)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.message (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:message: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerAbortJobUpdateArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerAbortJobUpdateArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraSchedulerManagerAbortJobUpdateResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraSchedulerManagerAbortJobUpdateResult() *AuroraSchedulerManagerAbortJobUpdateResult { - return &AuroraSchedulerManagerAbortJobUpdateResult{} -} - -var AuroraSchedulerManagerAbortJobUpdateResult_Success_DEFAULT *Response - -func (p *AuroraSchedulerManagerAbortJobUpdateResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraSchedulerManagerAbortJobUpdateResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraSchedulerManagerAbortJobUpdateResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraSchedulerManagerAbortJobUpdateResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerAbortJobUpdateResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraSchedulerManagerAbortJobUpdateResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("abortJobUpdate_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerAbortJobUpdateResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraSchedulerManagerAbortJobUpdateResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerAbortJobUpdateResult(%+v)", *p) -} - -// Attributes: -// - Key: The update to rollback. -// - Message: A user-specified message to include with the induced job update state change. -type AuroraSchedulerManagerRollbackJobUpdateArgs struct { - Key *JobUpdateKey `thrift:"key,1" json:"key"` - Message string `thrift:"message,2" json:"message"` -} - -func NewAuroraSchedulerManagerRollbackJobUpdateArgs() *AuroraSchedulerManagerRollbackJobUpdateArgs { - return &AuroraSchedulerManagerRollbackJobUpdateArgs{} -} - -var AuroraSchedulerManagerRollbackJobUpdateArgs_Key_DEFAULT *JobUpdateKey - -func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) GetKey() *JobUpdateKey { - if !p.IsSetKey() { - return AuroraSchedulerManagerRollbackJobUpdateArgs_Key_DEFAULT - } - return p.Key -} - -func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) GetMessage() string { - return p.Message -} -func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) IsSetKey() bool { - return p.Key != nil -} - -func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) readField1(iprot thrift.TProtocol) error { - p.Key = &JobUpdateKey{} - if err := p.Key.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) - } - return nil -} - -func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Message = v - } - return nil -} - -func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("rollbackJobUpdate_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) - } - if err := p.Key.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:message: ", p), err) - } - if err := oprot.WriteString(string(p.Message)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.message (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:message: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerRollbackJobUpdateArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerRollbackJobUpdateArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraSchedulerManagerRollbackJobUpdateResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraSchedulerManagerRollbackJobUpdateResult() *AuroraSchedulerManagerRollbackJobUpdateResult { - return &AuroraSchedulerManagerRollbackJobUpdateResult{} -} - -var AuroraSchedulerManagerRollbackJobUpdateResult_Success_DEFAULT *Response - -func (p *AuroraSchedulerManagerRollbackJobUpdateResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraSchedulerManagerRollbackJobUpdateResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraSchedulerManagerRollbackJobUpdateResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraSchedulerManagerRollbackJobUpdateResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerRollbackJobUpdateResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraSchedulerManagerRollbackJobUpdateResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("rollbackJobUpdate_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerRollbackJobUpdateResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraSchedulerManagerRollbackJobUpdateResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerRollbackJobUpdateResult(%+v)", *p) -} - -// Attributes: -// - Key -type AuroraSchedulerManagerPulseJobUpdateArgs struct { - Key *JobUpdateKey `thrift:"key,1" json:"key"` -} - -func NewAuroraSchedulerManagerPulseJobUpdateArgs() *AuroraSchedulerManagerPulseJobUpdateArgs { - return &AuroraSchedulerManagerPulseJobUpdateArgs{} -} - -var AuroraSchedulerManagerPulseJobUpdateArgs_Key_DEFAULT *JobUpdateKey - -func (p *AuroraSchedulerManagerPulseJobUpdateArgs) GetKey() *JobUpdateKey { - if !p.IsSetKey() { - return AuroraSchedulerManagerPulseJobUpdateArgs_Key_DEFAULT - } - return p.Key -} -func (p *AuroraSchedulerManagerPulseJobUpdateArgs) IsSetKey() bool { - return p.Key != nil -} - -func (p *AuroraSchedulerManagerPulseJobUpdateArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerPulseJobUpdateArgs) readField1(iprot thrift.TProtocol) error { - p.Key = &JobUpdateKey{} - if err := p.Key.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) - } - return nil -} - -func (p *AuroraSchedulerManagerPulseJobUpdateArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("pulseJobUpdate_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerPulseJobUpdateArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) - } - if err := p.Key.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) - } - return err -} - -func (p *AuroraSchedulerManagerPulseJobUpdateArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerPulseJobUpdateArgs(%+v)", *p) -} - -// Attributes: -// - Success -type AuroraSchedulerManagerPulseJobUpdateResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewAuroraSchedulerManagerPulseJobUpdateResult() *AuroraSchedulerManagerPulseJobUpdateResult { - return &AuroraSchedulerManagerPulseJobUpdateResult{} -} - -var AuroraSchedulerManagerPulseJobUpdateResult_Success_DEFAULT *Response - -func (p *AuroraSchedulerManagerPulseJobUpdateResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return AuroraSchedulerManagerPulseJobUpdateResult_Success_DEFAULT - } - return p.Success -} -func (p *AuroraSchedulerManagerPulseJobUpdateResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *AuroraSchedulerManagerPulseJobUpdateResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AuroraSchedulerManagerPulseJobUpdateResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *AuroraSchedulerManagerPulseJobUpdateResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("pulseJobUpdate_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AuroraSchedulerManagerPulseJobUpdateResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *AuroraSchedulerManagerPulseJobUpdateResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AuroraSchedulerManagerPulseJobUpdateResult(%+v)", *p) -} diff --git a/gen-go/apache/aurora/constants.go b/gen-go/apache/aurora/constants.go deleted file mode 100644 index 073d675..0000000 --- a/gen-go/apache/aurora/constants.go +++ /dev/null @@ -1,80 +0,0 @@ -// Autogenerated by Thrift Compiler (0.9.3) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -package aurora - -import ( - "bytes" - "fmt" - "git.apache.org/thrift.git/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = bytes.Equal - -const AURORA_EXECUTOR_NAME = "AuroraExecutor" - -var ACTIVE_STATES map[ScheduleStatus]bool -var SLAVE_ASSIGNED_STATES map[ScheduleStatus]bool -var LIVE_STATES map[ScheduleStatus]bool -var TERMINAL_STATES map[ScheduleStatus]bool - -const GOOD_IDENTIFIER_PATTERN = "^[\\w\\-\\.]+$" -const GOOD_IDENTIFIER_PATTERN_JVM = "^[\\w\\-\\.]+$" -const GOOD_IDENTIFIER_PATTERN_PYTHON = "^[\\w\\-\\.]+$" - -var ACTIVE_JOB_UPDATE_STATES map[JobUpdateStatus]bool - -const BYPASS_LEADER_REDIRECT_HEADER_NAME = "Bypass-Leader-Redirect" -const TASK_FILESYSTEM_MOUNT_POINT = "taskfs" - -func init() { - ACTIVE_STATES = map[ScheduleStatus]bool{ - 9: true, - 17: true, - 6: true, - 0: true, - 13: true, - 12: true, - 2: true, - 1: true, - 16: true, - } - - SLAVE_ASSIGNED_STATES = map[ScheduleStatus]bool{ - 9: true, - 17: true, - 6: true, - 13: true, - 12: true, - 2: true, - 1: true, - } - - LIVE_STATES = map[ScheduleStatus]bool{ - 6: true, - 13: true, - 12: true, - 17: true, - 2: true, - } - - TERMINAL_STATES = map[ScheduleStatus]bool{ - 4: true, - 3: true, - 5: true, - 7: true, - } - - ACTIVE_JOB_UPDATE_STATES = map[JobUpdateStatus]bool{ - 0: true, - 1: true, - 2: true, - 3: true, - 9: true, - 10: true, - } - -} diff --git a/gen-go/apache/aurora/read_only_scheduler-remote/read_only_scheduler-remote.go b/gen-go/apache/aurora/read_only_scheduler-remote/read_only_scheduler-remote.go index b9c3d90..e802328 100755 --- a/gen-go/apache/aurora/read_only_scheduler-remote/read_only_scheduler-remote.go +++ b/gen-go/apache/aurora/read_only_scheduler-remote/read_only_scheduler-remote.go @@ -1,382 +1,411 @@ -// Autogenerated by Thrift Compiler (0.9.3) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +// Code generated by Thrift Compiler (0.14.0). DO NOT EDIT. package main import ( - "apache/aurora" + "context" "flag" "fmt" - "git.apache.org/thrift.git/lib/go/thrift" "math" "net" "net/url" "os" "strconv" "strings" + "github.com/apache/thrift/lib/go/thrift" + "apache/aurora" ) +var _ = aurora.GoUnusedProtection__ + func Usage() { - fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:") - flag.PrintDefaults() - fmt.Fprintln(os.Stderr, "\nFunctions:") - fmt.Fprintln(os.Stderr, " Response getRoleSummary()") - fmt.Fprintln(os.Stderr, " Response getJobSummary(string role)") - fmt.Fprintln(os.Stderr, " Response getTasksStatus(TaskQuery query)") - fmt.Fprintln(os.Stderr, " Response getTasksWithoutConfigs(TaskQuery query)") - fmt.Fprintln(os.Stderr, " Response getPendingReason(TaskQuery query)") - fmt.Fprintln(os.Stderr, " Response getConfigSummary(JobKey job)") - fmt.Fprintln(os.Stderr, " Response getJobs(string ownerRole)") - fmt.Fprintln(os.Stderr, " Response getQuota(string ownerRole)") - fmt.Fprintln(os.Stderr, " Response populateJobConfig(JobConfiguration description)") - fmt.Fprintln(os.Stderr, " Response getJobUpdateSummaries(JobUpdateQuery jobUpdateQuery)") - fmt.Fprintln(os.Stderr, " Response getJobUpdateDetails(JobUpdateQuery query)") - fmt.Fprintln(os.Stderr, " Response getJobUpdateDiff(JobUpdateRequest request)") - fmt.Fprintln(os.Stderr, " Response getTierConfigs()") - fmt.Fprintln(os.Stderr) - os.Exit(0) + fmt.Fprintln(os.Stderr, "Usage of ", os.Args[0], " [-h host:port] [-u url] [-f[ramed]] function [arg1 [arg2...]]:") + flag.PrintDefaults() + fmt.Fprintln(os.Stderr, "\nFunctions:") + fmt.Fprintln(os.Stderr, " Response getRoleSummary()") + fmt.Fprintln(os.Stderr, " Response getJobSummary(string role)") + fmt.Fprintln(os.Stderr, " Response getTasksStatus(TaskQuery query)") + fmt.Fprintln(os.Stderr, " Response getTasksWithoutConfigs(TaskQuery query)") + fmt.Fprintln(os.Stderr, " Response getPendingReason(TaskQuery query)") + fmt.Fprintln(os.Stderr, " Response getConfigSummary(JobKey job)") + fmt.Fprintln(os.Stderr, " Response getJobs(string ownerRole)") + fmt.Fprintln(os.Stderr, " Response getQuota(string ownerRole)") + fmt.Fprintln(os.Stderr, " Response populateJobConfig(JobConfiguration description)") + fmt.Fprintln(os.Stderr, " Response getJobUpdateSummaries(JobUpdateQuery jobUpdateQuery)") + fmt.Fprintln(os.Stderr, " Response getJobUpdateDetails(JobUpdateQuery query)") + fmt.Fprintln(os.Stderr, " Response getJobUpdateDiff(JobUpdateRequest request)") + fmt.Fprintln(os.Stderr, " Response getTierConfigs()") + fmt.Fprintln(os.Stderr) + os.Exit(0) +} + +type httpHeaders map[string]string + +func (h httpHeaders) String() string { + var m map[string]string = h + return fmt.Sprintf("%s", m) +} + +func (h httpHeaders) Set(value string) error { + parts := strings.Split(value, ": ") + if len(parts) != 2 { + return fmt.Errorf("header should be of format 'Key: Value'") + } + h[parts[0]] = parts[1] + return nil } func main() { - flag.Usage = Usage - var host string - var port int - var protocol string - var urlString string - var framed bool - var useHttp bool - var parsedUrl url.URL - var trans thrift.TTransport - _ = strconv.Atoi - _ = math.Abs - flag.Usage = Usage - flag.StringVar(&host, "h", "localhost", "Specify host and port") - flag.IntVar(&port, "p", 9090, "Specify port") - flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") - flag.StringVar(&urlString, "u", "", "Specify the url") - flag.BoolVar(&framed, "framed", false, "Use framed transport") - flag.BoolVar(&useHttp, "http", false, "Use http") - flag.Parse() - - if len(urlString) > 0 { - parsedUrl, err := url.Parse(urlString) - if err != nil { - fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) - flag.Usage() - } - host = parsedUrl.Host - useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" - } else if useHttp { - _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) - if err != nil { - fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) - flag.Usage() - } - } - - cmd := flag.Arg(0) - var err error - if useHttp { - trans, err = thrift.NewTHttpClient(parsedUrl.String()) - } else { - portStr := fmt.Sprint(port) - if strings.Contains(host, ":") { - host, portStr, err = net.SplitHostPort(host) - if err != nil { - fmt.Fprintln(os.Stderr, "error with host:", err) - os.Exit(1) - } - } - trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) - if err != nil { - fmt.Fprintln(os.Stderr, "error resolving address:", err) - os.Exit(1) - } - if framed { - trans = thrift.NewTFramedTransport(trans) - } - } - if err != nil { - fmt.Fprintln(os.Stderr, "Error creating transport", err) - os.Exit(1) - } - defer trans.Close() - var protocolFactory thrift.TProtocolFactory - switch protocol { - case "compact": - protocolFactory = thrift.NewTCompactProtocolFactory() - break - case "simplejson": - protocolFactory = thrift.NewTSimpleJSONProtocolFactory() - break - case "json": - protocolFactory = thrift.NewTJSONProtocolFactory() - break - case "binary", "": - protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() - break - default: - fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) - Usage() - os.Exit(1) - } - client := aurora.NewReadOnlySchedulerClientFactory(trans, protocolFactory) - if err := trans.Open(); err != nil { - fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) - os.Exit(1) - } - - switch cmd { - case "getRoleSummary": - if flag.NArg()-1 != 0 { - fmt.Fprintln(os.Stderr, "GetRoleSummary requires 0 args") - flag.Usage() - } - fmt.Print(client.GetRoleSummary()) - fmt.Print("\n") - break - case "getJobSummary": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetJobSummary requires 1 args") - flag.Usage() - } - argvalue0 := flag.Arg(1) - value0 := argvalue0 - fmt.Print(client.GetJobSummary(value0)) - fmt.Print("\n") - break - case "getTasksStatus": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetTasksStatus requires 1 args") - flag.Usage() - } - arg82 := flag.Arg(1) - mbTrans83 := thrift.NewTMemoryBufferLen(len(arg82)) - defer mbTrans83.Close() - _, err84 := mbTrans83.WriteString(arg82) - if err84 != nil { - Usage() - return - } - factory85 := thrift.NewTSimpleJSONProtocolFactory() - jsProt86 := factory85.GetProtocol(mbTrans83) - argvalue0 := aurora.NewTaskQuery() - err87 := argvalue0.Read(jsProt86) - if err87 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetTasksStatus(value0)) - fmt.Print("\n") - break - case "getTasksWithoutConfigs": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetTasksWithoutConfigs requires 1 args") - flag.Usage() - } - arg88 := flag.Arg(1) - mbTrans89 := thrift.NewTMemoryBufferLen(len(arg88)) - defer mbTrans89.Close() - _, err90 := mbTrans89.WriteString(arg88) - if err90 != nil { - Usage() - return - } - factory91 := thrift.NewTSimpleJSONProtocolFactory() - jsProt92 := factory91.GetProtocol(mbTrans89) - argvalue0 := aurora.NewTaskQuery() - err93 := argvalue0.Read(jsProt92) - if err93 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetTasksWithoutConfigs(value0)) - fmt.Print("\n") - break - case "getPendingReason": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetPendingReason requires 1 args") - flag.Usage() - } - arg94 := flag.Arg(1) - mbTrans95 := thrift.NewTMemoryBufferLen(len(arg94)) - defer mbTrans95.Close() - _, err96 := mbTrans95.WriteString(arg94) - if err96 != nil { - Usage() - return - } - factory97 := thrift.NewTSimpleJSONProtocolFactory() - jsProt98 := factory97.GetProtocol(mbTrans95) - argvalue0 := aurora.NewTaskQuery() - err99 := argvalue0.Read(jsProt98) - if err99 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetPendingReason(value0)) - fmt.Print("\n") - break - case "getConfigSummary": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetConfigSummary requires 1 args") - flag.Usage() - } - arg100 := flag.Arg(1) - mbTrans101 := thrift.NewTMemoryBufferLen(len(arg100)) - defer mbTrans101.Close() - _, err102 := mbTrans101.WriteString(arg100) - if err102 != nil { - Usage() - return - } - factory103 := thrift.NewTSimpleJSONProtocolFactory() - jsProt104 := factory103.GetProtocol(mbTrans101) - argvalue0 := aurora.NewJobKey() - err105 := argvalue0.Read(jsProt104) - if err105 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetConfigSummary(value0)) - fmt.Print("\n") - break - case "getJobs": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetJobs requires 1 args") - flag.Usage() - } - argvalue0 := flag.Arg(1) - value0 := argvalue0 - fmt.Print(client.GetJobs(value0)) - fmt.Print("\n") - break - case "getQuota": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetQuota requires 1 args") - flag.Usage() - } - argvalue0 := flag.Arg(1) - value0 := argvalue0 - fmt.Print(client.GetQuota(value0)) - fmt.Print("\n") - break - case "populateJobConfig": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "PopulateJobConfig requires 1 args") - flag.Usage() - } - arg108 := flag.Arg(1) - mbTrans109 := thrift.NewTMemoryBufferLen(len(arg108)) - defer mbTrans109.Close() - _, err110 := mbTrans109.WriteString(arg108) - if err110 != nil { - Usage() - return - } - factory111 := thrift.NewTSimpleJSONProtocolFactory() - jsProt112 := factory111.GetProtocol(mbTrans109) - argvalue0 := aurora.NewJobConfiguration() - err113 := argvalue0.Read(jsProt112) - if err113 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.PopulateJobConfig(value0)) - fmt.Print("\n") - break - case "getJobUpdateSummaries": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetJobUpdateSummaries requires 1 args") - flag.Usage() - } - arg114 := flag.Arg(1) - mbTrans115 := thrift.NewTMemoryBufferLen(len(arg114)) - defer mbTrans115.Close() - _, err116 := mbTrans115.WriteString(arg114) - if err116 != nil { - Usage() - return - } - factory117 := thrift.NewTSimpleJSONProtocolFactory() - jsProt118 := factory117.GetProtocol(mbTrans115) - argvalue0 := aurora.NewJobUpdateQuery() - err119 := argvalue0.Read(jsProt118) - if err119 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetJobUpdateSummaries(value0)) - fmt.Print("\n") - break - case "getJobUpdateDetails": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetJobUpdateDetails requires 1 args") - flag.Usage() - } - arg120 := flag.Arg(1) - mbTrans121 := thrift.NewTMemoryBufferLen(len(arg120)) - defer mbTrans121.Close() - _, err122 := mbTrans121.WriteString(arg120) - if err122 != nil { - Usage() - return - } - factory123 := thrift.NewTSimpleJSONProtocolFactory() - jsProt124 := factory123.GetProtocol(mbTrans121) - argvalue0 := aurora.NewJobUpdateQuery() - err125 := argvalue0.Read(jsProt124) - if err125 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetJobUpdateDetails(value0)) - fmt.Print("\n") - break - case "getJobUpdateDiff": - if flag.NArg()-1 != 1 { - fmt.Fprintln(os.Stderr, "GetJobUpdateDiff requires 1 args") - flag.Usage() - } - arg126 := flag.Arg(1) - mbTrans127 := thrift.NewTMemoryBufferLen(len(arg126)) - defer mbTrans127.Close() - _, err128 := mbTrans127.WriteString(arg126) - if err128 != nil { - Usage() - return - } - factory129 := thrift.NewTSimpleJSONProtocolFactory() - jsProt130 := factory129.GetProtocol(mbTrans127) - argvalue0 := aurora.NewJobUpdateRequest() - err131 := argvalue0.Read(jsProt130) - if err131 != nil { - Usage() - return - } - value0 := argvalue0 - fmt.Print(client.GetJobUpdateDiff(value0)) - fmt.Print("\n") - break - case "getTierConfigs": - if flag.NArg()-1 != 0 { - fmt.Fprintln(os.Stderr, "GetTierConfigs requires 0 args") - flag.Usage() - } - fmt.Print(client.GetTierConfigs()) - fmt.Print("\n") - break - case "": - Usage() - break - default: - fmt.Fprintln(os.Stderr, "Invalid function ", cmd) - } + flag.Usage = Usage + var host string + var port int + var protocol string + var urlString string + var framed bool + var useHttp bool + headers := make(httpHeaders) + var parsedUrl *url.URL + var trans thrift.TTransport + _ = strconv.Atoi + _ = math.Abs + flag.Usage = Usage + flag.StringVar(&host, "h", "localhost", "Specify host and port") + flag.IntVar(&port, "p", 9090, "Specify port") + flag.StringVar(&protocol, "P", "binary", "Specify the protocol (binary, compact, simplejson, json)") + flag.StringVar(&urlString, "u", "", "Specify the url") + flag.BoolVar(&framed, "framed", false, "Use framed transport") + flag.BoolVar(&useHttp, "http", false, "Use http") + flag.Var(headers, "H", "Headers to set on the http(s) request (e.g. -H \"Key: Value\")") + flag.Parse() + + if len(urlString) > 0 { + var err error + parsedUrl, err = url.Parse(urlString) + if err != nil { + fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) + flag.Usage() + } + host = parsedUrl.Host + useHttp = len(parsedUrl.Scheme) <= 0 || parsedUrl.Scheme == "http" || parsedUrl.Scheme == "https" + } else if useHttp { + _, err := url.Parse(fmt.Sprint("http://", host, ":", port)) + if err != nil { + fmt.Fprintln(os.Stderr, "Error parsing URL: ", err) + flag.Usage() + } + } + + cmd := flag.Arg(0) + var err error + if useHttp { + trans, err = thrift.NewTHttpClient(parsedUrl.String()) + if len(headers) > 0 { + httptrans := trans.(*thrift.THttpClient) + for key, value := range headers { + httptrans.SetHeader(key, value) + } + } + } else { + portStr := fmt.Sprint(port) + if strings.Contains(host, ":") { + host, portStr, err = net.SplitHostPort(host) + if err != nil { + fmt.Fprintln(os.Stderr, "error with host:", err) + os.Exit(1) + } + } + trans, err = thrift.NewTSocket(net.JoinHostPort(host, portStr)) + if err != nil { + fmt.Fprintln(os.Stderr, "error resolving address:", err) + os.Exit(1) + } + if framed { + trans = thrift.NewTFramedTransport(trans) + } + } + if err != nil { + fmt.Fprintln(os.Stderr, "Error creating transport", err) + os.Exit(1) + } + defer trans.Close() + var protocolFactory thrift.TProtocolFactory + switch protocol { + case "compact": + protocolFactory = thrift.NewTCompactProtocolFactory() + break + case "simplejson": + protocolFactory = thrift.NewTSimpleJSONProtocolFactory() + break + case "json": + protocolFactory = thrift.NewTJSONProtocolFactory() + break + case "binary", "": + protocolFactory = thrift.NewTBinaryProtocolFactoryDefault() + break + default: + fmt.Fprintln(os.Stderr, "Invalid protocol specified: ", protocol) + Usage() + os.Exit(1) + } + iprot := protocolFactory.GetProtocol(trans) + oprot := protocolFactory.GetProtocol(trans) + client := aurora.NewReadOnlySchedulerClient(thrift.NewTStandardClient(iprot, oprot)) + if err := trans.Open(); err != nil { + fmt.Fprintln(os.Stderr, "Error opening socket to ", host, ":", port, " ", err) + os.Exit(1) + } + + switch cmd { + case "getRoleSummary": + if flag.NArg() - 1 != 0 { + fmt.Fprintln(os.Stderr, "GetRoleSummary requires 0 args") + flag.Usage() + } + fmt.Print(client.GetRoleSummary(context.Background())) + fmt.Print("\n") + break + case "getJobSummary": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetJobSummary requires 1 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + fmt.Print(client.GetJobSummary(context.Background(), value0)) + fmt.Print("\n") + break + case "getTasksStatus": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetTasksStatus requires 1 args") + flag.Usage() + } + arg132 := flag.Arg(1) + mbTrans133 := thrift.NewTMemoryBufferLen(len(arg132)) + defer mbTrans133.Close() + _, err134 := mbTrans133.WriteString(arg132) + if err134 != nil { + Usage() + return + } + factory135 := thrift.NewTJSONProtocolFactory() + jsProt136 := factory135.GetProtocol(mbTrans133) + argvalue0 := aurora.NewTaskQuery() + err137 := argvalue0.Read(context.Background(), jsProt136) + if err137 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetTasksStatus(context.Background(), value0)) + fmt.Print("\n") + break + case "getTasksWithoutConfigs": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetTasksWithoutConfigs requires 1 args") + flag.Usage() + } + arg138 := flag.Arg(1) + mbTrans139 := thrift.NewTMemoryBufferLen(len(arg138)) + defer mbTrans139.Close() + _, err140 := mbTrans139.WriteString(arg138) + if err140 != nil { + Usage() + return + } + factory141 := thrift.NewTJSONProtocolFactory() + jsProt142 := factory141.GetProtocol(mbTrans139) + argvalue0 := aurora.NewTaskQuery() + err143 := argvalue0.Read(context.Background(), jsProt142) + if err143 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetTasksWithoutConfigs(context.Background(), value0)) + fmt.Print("\n") + break + case "getPendingReason": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetPendingReason requires 1 args") + flag.Usage() + } + arg144 := flag.Arg(1) + mbTrans145 := thrift.NewTMemoryBufferLen(len(arg144)) + defer mbTrans145.Close() + _, err146 := mbTrans145.WriteString(arg144) + if err146 != nil { + Usage() + return + } + factory147 := thrift.NewTJSONProtocolFactory() + jsProt148 := factory147.GetProtocol(mbTrans145) + argvalue0 := aurora.NewTaskQuery() + err149 := argvalue0.Read(context.Background(), jsProt148) + if err149 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetPendingReason(context.Background(), value0)) + fmt.Print("\n") + break + case "getConfigSummary": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetConfigSummary requires 1 args") + flag.Usage() + } + arg150 := flag.Arg(1) + mbTrans151 := thrift.NewTMemoryBufferLen(len(arg150)) + defer mbTrans151.Close() + _, err152 := mbTrans151.WriteString(arg150) + if err152 != nil { + Usage() + return + } + factory153 := thrift.NewTJSONProtocolFactory() + jsProt154 := factory153.GetProtocol(mbTrans151) + argvalue0 := aurora.NewJobKey() + err155 := argvalue0.Read(context.Background(), jsProt154) + if err155 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetConfigSummary(context.Background(), value0)) + fmt.Print("\n") + break + case "getJobs": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetJobs requires 1 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + fmt.Print(client.GetJobs(context.Background(), value0)) + fmt.Print("\n") + break + case "getQuota": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetQuota requires 1 args") + flag.Usage() + } + argvalue0 := flag.Arg(1) + value0 := argvalue0 + fmt.Print(client.GetQuota(context.Background(), value0)) + fmt.Print("\n") + break + case "populateJobConfig": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "PopulateJobConfig requires 1 args") + flag.Usage() + } + arg158 := flag.Arg(1) + mbTrans159 := thrift.NewTMemoryBufferLen(len(arg158)) + defer mbTrans159.Close() + _, err160 := mbTrans159.WriteString(arg158) + if err160 != nil { + Usage() + return + } + factory161 := thrift.NewTJSONProtocolFactory() + jsProt162 := factory161.GetProtocol(mbTrans159) + argvalue0 := aurora.NewJobConfiguration() + err163 := argvalue0.Read(context.Background(), jsProt162) + if err163 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.PopulateJobConfig(context.Background(), value0)) + fmt.Print("\n") + break + case "getJobUpdateSummaries": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetJobUpdateSummaries requires 1 args") + flag.Usage() + } + arg164 := flag.Arg(1) + mbTrans165 := thrift.NewTMemoryBufferLen(len(arg164)) + defer mbTrans165.Close() + _, err166 := mbTrans165.WriteString(arg164) + if err166 != nil { + Usage() + return + } + factory167 := thrift.NewTJSONProtocolFactory() + jsProt168 := factory167.GetProtocol(mbTrans165) + argvalue0 := aurora.NewJobUpdateQuery() + err169 := argvalue0.Read(context.Background(), jsProt168) + if err169 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetJobUpdateSummaries(context.Background(), value0)) + fmt.Print("\n") + break + case "getJobUpdateDetails": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetJobUpdateDetails requires 1 args") + flag.Usage() + } + arg170 := flag.Arg(1) + mbTrans171 := thrift.NewTMemoryBufferLen(len(arg170)) + defer mbTrans171.Close() + _, err172 := mbTrans171.WriteString(arg170) + if err172 != nil { + Usage() + return + } + factory173 := thrift.NewTJSONProtocolFactory() + jsProt174 := factory173.GetProtocol(mbTrans171) + argvalue0 := aurora.NewJobUpdateQuery() + err175 := argvalue0.Read(context.Background(), jsProt174) + if err175 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetJobUpdateDetails(context.Background(), value0)) + fmt.Print("\n") + break + case "getJobUpdateDiff": + if flag.NArg() - 1 != 1 { + fmt.Fprintln(os.Stderr, "GetJobUpdateDiff requires 1 args") + flag.Usage() + } + arg176 := flag.Arg(1) + mbTrans177 := thrift.NewTMemoryBufferLen(len(arg176)) + defer mbTrans177.Close() + _, err178 := mbTrans177.WriteString(arg176) + if err178 != nil { + Usage() + return + } + factory179 := thrift.NewTJSONProtocolFactory() + jsProt180 := factory179.GetProtocol(mbTrans177) + argvalue0 := aurora.NewJobUpdateRequest() + err181 := argvalue0.Read(context.Background(), jsProt180) + if err181 != nil { + Usage() + return + } + value0 := argvalue0 + fmt.Print(client.GetJobUpdateDiff(context.Background(), value0)) + fmt.Print("\n") + break + case "getTierConfigs": + if flag.NArg() - 1 != 0 { + fmt.Fprintln(os.Stderr, "GetTierConfigs requires 0 args") + flag.Usage() + } + fmt.Print(client.GetTierConfigs(context.Background())) + fmt.Print("\n") + break + case "": + Usage() + break + default: + fmt.Fprintln(os.Stderr, "Invalid function ", cmd) + } } diff --git a/gen-go/apache/aurora/readonlyscheduler.go b/gen-go/apache/aurora/readonlyscheduler.go deleted file mode 100644 index e87a66d..0000000 --- a/gen-go/apache/aurora/readonlyscheduler.go +++ /dev/null @@ -1,4293 +0,0 @@ -// Autogenerated by Thrift Compiler (0.9.3) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -package aurora - -import ( - "bytes" - "fmt" - "git.apache.org/thrift.git/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = bytes.Equal - -type ReadOnlyScheduler interface { - // Returns a summary of the jobs grouped by role. - GetRoleSummary() (r *Response, err error) - // Returns a summary of jobs, optionally only those owned by a specific role. - // - // Parameters: - // - Role - GetJobSummary(role string) (r *Response, err error) - // Fetches the status of tasks. - // - // Parameters: - // - Query - GetTasksStatus(query *TaskQuery) (r *Response, err error) - // Same as getTaskStatus but without the TaskConfig.ExecutorConfig data set. - // This is an interim solution until we have a better way to query TaskConfigs (AURORA-541). - // - // Parameters: - // - Query - GetTasksWithoutConfigs(query *TaskQuery) (r *Response, err error) - // Returns user-friendly reasons (if available) for tasks retained in PENDING state. - // - // Parameters: - // - Query - GetPendingReason(query *TaskQuery) (r *Response, err error) - // Fetches the configuration summary of active tasks for the specified job. - // - // Parameters: - // - Job - GetConfigSummary(job *JobKey) (r *Response, err error) - // Fetches the status of jobs. - // ownerRole is optional, in which case all jobs are returned. - // - // Parameters: - // - OwnerRole - GetJobs(ownerRole string) (r *Response, err error) - // Fetches the quota allocated for a user. - // - // Parameters: - // - OwnerRole - GetQuota(ownerRole string) (r *Response, err error) - // Populates fields in a job configuration as though it were about to be run. - // This can be used to diff a configuration running tasks. - // - // Parameters: - // - Description - PopulateJobConfig(description *JobConfiguration) (r *Response, err error) - // Gets job update summaries. - // - // Parameters: - // - JobUpdateQuery - GetJobUpdateSummaries(jobUpdateQuery *JobUpdateQuery) (r *Response, err error) - // Gets job update details. - // - // Parameters: - // - Query - GetJobUpdateDetails(query *JobUpdateQuery) (r *Response, err error) - // Gets the diff between client (desired) and server (current) job states. - // - // Parameters: - // - Request - GetJobUpdateDiff(request *JobUpdateRequest) (r *Response, err error) - // Gets tier configurations. - GetTierConfigs() (r *Response, err error) -} - -type ReadOnlySchedulerClient struct { - Transport thrift.TTransport - ProtocolFactory thrift.TProtocolFactory - InputProtocol thrift.TProtocol - OutputProtocol thrift.TProtocol - SeqId int32 -} - -func NewReadOnlySchedulerClientFactory(t thrift.TTransport, f thrift.TProtocolFactory) *ReadOnlySchedulerClient { - return &ReadOnlySchedulerClient{Transport: t, - ProtocolFactory: f, - InputProtocol: f.GetProtocol(t), - OutputProtocol: f.GetProtocol(t), - SeqId: 0, - } -} - -func NewReadOnlySchedulerClientProtocol(t thrift.TTransport, iprot thrift.TProtocol, oprot thrift.TProtocol) *ReadOnlySchedulerClient { - return &ReadOnlySchedulerClient{Transport: t, - ProtocolFactory: nil, - InputProtocol: iprot, - OutputProtocol: oprot, - SeqId: 0, - } -} - -// Returns a summary of the jobs grouped by role. -func (p *ReadOnlySchedulerClient) GetRoleSummary() (r *Response, err error) { - if err = p.sendGetRoleSummary(); err != nil { - return - } - return p.recvGetRoleSummary() -} - -func (p *ReadOnlySchedulerClient) sendGetRoleSummary() (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("getRoleSummary", thrift.CALL, p.SeqId); err != nil { - return - } - args := ReadOnlySchedulerGetRoleSummaryArgs{} - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *ReadOnlySchedulerClient) recvGetRoleSummary() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "getRoleSummary" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "getRoleSummary failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getRoleSummary failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error53 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error54 error - error54, err = error53.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error54 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "getRoleSummary failed: invalid message type") - return - } - result := ReadOnlySchedulerGetRoleSummaryResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Returns a summary of jobs, optionally only those owned by a specific role. -// -// Parameters: -// - Role -func (p *ReadOnlySchedulerClient) GetJobSummary(role string) (r *Response, err error) { - if err = p.sendGetJobSummary(role); err != nil { - return - } - return p.recvGetJobSummary() -} - -func (p *ReadOnlySchedulerClient) sendGetJobSummary(role string) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("getJobSummary", thrift.CALL, p.SeqId); err != nil { - return - } - args := ReadOnlySchedulerGetJobSummaryArgs{ - Role: role, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *ReadOnlySchedulerClient) recvGetJobSummary() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "getJobSummary" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "getJobSummary failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getJobSummary failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error55 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error56 error - error56, err = error55.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error56 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "getJobSummary failed: invalid message type") - return - } - result := ReadOnlySchedulerGetJobSummaryResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Fetches the status of tasks. -// -// Parameters: -// - Query -func (p *ReadOnlySchedulerClient) GetTasksStatus(query *TaskQuery) (r *Response, err error) { - if err = p.sendGetTasksStatus(query); err != nil { - return - } - return p.recvGetTasksStatus() -} - -func (p *ReadOnlySchedulerClient) sendGetTasksStatus(query *TaskQuery) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("getTasksStatus", thrift.CALL, p.SeqId); err != nil { - return - } - args := ReadOnlySchedulerGetTasksStatusArgs{ - Query: query, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *ReadOnlySchedulerClient) recvGetTasksStatus() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "getTasksStatus" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "getTasksStatus failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getTasksStatus failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error57 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error58 error - error58, err = error57.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error58 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "getTasksStatus failed: invalid message type") - return - } - result := ReadOnlySchedulerGetTasksStatusResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Same as getTaskStatus but without the TaskConfig.ExecutorConfig data set. -// This is an interim solution until we have a better way to query TaskConfigs (AURORA-541). -// -// Parameters: -// - Query -func (p *ReadOnlySchedulerClient) GetTasksWithoutConfigs(query *TaskQuery) (r *Response, err error) { - if err = p.sendGetTasksWithoutConfigs(query); err != nil { - return - } - return p.recvGetTasksWithoutConfigs() -} - -func (p *ReadOnlySchedulerClient) sendGetTasksWithoutConfigs(query *TaskQuery) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("getTasksWithoutConfigs", thrift.CALL, p.SeqId); err != nil { - return - } - args := ReadOnlySchedulerGetTasksWithoutConfigsArgs{ - Query: query, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *ReadOnlySchedulerClient) recvGetTasksWithoutConfigs() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "getTasksWithoutConfigs" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "getTasksWithoutConfigs failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getTasksWithoutConfigs failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error59 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error60 error - error60, err = error59.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error60 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "getTasksWithoutConfigs failed: invalid message type") - return - } - result := ReadOnlySchedulerGetTasksWithoutConfigsResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Returns user-friendly reasons (if available) for tasks retained in PENDING state. -// -// Parameters: -// - Query -func (p *ReadOnlySchedulerClient) GetPendingReason(query *TaskQuery) (r *Response, err error) { - if err = p.sendGetPendingReason(query); err != nil { - return - } - return p.recvGetPendingReason() -} - -func (p *ReadOnlySchedulerClient) sendGetPendingReason(query *TaskQuery) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("getPendingReason", thrift.CALL, p.SeqId); err != nil { - return - } - args := ReadOnlySchedulerGetPendingReasonArgs{ - Query: query, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *ReadOnlySchedulerClient) recvGetPendingReason() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "getPendingReason" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "getPendingReason failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getPendingReason failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error61 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error62 error - error62, err = error61.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error62 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "getPendingReason failed: invalid message type") - return - } - result := ReadOnlySchedulerGetPendingReasonResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Fetches the configuration summary of active tasks for the specified job. -// -// Parameters: -// - Job -func (p *ReadOnlySchedulerClient) GetConfigSummary(job *JobKey) (r *Response, err error) { - if err = p.sendGetConfigSummary(job); err != nil { - return - } - return p.recvGetConfigSummary() -} - -func (p *ReadOnlySchedulerClient) sendGetConfigSummary(job *JobKey) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("getConfigSummary", thrift.CALL, p.SeqId); err != nil { - return - } - args := ReadOnlySchedulerGetConfigSummaryArgs{ - Job: job, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *ReadOnlySchedulerClient) recvGetConfigSummary() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "getConfigSummary" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "getConfigSummary failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getConfigSummary failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error63 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error64 error - error64, err = error63.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error64 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "getConfigSummary failed: invalid message type") - return - } - result := ReadOnlySchedulerGetConfigSummaryResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Fetches the status of jobs. -// ownerRole is optional, in which case all jobs are returned. -// -// Parameters: -// - OwnerRole -func (p *ReadOnlySchedulerClient) GetJobs(ownerRole string) (r *Response, err error) { - if err = p.sendGetJobs(ownerRole); err != nil { - return - } - return p.recvGetJobs() -} - -func (p *ReadOnlySchedulerClient) sendGetJobs(ownerRole string) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("getJobs", thrift.CALL, p.SeqId); err != nil { - return - } - args := ReadOnlySchedulerGetJobsArgs{ - OwnerRole: ownerRole, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *ReadOnlySchedulerClient) recvGetJobs() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "getJobs" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "getJobs failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getJobs failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error65 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error66 error - error66, err = error65.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error66 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "getJobs failed: invalid message type") - return - } - result := ReadOnlySchedulerGetJobsResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Fetches the quota allocated for a user. -// -// Parameters: -// - OwnerRole -func (p *ReadOnlySchedulerClient) GetQuota(ownerRole string) (r *Response, err error) { - if err = p.sendGetQuota(ownerRole); err != nil { - return - } - return p.recvGetQuota() -} - -func (p *ReadOnlySchedulerClient) sendGetQuota(ownerRole string) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("getQuota", thrift.CALL, p.SeqId); err != nil { - return - } - args := ReadOnlySchedulerGetQuotaArgs{ - OwnerRole: ownerRole, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *ReadOnlySchedulerClient) recvGetQuota() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "getQuota" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "getQuota failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getQuota failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error67 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error68 error - error68, err = error67.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error68 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "getQuota failed: invalid message type") - return - } - result := ReadOnlySchedulerGetQuotaResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Populates fields in a job configuration as though it were about to be run. -// This can be used to diff a configuration running tasks. -// -// Parameters: -// - Description -func (p *ReadOnlySchedulerClient) PopulateJobConfig(description *JobConfiguration) (r *Response, err error) { - if err = p.sendPopulateJobConfig(description); err != nil { - return - } - return p.recvPopulateJobConfig() -} - -func (p *ReadOnlySchedulerClient) sendPopulateJobConfig(description *JobConfiguration) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("populateJobConfig", thrift.CALL, p.SeqId); err != nil { - return - } - args := ReadOnlySchedulerPopulateJobConfigArgs{ - Description: description, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *ReadOnlySchedulerClient) recvPopulateJobConfig() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "populateJobConfig" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "populateJobConfig failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "populateJobConfig failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error69 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error70 error - error70, err = error69.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error70 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "populateJobConfig failed: invalid message type") - return - } - result := ReadOnlySchedulerPopulateJobConfigResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Gets job update summaries. -// -// Parameters: -// - JobUpdateQuery -func (p *ReadOnlySchedulerClient) GetJobUpdateSummaries(jobUpdateQuery *JobUpdateQuery) (r *Response, err error) { - if err = p.sendGetJobUpdateSummaries(jobUpdateQuery); err != nil { - return - } - return p.recvGetJobUpdateSummaries() -} - -func (p *ReadOnlySchedulerClient) sendGetJobUpdateSummaries(jobUpdateQuery *JobUpdateQuery) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("getJobUpdateSummaries", thrift.CALL, p.SeqId); err != nil { - return - } - args := ReadOnlySchedulerGetJobUpdateSummariesArgs{ - JobUpdateQuery: jobUpdateQuery, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *ReadOnlySchedulerClient) recvGetJobUpdateSummaries() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "getJobUpdateSummaries" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "getJobUpdateSummaries failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getJobUpdateSummaries failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error71 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error72 error - error72, err = error71.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error72 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "getJobUpdateSummaries failed: invalid message type") - return - } - result := ReadOnlySchedulerGetJobUpdateSummariesResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Gets job update details. -// -// Parameters: -// - Query -func (p *ReadOnlySchedulerClient) GetJobUpdateDetails(query *JobUpdateQuery) (r *Response, err error) { - if err = p.sendGetJobUpdateDetails(query); err != nil { - return - } - return p.recvGetJobUpdateDetails() -} - -func (p *ReadOnlySchedulerClient) sendGetJobUpdateDetails(query *JobUpdateQuery) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("getJobUpdateDetails", thrift.CALL, p.SeqId); err != nil { - return - } - args := ReadOnlySchedulerGetJobUpdateDetailsArgs{ - Query: query, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *ReadOnlySchedulerClient) recvGetJobUpdateDetails() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "getJobUpdateDetails" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "getJobUpdateDetails failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getJobUpdateDetails failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error73 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error74 error - error74, err = error73.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error74 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "getJobUpdateDetails failed: invalid message type") - return - } - result := ReadOnlySchedulerGetJobUpdateDetailsResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Gets the diff between client (desired) and server (current) job states. -// -// Parameters: -// - Request -func (p *ReadOnlySchedulerClient) GetJobUpdateDiff(request *JobUpdateRequest) (r *Response, err error) { - if err = p.sendGetJobUpdateDiff(request); err != nil { - return - } - return p.recvGetJobUpdateDiff() -} - -func (p *ReadOnlySchedulerClient) sendGetJobUpdateDiff(request *JobUpdateRequest) (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("getJobUpdateDiff", thrift.CALL, p.SeqId); err != nil { - return - } - args := ReadOnlySchedulerGetJobUpdateDiffArgs{ - Request: request, - } - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *ReadOnlySchedulerClient) recvGetJobUpdateDiff() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "getJobUpdateDiff" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "getJobUpdateDiff failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getJobUpdateDiff failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error75 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error76 error - error76, err = error75.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error76 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "getJobUpdateDiff failed: invalid message type") - return - } - result := ReadOnlySchedulerGetJobUpdateDiffResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -// Gets tier configurations. -func (p *ReadOnlySchedulerClient) GetTierConfigs() (r *Response, err error) { - if err = p.sendGetTierConfigs(); err != nil { - return - } - return p.recvGetTierConfigs() -} - -func (p *ReadOnlySchedulerClient) sendGetTierConfigs() (err error) { - oprot := p.OutputProtocol - if oprot == nil { - oprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.OutputProtocol = oprot - } - p.SeqId++ - if err = oprot.WriteMessageBegin("getTierConfigs", thrift.CALL, p.SeqId); err != nil { - return - } - args := ReadOnlySchedulerGetTierConfigsArgs{} - if err = args.Write(oprot); err != nil { - return - } - if err = oprot.WriteMessageEnd(); err != nil { - return - } - return oprot.Flush() -} - -func (p *ReadOnlySchedulerClient) recvGetTierConfigs() (value *Response, err error) { - iprot := p.InputProtocol - if iprot == nil { - iprot = p.ProtocolFactory.GetProtocol(p.Transport) - p.InputProtocol = iprot - } - method, mTypeId, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return - } - if method != "getTierConfigs" { - err = thrift.NewTApplicationException(thrift.WRONG_METHOD_NAME, "getTierConfigs failed: wrong method name") - return - } - if p.SeqId != seqId { - err = thrift.NewTApplicationException(thrift.BAD_SEQUENCE_ID, "getTierConfigs failed: out of sequence response") - return - } - if mTypeId == thrift.EXCEPTION { - error77 := thrift.NewTApplicationException(thrift.UNKNOWN_APPLICATION_EXCEPTION, "Unknown Exception") - var error78 error - error78, err = error77.Read(iprot) - if err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - err = error78 - return - } - if mTypeId != thrift.REPLY { - err = thrift.NewTApplicationException(thrift.INVALID_MESSAGE_TYPE_EXCEPTION, "getTierConfigs failed: invalid message type") - return - } - result := ReadOnlySchedulerGetTierConfigsResult{} - if err = result.Read(iprot); err != nil { - return - } - if err = iprot.ReadMessageEnd(); err != nil { - return - } - value = result.GetSuccess() - return -} - -type ReadOnlySchedulerProcessor struct { - processorMap map[string]thrift.TProcessorFunction - handler ReadOnlyScheduler -} - -func (p *ReadOnlySchedulerProcessor) AddToProcessorMap(key string, processor thrift.TProcessorFunction) { - p.processorMap[key] = processor -} - -func (p *ReadOnlySchedulerProcessor) GetProcessorFunction(key string) (processor thrift.TProcessorFunction, ok bool) { - processor, ok = p.processorMap[key] - return processor, ok -} - -func (p *ReadOnlySchedulerProcessor) ProcessorMap() map[string]thrift.TProcessorFunction { - return p.processorMap -} - -func NewReadOnlySchedulerProcessor(handler ReadOnlyScheduler) *ReadOnlySchedulerProcessor { - - self79 := &ReadOnlySchedulerProcessor{handler: handler, processorMap: make(map[string]thrift.TProcessorFunction)} - self79.processorMap["getRoleSummary"] = &readOnlySchedulerProcessorGetRoleSummary{handler: handler} - self79.processorMap["getJobSummary"] = &readOnlySchedulerProcessorGetJobSummary{handler: handler} - self79.processorMap["getTasksStatus"] = &readOnlySchedulerProcessorGetTasksStatus{handler: handler} - self79.processorMap["getTasksWithoutConfigs"] = &readOnlySchedulerProcessorGetTasksWithoutConfigs{handler: handler} - self79.processorMap["getPendingReason"] = &readOnlySchedulerProcessorGetPendingReason{handler: handler} - self79.processorMap["getConfigSummary"] = &readOnlySchedulerProcessorGetConfigSummary{handler: handler} - self79.processorMap["getJobs"] = &readOnlySchedulerProcessorGetJobs{handler: handler} - self79.processorMap["getQuota"] = &readOnlySchedulerProcessorGetQuota{handler: handler} - self79.processorMap["populateJobConfig"] = &readOnlySchedulerProcessorPopulateJobConfig{handler: handler} - self79.processorMap["getJobUpdateSummaries"] = &readOnlySchedulerProcessorGetJobUpdateSummaries{handler: handler} - self79.processorMap["getJobUpdateDetails"] = &readOnlySchedulerProcessorGetJobUpdateDetails{handler: handler} - self79.processorMap["getJobUpdateDiff"] = &readOnlySchedulerProcessorGetJobUpdateDiff{handler: handler} - self79.processorMap["getTierConfigs"] = &readOnlySchedulerProcessorGetTierConfigs{handler: handler} - return self79 -} - -func (p *ReadOnlySchedulerProcessor) Process(iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - name, _, seqId, err := iprot.ReadMessageBegin() - if err != nil { - return false, err - } - if processor, ok := p.GetProcessorFunction(name); ok { - return processor.Process(seqId, iprot, oprot) - } - iprot.Skip(thrift.STRUCT) - iprot.ReadMessageEnd() - x80 := thrift.NewTApplicationException(thrift.UNKNOWN_METHOD, "Unknown function "+name) - oprot.WriteMessageBegin(name, thrift.EXCEPTION, seqId) - x80.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, x80 - -} - -type readOnlySchedulerProcessorGetRoleSummary struct { - handler ReadOnlyScheduler -} - -func (p *readOnlySchedulerProcessorGetRoleSummary) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ReadOnlySchedulerGetRoleSummaryArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getRoleSummary", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := ReadOnlySchedulerGetRoleSummaryResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.GetRoleSummary(); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getRoleSummary: "+err2.Error()) - oprot.WriteMessageBegin("getRoleSummary", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("getRoleSummary", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type readOnlySchedulerProcessorGetJobSummary struct { - handler ReadOnlyScheduler -} - -func (p *readOnlySchedulerProcessorGetJobSummary) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ReadOnlySchedulerGetJobSummaryArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getJobSummary", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := ReadOnlySchedulerGetJobSummaryResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.GetJobSummary(args.Role); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getJobSummary: "+err2.Error()) - oprot.WriteMessageBegin("getJobSummary", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("getJobSummary", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type readOnlySchedulerProcessorGetTasksStatus struct { - handler ReadOnlyScheduler -} - -func (p *readOnlySchedulerProcessorGetTasksStatus) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ReadOnlySchedulerGetTasksStatusArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getTasksStatus", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := ReadOnlySchedulerGetTasksStatusResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.GetTasksStatus(args.Query); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTasksStatus: "+err2.Error()) - oprot.WriteMessageBegin("getTasksStatus", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("getTasksStatus", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type readOnlySchedulerProcessorGetTasksWithoutConfigs struct { - handler ReadOnlyScheduler -} - -func (p *readOnlySchedulerProcessorGetTasksWithoutConfigs) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ReadOnlySchedulerGetTasksWithoutConfigsArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getTasksWithoutConfigs", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := ReadOnlySchedulerGetTasksWithoutConfigsResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.GetTasksWithoutConfigs(args.Query); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTasksWithoutConfigs: "+err2.Error()) - oprot.WriteMessageBegin("getTasksWithoutConfigs", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("getTasksWithoutConfigs", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type readOnlySchedulerProcessorGetPendingReason struct { - handler ReadOnlyScheduler -} - -func (p *readOnlySchedulerProcessorGetPendingReason) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ReadOnlySchedulerGetPendingReasonArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getPendingReason", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := ReadOnlySchedulerGetPendingReasonResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.GetPendingReason(args.Query); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getPendingReason: "+err2.Error()) - oprot.WriteMessageBegin("getPendingReason", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("getPendingReason", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type readOnlySchedulerProcessorGetConfigSummary struct { - handler ReadOnlyScheduler -} - -func (p *readOnlySchedulerProcessorGetConfigSummary) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ReadOnlySchedulerGetConfigSummaryArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getConfigSummary", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := ReadOnlySchedulerGetConfigSummaryResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.GetConfigSummary(args.Job); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getConfigSummary: "+err2.Error()) - oprot.WriteMessageBegin("getConfigSummary", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("getConfigSummary", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type readOnlySchedulerProcessorGetJobs struct { - handler ReadOnlyScheduler -} - -func (p *readOnlySchedulerProcessorGetJobs) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ReadOnlySchedulerGetJobsArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getJobs", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := ReadOnlySchedulerGetJobsResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.GetJobs(args.OwnerRole); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getJobs: "+err2.Error()) - oprot.WriteMessageBegin("getJobs", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("getJobs", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type readOnlySchedulerProcessorGetQuota struct { - handler ReadOnlyScheduler -} - -func (p *readOnlySchedulerProcessorGetQuota) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ReadOnlySchedulerGetQuotaArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getQuota", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := ReadOnlySchedulerGetQuotaResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.GetQuota(args.OwnerRole); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getQuota: "+err2.Error()) - oprot.WriteMessageBegin("getQuota", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("getQuota", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type readOnlySchedulerProcessorPopulateJobConfig struct { - handler ReadOnlyScheduler -} - -func (p *readOnlySchedulerProcessorPopulateJobConfig) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ReadOnlySchedulerPopulateJobConfigArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("populateJobConfig", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := ReadOnlySchedulerPopulateJobConfigResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.PopulateJobConfig(args.Description); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing populateJobConfig: "+err2.Error()) - oprot.WriteMessageBegin("populateJobConfig", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("populateJobConfig", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type readOnlySchedulerProcessorGetJobUpdateSummaries struct { - handler ReadOnlyScheduler -} - -func (p *readOnlySchedulerProcessorGetJobUpdateSummaries) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ReadOnlySchedulerGetJobUpdateSummariesArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getJobUpdateSummaries", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := ReadOnlySchedulerGetJobUpdateSummariesResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.GetJobUpdateSummaries(args.JobUpdateQuery); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getJobUpdateSummaries: "+err2.Error()) - oprot.WriteMessageBegin("getJobUpdateSummaries", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("getJobUpdateSummaries", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type readOnlySchedulerProcessorGetJobUpdateDetails struct { - handler ReadOnlyScheduler -} - -func (p *readOnlySchedulerProcessorGetJobUpdateDetails) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ReadOnlySchedulerGetJobUpdateDetailsArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getJobUpdateDetails", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := ReadOnlySchedulerGetJobUpdateDetailsResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.GetJobUpdateDetails(args.Query); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getJobUpdateDetails: "+err2.Error()) - oprot.WriteMessageBegin("getJobUpdateDetails", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("getJobUpdateDetails", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type readOnlySchedulerProcessorGetJobUpdateDiff struct { - handler ReadOnlyScheduler -} - -func (p *readOnlySchedulerProcessorGetJobUpdateDiff) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ReadOnlySchedulerGetJobUpdateDiffArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getJobUpdateDiff", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := ReadOnlySchedulerGetJobUpdateDiffResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.GetJobUpdateDiff(args.Request); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getJobUpdateDiff: "+err2.Error()) - oprot.WriteMessageBegin("getJobUpdateDiff", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("getJobUpdateDiff", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -type readOnlySchedulerProcessorGetTierConfigs struct { - handler ReadOnlyScheduler -} - -func (p *readOnlySchedulerProcessorGetTierConfigs) Process(seqId int32, iprot, oprot thrift.TProtocol) (success bool, err thrift.TException) { - args := ReadOnlySchedulerGetTierConfigsArgs{} - if err = args.Read(iprot); err != nil { - iprot.ReadMessageEnd() - x := thrift.NewTApplicationException(thrift.PROTOCOL_ERROR, err.Error()) - oprot.WriteMessageBegin("getTierConfigs", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return false, err - } - - iprot.ReadMessageEnd() - result := ReadOnlySchedulerGetTierConfigsResult{} - var retval *Response - var err2 error - if retval, err2 = p.handler.GetTierConfigs(); err2 != nil { - x := thrift.NewTApplicationException(thrift.INTERNAL_ERROR, "Internal error processing getTierConfigs: "+err2.Error()) - oprot.WriteMessageBegin("getTierConfigs", thrift.EXCEPTION, seqId) - x.Write(oprot) - oprot.WriteMessageEnd() - oprot.Flush() - return true, err2 - } else { - result.Success = retval - } - if err2 = oprot.WriteMessageBegin("getTierConfigs", thrift.REPLY, seqId); err2 != nil { - err = err2 - } - if err2 = result.Write(oprot); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.WriteMessageEnd(); err == nil && err2 != nil { - err = err2 - } - if err2 = oprot.Flush(); err == nil && err2 != nil { - err = err2 - } - if err != nil { - return - } - return true, err -} - -// HELPER FUNCTIONS AND STRUCTURES - -type ReadOnlySchedulerGetRoleSummaryArgs struct { -} - -func NewReadOnlySchedulerGetRoleSummaryArgs() *ReadOnlySchedulerGetRoleSummaryArgs { - return &ReadOnlySchedulerGetRoleSummaryArgs{} -} - -func (p *ReadOnlySchedulerGetRoleSummaryArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetRoleSummaryArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getRoleSummary_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetRoleSummaryArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetRoleSummaryArgs(%+v)", *p) -} - -// Attributes: -// - Success -type ReadOnlySchedulerGetRoleSummaryResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewReadOnlySchedulerGetRoleSummaryResult() *ReadOnlySchedulerGetRoleSummaryResult { - return &ReadOnlySchedulerGetRoleSummaryResult{} -} - -var ReadOnlySchedulerGetRoleSummaryResult_Success_DEFAULT *Response - -func (p *ReadOnlySchedulerGetRoleSummaryResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return ReadOnlySchedulerGetRoleSummaryResult_Success_DEFAULT - } - return p.Success -} -func (p *ReadOnlySchedulerGetRoleSummaryResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *ReadOnlySchedulerGetRoleSummaryResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetRoleSummaryResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetRoleSummaryResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getRoleSummary_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetRoleSummaryResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *ReadOnlySchedulerGetRoleSummaryResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetRoleSummaryResult(%+v)", *p) -} - -// Attributes: -// - Role -type ReadOnlySchedulerGetJobSummaryArgs struct { - Role string `thrift:"role,1" json:"role"` -} - -func NewReadOnlySchedulerGetJobSummaryArgs() *ReadOnlySchedulerGetJobSummaryArgs { - return &ReadOnlySchedulerGetJobSummaryArgs{} -} - -func (p *ReadOnlySchedulerGetJobSummaryArgs) GetRole() string { - return p.Role -} -func (p *ReadOnlySchedulerGetJobSummaryArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobSummaryArgs) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Role = v - } - return nil -} - -func (p *ReadOnlySchedulerGetJobSummaryArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobSummary_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobSummaryArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("role", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:role: ", p), err) - } - if err := oprot.WriteString(string(p.Role)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.role (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:role: ", p), err) - } - return err -} - -func (p *ReadOnlySchedulerGetJobSummaryArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetJobSummaryArgs(%+v)", *p) -} - -// Attributes: -// - Success -type ReadOnlySchedulerGetJobSummaryResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewReadOnlySchedulerGetJobSummaryResult() *ReadOnlySchedulerGetJobSummaryResult { - return &ReadOnlySchedulerGetJobSummaryResult{} -} - -var ReadOnlySchedulerGetJobSummaryResult_Success_DEFAULT *Response - -func (p *ReadOnlySchedulerGetJobSummaryResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return ReadOnlySchedulerGetJobSummaryResult_Success_DEFAULT - } - return p.Success -} -func (p *ReadOnlySchedulerGetJobSummaryResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *ReadOnlySchedulerGetJobSummaryResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobSummaryResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobSummaryResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobSummary_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobSummaryResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *ReadOnlySchedulerGetJobSummaryResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetJobSummaryResult(%+v)", *p) -} - -// Attributes: -// - Query -type ReadOnlySchedulerGetTasksStatusArgs struct { - Query *TaskQuery `thrift:"query,1" json:"query"` -} - -func NewReadOnlySchedulerGetTasksStatusArgs() *ReadOnlySchedulerGetTasksStatusArgs { - return &ReadOnlySchedulerGetTasksStatusArgs{} -} - -var ReadOnlySchedulerGetTasksStatusArgs_Query_DEFAULT *TaskQuery - -func (p *ReadOnlySchedulerGetTasksStatusArgs) GetQuery() *TaskQuery { - if !p.IsSetQuery() { - return ReadOnlySchedulerGetTasksStatusArgs_Query_DEFAULT - } - return p.Query -} -func (p *ReadOnlySchedulerGetTasksStatusArgs) IsSetQuery() bool { - return p.Query != nil -} - -func (p *ReadOnlySchedulerGetTasksStatusArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetTasksStatusArgs) readField1(iprot thrift.TProtocol) error { - p.Query = &TaskQuery{} - if err := p.Query.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetTasksStatusArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getTasksStatus_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetTasksStatusArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("query", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:query: ", p), err) - } - if err := p.Query.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:query: ", p), err) - } - return err -} - -func (p *ReadOnlySchedulerGetTasksStatusArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetTasksStatusArgs(%+v)", *p) -} - -// Attributes: -// - Success -type ReadOnlySchedulerGetTasksStatusResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewReadOnlySchedulerGetTasksStatusResult() *ReadOnlySchedulerGetTasksStatusResult { - return &ReadOnlySchedulerGetTasksStatusResult{} -} - -var ReadOnlySchedulerGetTasksStatusResult_Success_DEFAULT *Response - -func (p *ReadOnlySchedulerGetTasksStatusResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return ReadOnlySchedulerGetTasksStatusResult_Success_DEFAULT - } - return p.Success -} -func (p *ReadOnlySchedulerGetTasksStatusResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *ReadOnlySchedulerGetTasksStatusResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetTasksStatusResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetTasksStatusResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getTasksStatus_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetTasksStatusResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *ReadOnlySchedulerGetTasksStatusResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetTasksStatusResult(%+v)", *p) -} - -// Attributes: -// - Query -type ReadOnlySchedulerGetTasksWithoutConfigsArgs struct { - Query *TaskQuery `thrift:"query,1" json:"query"` -} - -func NewReadOnlySchedulerGetTasksWithoutConfigsArgs() *ReadOnlySchedulerGetTasksWithoutConfigsArgs { - return &ReadOnlySchedulerGetTasksWithoutConfigsArgs{} -} - -var ReadOnlySchedulerGetTasksWithoutConfigsArgs_Query_DEFAULT *TaskQuery - -func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) GetQuery() *TaskQuery { - if !p.IsSetQuery() { - return ReadOnlySchedulerGetTasksWithoutConfigsArgs_Query_DEFAULT - } - return p.Query -} -func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) IsSetQuery() bool { - return p.Query != nil -} - -func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) readField1(iprot thrift.TProtocol) error { - p.Query = &TaskQuery{} - if err := p.Query.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getTasksWithoutConfigs_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("query", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:query: ", p), err) - } - if err := p.Query.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:query: ", p), err) - } - return err -} - -func (p *ReadOnlySchedulerGetTasksWithoutConfigsArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetTasksWithoutConfigsArgs(%+v)", *p) -} - -// Attributes: -// - Success -type ReadOnlySchedulerGetTasksWithoutConfigsResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewReadOnlySchedulerGetTasksWithoutConfigsResult() *ReadOnlySchedulerGetTasksWithoutConfigsResult { - return &ReadOnlySchedulerGetTasksWithoutConfigsResult{} -} - -var ReadOnlySchedulerGetTasksWithoutConfigsResult_Success_DEFAULT *Response - -func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return ReadOnlySchedulerGetTasksWithoutConfigsResult_Success_DEFAULT - } - return p.Success -} -func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getTasksWithoutConfigs_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *ReadOnlySchedulerGetTasksWithoutConfigsResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetTasksWithoutConfigsResult(%+v)", *p) -} - -// Attributes: -// - Query -type ReadOnlySchedulerGetPendingReasonArgs struct { - Query *TaskQuery `thrift:"query,1" json:"query"` -} - -func NewReadOnlySchedulerGetPendingReasonArgs() *ReadOnlySchedulerGetPendingReasonArgs { - return &ReadOnlySchedulerGetPendingReasonArgs{} -} - -var ReadOnlySchedulerGetPendingReasonArgs_Query_DEFAULT *TaskQuery - -func (p *ReadOnlySchedulerGetPendingReasonArgs) GetQuery() *TaskQuery { - if !p.IsSetQuery() { - return ReadOnlySchedulerGetPendingReasonArgs_Query_DEFAULT - } - return p.Query -} -func (p *ReadOnlySchedulerGetPendingReasonArgs) IsSetQuery() bool { - return p.Query != nil -} - -func (p *ReadOnlySchedulerGetPendingReasonArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetPendingReasonArgs) readField1(iprot thrift.TProtocol) error { - p.Query = &TaskQuery{} - if err := p.Query.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetPendingReasonArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getPendingReason_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetPendingReasonArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("query", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:query: ", p), err) - } - if err := p.Query.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:query: ", p), err) - } - return err -} - -func (p *ReadOnlySchedulerGetPendingReasonArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetPendingReasonArgs(%+v)", *p) -} - -// Attributes: -// - Success -type ReadOnlySchedulerGetPendingReasonResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewReadOnlySchedulerGetPendingReasonResult() *ReadOnlySchedulerGetPendingReasonResult { - return &ReadOnlySchedulerGetPendingReasonResult{} -} - -var ReadOnlySchedulerGetPendingReasonResult_Success_DEFAULT *Response - -func (p *ReadOnlySchedulerGetPendingReasonResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return ReadOnlySchedulerGetPendingReasonResult_Success_DEFAULT - } - return p.Success -} -func (p *ReadOnlySchedulerGetPendingReasonResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *ReadOnlySchedulerGetPendingReasonResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetPendingReasonResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetPendingReasonResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getPendingReason_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetPendingReasonResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *ReadOnlySchedulerGetPendingReasonResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetPendingReasonResult(%+v)", *p) -} - -// Attributes: -// - Job -type ReadOnlySchedulerGetConfigSummaryArgs struct { - Job *JobKey `thrift:"job,1" json:"job"` -} - -func NewReadOnlySchedulerGetConfigSummaryArgs() *ReadOnlySchedulerGetConfigSummaryArgs { - return &ReadOnlySchedulerGetConfigSummaryArgs{} -} - -var ReadOnlySchedulerGetConfigSummaryArgs_Job_DEFAULT *JobKey - -func (p *ReadOnlySchedulerGetConfigSummaryArgs) GetJob() *JobKey { - if !p.IsSetJob() { - return ReadOnlySchedulerGetConfigSummaryArgs_Job_DEFAULT - } - return p.Job -} -func (p *ReadOnlySchedulerGetConfigSummaryArgs) IsSetJob() bool { - return p.Job != nil -} - -func (p *ReadOnlySchedulerGetConfigSummaryArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetConfigSummaryArgs) readField1(iprot thrift.TProtocol) error { - p.Job = &JobKey{} - if err := p.Job.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetConfigSummaryArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getConfigSummary_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetConfigSummaryArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("job", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:job: ", p), err) - } - if err := p.Job.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:job: ", p), err) - } - return err -} - -func (p *ReadOnlySchedulerGetConfigSummaryArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetConfigSummaryArgs(%+v)", *p) -} - -// Attributes: -// - Success -type ReadOnlySchedulerGetConfigSummaryResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewReadOnlySchedulerGetConfigSummaryResult() *ReadOnlySchedulerGetConfigSummaryResult { - return &ReadOnlySchedulerGetConfigSummaryResult{} -} - -var ReadOnlySchedulerGetConfigSummaryResult_Success_DEFAULT *Response - -func (p *ReadOnlySchedulerGetConfigSummaryResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return ReadOnlySchedulerGetConfigSummaryResult_Success_DEFAULT - } - return p.Success -} -func (p *ReadOnlySchedulerGetConfigSummaryResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *ReadOnlySchedulerGetConfigSummaryResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetConfigSummaryResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetConfigSummaryResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getConfigSummary_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetConfigSummaryResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *ReadOnlySchedulerGetConfigSummaryResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetConfigSummaryResult(%+v)", *p) -} - -// Attributes: -// - OwnerRole -type ReadOnlySchedulerGetJobsArgs struct { - OwnerRole string `thrift:"ownerRole,1" json:"ownerRole"` -} - -func NewReadOnlySchedulerGetJobsArgs() *ReadOnlySchedulerGetJobsArgs { - return &ReadOnlySchedulerGetJobsArgs{} -} - -func (p *ReadOnlySchedulerGetJobsArgs) GetOwnerRole() string { - return p.OwnerRole -} -func (p *ReadOnlySchedulerGetJobsArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobsArgs) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.OwnerRole = v - } - return nil -} - -func (p *ReadOnlySchedulerGetJobsArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobs_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobsArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("ownerRole", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ownerRole: ", p), err) - } - if err := oprot.WriteString(string(p.OwnerRole)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.ownerRole (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ownerRole: ", p), err) - } - return err -} - -func (p *ReadOnlySchedulerGetJobsArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetJobsArgs(%+v)", *p) -} - -// Attributes: -// - Success -type ReadOnlySchedulerGetJobsResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewReadOnlySchedulerGetJobsResult() *ReadOnlySchedulerGetJobsResult { - return &ReadOnlySchedulerGetJobsResult{} -} - -var ReadOnlySchedulerGetJobsResult_Success_DEFAULT *Response - -func (p *ReadOnlySchedulerGetJobsResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return ReadOnlySchedulerGetJobsResult_Success_DEFAULT - } - return p.Success -} -func (p *ReadOnlySchedulerGetJobsResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *ReadOnlySchedulerGetJobsResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobsResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobsResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobs_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobsResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *ReadOnlySchedulerGetJobsResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetJobsResult(%+v)", *p) -} - -// Attributes: -// - OwnerRole -type ReadOnlySchedulerGetQuotaArgs struct { - OwnerRole string `thrift:"ownerRole,1" json:"ownerRole"` -} - -func NewReadOnlySchedulerGetQuotaArgs() *ReadOnlySchedulerGetQuotaArgs { - return &ReadOnlySchedulerGetQuotaArgs{} -} - -func (p *ReadOnlySchedulerGetQuotaArgs) GetOwnerRole() string { - return p.OwnerRole -} -func (p *ReadOnlySchedulerGetQuotaArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetQuotaArgs) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.OwnerRole = v - } - return nil -} - -func (p *ReadOnlySchedulerGetQuotaArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getQuota_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetQuotaArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("ownerRole", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:ownerRole: ", p), err) - } - if err := oprot.WriteString(string(p.OwnerRole)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.ownerRole (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:ownerRole: ", p), err) - } - return err -} - -func (p *ReadOnlySchedulerGetQuotaArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetQuotaArgs(%+v)", *p) -} - -// Attributes: -// - Success -type ReadOnlySchedulerGetQuotaResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewReadOnlySchedulerGetQuotaResult() *ReadOnlySchedulerGetQuotaResult { - return &ReadOnlySchedulerGetQuotaResult{} -} - -var ReadOnlySchedulerGetQuotaResult_Success_DEFAULT *Response - -func (p *ReadOnlySchedulerGetQuotaResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return ReadOnlySchedulerGetQuotaResult_Success_DEFAULT - } - return p.Success -} -func (p *ReadOnlySchedulerGetQuotaResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *ReadOnlySchedulerGetQuotaResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetQuotaResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetQuotaResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getQuota_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetQuotaResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *ReadOnlySchedulerGetQuotaResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetQuotaResult(%+v)", *p) -} - -// Attributes: -// - Description -type ReadOnlySchedulerPopulateJobConfigArgs struct { - Description *JobConfiguration `thrift:"description,1" json:"description"` -} - -func NewReadOnlySchedulerPopulateJobConfigArgs() *ReadOnlySchedulerPopulateJobConfigArgs { - return &ReadOnlySchedulerPopulateJobConfigArgs{} -} - -var ReadOnlySchedulerPopulateJobConfigArgs_Description_DEFAULT *JobConfiguration - -func (p *ReadOnlySchedulerPopulateJobConfigArgs) GetDescription() *JobConfiguration { - if !p.IsSetDescription() { - return ReadOnlySchedulerPopulateJobConfigArgs_Description_DEFAULT - } - return p.Description -} -func (p *ReadOnlySchedulerPopulateJobConfigArgs) IsSetDescription() bool { - return p.Description != nil -} - -func (p *ReadOnlySchedulerPopulateJobConfigArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerPopulateJobConfigArgs) readField1(iprot thrift.TProtocol) error { - p.Description = &JobConfiguration{} - if err := p.Description.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Description), err) - } - return nil -} - -func (p *ReadOnlySchedulerPopulateJobConfigArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("populateJobConfig_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerPopulateJobConfigArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("description", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:description: ", p), err) - } - if err := p.Description.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Description), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:description: ", p), err) - } - return err -} - -func (p *ReadOnlySchedulerPopulateJobConfigArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerPopulateJobConfigArgs(%+v)", *p) -} - -// Attributes: -// - Success -type ReadOnlySchedulerPopulateJobConfigResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewReadOnlySchedulerPopulateJobConfigResult() *ReadOnlySchedulerPopulateJobConfigResult { - return &ReadOnlySchedulerPopulateJobConfigResult{} -} - -var ReadOnlySchedulerPopulateJobConfigResult_Success_DEFAULT *Response - -func (p *ReadOnlySchedulerPopulateJobConfigResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return ReadOnlySchedulerPopulateJobConfigResult_Success_DEFAULT - } - return p.Success -} -func (p *ReadOnlySchedulerPopulateJobConfigResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *ReadOnlySchedulerPopulateJobConfigResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerPopulateJobConfigResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *ReadOnlySchedulerPopulateJobConfigResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("populateJobConfig_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerPopulateJobConfigResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *ReadOnlySchedulerPopulateJobConfigResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerPopulateJobConfigResult(%+v)", *p) -} - -// Attributes: -// - JobUpdateQuery -type ReadOnlySchedulerGetJobUpdateSummariesArgs struct { - JobUpdateQuery *JobUpdateQuery `thrift:"jobUpdateQuery,1" json:"jobUpdateQuery"` -} - -func NewReadOnlySchedulerGetJobUpdateSummariesArgs() *ReadOnlySchedulerGetJobUpdateSummariesArgs { - return &ReadOnlySchedulerGetJobUpdateSummariesArgs{} -} - -var ReadOnlySchedulerGetJobUpdateSummariesArgs_JobUpdateQuery_DEFAULT *JobUpdateQuery - -func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) GetJobUpdateQuery() *JobUpdateQuery { - if !p.IsSetJobUpdateQuery() { - return ReadOnlySchedulerGetJobUpdateSummariesArgs_JobUpdateQuery_DEFAULT - } - return p.JobUpdateQuery -} -func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) IsSetJobUpdateQuery() bool { - return p.JobUpdateQuery != nil -} - -func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) readField1(iprot thrift.TProtocol) error { - p.JobUpdateQuery = &JobUpdateQuery{} - if err := p.JobUpdateQuery.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.JobUpdateQuery), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobUpdateSummaries_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("jobUpdateQuery", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:jobUpdateQuery: ", p), err) - } - if err := p.JobUpdateQuery.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.JobUpdateQuery), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:jobUpdateQuery: ", p), err) - } - return err -} - -func (p *ReadOnlySchedulerGetJobUpdateSummariesArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetJobUpdateSummariesArgs(%+v)", *p) -} - -// Attributes: -// - Success -type ReadOnlySchedulerGetJobUpdateSummariesResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewReadOnlySchedulerGetJobUpdateSummariesResult() *ReadOnlySchedulerGetJobUpdateSummariesResult { - return &ReadOnlySchedulerGetJobUpdateSummariesResult{} -} - -var ReadOnlySchedulerGetJobUpdateSummariesResult_Success_DEFAULT *Response - -func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return ReadOnlySchedulerGetJobUpdateSummariesResult_Success_DEFAULT - } - return p.Success -} -func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobUpdateSummaries_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *ReadOnlySchedulerGetJobUpdateSummariesResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetJobUpdateSummariesResult(%+v)", *p) -} - -// Attributes: -// - Query -type ReadOnlySchedulerGetJobUpdateDetailsArgs struct { - // unused field # 1 - Query *JobUpdateQuery `thrift:"query,2" json:"query"` -} - -func NewReadOnlySchedulerGetJobUpdateDetailsArgs() *ReadOnlySchedulerGetJobUpdateDetailsArgs { - return &ReadOnlySchedulerGetJobUpdateDetailsArgs{} -} - -var ReadOnlySchedulerGetJobUpdateDetailsArgs_Query_DEFAULT *JobUpdateQuery - -func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) GetQuery() *JobUpdateQuery { - if !p.IsSetQuery() { - return ReadOnlySchedulerGetJobUpdateDetailsArgs_Query_DEFAULT - } - return p.Query -} -func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) IsSetQuery() bool { - return p.Query != nil -} - -func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) readField2(iprot thrift.TProtocol) error { - p.Query = &JobUpdateQuery{} - if err := p.Query.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Query), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobUpdateDetails_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("query", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:query: ", p), err) - } - if err := p.Query.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Query), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:query: ", p), err) - } - return err -} - -func (p *ReadOnlySchedulerGetJobUpdateDetailsArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetJobUpdateDetailsArgs(%+v)", *p) -} - -// Attributes: -// - Success -type ReadOnlySchedulerGetJobUpdateDetailsResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewReadOnlySchedulerGetJobUpdateDetailsResult() *ReadOnlySchedulerGetJobUpdateDetailsResult { - return &ReadOnlySchedulerGetJobUpdateDetailsResult{} -} - -var ReadOnlySchedulerGetJobUpdateDetailsResult_Success_DEFAULT *Response - -func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return ReadOnlySchedulerGetJobUpdateDetailsResult_Success_DEFAULT - } - return p.Success -} -func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobUpdateDetails_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *ReadOnlySchedulerGetJobUpdateDetailsResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetJobUpdateDetailsResult(%+v)", *p) -} - -// Attributes: -// - Request -type ReadOnlySchedulerGetJobUpdateDiffArgs struct { - Request *JobUpdateRequest `thrift:"request,1" json:"request"` -} - -func NewReadOnlySchedulerGetJobUpdateDiffArgs() *ReadOnlySchedulerGetJobUpdateDiffArgs { - return &ReadOnlySchedulerGetJobUpdateDiffArgs{} -} - -var ReadOnlySchedulerGetJobUpdateDiffArgs_Request_DEFAULT *JobUpdateRequest - -func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) GetRequest() *JobUpdateRequest { - if !p.IsSetRequest() { - return ReadOnlySchedulerGetJobUpdateDiffArgs_Request_DEFAULT - } - return p.Request -} -func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) IsSetRequest() bool { - return p.Request != nil -} - -func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) readField1(iprot thrift.TProtocol) error { - p.Request = &JobUpdateRequest{} - if err := p.Request.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Request), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobUpdateDiff_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("request", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:request: ", p), err) - } - if err := p.Request.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Request), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:request: ", p), err) - } - return err -} - -func (p *ReadOnlySchedulerGetJobUpdateDiffArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetJobUpdateDiffArgs(%+v)", *p) -} - -// Attributes: -// - Success -type ReadOnlySchedulerGetJobUpdateDiffResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewReadOnlySchedulerGetJobUpdateDiffResult() *ReadOnlySchedulerGetJobUpdateDiffResult { - return &ReadOnlySchedulerGetJobUpdateDiffResult{} -} - -var ReadOnlySchedulerGetJobUpdateDiffResult_Success_DEFAULT *Response - -func (p *ReadOnlySchedulerGetJobUpdateDiffResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return ReadOnlySchedulerGetJobUpdateDiffResult_Success_DEFAULT - } - return p.Success -} -func (p *ReadOnlySchedulerGetJobUpdateDiffResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *ReadOnlySchedulerGetJobUpdateDiffResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateDiffResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateDiffResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getJobUpdateDiff_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetJobUpdateDiffResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *ReadOnlySchedulerGetJobUpdateDiffResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetJobUpdateDiffResult(%+v)", *p) -} - -type ReadOnlySchedulerGetTierConfigsArgs struct { -} - -func NewReadOnlySchedulerGetTierConfigsArgs() *ReadOnlySchedulerGetTierConfigsArgs { - return &ReadOnlySchedulerGetTierConfigsArgs{} -} - -func (p *ReadOnlySchedulerGetTierConfigsArgs) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetTierConfigsArgs) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getTierConfigs_args"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetTierConfigsArgs) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetTierConfigsArgs(%+v)", *p) -} - -// Attributes: -// - Success -type ReadOnlySchedulerGetTierConfigsResult struct { - Success *Response `thrift:"success,0" json:"success,omitempty"` -} - -func NewReadOnlySchedulerGetTierConfigsResult() *ReadOnlySchedulerGetTierConfigsResult { - return &ReadOnlySchedulerGetTierConfigsResult{} -} - -var ReadOnlySchedulerGetTierConfigsResult_Success_DEFAULT *Response - -func (p *ReadOnlySchedulerGetTierConfigsResult) GetSuccess() *Response { - if !p.IsSetSuccess() { - return ReadOnlySchedulerGetTierConfigsResult_Success_DEFAULT - } - return p.Success -} -func (p *ReadOnlySchedulerGetTierConfigsResult) IsSetSuccess() bool { - return p.Success != nil -} - -func (p *ReadOnlySchedulerGetTierConfigsResult) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 0: - if err := p.readField0(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetTierConfigsResult) readField0(iprot thrift.TProtocol) error { - p.Success = &Response{} - if err := p.Success.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Success), err) - } - return nil -} - -func (p *ReadOnlySchedulerGetTierConfigsResult) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("getTierConfigs_result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField0(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ReadOnlySchedulerGetTierConfigsResult) writeField0(oprot thrift.TProtocol) (err error) { - if p.IsSetSuccess() { - if err := oprot.WriteFieldBegin("success", thrift.STRUCT, 0); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 0:success: ", p), err) - } - if err := p.Success.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Success), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 0:success: ", p), err) - } - } - return err -} - -func (p *ReadOnlySchedulerGetTierConfigsResult) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ReadOnlySchedulerGetTierConfigsResult(%+v)", *p) -} diff --git a/gen-go/apache/aurora/ttypes.go b/gen-go/apache/aurora/ttypes.go deleted file mode 100644 index 564ecc1..0000000 --- a/gen-go/apache/aurora/ttypes.go +++ /dev/null @@ -1,15969 +0,0 @@ -// Autogenerated by Thrift Compiler (0.9.3) -// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING - -package aurora - -import ( - "bytes" - "fmt" - "git.apache.org/thrift.git/lib/go/thrift" -) - -// (needed to ensure safety because of naive import list construction.) -var _ = thrift.ZERO -var _ = fmt.Printf -var _ = bytes.Equal - -var GoUnusedProtection__ int - -type ResponseCode int64 - -const ( - ResponseCode_INVALID_REQUEST ResponseCode = 0 - ResponseCode_OK ResponseCode = 1 - ResponseCode_ERROR ResponseCode = 2 - ResponseCode_WARNING ResponseCode = 3 - ResponseCode_AUTH_FAILED ResponseCode = 4 - ResponseCode_LOCK_ERROR ResponseCode = 5 - ResponseCode_ERROR_TRANSIENT ResponseCode = 6 -) - -func (p ResponseCode) String() string { - switch p { - case ResponseCode_INVALID_REQUEST: - return "INVALID_REQUEST" - case ResponseCode_OK: - return "OK" - case ResponseCode_ERROR: - return "ERROR" - case ResponseCode_WARNING: - return "WARNING" - case ResponseCode_AUTH_FAILED: - return "AUTH_FAILED" - case ResponseCode_LOCK_ERROR: - return "LOCK_ERROR" - case ResponseCode_ERROR_TRANSIENT: - return "ERROR_TRANSIENT" - } - return "" -} - -func ResponseCodeFromString(s string) (ResponseCode, error) { - switch s { - case "INVALID_REQUEST": - return ResponseCode_INVALID_REQUEST, nil - case "OK": - return ResponseCode_OK, nil - case "ERROR": - return ResponseCode_ERROR, nil - case "WARNING": - return ResponseCode_WARNING, nil - case "AUTH_FAILED": - return ResponseCode_AUTH_FAILED, nil - case "LOCK_ERROR": - return ResponseCode_LOCK_ERROR, nil - case "ERROR_TRANSIENT": - return ResponseCode_ERROR_TRANSIENT, nil - } - return ResponseCode(0), fmt.Errorf("not a valid ResponseCode string") -} - -func ResponseCodePtr(v ResponseCode) *ResponseCode { return &v } - -func (p ResponseCode) MarshalText() ([]byte, error) { - return []byte(p.String()), nil -} - -func (p *ResponseCode) UnmarshalText(text []byte) error { - q, err := ResponseCodeFromString(string(text)) - if err != nil { - return err - } - *p = q - return nil -} - -type MaintenanceMode int64 - -const ( - MaintenanceMode_NONE MaintenanceMode = 1 - MaintenanceMode_SCHEDULED MaintenanceMode = 2 - MaintenanceMode_DRAINING MaintenanceMode = 3 - MaintenanceMode_DRAINED MaintenanceMode = 4 -) - -func (p MaintenanceMode) String() string { - switch p { - case MaintenanceMode_NONE: - return "NONE" - case MaintenanceMode_SCHEDULED: - return "SCHEDULED" - case MaintenanceMode_DRAINING: - return "DRAINING" - case MaintenanceMode_DRAINED: - return "DRAINED" - } - return "" -} - -func MaintenanceModeFromString(s string) (MaintenanceMode, error) { - switch s { - case "NONE": - return MaintenanceMode_NONE, nil - case "SCHEDULED": - return MaintenanceMode_SCHEDULED, nil - case "DRAINING": - return MaintenanceMode_DRAINING, nil - case "DRAINED": - return MaintenanceMode_DRAINED, nil - } - return MaintenanceMode(0), fmt.Errorf("not a valid MaintenanceMode string") -} - -func MaintenanceModePtr(v MaintenanceMode) *MaintenanceMode { return &v } - -func (p MaintenanceMode) MarshalText() ([]byte, error) { - return []byte(p.String()), nil -} - -func (p *MaintenanceMode) UnmarshalText(text []byte) error { - q, err := MaintenanceModeFromString(string(text)) - if err != nil { - return err - } - *p = q - return nil -} - -//The mode for a volume mount -type Mode int64 - -const ( - Mode_RW Mode = 1 - Mode_RO Mode = 2 -) - -func (p Mode) String() string { - switch p { - case Mode_RW: - return "RW" - case Mode_RO: - return "RO" - } - return "" -} - -func ModeFromString(s string) (Mode, error) { - switch s { - case "RW": - return Mode_RW, nil - case "RO": - return Mode_RO, nil - } - return Mode(0), fmt.Errorf("not a valid Mode string") -} - -func ModePtr(v Mode) *Mode { return &v } - -func (p Mode) MarshalText() ([]byte, error) { - return []byte(p.String()), nil -} - -func (p *Mode) UnmarshalText(text []byte) error { - q, err := ModeFromString(string(text)) - if err != nil { - return err - } - *p = q - return nil -} - -//Defines the policy for launching a new cron job when one is already running. -type CronCollisionPolicy int64 - -const ( - CronCollisionPolicy_KILL_EXISTING CronCollisionPolicy = 0 - CronCollisionPolicy_CANCEL_NEW CronCollisionPolicy = 1 - CronCollisionPolicy_RUN_OVERLAP CronCollisionPolicy = 2 -) - -func (p CronCollisionPolicy) String() string { - switch p { - case CronCollisionPolicy_KILL_EXISTING: - return "KILL_EXISTING" - case CronCollisionPolicy_CANCEL_NEW: - return "CANCEL_NEW" - case CronCollisionPolicy_RUN_OVERLAP: - return "RUN_OVERLAP" - } - return "" -} - -func CronCollisionPolicyFromString(s string) (CronCollisionPolicy, error) { - switch s { - case "KILL_EXISTING": - return CronCollisionPolicy_KILL_EXISTING, nil - case "CANCEL_NEW": - return CronCollisionPolicy_CANCEL_NEW, nil - case "RUN_OVERLAP": - return CronCollisionPolicy_RUN_OVERLAP, nil - } - return CronCollisionPolicy(0), fmt.Errorf("not a valid CronCollisionPolicy string") -} - -func CronCollisionPolicyPtr(v CronCollisionPolicy) *CronCollisionPolicy { return &v } - -func (p CronCollisionPolicy) MarshalText() ([]byte, error) { - return []byte(p.String()), nil -} - -func (p *CronCollisionPolicy) UnmarshalText(text []byte) error { - q, err := CronCollisionPolicyFromString(string(text)) - if err != nil { - return err - } - *p = q - return nil -} - -//States that a task may be in. -type ScheduleStatus int64 - -const ( - ScheduleStatus_INIT ScheduleStatus = 11 - ScheduleStatus_THROTTLED ScheduleStatus = 16 - ScheduleStatus_PENDING ScheduleStatus = 0 - ScheduleStatus_ASSIGNED ScheduleStatus = 9 - ScheduleStatus_STARTING ScheduleStatus = 1 - ScheduleStatus_RUNNING ScheduleStatus = 2 - ScheduleStatus_FINISHED ScheduleStatus = 3 - ScheduleStatus_PREEMPTING ScheduleStatus = 13 - ScheduleStatus_RESTARTING ScheduleStatus = 12 - ScheduleStatus_DRAINING ScheduleStatus = 17 - ScheduleStatus_FAILED ScheduleStatus = 4 - ScheduleStatus_KILLED ScheduleStatus = 5 - ScheduleStatus_KILLING ScheduleStatus = 6 - ScheduleStatus_LOST ScheduleStatus = 7 -) - -func (p ScheduleStatus) String() string { - switch p { - case ScheduleStatus_INIT: - return "INIT" - case ScheduleStatus_THROTTLED: - return "THROTTLED" - case ScheduleStatus_PENDING: - return "PENDING" - case ScheduleStatus_ASSIGNED: - return "ASSIGNED" - case ScheduleStatus_STARTING: - return "STARTING" - case ScheduleStatus_RUNNING: - return "RUNNING" - case ScheduleStatus_FINISHED: - return "FINISHED" - case ScheduleStatus_PREEMPTING: - return "PREEMPTING" - case ScheduleStatus_RESTARTING: - return "RESTARTING" - case ScheduleStatus_DRAINING: - return "DRAINING" - case ScheduleStatus_FAILED: - return "FAILED" - case ScheduleStatus_KILLED: - return "KILLED" - case ScheduleStatus_KILLING: - return "KILLING" - case ScheduleStatus_LOST: - return "LOST" - } - return "" -} - -func ScheduleStatusFromString(s string) (ScheduleStatus, error) { - switch s { - case "INIT": - return ScheduleStatus_INIT, nil - case "THROTTLED": - return ScheduleStatus_THROTTLED, nil - case "PENDING": - return ScheduleStatus_PENDING, nil - case "ASSIGNED": - return ScheduleStatus_ASSIGNED, nil - case "STARTING": - return ScheduleStatus_STARTING, nil - case "RUNNING": - return ScheduleStatus_RUNNING, nil - case "FINISHED": - return ScheduleStatus_FINISHED, nil - case "PREEMPTING": - return ScheduleStatus_PREEMPTING, nil - case "RESTARTING": - return ScheduleStatus_RESTARTING, nil - case "DRAINING": - return ScheduleStatus_DRAINING, nil - case "FAILED": - return ScheduleStatus_FAILED, nil - case "KILLED": - return ScheduleStatus_KILLED, nil - case "KILLING": - return ScheduleStatus_KILLING, nil - case "LOST": - return ScheduleStatus_LOST, nil - } - return ScheduleStatus(0), fmt.Errorf("not a valid ScheduleStatus string") -} - -func ScheduleStatusPtr(v ScheduleStatus) *ScheduleStatus { return &v } - -func (p ScheduleStatus) MarshalText() ([]byte, error) { - return []byte(p.String()), nil -} - -func (p *ScheduleStatus) UnmarshalText(text []byte) error { - q, err := ScheduleStatusFromString(string(text)) - if err != nil { - return err - } - *p = q - return nil -} - -//States that a job update may be in. -type JobUpdateStatus int64 - -const ( - JobUpdateStatus_ROLLING_FORWARD JobUpdateStatus = 0 - JobUpdateStatus_ROLLING_BACK JobUpdateStatus = 1 - JobUpdateStatus_ROLL_FORWARD_PAUSED JobUpdateStatus = 2 - JobUpdateStatus_ROLL_BACK_PAUSED JobUpdateStatus = 3 - JobUpdateStatus_ROLLED_FORWARD JobUpdateStatus = 4 - JobUpdateStatus_ROLLED_BACK JobUpdateStatus = 5 - JobUpdateStatus_ABORTED JobUpdateStatus = 6 - JobUpdateStatus_ERROR JobUpdateStatus = 7 - JobUpdateStatus_FAILED JobUpdateStatus = 8 - JobUpdateStatus_ROLL_FORWARD_AWAITING_PULSE JobUpdateStatus = 9 - JobUpdateStatus_ROLL_BACK_AWAITING_PULSE JobUpdateStatus = 10 -) - -func (p JobUpdateStatus) String() string { - switch p { - case JobUpdateStatus_ROLLING_FORWARD: - return "ROLLING_FORWARD" - case JobUpdateStatus_ROLLING_BACK: - return "ROLLING_BACK" - case JobUpdateStatus_ROLL_FORWARD_PAUSED: - return "ROLL_FORWARD_PAUSED" - case JobUpdateStatus_ROLL_BACK_PAUSED: - return "ROLL_BACK_PAUSED" - case JobUpdateStatus_ROLLED_FORWARD: - return "ROLLED_FORWARD" - case JobUpdateStatus_ROLLED_BACK: - return "ROLLED_BACK" - case JobUpdateStatus_ABORTED: - return "ABORTED" - case JobUpdateStatus_ERROR: - return "ERROR" - case JobUpdateStatus_FAILED: - return "FAILED" - case JobUpdateStatus_ROLL_FORWARD_AWAITING_PULSE: - return "ROLL_FORWARD_AWAITING_PULSE" - case JobUpdateStatus_ROLL_BACK_AWAITING_PULSE: - return "ROLL_BACK_AWAITING_PULSE" - } - return "" -} - -func JobUpdateStatusFromString(s string) (JobUpdateStatus, error) { - switch s { - case "ROLLING_FORWARD": - return JobUpdateStatus_ROLLING_FORWARD, nil - case "ROLLING_BACK": - return JobUpdateStatus_ROLLING_BACK, nil - case "ROLL_FORWARD_PAUSED": - return JobUpdateStatus_ROLL_FORWARD_PAUSED, nil - case "ROLL_BACK_PAUSED": - return JobUpdateStatus_ROLL_BACK_PAUSED, nil - case "ROLLED_FORWARD": - return JobUpdateStatus_ROLLED_FORWARD, nil - case "ROLLED_BACK": - return JobUpdateStatus_ROLLED_BACK, nil - case "ABORTED": - return JobUpdateStatus_ABORTED, nil - case "ERROR": - return JobUpdateStatus_ERROR, nil - case "FAILED": - return JobUpdateStatus_FAILED, nil - case "ROLL_FORWARD_AWAITING_PULSE": - return JobUpdateStatus_ROLL_FORWARD_AWAITING_PULSE, nil - case "ROLL_BACK_AWAITING_PULSE": - return JobUpdateStatus_ROLL_BACK_AWAITING_PULSE, nil - } - return JobUpdateStatus(0), fmt.Errorf("not a valid JobUpdateStatus string") -} - -func JobUpdateStatusPtr(v JobUpdateStatus) *JobUpdateStatus { return &v } - -func (p JobUpdateStatus) MarshalText() ([]byte, error) { - return []byte(p.String()), nil -} - -func (p *JobUpdateStatus) UnmarshalText(text []byte) error { - q, err := JobUpdateStatusFromString(string(text)) - if err != nil { - return err - } - *p = q - return nil -} - -//Job update actions that can be applied to job instances. -type JobUpdateAction int64 - -const ( - JobUpdateAction_INSTANCE_UPDATED JobUpdateAction = 1 - JobUpdateAction_INSTANCE_ROLLED_BACK JobUpdateAction = 2 - JobUpdateAction_INSTANCE_UPDATING JobUpdateAction = 3 - JobUpdateAction_INSTANCE_ROLLING_BACK JobUpdateAction = 4 - JobUpdateAction_INSTANCE_UPDATE_FAILED JobUpdateAction = 5 - JobUpdateAction_INSTANCE_ROLLBACK_FAILED JobUpdateAction = 6 -) - -func (p JobUpdateAction) String() string { - switch p { - case JobUpdateAction_INSTANCE_UPDATED: - return "INSTANCE_UPDATED" - case JobUpdateAction_INSTANCE_ROLLED_BACK: - return "INSTANCE_ROLLED_BACK" - case JobUpdateAction_INSTANCE_UPDATING: - return "INSTANCE_UPDATING" - case JobUpdateAction_INSTANCE_ROLLING_BACK: - return "INSTANCE_ROLLING_BACK" - case JobUpdateAction_INSTANCE_UPDATE_FAILED: - return "INSTANCE_UPDATE_FAILED" - case JobUpdateAction_INSTANCE_ROLLBACK_FAILED: - return "INSTANCE_ROLLBACK_FAILED" - } - return "" -} - -func JobUpdateActionFromString(s string) (JobUpdateAction, error) { - switch s { - case "INSTANCE_UPDATED": - return JobUpdateAction_INSTANCE_UPDATED, nil - case "INSTANCE_ROLLED_BACK": - return JobUpdateAction_INSTANCE_ROLLED_BACK, nil - case "INSTANCE_UPDATING": - return JobUpdateAction_INSTANCE_UPDATING, nil - case "INSTANCE_ROLLING_BACK": - return JobUpdateAction_INSTANCE_ROLLING_BACK, nil - case "INSTANCE_UPDATE_FAILED": - return JobUpdateAction_INSTANCE_UPDATE_FAILED, nil - case "INSTANCE_ROLLBACK_FAILED": - return JobUpdateAction_INSTANCE_ROLLBACK_FAILED, nil - } - return JobUpdateAction(0), fmt.Errorf("not a valid JobUpdateAction string") -} - -func JobUpdateActionPtr(v JobUpdateAction) *JobUpdateAction { return &v } - -func (p JobUpdateAction) MarshalText() ([]byte, error) { - return []byte(p.String()), nil -} - -func (p *JobUpdateAction) UnmarshalText(text []byte) error { - q, err := JobUpdateActionFromString(string(text)) - if err != nil { - return err - } - *p = q - return nil -} - -//Status of the coordinated update. Intended as a response to pulseJobUpdate RPC. -type JobUpdatePulseStatus int64 - -const ( - JobUpdatePulseStatus_OK JobUpdatePulseStatus = 1 - JobUpdatePulseStatus_FINISHED JobUpdatePulseStatus = 2 -) - -func (p JobUpdatePulseStatus) String() string { - switch p { - case JobUpdatePulseStatus_OK: - return "OK" - case JobUpdatePulseStatus_FINISHED: - return "FINISHED" - } - return "" -} - -func JobUpdatePulseStatusFromString(s string) (JobUpdatePulseStatus, error) { - switch s { - case "OK": - return JobUpdatePulseStatus_OK, nil - case "FINISHED": - return JobUpdatePulseStatus_FINISHED, nil - } - return JobUpdatePulseStatus(0), fmt.Errorf("not a valid JobUpdatePulseStatus string") -} - -func JobUpdatePulseStatusPtr(v JobUpdatePulseStatus) *JobUpdatePulseStatus { return &v } - -func (p JobUpdatePulseStatus) MarshalText() ([]byte, error) { - return []byte(p.String()), nil -} - -func (p *JobUpdatePulseStatus) UnmarshalText(text []byte) error { - q, err := JobUpdatePulseStatusFromString(string(text)) - if err != nil { - return err - } - *p = q - return nil -} - -// Attributes: -// - User -type Identity struct { - // unused field # 1 - User string `thrift:"user,2" json:"user"` -} - -func NewIdentity() *Identity { - return &Identity{} -} - -func (p *Identity) GetUser() string { - return p.User -} -func (p *Identity) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Identity) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.User = v - } - return nil -} - -func (p *Identity) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Identity"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *Identity) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("user", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:user: ", p), err) - } - if err := oprot.WriteString(string(p.User)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.user (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:user: ", p), err) - } - return err -} - -func (p *Identity) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Identity(%+v)", *p) -} - -// A single host attribute. -// -// Attributes: -// - Name -// - Values -type Attribute struct { - Name string `thrift:"name,1" json:"name"` - Values map[string]bool `thrift:"values,2" json:"values"` -} - -func NewAttribute() *Attribute { - return &Attribute{} -} - -func (p *Attribute) GetName() string { - return p.Name -} - -func (p *Attribute) GetValues() map[string]bool { - return p.Values -} -func (p *Attribute) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Attribute) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Attribute) readField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[string]bool, size) - p.Values = tSet - for i := 0; i < size; i++ { - var _elem0 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem0 = v - } - p.Values[_elem0] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *Attribute) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Attribute"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *Attribute) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) - } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) - } - return err -} - -func (p *Attribute) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("values", thrift.SET, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:values: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.Values)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Values { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:values: ", p), err) - } - return err -} - -func (p *Attribute) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Attribute(%+v)", *p) -} - -// The attributes assigned to a host. -// -// Attributes: -// - Host -// - Attributes -// - Mode -// - SlaveId -type HostAttributes struct { - Host string `thrift:"host,1" json:"host"` - Attributes map[*Attribute]bool `thrift:"attributes,2" json:"attributes"` - Mode *MaintenanceMode `thrift:"mode,3" json:"mode,omitempty"` - SlaveId *string `thrift:"slaveId,4" json:"slaveId,omitempty"` -} - -func NewHostAttributes() *HostAttributes { - return &HostAttributes{} -} - -func (p *HostAttributes) GetHost() string { - return p.Host -} - -func (p *HostAttributes) GetAttributes() map[*Attribute]bool { - return p.Attributes -} - -var HostAttributes_Mode_DEFAULT MaintenanceMode - -func (p *HostAttributes) GetMode() MaintenanceMode { - if !p.IsSetMode() { - return HostAttributes_Mode_DEFAULT - } - return *p.Mode -} - -var HostAttributes_SlaveId_DEFAULT string - -func (p *HostAttributes) GetSlaveId() string { - if !p.IsSetSlaveId() { - return HostAttributes_SlaveId_DEFAULT - } - return *p.SlaveId -} -func (p *HostAttributes) IsSetMode() bool { - return p.Mode != nil -} - -func (p *HostAttributes) IsSetSlaveId() bool { - return p.SlaveId != nil -} - -func (p *HostAttributes) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *HostAttributes) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Host = v - } - return nil -} - -func (p *HostAttributes) readField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*Attribute]bool, size) - p.Attributes = tSet - for i := 0; i < size; i++ { - _elem1 := &Attribute{} - if err := _elem1.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem1), err) - } - p.Attributes[_elem1] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *HostAttributes) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - temp := MaintenanceMode(v) - p.Mode = &temp - } - return nil -} - -func (p *HostAttributes) readField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.SlaveId = &v - } - return nil -} - -func (p *HostAttributes) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("HostAttributes"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *HostAttributes) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("host", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:host: ", p), err) - } - if err := oprot.WriteString(string(p.Host)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.host (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:host: ", p), err) - } - return err -} - -func (p *HostAttributes) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("attributes", thrift.SET, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:attributes: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Attributes)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Attributes { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:attributes: ", p), err) - } - return err -} - -func (p *HostAttributes) writeField3(oprot thrift.TProtocol) (err error) { - if p.IsSetMode() { - if err := oprot.WriteFieldBegin("mode", thrift.I32, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:mode: ", p), err) - } - if err := oprot.WriteI32(int32(*p.Mode)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.mode (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:mode: ", p), err) - } - } - return err -} - -func (p *HostAttributes) writeField4(oprot thrift.TProtocol) (err error) { - if p.IsSetSlaveId() { - if err := oprot.WriteFieldBegin("slaveId", thrift.STRING, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:slaveId: ", p), err) - } - if err := oprot.WriteString(string(*p.SlaveId)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.slaveId (4) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:slaveId: ", p), err) - } - } - return err -} - -func (p *HostAttributes) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("HostAttributes(%+v)", *p) -} - -// A constraint that specifies an explicit set of values, at least one of which must be present -// on a host for a task to be scheduled there. -// -// Attributes: -// - Negated: If true, treat this as a 'not' - to avoid specific values. -// - Values -type ValueConstraint struct { - Negated bool `thrift:"negated,1" json:"negated"` - Values map[string]bool `thrift:"values,2" json:"values"` -} - -func NewValueConstraint() *ValueConstraint { - return &ValueConstraint{} -} - -func (p *ValueConstraint) GetNegated() bool { - return p.Negated -} - -func (p *ValueConstraint) GetValues() map[string]bool { - return p.Values -} -func (p *ValueConstraint) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ValueConstraint) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Negated = v - } - return nil -} - -func (p *ValueConstraint) readField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[string]bool, size) - p.Values = tSet - for i := 0; i < size; i++ { - var _elem2 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem2 = v - } - p.Values[_elem2] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *ValueConstraint) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ValueConstraint"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ValueConstraint) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("negated", thrift.BOOL, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:negated: ", p), err) - } - if err := oprot.WriteBool(bool(p.Negated)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.negated (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:negated: ", p), err) - } - return err -} - -func (p *ValueConstraint) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("values", thrift.SET, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:values: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.Values)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Values { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:values: ", p), err) - } - return err -} - -func (p *ValueConstraint) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ValueConstraint(%+v)", *p) -} - -// A constraint the specifies the maximum number of active tasks on a host with a matching -// attribute that may be scheduled simultaneously. -// -// Attributes: -// - Limit -type LimitConstraint struct { - Limit int32 `thrift:"limit,1" json:"limit"` -} - -func NewLimitConstraint() *LimitConstraint { - return &LimitConstraint{} -} - -func (p *LimitConstraint) GetLimit() int32 { - return p.Limit -} -func (p *LimitConstraint) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *LimitConstraint) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Limit = v - } - return nil -} - -func (p *LimitConstraint) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("LimitConstraint"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *LimitConstraint) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("limit", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:limit: ", p), err) - } - if err := oprot.WriteI32(int32(p.Limit)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.limit (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:limit: ", p), err) - } - return err -} - -func (p *LimitConstraint) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("LimitConstraint(%+v)", *p) -} - -// Types of constraints that may be applied to a task. -// -// Attributes: -// - Value -// - Limit -type TaskConstraint struct { - Value *ValueConstraint `thrift:"value,1" json:"value,omitempty"` - Limit *LimitConstraint `thrift:"limit,2" json:"limit,omitempty"` -} - -func NewTaskConstraint() *TaskConstraint { - return &TaskConstraint{} -} - -var TaskConstraint_Value_DEFAULT *ValueConstraint - -func (p *TaskConstraint) GetValue() *ValueConstraint { - if !p.IsSetValue() { - return TaskConstraint_Value_DEFAULT - } - return p.Value -} - -var TaskConstraint_Limit_DEFAULT *LimitConstraint - -func (p *TaskConstraint) GetLimit() *LimitConstraint { - if !p.IsSetLimit() { - return TaskConstraint_Limit_DEFAULT - } - return p.Limit -} -func (p *TaskConstraint) CountSetFieldsTaskConstraint() int { - count := 0 - if p.IsSetValue() { - count++ - } - if p.IsSetLimit() { - count++ - } - return count - -} - -func (p *TaskConstraint) IsSetValue() bool { - return p.Value != nil -} - -func (p *TaskConstraint) IsSetLimit() bool { - return p.Limit != nil -} - -func (p *TaskConstraint) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TaskConstraint) readField1(iprot thrift.TProtocol) error { - p.Value = &ValueConstraint{} - if err := p.Value.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Value), err) - } - return nil -} - -func (p *TaskConstraint) readField2(iprot thrift.TProtocol) error { - p.Limit = &LimitConstraint{} - if err := p.Limit.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Limit), err) - } - return nil -} - -func (p *TaskConstraint) Write(oprot thrift.TProtocol) error { - if c := p.CountSetFieldsTaskConstraint(); c != 1 { - return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("TaskConstraint"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *TaskConstraint) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetValue() { - if err := oprot.WriteFieldBegin("value", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) - } - if err := p.Value.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Value), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) - } - } - return err -} - -func (p *TaskConstraint) writeField2(oprot thrift.TProtocol) (err error) { - if p.IsSetLimit() { - if err := oprot.WriteFieldBegin("limit", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:limit: ", p), err) - } - if err := p.Limit.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Limit), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:limit: ", p), err) - } - } - return err -} - -func (p *TaskConstraint) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("TaskConstraint(%+v)", *p) -} - -// A constraint that defines whether a task may be scheduled on a host. -// -// Attributes: -// - Name: Mesos slave attribute that the constraint is matched against. -// - Constraint -type Constraint struct { - Name string `thrift:"name,1" json:"name"` - Constraint *TaskConstraint `thrift:"constraint,2" json:"constraint"` -} - -func NewConstraint() *Constraint { - return &Constraint{} -} - -func (p *Constraint) GetName() string { - return p.Name -} - -var Constraint_Constraint_DEFAULT *TaskConstraint - -func (p *Constraint) GetConstraint() *TaskConstraint { - if !p.IsSetConstraint() { - return Constraint_Constraint_DEFAULT - } - return p.Constraint -} -func (p *Constraint) IsSetConstraint() bool { - return p.Constraint != nil -} - -func (p *Constraint) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Constraint) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Constraint) readField2(iprot thrift.TProtocol) error { - p.Constraint = &TaskConstraint{} - if err := p.Constraint.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Constraint), err) - } - return nil -} - -func (p *Constraint) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Constraint"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *Constraint) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) - } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) - } - return err -} - -func (p *Constraint) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("constraint", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:constraint: ", p), err) - } - if err := p.Constraint.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Constraint), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:constraint: ", p), err) - } - return err -} - -func (p *Constraint) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Constraint(%+v)", *p) -} - -// Attributes: -// - Role -// - Name -// - Version -type Package struct { - Role string `thrift:"role,1" json:"role"` - Name string `thrift:"name,2" json:"name"` - Version int32 `thrift:"version,3" json:"version"` -} - -func NewPackage() *Package { - return &Package{} -} - -func (p *Package) GetRole() string { - return p.Role -} - -func (p *Package) GetName() string { - return p.Name -} - -func (p *Package) GetVersion() int32 { - return p.Version -} -func (p *Package) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Package) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Role = v - } - return nil -} - -func (p *Package) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *Package) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.Version = v - } - return nil -} - -func (p *Package) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Package"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *Package) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("role", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:role: ", p), err) - } - if err := oprot.WriteString(string(p.Role)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.role (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:role: ", p), err) - } - return err -} - -func (p *Package) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:name: ", p), err) - } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:name: ", p), err) - } - return err -} - -func (p *Package) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("version", thrift.I32, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:version: ", p), err) - } - if err := oprot.WriteI32(int32(p.Version)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.version (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:version: ", p), err) - } - return err -} - -func (p *Package) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Package(%+v)", *p) -} - -// Arbitrary key-value metadata to be included into TaskConfig. -// -// Attributes: -// - Key -// - Value -type Metadata struct { - Key string `thrift:"key,1" json:"key"` - Value string `thrift:"value,2" json:"value"` -} - -func NewMetadata() *Metadata { - return &Metadata{} -} - -func (p *Metadata) GetKey() string { - return p.Key -} - -func (p *Metadata) GetValue() string { - return p.Value -} -func (p *Metadata) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Metadata) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Key = v - } - return nil -} - -func (p *Metadata) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *Metadata) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Metadata"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *Metadata) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) - } - if err := oprot.WriteString(string(p.Key)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.key (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) - } - return err -} - -func (p *Metadata) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:value: ", p), err) - } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:value: ", p), err) - } - return err -} - -func (p *Metadata) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Metadata(%+v)", *p) -} - -// A unique identifier for a Job. -// -// Attributes: -// - Role: User role (Unix service account), for example "mesos" -// - Environment: Environment, for example "devel" -// - Name: Name, for example "labrat" -type JobKey struct { - Role string `thrift:"role,1" json:"role"` - Environment string `thrift:"environment,2" json:"environment"` - Name string `thrift:"name,3" json:"name"` -} - -func NewJobKey() *JobKey { - return &JobKey{} -} - -func (p *JobKey) GetRole() string { - return p.Role -} - -func (p *JobKey) GetEnvironment() string { - return p.Environment -} - -func (p *JobKey) GetName() string { - return p.Name -} -func (p *JobKey) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *JobKey) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Role = v - } - return nil -} - -func (p *JobKey) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Environment = v - } - return nil -} - -func (p *JobKey) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *JobKey) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobKey"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *JobKey) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("role", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:role: ", p), err) - } - if err := oprot.WriteString(string(p.Role)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.role (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:role: ", p), err) - } - return err -} - -func (p *JobKey) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("environment", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:environment: ", p), err) - } - if err := oprot.WriteString(string(p.Environment)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.environment (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:environment: ", p), err) - } - return err -} - -func (p *JobKey) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:name: ", p), err) - } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:name: ", p), err) - } - return err -} - -func (p *JobKey) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JobKey(%+v)", *p) -} - -// A unique lock key. -// -// Attributes: -// - Job -type LockKey struct { - Job *JobKey `thrift:"job,1" json:"job,omitempty"` -} - -func NewLockKey() *LockKey { - return &LockKey{} -} - -var LockKey_Job_DEFAULT *JobKey - -func (p *LockKey) GetJob() *JobKey { - if !p.IsSetJob() { - return LockKey_Job_DEFAULT - } - return p.Job -} -func (p *LockKey) CountSetFieldsLockKey() int { - count := 0 - if p.IsSetJob() { - count++ - } - return count - -} - -func (p *LockKey) IsSetJob() bool { - return p.Job != nil -} - -func (p *LockKey) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *LockKey) readField1(iprot thrift.TProtocol) error { - p.Job = &JobKey{} - if err := p.Job.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) - } - return nil -} - -func (p *LockKey) Write(oprot thrift.TProtocol) error { - if c := p.CountSetFieldsLockKey(); c != 1 { - return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("LockKey"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *LockKey) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetJob() { - if err := oprot.WriteFieldBegin("job", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:job: ", p), err) - } - if err := p.Job.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:job: ", p), err) - } - } - return err -} - -func (p *LockKey) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("LockKey(%+v)", *p) -} - -// A generic lock struct to facilitate context specific resource/operation serialization. -// -// Attributes: -// - Key: ID of the lock - unique per storage -// - Token: UUID - facilitating soft lock authorization -// - User: Lock creator -// - TimestampMs: Lock creation timestamp in milliseconds -// - Message: Optional message to record with the lock -type Lock struct { - Key *LockKey `thrift:"key,1" json:"key"` - Token string `thrift:"token,2" json:"token"` - User string `thrift:"user,3" json:"user"` - TimestampMs int64 `thrift:"timestampMs,4" json:"timestampMs"` - Message *string `thrift:"message,5" json:"message,omitempty"` -} - -func NewLock() *Lock { - return &Lock{} -} - -var Lock_Key_DEFAULT *LockKey - -func (p *Lock) GetKey() *LockKey { - if !p.IsSetKey() { - return Lock_Key_DEFAULT - } - return p.Key -} - -func (p *Lock) GetToken() string { - return p.Token -} - -func (p *Lock) GetUser() string { - return p.User -} - -func (p *Lock) GetTimestampMs() int64 { - return p.TimestampMs -} - -var Lock_Message_DEFAULT string - -func (p *Lock) GetMessage() string { - if !p.IsSetMessage() { - return Lock_Message_DEFAULT - } - return *p.Message -} -func (p *Lock) IsSetKey() bool { - return p.Key != nil -} - -func (p *Lock) IsSetMessage() bool { - return p.Message != nil -} - -func (p *Lock) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - case 5: - if err := p.readField5(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Lock) readField1(iprot thrift.TProtocol) error { - p.Key = &LockKey{} - if err := p.Key.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) - } - return nil -} - -func (p *Lock) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Token = v - } - return nil -} - -func (p *Lock) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.User = v - } - return nil -} - -func (p *Lock) readField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.TimestampMs = v - } - return nil -} - -func (p *Lock) readField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.Message = &v - } - return nil -} - -func (p *Lock) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Lock"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := p.writeField5(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *Lock) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) - } - if err := p.Key.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) - } - return err -} - -func (p *Lock) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("token", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:token: ", p), err) - } - if err := oprot.WriteString(string(p.Token)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.token (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:token: ", p), err) - } - return err -} - -func (p *Lock) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("user", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:user: ", p), err) - } - if err := oprot.WriteString(string(p.User)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.user (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:user: ", p), err) - } - return err -} - -func (p *Lock) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("timestampMs", thrift.I64, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:timestampMs: ", p), err) - } - if err := oprot.WriteI64(int64(p.TimestampMs)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.timestampMs (4) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:timestampMs: ", p), err) - } - return err -} - -func (p *Lock) writeField5(oprot thrift.TProtocol) (err error) { - if p.IsSetMessage() { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:message: ", p), err) - } - if err := oprot.WriteString(string(*p.Message)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.message (5) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:message: ", p), err) - } - } - return err -} - -func (p *Lock) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Lock(%+v)", *p) -} - -// A unique identifier for the active task within a job. -// -// Attributes: -// - JobKey: Key identifying the job. -// - InstanceId: Unique instance ID for the active task in a job. -type InstanceKey struct { - JobKey *JobKey `thrift:"jobKey,1" json:"jobKey"` - InstanceId int32 `thrift:"instanceId,2" json:"instanceId"` -} - -func NewInstanceKey() *InstanceKey { - return &InstanceKey{} -} - -var InstanceKey_JobKey_DEFAULT *JobKey - -func (p *InstanceKey) GetJobKey() *JobKey { - if !p.IsSetJobKey() { - return InstanceKey_JobKey_DEFAULT - } - return p.JobKey -} - -func (p *InstanceKey) GetInstanceId() int32 { - return p.InstanceId -} -func (p *InstanceKey) IsSetJobKey() bool { - return p.JobKey != nil -} - -func (p *InstanceKey) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *InstanceKey) readField1(iprot thrift.TProtocol) error { - p.JobKey = &JobKey{} - if err := p.JobKey.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.JobKey), err) - } - return nil -} - -func (p *InstanceKey) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.InstanceId = v - } - return nil -} - -func (p *InstanceKey) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("InstanceKey"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *InstanceKey) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("jobKey", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:jobKey: ", p), err) - } - if err := p.JobKey.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.JobKey), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:jobKey: ", p), err) - } - return err -} - -func (p *InstanceKey) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instanceId", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:instanceId: ", p), err) - } - if err := oprot.WriteI32(int32(p.InstanceId)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.instanceId (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:instanceId: ", p), err) - } - return err -} - -func (p *InstanceKey) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("InstanceKey(%+v)", *p) -} - -// URI which mirrors CommandInfo.URI in the Mesos Protobuf -// -// Attributes: -// - Value: Where to get the resource from -// - Extract: Extract compressed archive after downloading -// - Cache: Cache value using Mesos Fetcher caching mechanism * -type MesosFetcherURI struct { - Value string `thrift:"value,1" json:"value"` - Extract *bool `thrift:"extract,2" json:"extract,omitempty"` - Cache *bool `thrift:"cache,3" json:"cache,omitempty"` -} - -func NewMesosFetcherURI() *MesosFetcherURI { - return &MesosFetcherURI{} -} - -func (p *MesosFetcherURI) GetValue() string { - return p.Value -} - -var MesosFetcherURI_Extract_DEFAULT bool - -func (p *MesosFetcherURI) GetExtract() bool { - if !p.IsSetExtract() { - return MesosFetcherURI_Extract_DEFAULT - } - return *p.Extract -} - -var MesosFetcherURI_Cache_DEFAULT bool - -func (p *MesosFetcherURI) GetCache() bool { - if !p.IsSetCache() { - return MesosFetcherURI_Cache_DEFAULT - } - return *p.Cache -} -func (p *MesosFetcherURI) IsSetExtract() bool { - return p.Extract != nil -} - -func (p *MesosFetcherURI) IsSetCache() bool { - return p.Cache != nil -} - -func (p *MesosFetcherURI) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MesosFetcherURI) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *MesosFetcherURI) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Extract = &v - } - return nil -} - -func (p *MesosFetcherURI) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.Cache = &v - } - return nil -} - -func (p *MesosFetcherURI) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("MesosFetcherURI"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *MesosFetcherURI) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:value: ", p), err) - } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:value: ", p), err) - } - return err -} - -func (p *MesosFetcherURI) writeField2(oprot thrift.TProtocol) (err error) { - if p.IsSetExtract() { - if err := oprot.WriteFieldBegin("extract", thrift.BOOL, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:extract: ", p), err) - } - if err := oprot.WriteBool(bool(*p.Extract)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.extract (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:extract: ", p), err) - } - } - return err -} - -func (p *MesosFetcherURI) writeField3(oprot thrift.TProtocol) (err error) { - if p.IsSetCache() { - if err := oprot.WriteFieldBegin("cache", thrift.BOOL, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:cache: ", p), err) - } - if err := oprot.WriteBool(bool(*p.Cache)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.cache (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:cache: ", p), err) - } - } - return err -} - -func (p *MesosFetcherURI) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("MesosFetcherURI(%+v)", *p) -} - -// Attributes: -// - Name: Name identifying the Executor. -// - Data: Executor configuration data. -type ExecutorConfig struct { - Name string `thrift:"name,1" json:"name"` - Data string `thrift:"data,2" json:"data"` -} - -func NewExecutorConfig() *ExecutorConfig { - return &ExecutorConfig{} -} - -func (p *ExecutorConfig) GetName() string { - return p.Name -} - -func (p *ExecutorConfig) GetData() string { - return p.Data -} -func (p *ExecutorConfig) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ExecutorConfig) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *ExecutorConfig) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Data = v - } - return nil -} - -func (p *ExecutorConfig) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ExecutorConfig"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ExecutorConfig) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) - } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) - } - return err -} - -func (p *ExecutorConfig) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("data", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:data: ", p), err) - } - if err := oprot.WriteString(string(p.Data)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.data (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:data: ", p), err) - } - return err -} - -func (p *ExecutorConfig) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExecutorConfig(%+v)", *p) -} - -// A volume mount point within a container -// -// Attributes: -// - ContainerPath: The path inside the container where the mount will be created. -// - HostPath: The path on the host that will serve as the source for the mount. -// - Mode: The access mode -type Volume struct { - ContainerPath string `thrift:"containerPath,1" json:"containerPath"` - HostPath string `thrift:"hostPath,2" json:"hostPath"` - Mode Mode `thrift:"mode,3" json:"mode"` -} - -func NewVolume() *Volume { - return &Volume{} -} - -func (p *Volume) GetContainerPath() string { - return p.ContainerPath -} - -func (p *Volume) GetHostPath() string { - return p.HostPath -} - -func (p *Volume) GetMode() Mode { - return p.Mode -} -func (p *Volume) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Volume) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.ContainerPath = v - } - return nil -} - -func (p *Volume) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.HostPath = v - } - return nil -} - -func (p *Volume) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - temp := Mode(v) - p.Mode = temp - } - return nil -} - -func (p *Volume) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Volume"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *Volume) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("containerPath", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:containerPath: ", p), err) - } - if err := oprot.WriteString(string(p.ContainerPath)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.containerPath (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:containerPath: ", p), err) - } - return err -} - -func (p *Volume) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("hostPath", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:hostPath: ", p), err) - } - if err := oprot.WriteString(string(p.HostPath)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.hostPath (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:hostPath: ", p), err) - } - return err -} - -func (p *Volume) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("mode", thrift.I32, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:mode: ", p), err) - } - if err := oprot.WriteI32(int32(p.Mode)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.mode (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:mode: ", p), err) - } - return err -} - -func (p *Volume) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Volume(%+v)", *p) -} - -// Describes an image for use with the Mesos unified containerizer in the Docker format -// -// Attributes: -// - Name: The name of the image to run -// - Tag: The Docker tag identifying the image -type DockerImage struct { - Name string `thrift:"name,1" json:"name"` - Tag string `thrift:"tag,2" json:"tag"` -} - -func NewDockerImage() *DockerImage { - return &DockerImage{} -} - -func (p *DockerImage) GetName() string { - return p.Name -} - -func (p *DockerImage) GetTag() string { - return p.Tag -} -func (p *DockerImage) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DockerImage) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *DockerImage) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Tag = v - } - return nil -} - -func (p *DockerImage) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("DockerImage"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *DockerImage) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) - } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) - } - return err -} - -func (p *DockerImage) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("tag", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:tag: ", p), err) - } - if err := oprot.WriteString(string(p.Tag)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.tag (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:tag: ", p), err) - } - return err -} - -func (p *DockerImage) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("DockerImage(%+v)", *p) -} - -// Describes an image for use with the Mesos unified containerizer in the AppC format -// -// Attributes: -// - Name: The name of the image to run -// - ImageId: The appc image id identifying the image -type AppcImage struct { - Name string `thrift:"name,1" json:"name"` - ImageId string `thrift:"imageId,2" json:"imageId"` -} - -func NewAppcImage() *AppcImage { - return &AppcImage{} -} - -func (p *AppcImage) GetName() string { - return p.Name -} - -func (p *AppcImage) GetImageId() string { - return p.ImageId -} -func (p *AppcImage) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AppcImage) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *AppcImage) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.ImageId = v - } - return nil -} - -func (p *AppcImage) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("AppcImage"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AppcImage) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) - } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) - } - return err -} - -func (p *AppcImage) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("imageId", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:imageId: ", p), err) - } - if err := oprot.WriteString(string(p.ImageId)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.imageId (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:imageId: ", p), err) - } - return err -} - -func (p *AppcImage) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AppcImage(%+v)", *p) -} - -// Describes an image to be used with the Mesos unified containerizer -// -// Attributes: -// - Docker -// - Appc -type Image struct { - Docker *DockerImage `thrift:"docker,1" json:"docker,omitempty"` - Appc *AppcImage `thrift:"appc,2" json:"appc,omitempty"` -} - -func NewImage() *Image { - return &Image{} -} - -var Image_Docker_DEFAULT *DockerImage - -func (p *Image) GetDocker() *DockerImage { - if !p.IsSetDocker() { - return Image_Docker_DEFAULT - } - return p.Docker -} - -var Image_Appc_DEFAULT *AppcImage - -func (p *Image) GetAppc() *AppcImage { - if !p.IsSetAppc() { - return Image_Appc_DEFAULT - } - return p.Appc -} -func (p *Image) CountSetFieldsImage() int { - count := 0 - if p.IsSetDocker() { - count++ - } - if p.IsSetAppc() { - count++ - } - return count - -} - -func (p *Image) IsSetDocker() bool { - return p.Docker != nil -} - -func (p *Image) IsSetAppc() bool { - return p.Appc != nil -} - -func (p *Image) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Image) readField1(iprot thrift.TProtocol) error { - p.Docker = &DockerImage{} - if err := p.Docker.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Docker), err) - } - return nil -} - -func (p *Image) readField2(iprot thrift.TProtocol) error { - p.Appc = &AppcImage{} - if err := p.Appc.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Appc), err) - } - return nil -} - -func (p *Image) Write(oprot thrift.TProtocol) error { - if c := p.CountSetFieldsImage(); c != 1 { - return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("Image"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *Image) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetDocker() { - if err := oprot.WriteFieldBegin("docker", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:docker: ", p), err) - } - if err := p.Docker.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Docker), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:docker: ", p), err) - } - } - return err -} - -func (p *Image) writeField2(oprot thrift.TProtocol) (err error) { - if p.IsSetAppc() { - if err := oprot.WriteFieldBegin("appc", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:appc: ", p), err) - } - if err := p.Appc.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Appc), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:appc: ", p), err) - } - } - return err -} - -func (p *Image) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Image(%+v)", *p) -} - -// Describes a mesos container, this is the default -// -// Attributes: -// - Image: the optional filesystem image to use when launching this task. -type MesosContainer struct { - Image *Image `thrift:"image,1" json:"image,omitempty"` -} - -func NewMesosContainer() *MesosContainer { - return &MesosContainer{} -} - -var MesosContainer_Image_DEFAULT *Image - -func (p *MesosContainer) GetImage() *Image { - if !p.IsSetImage() { - return MesosContainer_Image_DEFAULT - } - return p.Image -} -func (p *MesosContainer) IsSetImage() bool { - return p.Image != nil -} - -func (p *MesosContainer) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MesosContainer) readField1(iprot thrift.TProtocol) error { - p.Image = &Image{} - if err := p.Image.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Image), err) - } - return nil -} - -func (p *MesosContainer) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("MesosContainer"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *MesosContainer) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetImage() { - if err := oprot.WriteFieldBegin("image", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:image: ", p), err) - } - if err := p.Image.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Image), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:image: ", p), err) - } - } - return err -} - -func (p *MesosContainer) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("MesosContainer(%+v)", *p) -} - -// Describes a parameter passed to docker cli -// -// Attributes: -// - Name: a parameter to pass to docker. (e.g. volume) -// - Value: the value to pass to a parameter (e.g. /src/webapp:/opt/webapp) -type DockerParameter struct { - Name string `thrift:"name,1" json:"name"` - Value string `thrift:"value,2" json:"value"` -} - -func NewDockerParameter() *DockerParameter { - return &DockerParameter{} -} - -func (p *DockerParameter) GetName() string { - return p.Name -} - -func (p *DockerParameter) GetValue() string { - return p.Value -} -func (p *DockerParameter) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DockerParameter) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *DockerParameter) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Value = v - } - return nil -} - -func (p *DockerParameter) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("DockerParameter"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *DockerParameter) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) - } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) - } - return err -} - -func (p *DockerParameter) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("value", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:value: ", p), err) - } - if err := oprot.WriteString(string(p.Value)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.value (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:value: ", p), err) - } - return err -} - -func (p *DockerParameter) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("DockerParameter(%+v)", *p) -} - -// Describes a docker container -// -// Attributes: -// - Image: The container image to be run -// - Parameters: The arbitrary parameters to pass to container -type DockerContainer struct { - Image string `thrift:"image,1" json:"image"` - Parameters []*DockerParameter `thrift:"parameters,2" json:"parameters,omitempty"` -} - -func NewDockerContainer() *DockerContainer { - return &DockerContainer{} -} - -func (p *DockerContainer) GetImage() string { - return p.Image -} - -var DockerContainer_Parameters_DEFAULT []*DockerParameter - -func (p *DockerContainer) GetParameters() []*DockerParameter { - return p.Parameters -} -func (p *DockerContainer) IsSetParameters() bool { - return p.Parameters != nil -} - -func (p *DockerContainer) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DockerContainer) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Image = v - } - return nil -} - -func (p *DockerContainer) readField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*DockerParameter, 0, size) - p.Parameters = tSlice - for i := 0; i < size; i++ { - _elem3 := &DockerParameter{} - if err := _elem3.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem3), err) - } - p.Parameters = append(p.Parameters, _elem3) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *DockerContainer) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("DockerContainer"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *DockerContainer) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("image", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:image: ", p), err) - } - if err := oprot.WriteString(string(p.Image)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.image (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:image: ", p), err) - } - return err -} - -func (p *DockerContainer) writeField2(oprot thrift.TProtocol) (err error) { - if p.IsSetParameters() { - if err := oprot.WriteFieldBegin("parameters", thrift.LIST, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:parameters: ", p), err) - } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Parameters)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Parameters { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:parameters: ", p), err) - } - } - return err -} - -func (p *DockerContainer) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("DockerContainer(%+v)", *p) -} - -// Describes a container to be used in a task -// -// Attributes: -// - Mesos -// - Docker -type Container struct { - Mesos *MesosContainer `thrift:"mesos,1" json:"mesos,omitempty"` - Docker *DockerContainer `thrift:"docker,2" json:"docker,omitempty"` -} - -func NewContainer() *Container { - return &Container{} -} - -var Container_Mesos_DEFAULT *MesosContainer - -func (p *Container) GetMesos() *MesosContainer { - if !p.IsSetMesos() { - return Container_Mesos_DEFAULT - } - return p.Mesos -} - -var Container_Docker_DEFAULT *DockerContainer - -func (p *Container) GetDocker() *DockerContainer { - if !p.IsSetDocker() { - return Container_Docker_DEFAULT - } - return p.Docker -} -func (p *Container) CountSetFieldsContainer() int { - count := 0 - if p.IsSetMesos() { - count++ - } - if p.IsSetDocker() { - count++ - } - return count - -} - -func (p *Container) IsSetMesos() bool { - return p.Mesos != nil -} - -func (p *Container) IsSetDocker() bool { - return p.Docker != nil -} - -func (p *Container) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Container) readField1(iprot thrift.TProtocol) error { - p.Mesos = &MesosContainer{} - if err := p.Mesos.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Mesos), err) - } - return nil -} - -func (p *Container) readField2(iprot thrift.TProtocol) error { - p.Docker = &DockerContainer{} - if err := p.Docker.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Docker), err) - } - return nil -} - -func (p *Container) Write(oprot thrift.TProtocol) error { - if c := p.CountSetFieldsContainer(); c != 1 { - return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("Container"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *Container) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetMesos() { - if err := oprot.WriteFieldBegin("mesos", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:mesos: ", p), err) - } - if err := p.Mesos.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Mesos), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:mesos: ", p), err) - } - } - return err -} - -func (p *Container) writeField2(oprot thrift.TProtocol) (err error) { - if p.IsSetDocker() { - if err := oprot.WriteFieldBegin("docker", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:docker: ", p), err) - } - if err := p.Docker.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Docker), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:docker: ", p), err) - } - } - return err -} - -func (p *Container) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Container(%+v)", *p) -} - -// Describes resource value required to run a task. -// -// Attributes: -// - NumCpus -// - RamMb -// - DiskMb -// - NamedPort -// - NumGpus -type Resource struct { - NumCpus *float64 `thrift:"numCpus,1" json:"numCpus,omitempty"` - RamMb *int64 `thrift:"ramMb,2" json:"ramMb,omitempty"` - DiskMb *int64 `thrift:"diskMb,3" json:"diskMb,omitempty"` - NamedPort *string `thrift:"namedPort,4" json:"namedPort,omitempty"` - NumGpus *int64 `thrift:"numGpus,5" json:"numGpus,omitempty"` -} - -func NewResource() *Resource { - return &Resource{} -} - -var Resource_NumCpus_DEFAULT float64 - -func (p *Resource) GetNumCpus() float64 { - if !p.IsSetNumCpus() { - return Resource_NumCpus_DEFAULT - } - return *p.NumCpus -} - -var Resource_RamMb_DEFAULT int64 - -func (p *Resource) GetRamMb() int64 { - if !p.IsSetRamMb() { - return Resource_RamMb_DEFAULT - } - return *p.RamMb -} - -var Resource_DiskMb_DEFAULT int64 - -func (p *Resource) GetDiskMb() int64 { - if !p.IsSetDiskMb() { - return Resource_DiskMb_DEFAULT - } - return *p.DiskMb -} - -var Resource_NamedPort_DEFAULT string - -func (p *Resource) GetNamedPort() string { - if !p.IsSetNamedPort() { - return Resource_NamedPort_DEFAULT - } - return *p.NamedPort -} - -var Resource_NumGpus_DEFAULT int64 - -func (p *Resource) GetNumGpus() int64 { - if !p.IsSetNumGpus() { - return Resource_NumGpus_DEFAULT - } - return *p.NumGpus -} -func (p *Resource) CountSetFieldsResource() int { - count := 0 - if p.IsSetNumCpus() { - count++ - } - if p.IsSetRamMb() { - count++ - } - if p.IsSetDiskMb() { - count++ - } - if p.IsSetNamedPort() { - count++ - } - if p.IsSetNumGpus() { - count++ - } - return count - -} - -func (p *Resource) IsSetNumCpus() bool { - return p.NumCpus != nil -} - -func (p *Resource) IsSetRamMb() bool { - return p.RamMb != nil -} - -func (p *Resource) IsSetDiskMb() bool { - return p.DiskMb != nil -} - -func (p *Resource) IsSetNamedPort() bool { - return p.NamedPort != nil -} - -func (p *Resource) IsSetNumGpus() bool { - return p.NumGpus != nil -} - -func (p *Resource) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - case 5: - if err := p.readField5(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Resource) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.NumCpus = &v - } - return nil -} - -func (p *Resource) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.RamMb = &v - } - return nil -} - -func (p *Resource) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.DiskMb = &v - } - return nil -} - -func (p *Resource) readField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.NamedPort = &v - } - return nil -} - -func (p *Resource) readField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.NumGpus = &v - } - return nil -} - -func (p *Resource) Write(oprot thrift.TProtocol) error { - if c := p.CountSetFieldsResource(); c != 1 { - return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("Resource"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := p.writeField5(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *Resource) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetNumCpus() { - if err := oprot.WriteFieldBegin("numCpus", thrift.DOUBLE, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:numCpus: ", p), err) - } - if err := oprot.WriteDouble(float64(*p.NumCpus)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.numCpus (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:numCpus: ", p), err) - } - } - return err -} - -func (p *Resource) writeField2(oprot thrift.TProtocol) (err error) { - if p.IsSetRamMb() { - if err := oprot.WriteFieldBegin("ramMb", thrift.I64, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:ramMb: ", p), err) - } - if err := oprot.WriteI64(int64(*p.RamMb)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.ramMb (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:ramMb: ", p), err) - } - } - return err -} - -func (p *Resource) writeField3(oprot thrift.TProtocol) (err error) { - if p.IsSetDiskMb() { - if err := oprot.WriteFieldBegin("diskMb", thrift.I64, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:diskMb: ", p), err) - } - if err := oprot.WriteI64(int64(*p.DiskMb)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.diskMb (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:diskMb: ", p), err) - } - } - return err -} - -func (p *Resource) writeField4(oprot thrift.TProtocol) (err error) { - if p.IsSetNamedPort() { - if err := oprot.WriteFieldBegin("namedPort", thrift.STRING, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:namedPort: ", p), err) - } - if err := oprot.WriteString(string(*p.NamedPort)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.namedPort (4) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:namedPort: ", p), err) - } - } - return err -} - -func (p *Resource) writeField5(oprot thrift.TProtocol) (err error) { - if p.IsSetNumGpus() { - if err := oprot.WriteFieldBegin("numGpus", thrift.I64, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:numGpus: ", p), err) - } - if err := oprot.WriteI64(int64(*p.NumGpus)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.numGpus (5) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:numGpus: ", p), err) - } - } - return err -} - -func (p *Resource) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Resource(%+v)", *p) -} - -// Description of the tasks contained within a job. -// -// Attributes: -// - Job: Job task belongs to. -// - Owner: contains the role component of JobKey -// - IsService -// - NumCpus -// - RamMb -// - DiskMb -// - Priority -// - MaxTaskFailures -// - Production: Whether this is a production task, which can preempt. -// - Tier: Task tier type. -// - Resources: All resources required to run a task. -// - Constraints -// - RequestedPorts: a list of named ports this task requests -// - MesosFetcherUris: Resources to retrieve with Mesos Fetcher -// - TaskLinks: Custom links to include when displaying this task on the scheduler dashboard. Keys are anchor -// text, values are URLs. Wildcards are supported for dynamic link crafting based on host, ports, -// instance, etc. -// - ContactEmail -// - ExecutorConfig: Executor configuration -// - Metadata: Used to display additional details in the UI. -// - Container: the container the task should use to execute -type TaskConfig struct { - // unused fields # 1 to 6 - IsService bool `thrift:"isService,7" json:"isService"` - NumCpus float64 `thrift:"numCpus,8" json:"numCpus"` - RamMb int64 `thrift:"ramMb,9" json:"ramMb"` - DiskMb int64 `thrift:"diskMb,10" json:"diskMb"` - Priority int32 `thrift:"priority,11" json:"priority"` - // unused field # 12 - MaxTaskFailures int32 `thrift:"maxTaskFailures,13" json:"maxTaskFailures"` - // unused fields # 14 to 16 - Owner *Identity `thrift:"owner,17" json:"owner"` - Production *bool `thrift:"production,18" json:"production,omitempty"` - // unused field # 19 - Constraints map[*Constraint]bool `thrift:"constraints,20" json:"constraints"` - RequestedPorts map[string]bool `thrift:"requestedPorts,21" json:"requestedPorts"` - TaskLinks map[string]string `thrift:"taskLinks,22" json:"taskLinks,omitempty"` - ContactEmail *string `thrift:"contactEmail,23" json:"contactEmail,omitempty"` - // unused field # 24 - ExecutorConfig *ExecutorConfig `thrift:"executorConfig,25" json:"executorConfig,omitempty"` - // unused field # 26 - Metadata map[*Metadata]bool `thrift:"metadata,27" json:"metadata,omitempty"` - Job *JobKey `thrift:"job,28" json:"job"` - Container *Container `thrift:"container,29" json:"container"` - Tier *string `thrift:"tier,30" json:"tier,omitempty"` - // unused field # 31 - Resources map[*Resource]bool `thrift:"resources,32" json:"resources"` - MesosFetcherUris map[*MesosFetcherURI]bool `thrift:"mesosFetcherUris,33" json:"mesosFetcherUris,omitempty"` -} - -func NewTaskConfig() *TaskConfig { - return &TaskConfig{} -} - -var TaskConfig_Job_DEFAULT *JobKey - -func (p *TaskConfig) GetJob() *JobKey { - if !p.IsSetJob() { - return TaskConfig_Job_DEFAULT - } - return p.Job -} - -var TaskConfig_Owner_DEFAULT *Identity - -func (p *TaskConfig) GetOwner() *Identity { - if !p.IsSetOwner() { - return TaskConfig_Owner_DEFAULT - } - return p.Owner -} - -func (p *TaskConfig) GetIsService() bool { - return p.IsService -} - -func (p *TaskConfig) GetNumCpus() float64 { - return p.NumCpus -} - -func (p *TaskConfig) GetRamMb() int64 { - return p.RamMb -} - -func (p *TaskConfig) GetDiskMb() int64 { - return p.DiskMb -} - -func (p *TaskConfig) GetPriority() int32 { - return p.Priority -} - -func (p *TaskConfig) GetMaxTaskFailures() int32 { - return p.MaxTaskFailures -} - -var TaskConfig_Production_DEFAULT bool - -func (p *TaskConfig) GetProduction() bool { - if !p.IsSetProduction() { - return TaskConfig_Production_DEFAULT - } - return *p.Production -} - -var TaskConfig_Tier_DEFAULT string - -func (p *TaskConfig) GetTier() string { - if !p.IsSetTier() { - return TaskConfig_Tier_DEFAULT - } - return *p.Tier -} - -func (p *TaskConfig) GetResources() map[*Resource]bool { - return p.Resources -} - -func (p *TaskConfig) GetConstraints() map[*Constraint]bool { - return p.Constraints -} - -func (p *TaskConfig) GetRequestedPorts() map[string]bool { - return p.RequestedPorts -} - -var TaskConfig_MesosFetcherUris_DEFAULT map[*MesosFetcherURI]bool - -func (p *TaskConfig) GetMesosFetcherUris() map[*MesosFetcherURI]bool { - return p.MesosFetcherUris -} - -var TaskConfig_TaskLinks_DEFAULT map[string]string - -func (p *TaskConfig) GetTaskLinks() map[string]string { - return p.TaskLinks -} - -var TaskConfig_ContactEmail_DEFAULT string - -func (p *TaskConfig) GetContactEmail() string { - if !p.IsSetContactEmail() { - return TaskConfig_ContactEmail_DEFAULT - } - return *p.ContactEmail -} - -var TaskConfig_ExecutorConfig_DEFAULT *ExecutorConfig - -func (p *TaskConfig) GetExecutorConfig() *ExecutorConfig { - if !p.IsSetExecutorConfig() { - return TaskConfig_ExecutorConfig_DEFAULT - } - return p.ExecutorConfig -} - -var TaskConfig_Metadata_DEFAULT map[*Metadata]bool - -func (p *TaskConfig) GetMetadata() map[*Metadata]bool { - return p.Metadata -} - -var TaskConfig_Container_DEFAULT *Container = &Container{ - Mesos: &MesosContainer{}, -} - -func (p *TaskConfig) GetContainer() *Container { - if !p.IsSetContainer() { - return TaskConfig_Container_DEFAULT - } - return p.Container -} -func (p *TaskConfig) IsSetJob() bool { - return p.Job != nil -} - -func (p *TaskConfig) IsSetOwner() bool { - return p.Owner != nil -} - -func (p *TaskConfig) IsSetProduction() bool { - return p.Production != nil -} - -func (p *TaskConfig) IsSetTier() bool { - return p.Tier != nil -} - -func (p *TaskConfig) IsSetMesosFetcherUris() bool { - return p.MesosFetcherUris != nil -} - -func (p *TaskConfig) IsSetTaskLinks() bool { - return p.TaskLinks != nil -} - -func (p *TaskConfig) IsSetContactEmail() bool { - return p.ContactEmail != nil -} - -func (p *TaskConfig) IsSetExecutorConfig() bool { - return p.ExecutorConfig != nil -} - -func (p *TaskConfig) IsSetMetadata() bool { - return p.Metadata != nil -} - -func (p *TaskConfig) IsSetContainer() bool { - return p.Container != nil -} - -func (p *TaskConfig) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 28: - if err := p.readField28(iprot); err != nil { - return err - } - case 17: - if err := p.readField17(iprot); err != nil { - return err - } - case 7: - if err := p.readField7(iprot); err != nil { - return err - } - case 8: - if err := p.readField8(iprot); err != nil { - return err - } - case 9: - if err := p.readField9(iprot); err != nil { - return err - } - case 10: - if err := p.readField10(iprot); err != nil { - return err - } - case 11: - if err := p.readField11(iprot); err != nil { - return err - } - case 13: - if err := p.readField13(iprot); err != nil { - return err - } - case 18: - if err := p.readField18(iprot); err != nil { - return err - } - case 30: - if err := p.readField30(iprot); err != nil { - return err - } - case 32: - if err := p.readField32(iprot); err != nil { - return err - } - case 20: - if err := p.readField20(iprot); err != nil { - return err - } - case 21: - if err := p.readField21(iprot); err != nil { - return err - } - case 33: - if err := p.readField33(iprot); err != nil { - return err - } - case 22: - if err := p.readField22(iprot); err != nil { - return err - } - case 23: - if err := p.readField23(iprot); err != nil { - return err - } - case 25: - if err := p.readField25(iprot); err != nil { - return err - } - case 27: - if err := p.readField27(iprot); err != nil { - return err - } - case 29: - if err := p.readField29(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TaskConfig) readField28(iprot thrift.TProtocol) error { - p.Job = &JobKey{} - if err := p.Job.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) - } - return nil -} - -func (p *TaskConfig) readField17(iprot thrift.TProtocol) error { - p.Owner = &Identity{} - if err := p.Owner.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Owner), err) - } - return nil -} - -func (p *TaskConfig) readField7(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 7: ", err) - } else { - p.IsService = v - } - return nil -} - -func (p *TaskConfig) readField8(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - p.NumCpus = v - } - return nil -} - -func (p *TaskConfig) readField9(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 9: ", err) - } else { - p.RamMb = v - } - return nil -} - -func (p *TaskConfig) readField10(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 10: ", err) - } else { - p.DiskMb = v - } - return nil -} - -func (p *TaskConfig) readField11(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 11: ", err) - } else { - p.Priority = v - } - return nil -} - -func (p *TaskConfig) readField13(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 13: ", err) - } else { - p.MaxTaskFailures = v - } - return nil -} - -func (p *TaskConfig) readField18(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 18: ", err) - } else { - p.Production = &v - } - return nil -} - -func (p *TaskConfig) readField30(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 30: ", err) - } else { - p.Tier = &v - } - return nil -} - -func (p *TaskConfig) readField32(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*Resource]bool, size) - p.Resources = tSet - for i := 0; i < size; i++ { - _elem4 := &Resource{} - if err := _elem4.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem4), err) - } - p.Resources[_elem4] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *TaskConfig) readField20(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*Constraint]bool, size) - p.Constraints = tSet - for i := 0; i < size; i++ { - _elem5 := &Constraint{} - if err := _elem5.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem5), err) - } - p.Constraints[_elem5] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *TaskConfig) readField21(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[string]bool, size) - p.RequestedPorts = tSet - for i := 0; i < size; i++ { - var _elem6 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem6 = v - } - p.RequestedPorts[_elem6] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *TaskConfig) readField33(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*MesosFetcherURI]bool, size) - p.MesosFetcherUris = tSet - for i := 0; i < size; i++ { - _elem7 := &MesosFetcherURI{} - if err := _elem7.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem7), err) - } - p.MesosFetcherUris[_elem7] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *TaskConfig) readField22(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.TaskLinks = tMap - for i := 0; i < size; i++ { - var _key8 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key8 = v - } - var _val9 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val9 = v - } - p.TaskLinks[_key8] = _val9 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *TaskConfig) readField23(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 23: ", err) - } else { - p.ContactEmail = &v - } - return nil -} - -func (p *TaskConfig) readField25(iprot thrift.TProtocol) error { - p.ExecutorConfig = &ExecutorConfig{} - if err := p.ExecutorConfig.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ExecutorConfig), err) - } - return nil -} - -func (p *TaskConfig) readField27(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*Metadata]bool, size) - p.Metadata = tSet - for i := 0; i < size; i++ { - _elem10 := &Metadata{} - if err := _elem10.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem10), err) - } - p.Metadata[_elem10] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *TaskConfig) readField29(iprot thrift.TProtocol) error { - p.Container = &Container{} - if err := p.Container.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Container), err) - } - return nil -} - -func (p *TaskConfig) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("TaskConfig"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField7(oprot); err != nil { - return err - } - if err := p.writeField8(oprot); err != nil { - return err - } - if err := p.writeField9(oprot); err != nil { - return err - } - if err := p.writeField10(oprot); err != nil { - return err - } - if err := p.writeField11(oprot); err != nil { - return err - } - if err := p.writeField13(oprot); err != nil { - return err - } - if err := p.writeField17(oprot); err != nil { - return err - } - if err := p.writeField18(oprot); err != nil { - return err - } - if err := p.writeField20(oprot); err != nil { - return err - } - if err := p.writeField21(oprot); err != nil { - return err - } - if err := p.writeField22(oprot); err != nil { - return err - } - if err := p.writeField23(oprot); err != nil { - return err - } - if err := p.writeField25(oprot); err != nil { - return err - } - if err := p.writeField27(oprot); err != nil { - return err - } - if err := p.writeField28(oprot); err != nil { - return err - } - if err := p.writeField29(oprot); err != nil { - return err - } - if err := p.writeField30(oprot); err != nil { - return err - } - if err := p.writeField32(oprot); err != nil { - return err - } - if err := p.writeField33(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *TaskConfig) writeField7(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("isService", thrift.BOOL, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:isService: ", p), err) - } - if err := oprot.WriteBool(bool(p.IsService)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.isService (7) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:isService: ", p), err) - } - return err -} - -func (p *TaskConfig) writeField8(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("numCpus", thrift.DOUBLE, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:numCpus: ", p), err) - } - if err := oprot.WriteDouble(float64(p.NumCpus)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.numCpus (8) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:numCpus: ", p), err) - } - return err -} - -func (p *TaskConfig) writeField9(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("ramMb", thrift.I64, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:ramMb: ", p), err) - } - if err := oprot.WriteI64(int64(p.RamMb)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.ramMb (9) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:ramMb: ", p), err) - } - return err -} - -func (p *TaskConfig) writeField10(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("diskMb", thrift.I64, 10); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:diskMb: ", p), err) - } - if err := oprot.WriteI64(int64(p.DiskMb)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.diskMb (10) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 10:diskMb: ", p), err) - } - return err -} - -func (p *TaskConfig) writeField11(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("priority", thrift.I32, 11); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:priority: ", p), err) - } - if err := oprot.WriteI32(int32(p.Priority)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.priority (11) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 11:priority: ", p), err) - } - return err -} - -func (p *TaskConfig) writeField13(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("maxTaskFailures", thrift.I32, 13); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 13:maxTaskFailures: ", p), err) - } - if err := oprot.WriteI32(int32(p.MaxTaskFailures)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.maxTaskFailures (13) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 13:maxTaskFailures: ", p), err) - } - return err -} - -func (p *TaskConfig) writeField17(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("owner", thrift.STRUCT, 17); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 17:owner: ", p), err) - } - if err := p.Owner.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Owner), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 17:owner: ", p), err) - } - return err -} - -func (p *TaskConfig) writeField18(oprot thrift.TProtocol) (err error) { - if p.IsSetProduction() { - if err := oprot.WriteFieldBegin("production", thrift.BOOL, 18); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 18:production: ", p), err) - } - if err := oprot.WriteBool(bool(*p.Production)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.production (18) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 18:production: ", p), err) - } - } - return err -} - -func (p *TaskConfig) writeField20(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("constraints", thrift.SET, 20); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 20:constraints: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Constraints)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Constraints { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 20:constraints: ", p), err) - } - return err -} - -func (p *TaskConfig) writeField21(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("requestedPorts", thrift.SET, 21); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 21:requestedPorts: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.RequestedPorts)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.RequestedPorts { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 21:requestedPorts: ", p), err) - } - return err -} - -func (p *TaskConfig) writeField22(oprot thrift.TProtocol) (err error) { - if p.IsSetTaskLinks() { - if err := oprot.WriteFieldBegin("taskLinks", thrift.MAP, 22); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 22:taskLinks: ", p), err) - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.TaskLinks)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.TaskLinks { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 22:taskLinks: ", p), err) - } - } - return err -} - -func (p *TaskConfig) writeField23(oprot thrift.TProtocol) (err error) { - if p.IsSetContactEmail() { - if err := oprot.WriteFieldBegin("contactEmail", thrift.STRING, 23); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 23:contactEmail: ", p), err) - } - if err := oprot.WriteString(string(*p.ContactEmail)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.contactEmail (23) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 23:contactEmail: ", p), err) - } - } - return err -} - -func (p *TaskConfig) writeField25(oprot thrift.TProtocol) (err error) { - if p.IsSetExecutorConfig() { - if err := oprot.WriteFieldBegin("executorConfig", thrift.STRUCT, 25); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 25:executorConfig: ", p), err) - } - if err := p.ExecutorConfig.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ExecutorConfig), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 25:executorConfig: ", p), err) - } - } - return err -} - -func (p *TaskConfig) writeField27(oprot thrift.TProtocol) (err error) { - if p.IsSetMetadata() { - if err := oprot.WriteFieldBegin("metadata", thrift.SET, 27); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 27:metadata: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Metadata)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Metadata { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 27:metadata: ", p), err) - } - } - return err -} - -func (p *TaskConfig) writeField28(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("job", thrift.STRUCT, 28); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 28:job: ", p), err) - } - if err := p.Job.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 28:job: ", p), err) - } - return err -} - -func (p *TaskConfig) writeField29(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("container", thrift.STRUCT, 29); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 29:container: ", p), err) - } - if err := p.Container.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Container), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 29:container: ", p), err) - } - return err -} - -func (p *TaskConfig) writeField30(oprot thrift.TProtocol) (err error) { - if p.IsSetTier() { - if err := oprot.WriteFieldBegin("tier", thrift.STRING, 30); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 30:tier: ", p), err) - } - if err := oprot.WriteString(string(*p.Tier)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.tier (30) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 30:tier: ", p), err) - } - } - return err -} - -func (p *TaskConfig) writeField32(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("resources", thrift.SET, 32); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 32:resources: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Resources)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Resources { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 32:resources: ", p), err) - } - return err -} - -func (p *TaskConfig) writeField33(oprot thrift.TProtocol) (err error) { - if p.IsSetMesosFetcherUris() { - if err := oprot.WriteFieldBegin("mesosFetcherUris", thrift.SET, 33); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 33:mesosFetcherUris: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.MesosFetcherUris)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.MesosFetcherUris { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 33:mesosFetcherUris: ", p), err) - } - } - return err -} - -func (p *TaskConfig) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("TaskConfig(%+v)", *p) -} - -// Attributes: -// - NumCpus: Number of CPU cores allotted. -// - RamMb: Megabytes of RAM allotted. -// - DiskMb: Megabytes of disk space allotted. -// - Resources: Aggregated resource values. -type ResourceAggregate struct { - NumCpus float64 `thrift:"numCpus,1" json:"numCpus"` - RamMb int64 `thrift:"ramMb,2" json:"ramMb"` - DiskMb int64 `thrift:"diskMb,3" json:"diskMb"` - Resources map[*Resource]bool `thrift:"resources,4" json:"resources"` -} - -func NewResourceAggregate() *ResourceAggregate { - return &ResourceAggregate{} -} - -func (p *ResourceAggregate) GetNumCpus() float64 { - return p.NumCpus -} - -func (p *ResourceAggregate) GetRamMb() int64 { - return p.RamMb -} - -func (p *ResourceAggregate) GetDiskMb() int64 { - return p.DiskMb -} - -func (p *ResourceAggregate) GetResources() map[*Resource]bool { - return p.Resources -} -func (p *ResourceAggregate) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ResourceAggregate) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadDouble(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.NumCpus = v - } - return nil -} - -func (p *ResourceAggregate) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.RamMb = v - } - return nil -} - -func (p *ResourceAggregate) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.DiskMb = v - } - return nil -} - -func (p *ResourceAggregate) readField4(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*Resource]bool, size) - p.Resources = tSet - for i := 0; i < size; i++ { - _elem11 := &Resource{} - if err := _elem11.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem11), err) - } - p.Resources[_elem11] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *ResourceAggregate) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ResourceAggregate"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ResourceAggregate) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("numCpus", thrift.DOUBLE, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:numCpus: ", p), err) - } - if err := oprot.WriteDouble(float64(p.NumCpus)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.numCpus (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:numCpus: ", p), err) - } - return err -} - -func (p *ResourceAggregate) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("ramMb", thrift.I64, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:ramMb: ", p), err) - } - if err := oprot.WriteI64(int64(p.RamMb)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.ramMb (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:ramMb: ", p), err) - } - return err -} - -func (p *ResourceAggregate) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("diskMb", thrift.I64, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:diskMb: ", p), err) - } - if err := oprot.WriteI64(int64(p.DiskMb)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.diskMb (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:diskMb: ", p), err) - } - return err -} - -func (p *ResourceAggregate) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("resources", thrift.SET, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:resources: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Resources)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Resources { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:resources: ", p), err) - } - return err -} - -func (p *ResourceAggregate) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ResourceAggregate(%+v)", *p) -} - -// Description of an Aurora job. One task will be scheduled for each instance within the job. -// -// Attributes: -// - Key: Key for this job. If not specified name, owner.role, and a reasonable default environment are -// used to construct it server-side. -// - Owner: Owner of this job. -// - CronSchedule: If present, the job will be handled as a cron job with this crontab-syntax schedule. -// - CronCollisionPolicy: Collision policy to use when handling overlapping cron runs. Default is KILL_EXISTING. -// - TaskConfig: Task configuration for this job. -// - InstanceCount: The number of instances in the job. Generated instance IDs for tasks will be in the range -// [0, instances). -type JobConfiguration struct { - // unused fields # 1 to 3 - CronSchedule *string `thrift:"cronSchedule,4" json:"cronSchedule,omitempty"` - CronCollisionPolicy CronCollisionPolicy `thrift:"cronCollisionPolicy,5" json:"cronCollisionPolicy"` - TaskConfig *TaskConfig `thrift:"taskConfig,6" json:"taskConfig"` - Owner *Identity `thrift:"owner,7" json:"owner"` - InstanceCount int32 `thrift:"instanceCount,8" json:"instanceCount"` - Key *JobKey `thrift:"key,9" json:"key"` -} - -func NewJobConfiguration() *JobConfiguration { - return &JobConfiguration{} -} - -var JobConfiguration_Key_DEFAULT *JobKey - -func (p *JobConfiguration) GetKey() *JobKey { - if !p.IsSetKey() { - return JobConfiguration_Key_DEFAULT - } - return p.Key -} - -var JobConfiguration_Owner_DEFAULT *Identity - -func (p *JobConfiguration) GetOwner() *Identity { - if !p.IsSetOwner() { - return JobConfiguration_Owner_DEFAULT - } - return p.Owner -} - -var JobConfiguration_CronSchedule_DEFAULT string - -func (p *JobConfiguration) GetCronSchedule() string { - if !p.IsSetCronSchedule() { - return JobConfiguration_CronSchedule_DEFAULT - } - return *p.CronSchedule -} - -func (p *JobConfiguration) GetCronCollisionPolicy() CronCollisionPolicy { - return p.CronCollisionPolicy -} - -var JobConfiguration_TaskConfig_DEFAULT *TaskConfig - -func (p *JobConfiguration) GetTaskConfig() *TaskConfig { - if !p.IsSetTaskConfig() { - return JobConfiguration_TaskConfig_DEFAULT - } - return p.TaskConfig -} - -func (p *JobConfiguration) GetInstanceCount() int32 { - return p.InstanceCount -} -func (p *JobConfiguration) IsSetKey() bool { - return p.Key != nil -} - -func (p *JobConfiguration) IsSetOwner() bool { - return p.Owner != nil -} - -func (p *JobConfiguration) IsSetCronSchedule() bool { - return p.CronSchedule != nil -} - -func (p *JobConfiguration) IsSetTaskConfig() bool { - return p.TaskConfig != nil -} - -func (p *JobConfiguration) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 9: - if err := p.readField9(iprot); err != nil { - return err - } - case 7: - if err := p.readField7(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - case 5: - if err := p.readField5(iprot); err != nil { - return err - } - case 6: - if err := p.readField6(iprot); err != nil { - return err - } - case 8: - if err := p.readField8(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *JobConfiguration) readField9(iprot thrift.TProtocol) error { - p.Key = &JobKey{} - if err := p.Key.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) - } - return nil -} - -func (p *JobConfiguration) readField7(iprot thrift.TProtocol) error { - p.Owner = &Identity{} - if err := p.Owner.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Owner), err) - } - return nil -} - -func (p *JobConfiguration) readField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.CronSchedule = &v - } - return nil -} - -func (p *JobConfiguration) readField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - temp := CronCollisionPolicy(v) - p.CronCollisionPolicy = temp - } - return nil -} - -func (p *JobConfiguration) readField6(iprot thrift.TProtocol) error { - p.TaskConfig = &TaskConfig{} - if err := p.TaskConfig.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.TaskConfig), err) - } - return nil -} - -func (p *JobConfiguration) readField8(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - p.InstanceCount = v - } - return nil -} - -func (p *JobConfiguration) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobConfiguration"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := p.writeField5(oprot); err != nil { - return err - } - if err := p.writeField6(oprot); err != nil { - return err - } - if err := p.writeField7(oprot); err != nil { - return err - } - if err := p.writeField8(oprot); err != nil { - return err - } - if err := p.writeField9(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *JobConfiguration) writeField4(oprot thrift.TProtocol) (err error) { - if p.IsSetCronSchedule() { - if err := oprot.WriteFieldBegin("cronSchedule", thrift.STRING, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:cronSchedule: ", p), err) - } - if err := oprot.WriteString(string(*p.CronSchedule)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.cronSchedule (4) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:cronSchedule: ", p), err) - } - } - return err -} - -func (p *JobConfiguration) writeField5(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("cronCollisionPolicy", thrift.I32, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:cronCollisionPolicy: ", p), err) - } - if err := oprot.WriteI32(int32(p.CronCollisionPolicy)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.cronCollisionPolicy (5) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:cronCollisionPolicy: ", p), err) - } - return err -} - -func (p *JobConfiguration) writeField6(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("taskConfig", thrift.STRUCT, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:taskConfig: ", p), err) - } - if err := p.TaskConfig.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.TaskConfig), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:taskConfig: ", p), err) - } - return err -} - -func (p *JobConfiguration) writeField7(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("owner", thrift.STRUCT, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:owner: ", p), err) - } - if err := p.Owner.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Owner), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:owner: ", p), err) - } - return err -} - -func (p *JobConfiguration) writeField8(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instanceCount", thrift.I32, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:instanceCount: ", p), err) - } - if err := oprot.WriteI32(int32(p.InstanceCount)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.instanceCount (8) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:instanceCount: ", p), err) - } - return err -} - -func (p *JobConfiguration) writeField9(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRUCT, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:key: ", p), err) - } - if err := p.Key.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:key: ", p), err) - } - return err -} - -func (p *JobConfiguration) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JobConfiguration(%+v)", *p) -} - -// Attributes: -// - ActiveTaskCount: Number of tasks in active state for this job. -// - FinishedTaskCount: Number of tasks in finished state for this job. -// - FailedTaskCount: Number of failed tasks for this job. -// - PendingTaskCount: Number of tasks in pending state for this job. -type JobStats struct { - ActiveTaskCount int32 `thrift:"activeTaskCount,1" json:"activeTaskCount"` - FinishedTaskCount int32 `thrift:"finishedTaskCount,2" json:"finishedTaskCount"` - FailedTaskCount int32 `thrift:"failedTaskCount,3" json:"failedTaskCount"` - PendingTaskCount int32 `thrift:"pendingTaskCount,4" json:"pendingTaskCount"` -} - -func NewJobStats() *JobStats { - return &JobStats{} -} - -func (p *JobStats) GetActiveTaskCount() int32 { - return p.ActiveTaskCount -} - -func (p *JobStats) GetFinishedTaskCount() int32 { - return p.FinishedTaskCount -} - -func (p *JobStats) GetFailedTaskCount() int32 { - return p.FailedTaskCount -} - -func (p *JobStats) GetPendingTaskCount() int32 { - return p.PendingTaskCount -} -func (p *JobStats) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *JobStats) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.ActiveTaskCount = v - } - return nil -} - -func (p *JobStats) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.FinishedTaskCount = v - } - return nil -} - -func (p *JobStats) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.FailedTaskCount = v - } - return nil -} - -func (p *JobStats) readField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.PendingTaskCount = v - } - return nil -} - -func (p *JobStats) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobStats"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *JobStats) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("activeTaskCount", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:activeTaskCount: ", p), err) - } - if err := oprot.WriteI32(int32(p.ActiveTaskCount)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.activeTaskCount (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:activeTaskCount: ", p), err) - } - return err -} - -func (p *JobStats) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("finishedTaskCount", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:finishedTaskCount: ", p), err) - } - if err := oprot.WriteI32(int32(p.FinishedTaskCount)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.finishedTaskCount (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:finishedTaskCount: ", p), err) - } - return err -} - -func (p *JobStats) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("failedTaskCount", thrift.I32, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:failedTaskCount: ", p), err) - } - if err := oprot.WriteI32(int32(p.FailedTaskCount)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.failedTaskCount (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:failedTaskCount: ", p), err) - } - return err -} - -func (p *JobStats) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("pendingTaskCount", thrift.I32, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:pendingTaskCount: ", p), err) - } - if err := oprot.WriteI32(int32(p.PendingTaskCount)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.pendingTaskCount (4) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:pendingTaskCount: ", p), err) - } - return err -} - -func (p *JobStats) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JobStats(%+v)", *p) -} - -// Attributes: -// - Job -// - Stats -// - NextCronRunMs: Timestamp of next cron run in ms since epoch, for a cron job -type JobSummary struct { - Job *JobConfiguration `thrift:"job,1" json:"job"` - Stats *JobStats `thrift:"stats,2" json:"stats"` - NextCronRunMs *int64 `thrift:"nextCronRunMs,3" json:"nextCronRunMs,omitempty"` -} - -func NewJobSummary() *JobSummary { - return &JobSummary{} -} - -var JobSummary_Job_DEFAULT *JobConfiguration - -func (p *JobSummary) GetJob() *JobConfiguration { - if !p.IsSetJob() { - return JobSummary_Job_DEFAULT - } - return p.Job -} - -var JobSummary_Stats_DEFAULT *JobStats - -func (p *JobSummary) GetStats() *JobStats { - if !p.IsSetStats() { - return JobSummary_Stats_DEFAULT - } - return p.Stats -} - -var JobSummary_NextCronRunMs_DEFAULT int64 - -func (p *JobSummary) GetNextCronRunMs() int64 { - if !p.IsSetNextCronRunMs() { - return JobSummary_NextCronRunMs_DEFAULT - } - return *p.NextCronRunMs -} -func (p *JobSummary) IsSetJob() bool { - return p.Job != nil -} - -func (p *JobSummary) IsSetStats() bool { - return p.Stats != nil -} - -func (p *JobSummary) IsSetNextCronRunMs() bool { - return p.NextCronRunMs != nil -} - -func (p *JobSummary) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *JobSummary) readField1(iprot thrift.TProtocol) error { - p.Job = &JobConfiguration{} - if err := p.Job.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) - } - return nil -} - -func (p *JobSummary) readField2(iprot thrift.TProtocol) error { - p.Stats = &JobStats{} - if err := p.Stats.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Stats), err) - } - return nil -} - -func (p *JobSummary) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.NextCronRunMs = &v - } - return nil -} - -func (p *JobSummary) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobSummary"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *JobSummary) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("job", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:job: ", p), err) - } - if err := p.Job.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:job: ", p), err) - } - return err -} - -func (p *JobSummary) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("stats", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:stats: ", p), err) - } - if err := p.Stats.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Stats), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:stats: ", p), err) - } - return err -} - -func (p *JobSummary) writeField3(oprot thrift.TProtocol) (err error) { - if p.IsSetNextCronRunMs() { - if err := oprot.WriteFieldBegin("nextCronRunMs", thrift.I64, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:nextCronRunMs: ", p), err) - } - if err := oprot.WriteI64(int64(*p.NextCronRunMs)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.nextCronRunMs (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:nextCronRunMs: ", p), err) - } - } - return err -} - -func (p *JobSummary) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JobSummary(%+v)", *p) -} - -// Closed range of integers. -// -// Attributes: -// - First -// - Last -type Range struct { - First int32 `thrift:"first,1" json:"first"` - Last int32 `thrift:"last,2" json:"last"` -} - -func NewRange() *Range { - return &Range{} -} - -func (p *Range) GetFirst() int32 { - return p.First -} - -func (p *Range) GetLast() int32 { - return p.Last -} -func (p *Range) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Range) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.First = v - } - return nil -} - -func (p *Range) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Last = v - } - return nil -} - -func (p *Range) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Range"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *Range) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("first", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:first: ", p), err) - } - if err := oprot.WriteI32(int32(p.First)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.first (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:first: ", p), err) - } - return err -} - -func (p *Range) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("last", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:last: ", p), err) - } - if err := oprot.WriteI32(int32(p.Last)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.last (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:last: ", p), err) - } - return err -} - -func (p *Range) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Range(%+v)", *p) -} - -// Attributes: -// - Config -// - Instances -type ConfigGroup struct { - Config *TaskConfig `thrift:"config,1" json:"config"` - // unused field # 2 - Instances map[*Range]bool `thrift:"instances,3" json:"instances"` -} - -func NewConfigGroup() *ConfigGroup { - return &ConfigGroup{} -} - -var ConfigGroup_Config_DEFAULT *TaskConfig - -func (p *ConfigGroup) GetConfig() *TaskConfig { - if !p.IsSetConfig() { - return ConfigGroup_Config_DEFAULT - } - return p.Config -} - -func (p *ConfigGroup) GetInstances() map[*Range]bool { - return p.Instances -} -func (p *ConfigGroup) IsSetConfig() bool { - return p.Config != nil -} - -func (p *ConfigGroup) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ConfigGroup) readField1(iprot thrift.TProtocol) error { - p.Config = &TaskConfig{} - if err := p.Config.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Config), err) - } - return nil -} - -func (p *ConfigGroup) readField3(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*Range]bool, size) - p.Instances = tSet - for i := 0; i < size; i++ { - _elem12 := &Range{} - if err := _elem12.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem12), err) - } - p.Instances[_elem12] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *ConfigGroup) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ConfigGroup"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ConfigGroup) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("config", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:config: ", p), err) - } - if err := p.Config.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Config), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:config: ", p), err) - } - return err -} - -func (p *ConfigGroup) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instances", thrift.SET, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:instances: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Instances)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Instances { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:instances: ", p), err) - } - return err -} - -func (p *ConfigGroup) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ConfigGroup(%+v)", *p) -} - -// Attributes: -// - Key -// - Groups -type ConfigSummary struct { - Key *JobKey `thrift:"key,1" json:"key"` - Groups map[*ConfigGroup]bool `thrift:"groups,2" json:"groups"` -} - -func NewConfigSummary() *ConfigSummary { - return &ConfigSummary{} -} - -var ConfigSummary_Key_DEFAULT *JobKey - -func (p *ConfigSummary) GetKey() *JobKey { - if !p.IsSetKey() { - return ConfigSummary_Key_DEFAULT - } - return p.Key -} - -func (p *ConfigSummary) GetGroups() map[*ConfigGroup]bool { - return p.Groups -} -func (p *ConfigSummary) IsSetKey() bool { - return p.Key != nil -} - -func (p *ConfigSummary) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ConfigSummary) readField1(iprot thrift.TProtocol) error { - p.Key = &JobKey{} - if err := p.Key.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) - } - return nil -} - -func (p *ConfigSummary) readField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*ConfigGroup]bool, size) - p.Groups = tSet - for i := 0; i < size; i++ { - _elem13 := &ConfigGroup{} - if err := _elem13.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem13), err) - } - p.Groups[_elem13] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *ConfigSummary) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ConfigSummary"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ConfigSummary) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) - } - if err := p.Key.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) - } - return err -} - -func (p *ConfigSummary) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("groups", thrift.SET, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:groups: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Groups)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Groups { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:groups: ", p), err) - } - return err -} - -func (p *ConfigSummary) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ConfigSummary(%+v)", *p) -} - -// Attributes: -// - TaskConfig -type PopulateJobResult_ struct { - // unused field # 1 - TaskConfig *TaskConfig `thrift:"taskConfig,2" json:"taskConfig"` -} - -func NewPopulateJobResult_() *PopulateJobResult_ { - return &PopulateJobResult_{} -} - -var PopulateJobResult__TaskConfig_DEFAULT *TaskConfig - -func (p *PopulateJobResult_) GetTaskConfig() *TaskConfig { - if !p.IsSetTaskConfig() { - return PopulateJobResult__TaskConfig_DEFAULT - } - return p.TaskConfig -} -func (p *PopulateJobResult_) IsSetTaskConfig() bool { - return p.TaskConfig != nil -} - -func (p *PopulateJobResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *PopulateJobResult_) readField2(iprot thrift.TProtocol) error { - p.TaskConfig = &TaskConfig{} - if err := p.TaskConfig.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.TaskConfig), err) - } - return nil -} - -func (p *PopulateJobResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("PopulateJobResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *PopulateJobResult_) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("taskConfig", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:taskConfig: ", p), err) - } - if err := p.TaskConfig.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.TaskConfig), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:taskConfig: ", p), err) - } - return err -} - -func (p *PopulateJobResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("PopulateJobResult_(%+v)", *p) -} - -// Attributes: -// - Quota: Total allocated resource quota. -// - ProdSharedConsumption: Resources consumed by production jobs from a shared resource pool. -// - NonProdSharedConsumption: Resources consumed by non-production jobs from a shared resource pool. -// - ProdDedicatedConsumption: Resources consumed by production jobs from a dedicated resource pool. -// - NonProdDedicatedConsumption: Resources consumed by non-production jobs from a dedicated resource pool. -type GetQuotaResult_ struct { - Quota *ResourceAggregate `thrift:"quota,1" json:"quota"` - ProdSharedConsumption *ResourceAggregate `thrift:"prodSharedConsumption,2" json:"prodSharedConsumption,omitempty"` - NonProdSharedConsumption *ResourceAggregate `thrift:"nonProdSharedConsumption,3" json:"nonProdSharedConsumption,omitempty"` - ProdDedicatedConsumption *ResourceAggregate `thrift:"prodDedicatedConsumption,4" json:"prodDedicatedConsumption,omitempty"` - NonProdDedicatedConsumption *ResourceAggregate `thrift:"nonProdDedicatedConsumption,5" json:"nonProdDedicatedConsumption,omitempty"` -} - -func NewGetQuotaResult_() *GetQuotaResult_ { - return &GetQuotaResult_{} -} - -var GetQuotaResult__Quota_DEFAULT *ResourceAggregate - -func (p *GetQuotaResult_) GetQuota() *ResourceAggregate { - if !p.IsSetQuota() { - return GetQuotaResult__Quota_DEFAULT - } - return p.Quota -} - -var GetQuotaResult__ProdSharedConsumption_DEFAULT *ResourceAggregate - -func (p *GetQuotaResult_) GetProdSharedConsumption() *ResourceAggregate { - if !p.IsSetProdSharedConsumption() { - return GetQuotaResult__ProdSharedConsumption_DEFAULT - } - return p.ProdSharedConsumption -} - -var GetQuotaResult__NonProdSharedConsumption_DEFAULT *ResourceAggregate - -func (p *GetQuotaResult_) GetNonProdSharedConsumption() *ResourceAggregate { - if !p.IsSetNonProdSharedConsumption() { - return GetQuotaResult__NonProdSharedConsumption_DEFAULT - } - return p.NonProdSharedConsumption -} - -var GetQuotaResult__ProdDedicatedConsumption_DEFAULT *ResourceAggregate - -func (p *GetQuotaResult_) GetProdDedicatedConsumption() *ResourceAggregate { - if !p.IsSetProdDedicatedConsumption() { - return GetQuotaResult__ProdDedicatedConsumption_DEFAULT - } - return p.ProdDedicatedConsumption -} - -var GetQuotaResult__NonProdDedicatedConsumption_DEFAULT *ResourceAggregate - -func (p *GetQuotaResult_) GetNonProdDedicatedConsumption() *ResourceAggregate { - if !p.IsSetNonProdDedicatedConsumption() { - return GetQuotaResult__NonProdDedicatedConsumption_DEFAULT - } - return p.NonProdDedicatedConsumption -} -func (p *GetQuotaResult_) IsSetQuota() bool { - return p.Quota != nil -} - -func (p *GetQuotaResult_) IsSetProdSharedConsumption() bool { - return p.ProdSharedConsumption != nil -} - -func (p *GetQuotaResult_) IsSetNonProdSharedConsumption() bool { - return p.NonProdSharedConsumption != nil -} - -func (p *GetQuotaResult_) IsSetProdDedicatedConsumption() bool { - return p.ProdDedicatedConsumption != nil -} - -func (p *GetQuotaResult_) IsSetNonProdDedicatedConsumption() bool { - return p.NonProdDedicatedConsumption != nil -} - -func (p *GetQuotaResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - case 5: - if err := p.readField5(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetQuotaResult_) readField1(iprot thrift.TProtocol) error { - p.Quota = &ResourceAggregate{} - if err := p.Quota.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Quota), err) - } - return nil -} - -func (p *GetQuotaResult_) readField2(iprot thrift.TProtocol) error { - p.ProdSharedConsumption = &ResourceAggregate{} - if err := p.ProdSharedConsumption.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ProdSharedConsumption), err) - } - return nil -} - -func (p *GetQuotaResult_) readField3(iprot thrift.TProtocol) error { - p.NonProdSharedConsumption = &ResourceAggregate{} - if err := p.NonProdSharedConsumption.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.NonProdSharedConsumption), err) - } - return nil -} - -func (p *GetQuotaResult_) readField4(iprot thrift.TProtocol) error { - p.ProdDedicatedConsumption = &ResourceAggregate{} - if err := p.ProdDedicatedConsumption.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ProdDedicatedConsumption), err) - } - return nil -} - -func (p *GetQuotaResult_) readField5(iprot thrift.TProtocol) error { - p.NonProdDedicatedConsumption = &ResourceAggregate{} - if err := p.NonProdDedicatedConsumption.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.NonProdDedicatedConsumption), err) - } - return nil -} - -func (p *GetQuotaResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("GetQuotaResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := p.writeField5(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *GetQuotaResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("quota", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:quota: ", p), err) - } - if err := p.Quota.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Quota), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:quota: ", p), err) - } - return err -} - -func (p *GetQuotaResult_) writeField2(oprot thrift.TProtocol) (err error) { - if p.IsSetProdSharedConsumption() { - if err := oprot.WriteFieldBegin("prodSharedConsumption", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:prodSharedConsumption: ", p), err) - } - if err := p.ProdSharedConsumption.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ProdSharedConsumption), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:prodSharedConsumption: ", p), err) - } - } - return err -} - -func (p *GetQuotaResult_) writeField3(oprot thrift.TProtocol) (err error) { - if p.IsSetNonProdSharedConsumption() { - if err := oprot.WriteFieldBegin("nonProdSharedConsumption", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:nonProdSharedConsumption: ", p), err) - } - if err := p.NonProdSharedConsumption.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.NonProdSharedConsumption), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:nonProdSharedConsumption: ", p), err) - } - } - return err -} - -func (p *GetQuotaResult_) writeField4(oprot thrift.TProtocol) (err error) { - if p.IsSetProdDedicatedConsumption() { - if err := oprot.WriteFieldBegin("prodDedicatedConsumption", thrift.STRUCT, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:prodDedicatedConsumption: ", p), err) - } - if err := p.ProdDedicatedConsumption.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ProdDedicatedConsumption), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:prodDedicatedConsumption: ", p), err) - } - } - return err -} - -func (p *GetQuotaResult_) writeField5(oprot thrift.TProtocol) (err error) { - if p.IsSetNonProdDedicatedConsumption() { - if err := oprot.WriteFieldBegin("nonProdDedicatedConsumption", thrift.STRUCT, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:nonProdDedicatedConsumption: ", p), err) - } - if err := p.NonProdDedicatedConsumption.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.NonProdDedicatedConsumption), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:nonProdDedicatedConsumption: ", p), err) - } - } - return err -} - -func (p *GetQuotaResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("GetQuotaResult_(%+v)", *p) -} - -// Event marking a state transition within a task's lifecycle. -// -// Attributes: -// - Timestamp: Epoch timestamp in milliseconds. -// - Status: New status of the task. -// - Message: Audit message that explains why a transition occurred. -// - Scheduler: Hostname of the scheduler machine that performed the event. -type TaskEvent struct { - Timestamp int64 `thrift:"timestamp,1" json:"timestamp"` - Status ScheduleStatus `thrift:"status,2" json:"status"` - Message *string `thrift:"message,3" json:"message,omitempty"` - Scheduler *string `thrift:"scheduler,4" json:"scheduler,omitempty"` -} - -func NewTaskEvent() *TaskEvent { - return &TaskEvent{} -} - -func (p *TaskEvent) GetTimestamp() int64 { - return p.Timestamp -} - -func (p *TaskEvent) GetStatus() ScheduleStatus { - return p.Status -} - -var TaskEvent_Message_DEFAULT string - -func (p *TaskEvent) GetMessage() string { - if !p.IsSetMessage() { - return TaskEvent_Message_DEFAULT - } - return *p.Message -} - -var TaskEvent_Scheduler_DEFAULT string - -func (p *TaskEvent) GetScheduler() string { - if !p.IsSetScheduler() { - return TaskEvent_Scheduler_DEFAULT - } - return *p.Scheduler -} -func (p *TaskEvent) IsSetMessage() bool { - return p.Message != nil -} - -func (p *TaskEvent) IsSetScheduler() bool { - return p.Scheduler != nil -} - -func (p *TaskEvent) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TaskEvent) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Timestamp = v - } - return nil -} - -func (p *TaskEvent) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := ScheduleStatus(v) - p.Status = temp - } - return nil -} - -func (p *TaskEvent) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.Message = &v - } - return nil -} - -func (p *TaskEvent) readField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.Scheduler = &v - } - return nil -} - -func (p *TaskEvent) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("TaskEvent"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *TaskEvent) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("timestamp", thrift.I64, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:timestamp: ", p), err) - } - if err := oprot.WriteI64(int64(p.Timestamp)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.timestamp (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:timestamp: ", p), err) - } - return err -} - -func (p *TaskEvent) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("status", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:status: ", p), err) - } - if err := oprot.WriteI32(int32(p.Status)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.status (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:status: ", p), err) - } - return err -} - -func (p *TaskEvent) writeField3(oprot thrift.TProtocol) (err error) { - if p.IsSetMessage() { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:message: ", p), err) - } - if err := oprot.WriteString(string(*p.Message)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.message (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:message: ", p), err) - } - } - return err -} - -func (p *TaskEvent) writeField4(oprot thrift.TProtocol) (err error) { - if p.IsSetScheduler() { - if err := oprot.WriteFieldBegin("scheduler", thrift.STRING, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:scheduler: ", p), err) - } - if err := oprot.WriteString(string(*p.Scheduler)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.scheduler (4) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:scheduler: ", p), err) - } - } - return err -} - -func (p *TaskEvent) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("TaskEvent(%+v)", *p) -} - -// A task assignment that is provided to an executor. -// -// Attributes: -// - TaskId: The mesos task ID for this task. Guaranteed to be globally unique -// - SlaveId: The mesos slave ID that this task has been assigned to. -// This will not be populated for a PENDING task. -// - SlaveHost: The name of the machine that this task has been assigned to. -// This will not be populated for a PENDING task. -// - Task: Information about how to run this task. -// - AssignedPorts: Ports reserved on the machine while this task is running. -// - InstanceId: The instance ID assigned to this task. Instance IDs must be unique and contiguous within a -// job, and will be in the range [0, N-1] (inclusive) for a job that has N instances. -type AssignedTask struct { - TaskId string `thrift:"taskId,1" json:"taskId"` - SlaveId string `thrift:"slaveId,2" json:"slaveId"` - SlaveHost string `thrift:"slaveHost,3" json:"slaveHost"` - Task *TaskConfig `thrift:"task,4" json:"task"` - AssignedPorts map[string]int32 `thrift:"assignedPorts,5" json:"assignedPorts"` - InstanceId int32 `thrift:"instanceId,6" json:"instanceId"` -} - -func NewAssignedTask() *AssignedTask { - return &AssignedTask{} -} - -func (p *AssignedTask) GetTaskId() string { - return p.TaskId -} - -func (p *AssignedTask) GetSlaveId() string { - return p.SlaveId -} - -func (p *AssignedTask) GetSlaveHost() string { - return p.SlaveHost -} - -var AssignedTask_Task_DEFAULT *TaskConfig - -func (p *AssignedTask) GetTask() *TaskConfig { - if !p.IsSetTask() { - return AssignedTask_Task_DEFAULT - } - return p.Task -} - -func (p *AssignedTask) GetAssignedPorts() map[string]int32 { - return p.AssignedPorts -} - -func (p *AssignedTask) GetInstanceId() int32 { - return p.InstanceId -} -func (p *AssignedTask) IsSetTask() bool { - return p.Task != nil -} - -func (p *AssignedTask) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - case 5: - if err := p.readField5(iprot); err != nil { - return err - } - case 6: - if err := p.readField6(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *AssignedTask) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.TaskId = v - } - return nil -} - -func (p *AssignedTask) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.SlaveId = v - } - return nil -} - -func (p *AssignedTask) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.SlaveHost = v - } - return nil -} - -func (p *AssignedTask) readField4(iprot thrift.TProtocol) error { - p.Task = &TaskConfig{} - if err := p.Task.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Task), err) - } - return nil -} - -func (p *AssignedTask) readField5(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]int32, size) - p.AssignedPorts = tMap - for i := 0; i < size; i++ { - var _key14 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key14 = v - } - var _val15 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val15 = v - } - p.AssignedPorts[_key14] = _val15 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *AssignedTask) readField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 6: ", err) - } else { - p.InstanceId = v - } - return nil -} - -func (p *AssignedTask) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("AssignedTask"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := p.writeField5(oprot); err != nil { - return err - } - if err := p.writeField6(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *AssignedTask) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("taskId", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:taskId: ", p), err) - } - if err := oprot.WriteString(string(p.TaskId)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.taskId (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:taskId: ", p), err) - } - return err -} - -func (p *AssignedTask) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("slaveId", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:slaveId: ", p), err) - } - if err := oprot.WriteString(string(p.SlaveId)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.slaveId (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:slaveId: ", p), err) - } - return err -} - -func (p *AssignedTask) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("slaveHost", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:slaveHost: ", p), err) - } - if err := oprot.WriteString(string(p.SlaveHost)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.slaveHost (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:slaveHost: ", p), err) - } - return err -} - -func (p *AssignedTask) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("task", thrift.STRUCT, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:task: ", p), err) - } - if err := p.Task.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Task), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:task: ", p), err) - } - return err -} - -func (p *AssignedTask) writeField5(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("assignedPorts", thrift.MAP, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:assignedPorts: ", p), err) - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.I32, len(p.AssignedPorts)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.AssignedPorts { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:assignedPorts: ", p), err) - } - return err -} - -func (p *AssignedTask) writeField6(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instanceId", thrift.I32, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:instanceId: ", p), err) - } - if err := oprot.WriteI32(int32(p.InstanceId)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.instanceId (6) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:instanceId: ", p), err) - } - return err -} - -func (p *AssignedTask) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("AssignedTask(%+v)", *p) -} - -// A task that has been scheduled. -// -// Attributes: -// - AssignedTask: The task that was scheduled. -// - Status: The current status of this task. -// - FailureCount: The number of failures that this task has accumulated over the multi-generational history of -// this task. -// - TaskEvents: State change history for this task. -// - AncestorId: The task ID of the previous generation of this task. When a task is automatically rescheduled, -// a copy of the task is created and ancestor ID of the previous task's task ID. -type ScheduledTask struct { - AssignedTask *AssignedTask `thrift:"assignedTask,1" json:"assignedTask"` - Status ScheduleStatus `thrift:"status,2" json:"status"` - FailureCount int32 `thrift:"failureCount,3" json:"failureCount"` - TaskEvents []*TaskEvent `thrift:"taskEvents,4" json:"taskEvents"` - AncestorId string `thrift:"ancestorId,5" json:"ancestorId"` -} - -func NewScheduledTask() *ScheduledTask { - return &ScheduledTask{} -} - -var ScheduledTask_AssignedTask_DEFAULT *AssignedTask - -func (p *ScheduledTask) GetAssignedTask() *AssignedTask { - if !p.IsSetAssignedTask() { - return ScheduledTask_AssignedTask_DEFAULT - } - return p.AssignedTask -} - -func (p *ScheduledTask) GetStatus() ScheduleStatus { - return p.Status -} - -func (p *ScheduledTask) GetFailureCount() int32 { - return p.FailureCount -} - -func (p *ScheduledTask) GetTaskEvents() []*TaskEvent { - return p.TaskEvents -} - -func (p *ScheduledTask) GetAncestorId() string { - return p.AncestorId -} -func (p *ScheduledTask) IsSetAssignedTask() bool { - return p.AssignedTask != nil -} - -func (p *ScheduledTask) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - case 5: - if err := p.readField5(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ScheduledTask) readField1(iprot thrift.TProtocol) error { - p.AssignedTask = &AssignedTask{} - if err := p.AssignedTask.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.AssignedTask), err) - } - return nil -} - -func (p *ScheduledTask) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := ScheduleStatus(v) - p.Status = temp - } - return nil -} - -func (p *ScheduledTask) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.FailureCount = v - } - return nil -} - -func (p *ScheduledTask) readField4(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*TaskEvent, 0, size) - p.TaskEvents = tSlice - for i := 0; i < size; i++ { - _elem16 := &TaskEvent{} - if err := _elem16.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem16), err) - } - p.TaskEvents = append(p.TaskEvents, _elem16) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ScheduledTask) readField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.AncestorId = v - } - return nil -} - -func (p *ScheduledTask) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ScheduledTask"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := p.writeField5(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ScheduledTask) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("assignedTask", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:assignedTask: ", p), err) - } - if err := p.AssignedTask.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.AssignedTask), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:assignedTask: ", p), err) - } - return err -} - -func (p *ScheduledTask) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("status", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:status: ", p), err) - } - if err := oprot.WriteI32(int32(p.Status)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.status (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:status: ", p), err) - } - return err -} - -func (p *ScheduledTask) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("failureCount", thrift.I32, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:failureCount: ", p), err) - } - if err := oprot.WriteI32(int32(p.FailureCount)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.failureCount (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:failureCount: ", p), err) - } - return err -} - -func (p *ScheduledTask) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("taskEvents", thrift.LIST, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:taskEvents: ", p), err) - } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.TaskEvents)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.TaskEvents { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:taskEvents: ", p), err) - } - return err -} - -func (p *ScheduledTask) writeField5(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("ancestorId", thrift.STRING, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:ancestorId: ", p), err) - } - if err := oprot.WriteString(string(p.AncestorId)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.ancestorId (5) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:ancestorId: ", p), err) - } - return err -} - -func (p *ScheduledTask) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ScheduledTask(%+v)", *p) -} - -// Attributes: -// - Tasks -type ScheduleStatusResult_ struct { - Tasks []*ScheduledTask `thrift:"tasks,1" json:"tasks"` -} - -func NewScheduleStatusResult_() *ScheduleStatusResult_ { - return &ScheduleStatusResult_{} -} - -func (p *ScheduleStatusResult_) GetTasks() []*ScheduledTask { - return p.Tasks -} -func (p *ScheduleStatusResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ScheduleStatusResult_) readField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*ScheduledTask, 0, size) - p.Tasks = tSlice - for i := 0; i < size; i++ { - _elem17 := &ScheduledTask{} - if err := _elem17.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem17), err) - } - p.Tasks = append(p.Tasks, _elem17) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *ScheduleStatusResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ScheduleStatusResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ScheduleStatusResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("tasks", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:tasks: ", p), err) - } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Tasks)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Tasks { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:tasks: ", p), err) - } - return err -} - -func (p *ScheduleStatusResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ScheduleStatusResult_(%+v)", *p) -} - -// Attributes: -// - Configs -type GetJobsResult_ struct { - Configs map[*JobConfiguration]bool `thrift:"configs,1" json:"configs"` -} - -func NewGetJobsResult_() *GetJobsResult_ { - return &GetJobsResult_{} -} - -func (p *GetJobsResult_) GetConfigs() map[*JobConfiguration]bool { - return p.Configs -} -func (p *GetJobsResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetJobsResult_) readField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*JobConfiguration]bool, size) - p.Configs = tSet - for i := 0; i < size; i++ { - _elem18 := &JobConfiguration{} - if err := _elem18.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem18), err) - } - p.Configs[_elem18] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *GetJobsResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("GetJobsResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *GetJobsResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("configs", thrift.SET, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:configs: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Configs)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Configs { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:configs: ", p), err) - } - return err -} - -func (p *GetJobsResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("GetJobsResult_(%+v)", *p) -} - -// Contains a set of restrictions on matching tasks where all restrictions must be met -// (terms are AND'ed together). -// -// Attributes: -// - Role -// - Environment -// - JobName -// - TaskIds -// - Statuses -// - InstanceIds -// - SlaveHosts -// - JobKeys -// - Offset -// - Limit -type TaskQuery struct { - // unused field # 1 - JobName string `thrift:"jobName,2" json:"jobName"` - // unused field # 3 - TaskIds map[string]bool `thrift:"taskIds,4" json:"taskIds"` - Statuses map[ScheduleStatus]bool `thrift:"statuses,5" json:"statuses"` - // unused field # 6 - InstanceIds map[int32]bool `thrift:"instanceIds,7" json:"instanceIds"` - // unused field # 8 - Environment string `thrift:"environment,9" json:"environment"` - SlaveHosts map[string]bool `thrift:"slaveHosts,10" json:"slaveHosts"` - JobKeys map[*JobKey]bool `thrift:"jobKeys,11" json:"jobKeys"` - Offset int32 `thrift:"offset,12" json:"offset"` - Limit int32 `thrift:"limit,13" json:"limit"` - Role string `thrift:"role,14" json:"role"` -} - -func NewTaskQuery() *TaskQuery { - return &TaskQuery{} -} - -func (p *TaskQuery) GetRole() string { - return p.Role -} - -func (p *TaskQuery) GetEnvironment() string { - return p.Environment -} - -func (p *TaskQuery) GetJobName() string { - return p.JobName -} - -func (p *TaskQuery) GetTaskIds() map[string]bool { - return p.TaskIds -} - -func (p *TaskQuery) GetStatuses() map[ScheduleStatus]bool { - return p.Statuses -} - -func (p *TaskQuery) GetInstanceIds() map[int32]bool { - return p.InstanceIds -} - -func (p *TaskQuery) GetSlaveHosts() map[string]bool { - return p.SlaveHosts -} - -func (p *TaskQuery) GetJobKeys() map[*JobKey]bool { - return p.JobKeys -} - -func (p *TaskQuery) GetOffset() int32 { - return p.Offset -} - -func (p *TaskQuery) GetLimit() int32 { - return p.Limit -} -func (p *TaskQuery) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 14: - if err := p.readField14(iprot); err != nil { - return err - } - case 9: - if err := p.readField9(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - case 5: - if err := p.readField5(iprot); err != nil { - return err - } - case 7: - if err := p.readField7(iprot); err != nil { - return err - } - case 10: - if err := p.readField10(iprot); err != nil { - return err - } - case 11: - if err := p.readField11(iprot); err != nil { - return err - } - case 12: - if err := p.readField12(iprot); err != nil { - return err - } - case 13: - if err := p.readField13(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TaskQuery) readField14(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 14: ", err) - } else { - p.Role = v - } - return nil -} - -func (p *TaskQuery) readField9(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 9: ", err) - } else { - p.Environment = v - } - return nil -} - -func (p *TaskQuery) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.JobName = v - } - return nil -} - -func (p *TaskQuery) readField4(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[string]bool, size) - p.TaskIds = tSet - for i := 0; i < size; i++ { - var _elem19 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem19 = v - } - p.TaskIds[_elem19] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *TaskQuery) readField5(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[ScheduleStatus]bool, size) - p.Statuses = tSet - for i := 0; i < size; i++ { - var _elem20 ScheduleStatus - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - temp := ScheduleStatus(v) - _elem20 = temp - } - p.Statuses[_elem20] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *TaskQuery) readField7(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[int32]bool, size) - p.InstanceIds = tSet - for i := 0; i < size; i++ { - var _elem21 int32 - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem21 = v - } - p.InstanceIds[_elem21] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *TaskQuery) readField10(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[string]bool, size) - p.SlaveHosts = tSet - for i := 0; i < size; i++ { - var _elem22 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem22 = v - } - p.SlaveHosts[_elem22] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *TaskQuery) readField11(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*JobKey]bool, size) - p.JobKeys = tSet - for i := 0; i < size; i++ { - _elem23 := &JobKey{} - if err := _elem23.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem23), err) - } - p.JobKeys[_elem23] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *TaskQuery) readField12(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 12: ", err) - } else { - p.Offset = v - } - return nil -} - -func (p *TaskQuery) readField13(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 13: ", err) - } else { - p.Limit = v - } - return nil -} - -func (p *TaskQuery) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("TaskQuery"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := p.writeField5(oprot); err != nil { - return err - } - if err := p.writeField7(oprot); err != nil { - return err - } - if err := p.writeField9(oprot); err != nil { - return err - } - if err := p.writeField10(oprot); err != nil { - return err - } - if err := p.writeField11(oprot); err != nil { - return err - } - if err := p.writeField12(oprot); err != nil { - return err - } - if err := p.writeField13(oprot); err != nil { - return err - } - if err := p.writeField14(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *TaskQuery) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("jobName", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:jobName: ", p), err) - } - if err := oprot.WriteString(string(p.JobName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.jobName (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:jobName: ", p), err) - } - return err -} - -func (p *TaskQuery) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("taskIds", thrift.SET, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:taskIds: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.TaskIds)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.TaskIds { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:taskIds: ", p), err) - } - return err -} - -func (p *TaskQuery) writeField5(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("statuses", thrift.SET, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:statuses: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.I32, len(p.Statuses)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Statuses { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:statuses: ", p), err) - } - return err -} - -func (p *TaskQuery) writeField7(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instanceIds", thrift.SET, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:instanceIds: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.I32, len(p.InstanceIds)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.InstanceIds { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:instanceIds: ", p), err) - } - return err -} - -func (p *TaskQuery) writeField9(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("environment", thrift.STRING, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:environment: ", p), err) - } - if err := oprot.WriteString(string(p.Environment)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.environment (9) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:environment: ", p), err) - } - return err -} - -func (p *TaskQuery) writeField10(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("slaveHosts", thrift.SET, 10); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:slaveHosts: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.SlaveHosts)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.SlaveHosts { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 10:slaveHosts: ", p), err) - } - return err -} - -func (p *TaskQuery) writeField11(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("jobKeys", thrift.SET, 11); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:jobKeys: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.JobKeys)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.JobKeys { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 11:jobKeys: ", p), err) - } - return err -} - -func (p *TaskQuery) writeField12(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("offset", thrift.I32, 12); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 12:offset: ", p), err) - } - if err := oprot.WriteI32(int32(p.Offset)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.offset (12) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 12:offset: ", p), err) - } - return err -} - -func (p *TaskQuery) writeField13(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("limit", thrift.I32, 13); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 13:limit: ", p), err) - } - if err := oprot.WriteI32(int32(p.Limit)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.limit (13) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 13:limit: ", p), err) - } - return err -} - -func (p *TaskQuery) writeField14(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("role", thrift.STRING, 14); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 14:role: ", p), err) - } - if err := oprot.WriteString(string(p.Role)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.role (14) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 14:role: ", p), err) - } - return err -} - -func (p *TaskQuery) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("TaskQuery(%+v)", *p) -} - -// Attributes: -// - Host -// - Mode -type HostStatus struct { - Host string `thrift:"host,1" json:"host"` - Mode MaintenanceMode `thrift:"mode,2" json:"mode"` -} - -func NewHostStatus() *HostStatus { - return &HostStatus{} -} - -func (p *HostStatus) GetHost() string { - return p.Host -} - -func (p *HostStatus) GetMode() MaintenanceMode { - return p.Mode -} -func (p *HostStatus) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *HostStatus) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Host = v - } - return nil -} - -func (p *HostStatus) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - temp := MaintenanceMode(v) - p.Mode = temp - } - return nil -} - -func (p *HostStatus) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("HostStatus"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *HostStatus) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("host", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:host: ", p), err) - } - if err := oprot.WriteString(string(p.Host)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.host (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:host: ", p), err) - } - return err -} - -func (p *HostStatus) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("mode", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:mode: ", p), err) - } - if err := oprot.WriteI32(int32(p.Mode)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.mode (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:mode: ", p), err) - } - return err -} - -func (p *HostStatus) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("HostStatus(%+v)", *p) -} - -// Attributes: -// - Role -// - JobCount -// - CronJobCount -type RoleSummary struct { - Role string `thrift:"role,1" json:"role"` - JobCount int32 `thrift:"jobCount,2" json:"jobCount"` - CronJobCount int32 `thrift:"cronJobCount,3" json:"cronJobCount"` -} - -func NewRoleSummary() *RoleSummary { - return &RoleSummary{} -} - -func (p *RoleSummary) GetRole() string { - return p.Role -} - -func (p *RoleSummary) GetJobCount() int32 { - return p.JobCount -} - -func (p *RoleSummary) GetCronJobCount() int32 { - return p.CronJobCount -} -func (p *RoleSummary) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RoleSummary) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Role = v - } - return nil -} - -func (p *RoleSummary) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.JobCount = v - } - return nil -} - -func (p *RoleSummary) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.CronJobCount = v - } - return nil -} - -func (p *RoleSummary) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("RoleSummary"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *RoleSummary) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("role", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:role: ", p), err) - } - if err := oprot.WriteString(string(p.Role)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.role (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:role: ", p), err) - } - return err -} - -func (p *RoleSummary) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("jobCount", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:jobCount: ", p), err) - } - if err := oprot.WriteI32(int32(p.JobCount)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.jobCount (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:jobCount: ", p), err) - } - return err -} - -func (p *RoleSummary) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("cronJobCount", thrift.I32, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:cronJobCount: ", p), err) - } - if err := oprot.WriteI32(int32(p.CronJobCount)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.cronJobCount (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:cronJobCount: ", p), err) - } - return err -} - -func (p *RoleSummary) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("RoleSummary(%+v)", *p) -} - -// Attributes: -// - HostNames -type Hosts struct { - HostNames map[string]bool `thrift:"hostNames,1" json:"hostNames"` -} - -func NewHosts() *Hosts { - return &Hosts{} -} - -func (p *Hosts) GetHostNames() map[string]bool { - return p.HostNames -} -func (p *Hosts) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Hosts) readField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[string]bool, size) - p.HostNames = tSet - for i := 0; i < size; i++ { - var _elem24 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem24 = v - } - p.HostNames[_elem24] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *Hosts) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Hosts"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *Hosts) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("hostNames", thrift.SET, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:hostNames: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.HostNames)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.HostNames { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:hostNames: ", p), err) - } - return err -} - -func (p *Hosts) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Hosts(%+v)", *p) -} - -// Attributes: -// - TaskId -// - Reason -type PendingReason struct { - TaskId string `thrift:"taskId,1" json:"taskId"` - Reason string `thrift:"reason,2" json:"reason"` -} - -func NewPendingReason() *PendingReason { - return &PendingReason{} -} - -func (p *PendingReason) GetTaskId() string { - return p.TaskId -} - -func (p *PendingReason) GetReason() string { - return p.Reason -} -func (p *PendingReason) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *PendingReason) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.TaskId = v - } - return nil -} - -func (p *PendingReason) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Reason = v - } - return nil -} - -func (p *PendingReason) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("PendingReason"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *PendingReason) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("taskId", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:taskId: ", p), err) - } - if err := oprot.WriteString(string(p.TaskId)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.taskId (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:taskId: ", p), err) - } - return err -} - -func (p *PendingReason) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("reason", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:reason: ", p), err) - } - if err := oprot.WriteString(string(p.Reason)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.reason (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:reason: ", p), err) - } - return err -} - -func (p *PendingReason) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("PendingReason(%+v)", *p) -} - -// Job update key. -// -// Attributes: -// - Job: Job being updated -// - ID: Update ID. -type JobUpdateKey struct { - Job *JobKey `thrift:"job,1" json:"job"` - ID string `thrift:"id,2" json:"id"` -} - -func NewJobUpdateKey() *JobUpdateKey { - return &JobUpdateKey{} -} - -var JobUpdateKey_Job_DEFAULT *JobKey - -func (p *JobUpdateKey) GetJob() *JobKey { - if !p.IsSetJob() { - return JobUpdateKey_Job_DEFAULT - } - return p.Job -} - -func (p *JobUpdateKey) GetID() string { - return p.ID -} -func (p *JobUpdateKey) IsSetJob() bool { - return p.Job != nil -} - -func (p *JobUpdateKey) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *JobUpdateKey) readField1(iprot thrift.TProtocol) error { - p.Job = &JobKey{} - if err := p.Job.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Job), err) - } - return nil -} - -func (p *JobUpdateKey) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.ID = v - } - return nil -} - -func (p *JobUpdateKey) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateKey"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *JobUpdateKey) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("job", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:job: ", p), err) - } - if err := p.Job.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Job), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:job: ", p), err) - } - return err -} - -func (p *JobUpdateKey) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("id", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:id: ", p), err) - } - if err := oprot.WriteString(string(p.ID)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.id (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:id: ", p), err) - } - return err -} - -func (p *JobUpdateKey) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JobUpdateKey(%+v)", *p) -} - -// Job update thresholds and limits. -// -// Attributes: -// - UpdateGroupSize: Max number of instances being updated at any given moment. -// - MaxPerInstanceFailures: Max number of instance failures to tolerate before marking instance as FAILED. -// - MaxFailedInstances: Max number of FAILED instances to tolerate before terminating the update. -// - MinWaitInInstanceRunningMs: Min time to watch a RUNNING instance. -// - RollbackOnFailure: If true, enables failed update rollback. -// - UpdateOnlyTheseInstances: Instance IDs to act on. All instances will be affected if this is not set. -// - WaitForBatchCompletion: If true, use updateGroupSize as strict batching boundaries, and avoid proceeding to another -// batch until the preceding batch finishes updating. -// - BlockIfNoPulsesAfterMs: If set, requires external calls to pulseJobUpdate RPC within the specified rate for the -// update to make progress. If no pulses received within specified interval the update will -// block. A blocked update is unable to continue but retains its current status. It may only get -// unblocked by a fresh pulseJobUpdate call. -type JobUpdateSettings struct { - UpdateGroupSize int32 `thrift:"updateGroupSize,1" json:"updateGroupSize"` - MaxPerInstanceFailures int32 `thrift:"maxPerInstanceFailures,2" json:"maxPerInstanceFailures"` - MaxFailedInstances int32 `thrift:"maxFailedInstances,3" json:"maxFailedInstances"` - // unused field # 4 - MinWaitInInstanceRunningMs int32 `thrift:"minWaitInInstanceRunningMs,5" json:"minWaitInInstanceRunningMs"` - RollbackOnFailure bool `thrift:"rollbackOnFailure,6" json:"rollbackOnFailure"` - UpdateOnlyTheseInstances map[*Range]bool `thrift:"updateOnlyTheseInstances,7" json:"updateOnlyTheseInstances"` - WaitForBatchCompletion bool `thrift:"waitForBatchCompletion,8" json:"waitForBatchCompletion"` - BlockIfNoPulsesAfterMs *int32 `thrift:"blockIfNoPulsesAfterMs,9" json:"blockIfNoPulsesAfterMs,omitempty"` -} - -func NewJobUpdateSettings() *JobUpdateSettings { - return &JobUpdateSettings{} -} - -func (p *JobUpdateSettings) GetUpdateGroupSize() int32 { - return p.UpdateGroupSize -} - -func (p *JobUpdateSettings) GetMaxPerInstanceFailures() int32 { - return p.MaxPerInstanceFailures -} - -func (p *JobUpdateSettings) GetMaxFailedInstances() int32 { - return p.MaxFailedInstances -} - -func (p *JobUpdateSettings) GetMinWaitInInstanceRunningMs() int32 { - return p.MinWaitInInstanceRunningMs -} - -func (p *JobUpdateSettings) GetRollbackOnFailure() bool { - return p.RollbackOnFailure -} - -func (p *JobUpdateSettings) GetUpdateOnlyTheseInstances() map[*Range]bool { - return p.UpdateOnlyTheseInstances -} - -func (p *JobUpdateSettings) GetWaitForBatchCompletion() bool { - return p.WaitForBatchCompletion -} - -var JobUpdateSettings_BlockIfNoPulsesAfterMs_DEFAULT int32 - -func (p *JobUpdateSettings) GetBlockIfNoPulsesAfterMs() int32 { - if !p.IsSetBlockIfNoPulsesAfterMs() { - return JobUpdateSettings_BlockIfNoPulsesAfterMs_DEFAULT - } - return *p.BlockIfNoPulsesAfterMs -} -func (p *JobUpdateSettings) IsSetBlockIfNoPulsesAfterMs() bool { - return p.BlockIfNoPulsesAfterMs != nil -} - -func (p *JobUpdateSettings) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 5: - if err := p.readField5(iprot); err != nil { - return err - } - case 6: - if err := p.readField6(iprot); err != nil { - return err - } - case 7: - if err := p.readField7(iprot); err != nil { - return err - } - case 8: - if err := p.readField8(iprot); err != nil { - return err - } - case 9: - if err := p.readField9(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *JobUpdateSettings) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.UpdateGroupSize = v - } - return nil -} - -func (p *JobUpdateSettings) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.MaxPerInstanceFailures = v - } - return nil -} - -func (p *JobUpdateSettings) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.MaxFailedInstances = v - } - return nil -} - -func (p *JobUpdateSettings) readField5(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 5: ", err) - } else { - p.MinWaitInInstanceRunningMs = v - } - return nil -} - -func (p *JobUpdateSettings) readField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 6: ", err) - } else { - p.RollbackOnFailure = v - } - return nil -} - -func (p *JobUpdateSettings) readField7(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*Range]bool, size) - p.UpdateOnlyTheseInstances = tSet - for i := 0; i < size; i++ { - _elem25 := &Range{} - if err := _elem25.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem25), err) - } - p.UpdateOnlyTheseInstances[_elem25] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *JobUpdateSettings) readField8(iprot thrift.TProtocol) error { - if v, err := iprot.ReadBool(); err != nil { - return thrift.PrependError("error reading field 8: ", err) - } else { - p.WaitForBatchCompletion = v - } - return nil -} - -func (p *JobUpdateSettings) readField9(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 9: ", err) - } else { - p.BlockIfNoPulsesAfterMs = &v - } - return nil -} - -func (p *JobUpdateSettings) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateSettings"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField5(oprot); err != nil { - return err - } - if err := p.writeField6(oprot); err != nil { - return err - } - if err := p.writeField7(oprot); err != nil { - return err - } - if err := p.writeField8(oprot); err != nil { - return err - } - if err := p.writeField9(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *JobUpdateSettings) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("updateGroupSize", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:updateGroupSize: ", p), err) - } - if err := oprot.WriteI32(int32(p.UpdateGroupSize)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.updateGroupSize (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:updateGroupSize: ", p), err) - } - return err -} - -func (p *JobUpdateSettings) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("maxPerInstanceFailures", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:maxPerInstanceFailures: ", p), err) - } - if err := oprot.WriteI32(int32(p.MaxPerInstanceFailures)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.maxPerInstanceFailures (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:maxPerInstanceFailures: ", p), err) - } - return err -} - -func (p *JobUpdateSettings) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("maxFailedInstances", thrift.I32, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:maxFailedInstances: ", p), err) - } - if err := oprot.WriteI32(int32(p.MaxFailedInstances)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.maxFailedInstances (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:maxFailedInstances: ", p), err) - } - return err -} - -func (p *JobUpdateSettings) writeField5(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("minWaitInInstanceRunningMs", thrift.I32, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:minWaitInInstanceRunningMs: ", p), err) - } - if err := oprot.WriteI32(int32(p.MinWaitInInstanceRunningMs)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.minWaitInInstanceRunningMs (5) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:minWaitInInstanceRunningMs: ", p), err) - } - return err -} - -func (p *JobUpdateSettings) writeField6(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("rollbackOnFailure", thrift.BOOL, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:rollbackOnFailure: ", p), err) - } - if err := oprot.WriteBool(bool(p.RollbackOnFailure)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.rollbackOnFailure (6) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:rollbackOnFailure: ", p), err) - } - return err -} - -func (p *JobUpdateSettings) writeField7(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("updateOnlyTheseInstances", thrift.SET, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:updateOnlyTheseInstances: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.UpdateOnlyTheseInstances)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.UpdateOnlyTheseInstances { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:updateOnlyTheseInstances: ", p), err) - } - return err -} - -func (p *JobUpdateSettings) writeField8(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("waitForBatchCompletion", thrift.BOOL, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:waitForBatchCompletion: ", p), err) - } - if err := oprot.WriteBool(bool(p.WaitForBatchCompletion)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.waitForBatchCompletion (8) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:waitForBatchCompletion: ", p), err) - } - return err -} - -func (p *JobUpdateSettings) writeField9(oprot thrift.TProtocol) (err error) { - if p.IsSetBlockIfNoPulsesAfterMs() { - if err := oprot.WriteFieldBegin("blockIfNoPulsesAfterMs", thrift.I32, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:blockIfNoPulsesAfterMs: ", p), err) - } - if err := oprot.WriteI32(int32(*p.BlockIfNoPulsesAfterMs)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.blockIfNoPulsesAfterMs (9) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:blockIfNoPulsesAfterMs: ", p), err) - } - } - return err -} - -func (p *JobUpdateSettings) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JobUpdateSettings(%+v)", *p) -} - -// Event marking a state transition in job update lifecycle. -// -// Attributes: -// - Status: Update status. -// - TimestampMs: Epoch timestamp in milliseconds. -// - User: User who performed this event (if user-initiated). -// - Message: Message from the user (for user-initiated transitions) or the scheduler about why the state was -// changed. -type JobUpdateEvent struct { - Status JobUpdateStatus `thrift:"status,1" json:"status"` - TimestampMs int64 `thrift:"timestampMs,2" json:"timestampMs"` - User *string `thrift:"user,3" json:"user,omitempty"` - Message *string `thrift:"message,4" json:"message,omitempty"` -} - -func NewJobUpdateEvent() *JobUpdateEvent { - return &JobUpdateEvent{} -} - -func (p *JobUpdateEvent) GetStatus() JobUpdateStatus { - return p.Status -} - -func (p *JobUpdateEvent) GetTimestampMs() int64 { - return p.TimestampMs -} - -var JobUpdateEvent_User_DEFAULT string - -func (p *JobUpdateEvent) GetUser() string { - if !p.IsSetUser() { - return JobUpdateEvent_User_DEFAULT - } - return *p.User -} - -var JobUpdateEvent_Message_DEFAULT string - -func (p *JobUpdateEvent) GetMessage() string { - if !p.IsSetMessage() { - return JobUpdateEvent_Message_DEFAULT - } - return *p.Message -} -func (p *JobUpdateEvent) IsSetUser() bool { - return p.User != nil -} - -func (p *JobUpdateEvent) IsSetMessage() bool { - return p.Message != nil -} - -func (p *JobUpdateEvent) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *JobUpdateEvent) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := JobUpdateStatus(v) - p.Status = temp - } - return nil -} - -func (p *JobUpdateEvent) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.TimestampMs = v - } - return nil -} - -func (p *JobUpdateEvent) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.User = &v - } - return nil -} - -func (p *JobUpdateEvent) readField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.Message = &v - } - return nil -} - -func (p *JobUpdateEvent) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateEvent"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *JobUpdateEvent) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("status", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:status: ", p), err) - } - if err := oprot.WriteI32(int32(p.Status)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.status (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:status: ", p), err) - } - return err -} - -func (p *JobUpdateEvent) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("timestampMs", thrift.I64, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:timestampMs: ", p), err) - } - if err := oprot.WriteI64(int64(p.TimestampMs)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.timestampMs (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:timestampMs: ", p), err) - } - return err -} - -func (p *JobUpdateEvent) writeField3(oprot thrift.TProtocol) (err error) { - if p.IsSetUser() { - if err := oprot.WriteFieldBegin("user", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:user: ", p), err) - } - if err := oprot.WriteString(string(*p.User)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.user (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:user: ", p), err) - } - } - return err -} - -func (p *JobUpdateEvent) writeField4(oprot thrift.TProtocol) (err error) { - if p.IsSetMessage() { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:message: ", p), err) - } - if err := oprot.WriteString(string(*p.Message)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.message (4) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:message: ", p), err) - } - } - return err -} - -func (p *JobUpdateEvent) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JobUpdateEvent(%+v)", *p) -} - -// Event marking a state transition in job instance update lifecycle. -// -// Attributes: -// - InstanceId: Job instance ID. -// - TimestampMs: Epoch timestamp in milliseconds. -// - Action: Job update action taken on the instance. -type JobInstanceUpdateEvent struct { - InstanceId int32 `thrift:"instanceId,1" json:"instanceId"` - TimestampMs int64 `thrift:"timestampMs,2" json:"timestampMs"` - Action JobUpdateAction `thrift:"action,3" json:"action"` -} - -func NewJobInstanceUpdateEvent() *JobInstanceUpdateEvent { - return &JobInstanceUpdateEvent{} -} - -func (p *JobInstanceUpdateEvent) GetInstanceId() int32 { - return p.InstanceId -} - -func (p *JobInstanceUpdateEvent) GetTimestampMs() int64 { - return p.TimestampMs -} - -func (p *JobInstanceUpdateEvent) GetAction() JobUpdateAction { - return p.Action -} -func (p *JobInstanceUpdateEvent) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *JobInstanceUpdateEvent) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.InstanceId = v - } - return nil -} - -func (p *JobInstanceUpdateEvent) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.TimestampMs = v - } - return nil -} - -func (p *JobInstanceUpdateEvent) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - temp := JobUpdateAction(v) - p.Action = temp - } - return nil -} - -func (p *JobInstanceUpdateEvent) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobInstanceUpdateEvent"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *JobInstanceUpdateEvent) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instanceId", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:instanceId: ", p), err) - } - if err := oprot.WriteI32(int32(p.InstanceId)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.instanceId (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:instanceId: ", p), err) - } - return err -} - -func (p *JobInstanceUpdateEvent) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("timestampMs", thrift.I64, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:timestampMs: ", p), err) - } - if err := oprot.WriteI64(int64(p.TimestampMs)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.timestampMs (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:timestampMs: ", p), err) - } - return err -} - -func (p *JobInstanceUpdateEvent) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("action", thrift.I32, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:action: ", p), err) - } - if err := oprot.WriteI32(int32(p.Action)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.action (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:action: ", p), err) - } - return err -} - -func (p *JobInstanceUpdateEvent) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JobInstanceUpdateEvent(%+v)", *p) -} - -// Maps instance IDs to TaskConfigs it. -// -// Attributes: -// - Task: A TaskConfig associated with instances. -// - Instances: Instances associated with the TaskConfig. -type InstanceTaskConfig struct { - Task *TaskConfig `thrift:"task,1" json:"task"` - Instances map[*Range]bool `thrift:"instances,2" json:"instances"` -} - -func NewInstanceTaskConfig() *InstanceTaskConfig { - return &InstanceTaskConfig{} -} - -var InstanceTaskConfig_Task_DEFAULT *TaskConfig - -func (p *InstanceTaskConfig) GetTask() *TaskConfig { - if !p.IsSetTask() { - return InstanceTaskConfig_Task_DEFAULT - } - return p.Task -} - -func (p *InstanceTaskConfig) GetInstances() map[*Range]bool { - return p.Instances -} -func (p *InstanceTaskConfig) IsSetTask() bool { - return p.Task != nil -} - -func (p *InstanceTaskConfig) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *InstanceTaskConfig) readField1(iprot thrift.TProtocol) error { - p.Task = &TaskConfig{} - if err := p.Task.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Task), err) - } - return nil -} - -func (p *InstanceTaskConfig) readField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*Range]bool, size) - p.Instances = tSet - for i := 0; i < size; i++ { - _elem26 := &Range{} - if err := _elem26.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem26), err) - } - p.Instances[_elem26] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *InstanceTaskConfig) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("InstanceTaskConfig"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *InstanceTaskConfig) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("task", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:task: ", p), err) - } - if err := p.Task.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Task), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:task: ", p), err) - } - return err -} - -func (p *InstanceTaskConfig) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instances", thrift.SET, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:instances: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Instances)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Instances { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:instances: ", p), err) - } - return err -} - -func (p *InstanceTaskConfig) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("InstanceTaskConfig(%+v)", *p) -} - -// Current job update state including status and created/modified timestamps. -// -// Attributes: -// - Status: Current status of the update. -// - CreatedTimestampMs: Created timestamp in milliseconds. -// - LastModifiedTimestampMs: Last modified timestamp in milliseconds. -type JobUpdateState struct { - Status JobUpdateStatus `thrift:"status,1" json:"status"` - CreatedTimestampMs int64 `thrift:"createdTimestampMs,2" json:"createdTimestampMs"` - LastModifiedTimestampMs int64 `thrift:"lastModifiedTimestampMs,3" json:"lastModifiedTimestampMs"` -} - -func NewJobUpdateState() *JobUpdateState { - return &JobUpdateState{} -} - -func (p *JobUpdateState) GetStatus() JobUpdateStatus { - return p.Status -} - -func (p *JobUpdateState) GetCreatedTimestampMs() int64 { - return p.CreatedTimestampMs -} - -func (p *JobUpdateState) GetLastModifiedTimestampMs() int64 { - return p.LastModifiedTimestampMs -} -func (p *JobUpdateState) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *JobUpdateState) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := JobUpdateStatus(v) - p.Status = temp - } - return nil -} - -func (p *JobUpdateState) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.CreatedTimestampMs = v - } - return nil -} - -func (p *JobUpdateState) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI64(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.LastModifiedTimestampMs = v - } - return nil -} - -func (p *JobUpdateState) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateState"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *JobUpdateState) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("status", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:status: ", p), err) - } - if err := oprot.WriteI32(int32(p.Status)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.status (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:status: ", p), err) - } - return err -} - -func (p *JobUpdateState) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("createdTimestampMs", thrift.I64, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:createdTimestampMs: ", p), err) - } - if err := oprot.WriteI64(int64(p.CreatedTimestampMs)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.createdTimestampMs (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:createdTimestampMs: ", p), err) - } - return err -} - -func (p *JobUpdateState) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("lastModifiedTimestampMs", thrift.I64, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:lastModifiedTimestampMs: ", p), err) - } - if err := oprot.WriteI64(int64(p.LastModifiedTimestampMs)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.lastModifiedTimestampMs (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:lastModifiedTimestampMs: ", p), err) - } - return err -} - -func (p *JobUpdateState) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JobUpdateState(%+v)", *p) -} - -// Summary of the job update including job key, user and current state. -// -// Attributes: -// - Key: Unique identifier for the update. -// - User: User initiated an update. -// - State: Current job update state. -// - Metadata: Update metadata supplied by the client. -type JobUpdateSummary struct { - // unused fields # 1 to 2 - User string `thrift:"user,3" json:"user"` - State *JobUpdateState `thrift:"state,4" json:"state"` - Key *JobUpdateKey `thrift:"key,5" json:"key"` - Metadata map[*Metadata]bool `thrift:"metadata,6" json:"metadata,omitempty"` -} - -func NewJobUpdateSummary() *JobUpdateSummary { - return &JobUpdateSummary{} -} - -var JobUpdateSummary_Key_DEFAULT *JobUpdateKey - -func (p *JobUpdateSummary) GetKey() *JobUpdateKey { - if !p.IsSetKey() { - return JobUpdateSummary_Key_DEFAULT - } - return p.Key -} - -func (p *JobUpdateSummary) GetUser() string { - return p.User -} - -var JobUpdateSummary_State_DEFAULT *JobUpdateState - -func (p *JobUpdateSummary) GetState() *JobUpdateState { - if !p.IsSetState() { - return JobUpdateSummary_State_DEFAULT - } - return p.State -} - -var JobUpdateSummary_Metadata_DEFAULT map[*Metadata]bool - -func (p *JobUpdateSummary) GetMetadata() map[*Metadata]bool { - return p.Metadata -} -func (p *JobUpdateSummary) IsSetKey() bool { - return p.Key != nil -} - -func (p *JobUpdateSummary) IsSetState() bool { - return p.State != nil -} - -func (p *JobUpdateSummary) IsSetMetadata() bool { - return p.Metadata != nil -} - -func (p *JobUpdateSummary) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 5: - if err := p.readField5(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - case 6: - if err := p.readField6(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *JobUpdateSummary) readField5(iprot thrift.TProtocol) error { - p.Key = &JobUpdateKey{} - if err := p.Key.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) - } - return nil -} - -func (p *JobUpdateSummary) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.User = v - } - return nil -} - -func (p *JobUpdateSummary) readField4(iprot thrift.TProtocol) error { - p.State = &JobUpdateState{} - if err := p.State.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.State), err) - } - return nil -} - -func (p *JobUpdateSummary) readField6(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*Metadata]bool, size) - p.Metadata = tSet - for i := 0; i < size; i++ { - _elem27 := &Metadata{} - if err := _elem27.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem27), err) - } - p.Metadata[_elem27] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *JobUpdateSummary) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateSummary"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := p.writeField5(oprot); err != nil { - return err - } - if err := p.writeField6(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *JobUpdateSummary) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("user", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:user: ", p), err) - } - if err := oprot.WriteString(string(p.User)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.user (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:user: ", p), err) - } - return err -} - -func (p *JobUpdateSummary) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("state", thrift.STRUCT, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:state: ", p), err) - } - if err := p.State.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.State), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:state: ", p), err) - } - return err -} - -func (p *JobUpdateSummary) writeField5(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRUCT, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:key: ", p), err) - } - if err := p.Key.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:key: ", p), err) - } - return err -} - -func (p *JobUpdateSummary) writeField6(oprot thrift.TProtocol) (err error) { - if p.IsSetMetadata() { - if err := oprot.WriteFieldBegin("metadata", thrift.SET, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:metadata: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Metadata)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Metadata { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:metadata: ", p), err) - } - } - return err -} - -func (p *JobUpdateSummary) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JobUpdateSummary(%+v)", *p) -} - -// Update configuration and setting details. -// -// Attributes: -// - InitialState: Actual InstanceId -> TaskConfig mapping when the update was requested. -// - DesiredState: Desired configuration when the update completes. -// - Settings: Update specific settings. -type JobUpdateInstructions struct { - InitialState map[*InstanceTaskConfig]bool `thrift:"initialState,1" json:"initialState"` - DesiredState *InstanceTaskConfig `thrift:"desiredState,2" json:"desiredState"` - Settings *JobUpdateSettings `thrift:"settings,3" json:"settings"` -} - -func NewJobUpdateInstructions() *JobUpdateInstructions { - return &JobUpdateInstructions{} -} - -func (p *JobUpdateInstructions) GetInitialState() map[*InstanceTaskConfig]bool { - return p.InitialState -} - -var JobUpdateInstructions_DesiredState_DEFAULT *InstanceTaskConfig - -func (p *JobUpdateInstructions) GetDesiredState() *InstanceTaskConfig { - if !p.IsSetDesiredState() { - return JobUpdateInstructions_DesiredState_DEFAULT - } - return p.DesiredState -} - -var JobUpdateInstructions_Settings_DEFAULT *JobUpdateSettings - -func (p *JobUpdateInstructions) GetSettings() *JobUpdateSettings { - if !p.IsSetSettings() { - return JobUpdateInstructions_Settings_DEFAULT - } - return p.Settings -} -func (p *JobUpdateInstructions) IsSetDesiredState() bool { - return p.DesiredState != nil -} - -func (p *JobUpdateInstructions) IsSetSettings() bool { - return p.Settings != nil -} - -func (p *JobUpdateInstructions) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *JobUpdateInstructions) readField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*InstanceTaskConfig]bool, size) - p.InitialState = tSet - for i := 0; i < size; i++ { - _elem28 := &InstanceTaskConfig{} - if err := _elem28.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem28), err) - } - p.InitialState[_elem28] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *JobUpdateInstructions) readField2(iprot thrift.TProtocol) error { - p.DesiredState = &InstanceTaskConfig{} - if err := p.DesiredState.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.DesiredState), err) - } - return nil -} - -func (p *JobUpdateInstructions) readField3(iprot thrift.TProtocol) error { - p.Settings = &JobUpdateSettings{} - if err := p.Settings.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Settings), err) - } - return nil -} - -func (p *JobUpdateInstructions) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateInstructions"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *JobUpdateInstructions) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("initialState", thrift.SET, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:initialState: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.InitialState)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.InitialState { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:initialState: ", p), err) - } - return err -} - -func (p *JobUpdateInstructions) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("desiredState", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:desiredState: ", p), err) - } - if err := p.DesiredState.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.DesiredState), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:desiredState: ", p), err) - } - return err -} - -func (p *JobUpdateInstructions) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("settings", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:settings: ", p), err) - } - if err := p.Settings.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Settings), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:settings: ", p), err) - } - return err -} - -func (p *JobUpdateInstructions) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JobUpdateInstructions(%+v)", *p) -} - -// Full definition of the job update. -// -// Attributes: -// - Summary: Update summary. -// - Instructions: Update configuration. -type JobUpdate struct { - Summary *JobUpdateSummary `thrift:"summary,1" json:"summary"` - Instructions *JobUpdateInstructions `thrift:"instructions,2" json:"instructions"` -} - -func NewJobUpdate() *JobUpdate { - return &JobUpdate{} -} - -var JobUpdate_Summary_DEFAULT *JobUpdateSummary - -func (p *JobUpdate) GetSummary() *JobUpdateSummary { - if !p.IsSetSummary() { - return JobUpdate_Summary_DEFAULT - } - return p.Summary -} - -var JobUpdate_Instructions_DEFAULT *JobUpdateInstructions - -func (p *JobUpdate) GetInstructions() *JobUpdateInstructions { - if !p.IsSetInstructions() { - return JobUpdate_Instructions_DEFAULT - } - return p.Instructions -} -func (p *JobUpdate) IsSetSummary() bool { - return p.Summary != nil -} - -func (p *JobUpdate) IsSetInstructions() bool { - return p.Instructions != nil -} - -func (p *JobUpdate) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *JobUpdate) readField1(iprot thrift.TProtocol) error { - p.Summary = &JobUpdateSummary{} - if err := p.Summary.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Summary), err) - } - return nil -} - -func (p *JobUpdate) readField2(iprot thrift.TProtocol) error { - p.Instructions = &JobUpdateInstructions{} - if err := p.Instructions.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Instructions), err) - } - return nil -} - -func (p *JobUpdate) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdate"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *JobUpdate) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("summary", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:summary: ", p), err) - } - if err := p.Summary.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Summary), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:summary: ", p), err) - } - return err -} - -func (p *JobUpdate) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instructions", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:instructions: ", p), err) - } - if err := p.Instructions.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Instructions), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:instructions: ", p), err) - } - return err -} - -func (p *JobUpdate) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JobUpdate(%+v)", *p) -} - -// Attributes: -// - Update: Update definition. -// - UpdateEvents: History for this update. -// - InstanceEvents: History for the individual instances updated. -type JobUpdateDetails struct { - Update *JobUpdate `thrift:"update,1" json:"update"` - UpdateEvents []*JobUpdateEvent `thrift:"updateEvents,2" json:"updateEvents"` - InstanceEvents []*JobInstanceUpdateEvent `thrift:"instanceEvents,3" json:"instanceEvents"` -} - -func NewJobUpdateDetails() *JobUpdateDetails { - return &JobUpdateDetails{} -} - -var JobUpdateDetails_Update_DEFAULT *JobUpdate - -func (p *JobUpdateDetails) GetUpdate() *JobUpdate { - if !p.IsSetUpdate() { - return JobUpdateDetails_Update_DEFAULT - } - return p.Update -} - -func (p *JobUpdateDetails) GetUpdateEvents() []*JobUpdateEvent { - return p.UpdateEvents -} - -func (p *JobUpdateDetails) GetInstanceEvents() []*JobInstanceUpdateEvent { - return p.InstanceEvents -} -func (p *JobUpdateDetails) IsSetUpdate() bool { - return p.Update != nil -} - -func (p *JobUpdateDetails) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *JobUpdateDetails) readField1(iprot thrift.TProtocol) error { - p.Update = &JobUpdate{} - if err := p.Update.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Update), err) - } - return nil -} - -func (p *JobUpdateDetails) readField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*JobUpdateEvent, 0, size) - p.UpdateEvents = tSlice - for i := 0; i < size; i++ { - _elem29 := &JobUpdateEvent{} - if err := _elem29.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem29), err) - } - p.UpdateEvents = append(p.UpdateEvents, _elem29) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *JobUpdateDetails) readField3(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*JobInstanceUpdateEvent, 0, size) - p.InstanceEvents = tSlice - for i := 0; i < size; i++ { - _elem30 := &JobInstanceUpdateEvent{} - if err := _elem30.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem30), err) - } - p.InstanceEvents = append(p.InstanceEvents, _elem30) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *JobUpdateDetails) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateDetails"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *JobUpdateDetails) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("update", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:update: ", p), err) - } - if err := p.Update.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Update), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:update: ", p), err) - } - return err -} - -func (p *JobUpdateDetails) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("updateEvents", thrift.LIST, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:updateEvents: ", p), err) - } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.UpdateEvents)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.UpdateEvents { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:updateEvents: ", p), err) - } - return err -} - -func (p *JobUpdateDetails) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instanceEvents", thrift.LIST, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:instanceEvents: ", p), err) - } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.InstanceEvents)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.InstanceEvents { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:instanceEvents: ", p), err) - } - return err -} - -func (p *JobUpdateDetails) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JobUpdateDetails(%+v)", *p) -} - -// A request to update the following instances of an existing job. Used by startUpdate. -// -// Attributes: -// - TaskConfig: Desired TaskConfig to apply. -// - InstanceCount: Desired number of instances of the task config. -// - Settings: Update settings and limits. -// - Metadata: Update metadata supplied by the client issuing the JobUpdateRequest. -type JobUpdateRequest struct { - TaskConfig *TaskConfig `thrift:"taskConfig,1" json:"taskConfig"` - InstanceCount int32 `thrift:"instanceCount,2" json:"instanceCount"` - Settings *JobUpdateSettings `thrift:"settings,3" json:"settings"` - Metadata map[*Metadata]bool `thrift:"metadata,4" json:"metadata,omitempty"` -} - -func NewJobUpdateRequest() *JobUpdateRequest { - return &JobUpdateRequest{} -} - -var JobUpdateRequest_TaskConfig_DEFAULT *TaskConfig - -func (p *JobUpdateRequest) GetTaskConfig() *TaskConfig { - if !p.IsSetTaskConfig() { - return JobUpdateRequest_TaskConfig_DEFAULT - } - return p.TaskConfig -} - -func (p *JobUpdateRequest) GetInstanceCount() int32 { - return p.InstanceCount -} - -var JobUpdateRequest_Settings_DEFAULT *JobUpdateSettings - -func (p *JobUpdateRequest) GetSettings() *JobUpdateSettings { - if !p.IsSetSettings() { - return JobUpdateRequest_Settings_DEFAULT - } - return p.Settings -} - -var JobUpdateRequest_Metadata_DEFAULT map[*Metadata]bool - -func (p *JobUpdateRequest) GetMetadata() map[*Metadata]bool { - return p.Metadata -} -func (p *JobUpdateRequest) IsSetTaskConfig() bool { - return p.TaskConfig != nil -} - -func (p *JobUpdateRequest) IsSetSettings() bool { - return p.Settings != nil -} - -func (p *JobUpdateRequest) IsSetMetadata() bool { - return p.Metadata != nil -} - -func (p *JobUpdateRequest) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *JobUpdateRequest) readField1(iprot thrift.TProtocol) error { - p.TaskConfig = &TaskConfig{} - if err := p.TaskConfig.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.TaskConfig), err) - } - return nil -} - -func (p *JobUpdateRequest) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.InstanceCount = v - } - return nil -} - -func (p *JobUpdateRequest) readField3(iprot thrift.TProtocol) error { - p.Settings = &JobUpdateSettings{} - if err := p.Settings.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Settings), err) - } - return nil -} - -func (p *JobUpdateRequest) readField4(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*Metadata]bool, size) - p.Metadata = tSet - for i := 0; i < size; i++ { - _elem31 := &Metadata{} - if err := _elem31.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem31), err) - } - p.Metadata[_elem31] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *JobUpdateRequest) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateRequest"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *JobUpdateRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("taskConfig", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:taskConfig: ", p), err) - } - if err := p.TaskConfig.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.TaskConfig), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:taskConfig: ", p), err) - } - return err -} - -func (p *JobUpdateRequest) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instanceCount", thrift.I32, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:instanceCount: ", p), err) - } - if err := oprot.WriteI32(int32(p.InstanceCount)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.instanceCount (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:instanceCount: ", p), err) - } - return err -} - -func (p *JobUpdateRequest) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("settings", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:settings: ", p), err) - } - if err := p.Settings.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Settings), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:settings: ", p), err) - } - return err -} - -func (p *JobUpdateRequest) writeField4(oprot thrift.TProtocol) (err error) { - if p.IsSetMetadata() { - if err := oprot.WriteFieldBegin("metadata", thrift.SET, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:metadata: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Metadata)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Metadata { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:metadata: ", p), err) - } - } - return err -} - -func (p *JobUpdateRequest) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JobUpdateRequest(%+v)", *p) -} - -// Contains a set of restrictions on matching job updates where all restrictions must be met -// (terms are AND'ed together). -// -// Attributes: -// - Role: Job role. -// - Key: Unique identifier for a job update. -// - JobKey: Job key. -// - User: User who created the update. -// - UpdateStatuses: Set of update statuses. -// - Offset: Offset to serve data from. Used by pagination. -// - Limit: Number or records to serve. Used by pagination. -type JobUpdateQuery struct { - // unused field # 1 - Role *string `thrift:"role,2" json:"role,omitempty"` - JobKey *JobKey `thrift:"jobKey,3" json:"jobKey,omitempty"` - User *string `thrift:"user,4" json:"user,omitempty"` - UpdateStatuses map[JobUpdateStatus]bool `thrift:"updateStatuses,5" json:"updateStatuses,omitempty"` - Offset int32 `thrift:"offset,6" json:"offset"` - Limit int32 `thrift:"limit,7" json:"limit"` - Key *JobUpdateKey `thrift:"key,8" json:"key,omitempty"` -} - -func NewJobUpdateQuery() *JobUpdateQuery { - return &JobUpdateQuery{} -} - -var JobUpdateQuery_Role_DEFAULT string - -func (p *JobUpdateQuery) GetRole() string { - if !p.IsSetRole() { - return JobUpdateQuery_Role_DEFAULT - } - return *p.Role -} - -var JobUpdateQuery_Key_DEFAULT *JobUpdateKey - -func (p *JobUpdateQuery) GetKey() *JobUpdateKey { - if !p.IsSetKey() { - return JobUpdateQuery_Key_DEFAULT - } - return p.Key -} - -var JobUpdateQuery_JobKey_DEFAULT *JobKey - -func (p *JobUpdateQuery) GetJobKey() *JobKey { - if !p.IsSetJobKey() { - return JobUpdateQuery_JobKey_DEFAULT - } - return p.JobKey -} - -var JobUpdateQuery_User_DEFAULT string - -func (p *JobUpdateQuery) GetUser() string { - if !p.IsSetUser() { - return JobUpdateQuery_User_DEFAULT - } - return *p.User -} - -var JobUpdateQuery_UpdateStatuses_DEFAULT map[JobUpdateStatus]bool - -func (p *JobUpdateQuery) GetUpdateStatuses() map[JobUpdateStatus]bool { - return p.UpdateStatuses -} - -func (p *JobUpdateQuery) GetOffset() int32 { - return p.Offset -} - -func (p *JobUpdateQuery) GetLimit() int32 { - return p.Limit -} -func (p *JobUpdateQuery) IsSetRole() bool { - return p.Role != nil -} - -func (p *JobUpdateQuery) IsSetKey() bool { - return p.Key != nil -} - -func (p *JobUpdateQuery) IsSetJobKey() bool { - return p.JobKey != nil -} - -func (p *JobUpdateQuery) IsSetUser() bool { - return p.User != nil -} - -func (p *JobUpdateQuery) IsSetUpdateStatuses() bool { - return p.UpdateStatuses != nil -} - -func (p *JobUpdateQuery) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 8: - if err := p.readField8(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - case 5: - if err := p.readField5(iprot); err != nil { - return err - } - case 6: - if err := p.readField6(iprot); err != nil { - return err - } - case 7: - if err := p.readField7(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *JobUpdateQuery) readField2(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 2: ", err) - } else { - p.Role = &v - } - return nil -} - -func (p *JobUpdateQuery) readField8(iprot thrift.TProtocol) error { - p.Key = &JobUpdateKey{} - if err := p.Key.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) - } - return nil -} - -func (p *JobUpdateQuery) readField3(iprot thrift.TProtocol) error { - p.JobKey = &JobKey{} - if err := p.JobKey.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.JobKey), err) - } - return nil -} - -func (p *JobUpdateQuery) readField4(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 4: ", err) - } else { - p.User = &v - } - return nil -} - -func (p *JobUpdateQuery) readField5(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[JobUpdateStatus]bool, size) - p.UpdateStatuses = tSet - for i := 0; i < size; i++ { - var _elem32 JobUpdateStatus - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - temp := JobUpdateStatus(v) - _elem32 = temp - } - p.UpdateStatuses[_elem32] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *JobUpdateQuery) readField6(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 6: ", err) - } else { - p.Offset = v - } - return nil -} - -func (p *JobUpdateQuery) readField7(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 7: ", err) - } else { - p.Limit = v - } - return nil -} - -func (p *JobUpdateQuery) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobUpdateQuery"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := p.writeField5(oprot); err != nil { - return err - } - if err := p.writeField6(oprot); err != nil { - return err - } - if err := p.writeField7(oprot); err != nil { - return err - } - if err := p.writeField8(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *JobUpdateQuery) writeField2(oprot thrift.TProtocol) (err error) { - if p.IsSetRole() { - if err := oprot.WriteFieldBegin("role", thrift.STRING, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:role: ", p), err) - } - if err := oprot.WriteString(string(*p.Role)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.role (2) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:role: ", p), err) - } - } - return err -} - -func (p *JobUpdateQuery) writeField3(oprot thrift.TProtocol) (err error) { - if p.IsSetJobKey() { - if err := oprot.WriteFieldBegin("jobKey", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:jobKey: ", p), err) - } - if err := p.JobKey.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.JobKey), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:jobKey: ", p), err) - } - } - return err -} - -func (p *JobUpdateQuery) writeField4(oprot thrift.TProtocol) (err error) { - if p.IsSetUser() { - if err := oprot.WriteFieldBegin("user", thrift.STRING, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:user: ", p), err) - } - if err := oprot.WriteString(string(*p.User)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.user (4) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:user: ", p), err) - } - } - return err -} - -func (p *JobUpdateQuery) writeField5(oprot thrift.TProtocol) (err error) { - if p.IsSetUpdateStatuses() { - if err := oprot.WriteFieldBegin("updateStatuses", thrift.SET, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:updateStatuses: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.I32, len(p.UpdateStatuses)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.UpdateStatuses { - if err := oprot.WriteI32(int32(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:updateStatuses: ", p), err) - } - } - return err -} - -func (p *JobUpdateQuery) writeField6(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("offset", thrift.I32, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:offset: ", p), err) - } - if err := oprot.WriteI32(int32(p.Offset)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.offset (6) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:offset: ", p), err) - } - return err -} - -func (p *JobUpdateQuery) writeField7(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("limit", thrift.I32, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:limit: ", p), err) - } - if err := oprot.WriteI32(int32(p.Limit)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.limit (7) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:limit: ", p), err) - } - return err -} - -func (p *JobUpdateQuery) writeField8(oprot thrift.TProtocol) (err error) { - if p.IsSetKey() { - if err := oprot.WriteFieldBegin("key", thrift.STRUCT, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:key: ", p), err) - } - if err := p.Key.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:key: ", p), err) - } - } - return err -} - -func (p *JobUpdateQuery) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JobUpdateQuery(%+v)", *p) -} - -// Attributes: -// - Backups -type ListBackupsResult_ struct { - Backups map[string]bool `thrift:"backups,1" json:"backups"` -} - -func NewListBackupsResult_() *ListBackupsResult_ { - return &ListBackupsResult_{} -} - -func (p *ListBackupsResult_) GetBackups() map[string]bool { - return p.Backups -} -func (p *ListBackupsResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ListBackupsResult_) readField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[string]bool, size) - p.Backups = tSet - for i := 0; i < size; i++ { - var _elem33 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _elem33 = v - } - p.Backups[_elem33] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *ListBackupsResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ListBackupsResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ListBackupsResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("backups", thrift.SET, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:backups: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRING, len(p.Backups)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Backups { - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:backups: ", p), err) - } - return err -} - -func (p *ListBackupsResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ListBackupsResult_(%+v)", *p) -} - -// Attributes: -// - Statuses -type StartMaintenanceResult_ struct { - Statuses map[*HostStatus]bool `thrift:"statuses,1" json:"statuses"` -} - -func NewStartMaintenanceResult_() *StartMaintenanceResult_ { - return &StartMaintenanceResult_{} -} - -func (p *StartMaintenanceResult_) GetStatuses() map[*HostStatus]bool { - return p.Statuses -} -func (p *StartMaintenanceResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StartMaintenanceResult_) readField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*HostStatus]bool, size) - p.Statuses = tSet - for i := 0; i < size; i++ { - _elem34 := &HostStatus{} - if err := _elem34.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem34), err) - } - p.Statuses[_elem34] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *StartMaintenanceResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("StartMaintenanceResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *StartMaintenanceResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("statuses", thrift.SET, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:statuses: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Statuses)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Statuses { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:statuses: ", p), err) - } - return err -} - -func (p *StartMaintenanceResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("StartMaintenanceResult_(%+v)", *p) -} - -// Attributes: -// - Statuses -type DrainHostsResult_ struct { - Statuses map[*HostStatus]bool `thrift:"statuses,1" json:"statuses"` -} - -func NewDrainHostsResult_() *DrainHostsResult_ { - return &DrainHostsResult_{} -} - -func (p *DrainHostsResult_) GetStatuses() map[*HostStatus]bool { - return p.Statuses -} -func (p *DrainHostsResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *DrainHostsResult_) readField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*HostStatus]bool, size) - p.Statuses = tSet - for i := 0; i < size; i++ { - _elem35 := &HostStatus{} - if err := _elem35.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem35), err) - } - p.Statuses[_elem35] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *DrainHostsResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("DrainHostsResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *DrainHostsResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("statuses", thrift.SET, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:statuses: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Statuses)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Statuses { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:statuses: ", p), err) - } - return err -} - -func (p *DrainHostsResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("DrainHostsResult_(%+v)", *p) -} - -// Attributes: -// - Tasks -type QueryRecoveryResult_ struct { - Tasks map[*ScheduledTask]bool `thrift:"tasks,1" json:"tasks"` -} - -func NewQueryRecoveryResult_() *QueryRecoveryResult_ { - return &QueryRecoveryResult_{} -} - -func (p *QueryRecoveryResult_) GetTasks() map[*ScheduledTask]bool { - return p.Tasks -} -func (p *QueryRecoveryResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *QueryRecoveryResult_) readField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*ScheduledTask]bool, size) - p.Tasks = tSet - for i := 0; i < size; i++ { - _elem36 := &ScheduledTask{} - if err := _elem36.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem36), err) - } - p.Tasks[_elem36] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *QueryRecoveryResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("QueryRecoveryResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *QueryRecoveryResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("tasks", thrift.SET, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:tasks: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Tasks)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Tasks { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:tasks: ", p), err) - } - return err -} - -func (p *QueryRecoveryResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("QueryRecoveryResult_(%+v)", *p) -} - -// Attributes: -// - Statuses -type MaintenanceStatusResult_ struct { - Statuses map[*HostStatus]bool `thrift:"statuses,1" json:"statuses"` -} - -func NewMaintenanceStatusResult_() *MaintenanceStatusResult_ { - return &MaintenanceStatusResult_{} -} - -func (p *MaintenanceStatusResult_) GetStatuses() map[*HostStatus]bool { - return p.Statuses -} -func (p *MaintenanceStatusResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *MaintenanceStatusResult_) readField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*HostStatus]bool, size) - p.Statuses = tSet - for i := 0; i < size; i++ { - _elem37 := &HostStatus{} - if err := _elem37.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem37), err) - } - p.Statuses[_elem37] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *MaintenanceStatusResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("MaintenanceStatusResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *MaintenanceStatusResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("statuses", thrift.SET, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:statuses: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Statuses)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Statuses { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:statuses: ", p), err) - } - return err -} - -func (p *MaintenanceStatusResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("MaintenanceStatusResult_(%+v)", *p) -} - -// Attributes: -// - Statuses -type EndMaintenanceResult_ struct { - Statuses map[*HostStatus]bool `thrift:"statuses,1" json:"statuses"` -} - -func NewEndMaintenanceResult_() *EndMaintenanceResult_ { - return &EndMaintenanceResult_{} -} - -func (p *EndMaintenanceResult_) GetStatuses() map[*HostStatus]bool { - return p.Statuses -} -func (p *EndMaintenanceResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *EndMaintenanceResult_) readField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*HostStatus]bool, size) - p.Statuses = tSet - for i := 0; i < size; i++ { - _elem38 := &HostStatus{} - if err := _elem38.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem38), err) - } - p.Statuses[_elem38] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *EndMaintenanceResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("EndMaintenanceResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *EndMaintenanceResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("statuses", thrift.SET, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:statuses: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Statuses)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Statuses { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:statuses: ", p), err) - } - return err -} - -func (p *EndMaintenanceResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("EndMaintenanceResult_(%+v)", *p) -} - -// Attributes: -// - Summaries -type RoleSummaryResult_ struct { - Summaries map[*RoleSummary]bool `thrift:"summaries,1" json:"summaries"` -} - -func NewRoleSummaryResult_() *RoleSummaryResult_ { - return &RoleSummaryResult_{} -} - -func (p *RoleSummaryResult_) GetSummaries() map[*RoleSummary]bool { - return p.Summaries -} -func (p *RoleSummaryResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RoleSummaryResult_) readField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*RoleSummary]bool, size) - p.Summaries = tSet - for i := 0; i < size; i++ { - _elem39 := &RoleSummary{} - if err := _elem39.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem39), err) - } - p.Summaries[_elem39] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *RoleSummaryResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("RoleSummaryResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *RoleSummaryResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("summaries", thrift.SET, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:summaries: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Summaries)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Summaries { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:summaries: ", p), err) - } - return err -} - -func (p *RoleSummaryResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("RoleSummaryResult_(%+v)", *p) -} - -// Attributes: -// - Summaries -type JobSummaryResult_ struct { - Summaries map[*JobSummary]bool `thrift:"summaries,1" json:"summaries"` -} - -func NewJobSummaryResult_() *JobSummaryResult_ { - return &JobSummaryResult_{} -} - -func (p *JobSummaryResult_) GetSummaries() map[*JobSummary]bool { - return p.Summaries -} -func (p *JobSummaryResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *JobSummaryResult_) readField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*JobSummary]bool, size) - p.Summaries = tSet - for i := 0; i < size; i++ { - _elem40 := &JobSummary{} - if err := _elem40.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem40), err) - } - p.Summaries[_elem40] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *JobSummaryResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobSummaryResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *JobSummaryResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("summaries", thrift.SET, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:summaries: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Summaries)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Summaries { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:summaries: ", p), err) - } - return err -} - -func (p *JobSummaryResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JobSummaryResult_(%+v)", *p) -} - -// Attributes: -// - Summary -type ConfigSummaryResult_ struct { - Summary *ConfigSummary `thrift:"summary,1" json:"summary"` -} - -func NewConfigSummaryResult_() *ConfigSummaryResult_ { - return &ConfigSummaryResult_{} -} - -var ConfigSummaryResult__Summary_DEFAULT *ConfigSummary - -func (p *ConfigSummaryResult_) GetSummary() *ConfigSummary { - if !p.IsSetSummary() { - return ConfigSummaryResult__Summary_DEFAULT - } - return p.Summary -} -func (p *ConfigSummaryResult_) IsSetSummary() bool { - return p.Summary != nil -} - -func (p *ConfigSummaryResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ConfigSummaryResult_) readField1(iprot thrift.TProtocol) error { - p.Summary = &ConfigSummary{} - if err := p.Summary.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Summary), err) - } - return nil -} - -func (p *ConfigSummaryResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ConfigSummaryResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ConfigSummaryResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("summary", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:summary: ", p), err) - } - if err := p.Summary.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Summary), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:summary: ", p), err) - } - return err -} - -func (p *ConfigSummaryResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ConfigSummaryResult_(%+v)", *p) -} - -// Attributes: -// - Reasons -type GetPendingReasonResult_ struct { - Reasons map[*PendingReason]bool `thrift:"reasons,1" json:"reasons"` -} - -func NewGetPendingReasonResult_() *GetPendingReasonResult_ { - return &GetPendingReasonResult_{} -} - -func (p *GetPendingReasonResult_) GetReasons() map[*PendingReason]bool { - return p.Reasons -} -func (p *GetPendingReasonResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetPendingReasonResult_) readField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*PendingReason]bool, size) - p.Reasons = tSet - for i := 0; i < size; i++ { - _elem41 := &PendingReason{} - if err := _elem41.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem41), err) - } - p.Reasons[_elem41] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *GetPendingReasonResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("GetPendingReasonResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *GetPendingReasonResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("reasons", thrift.SET, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:reasons: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Reasons)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Reasons { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:reasons: ", p), err) - } - return err -} - -func (p *GetPendingReasonResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("GetPendingReasonResult_(%+v)", *p) -} - -// Result of the startUpdate call. -// -// Attributes: -// - Key: Unique identifier for the job update. -// - UpdateSummary: Summary of the update that is in progress for the given JobKey. -type StartJobUpdateResult_ struct { - Key *JobUpdateKey `thrift:"key,1" json:"key"` - UpdateSummary *JobUpdateSummary `thrift:"updateSummary,2" json:"updateSummary,omitempty"` -} - -func NewStartJobUpdateResult_() *StartJobUpdateResult_ { - return &StartJobUpdateResult_{} -} - -var StartJobUpdateResult__Key_DEFAULT *JobUpdateKey - -func (p *StartJobUpdateResult_) GetKey() *JobUpdateKey { - if !p.IsSetKey() { - return StartJobUpdateResult__Key_DEFAULT - } - return p.Key -} - -var StartJobUpdateResult__UpdateSummary_DEFAULT *JobUpdateSummary - -func (p *StartJobUpdateResult_) GetUpdateSummary() *JobUpdateSummary { - if !p.IsSetUpdateSummary() { - return StartJobUpdateResult__UpdateSummary_DEFAULT - } - return p.UpdateSummary -} -func (p *StartJobUpdateResult_) IsSetKey() bool { - return p.Key != nil -} - -func (p *StartJobUpdateResult_) IsSetUpdateSummary() bool { - return p.UpdateSummary != nil -} - -func (p *StartJobUpdateResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *StartJobUpdateResult_) readField1(iprot thrift.TProtocol) error { - p.Key = &JobUpdateKey{} - if err := p.Key.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Key), err) - } - return nil -} - -func (p *StartJobUpdateResult_) readField2(iprot thrift.TProtocol) error { - p.UpdateSummary = &JobUpdateSummary{} - if err := p.UpdateSummary.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.UpdateSummary), err) - } - return nil -} - -func (p *StartJobUpdateResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("StartJobUpdateResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *StartJobUpdateResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("key", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:key: ", p), err) - } - if err := p.Key.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Key), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:key: ", p), err) - } - return err -} - -func (p *StartJobUpdateResult_) writeField2(oprot thrift.TProtocol) (err error) { - if p.IsSetUpdateSummary() { - if err := oprot.WriteFieldBegin("updateSummary", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:updateSummary: ", p), err) - } - if err := p.UpdateSummary.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.UpdateSummary), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:updateSummary: ", p), err) - } - } - return err -} - -func (p *StartJobUpdateResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("StartJobUpdateResult_(%+v)", *p) -} - -// Result of the getJobUpdateSummaries call. -// -// Attributes: -// - UpdateSummaries -type GetJobUpdateSummariesResult_ struct { - UpdateSummaries []*JobUpdateSummary `thrift:"updateSummaries,1" json:"updateSummaries"` -} - -func NewGetJobUpdateSummariesResult_() *GetJobUpdateSummariesResult_ { - return &GetJobUpdateSummariesResult_{} -} - -func (p *GetJobUpdateSummariesResult_) GetUpdateSummaries() []*JobUpdateSummary { - return p.UpdateSummaries -} -func (p *GetJobUpdateSummariesResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetJobUpdateSummariesResult_) readField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*JobUpdateSummary, 0, size) - p.UpdateSummaries = tSlice - for i := 0; i < size; i++ { - _elem42 := &JobUpdateSummary{} - if err := _elem42.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem42), err) - } - p.UpdateSummaries = append(p.UpdateSummaries, _elem42) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *GetJobUpdateSummariesResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("GetJobUpdateSummariesResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *GetJobUpdateSummariesResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("updateSummaries", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:updateSummaries: ", p), err) - } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.UpdateSummaries)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.UpdateSummaries { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:updateSummaries: ", p), err) - } - return err -} - -func (p *GetJobUpdateSummariesResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("GetJobUpdateSummariesResult_(%+v)", *p) -} - -// Result of the getJobUpdateDetails call. -// -// Attributes: -// - Details -// - DetailsList -type GetJobUpdateDetailsResult_ struct { - Details *JobUpdateDetails `thrift:"details,1" json:"details"` - DetailsList []*JobUpdateDetails `thrift:"detailsList,2" json:"detailsList"` -} - -func NewGetJobUpdateDetailsResult_() *GetJobUpdateDetailsResult_ { - return &GetJobUpdateDetailsResult_{} -} - -var GetJobUpdateDetailsResult__Details_DEFAULT *JobUpdateDetails - -func (p *GetJobUpdateDetailsResult_) GetDetails() *JobUpdateDetails { - if !p.IsSetDetails() { - return GetJobUpdateDetailsResult__Details_DEFAULT - } - return p.Details -} - -func (p *GetJobUpdateDetailsResult_) GetDetailsList() []*JobUpdateDetails { - return p.DetailsList -} -func (p *GetJobUpdateDetailsResult_) IsSetDetails() bool { - return p.Details != nil -} - -func (p *GetJobUpdateDetailsResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetJobUpdateDetailsResult_) readField1(iprot thrift.TProtocol) error { - p.Details = &JobUpdateDetails{} - if err := p.Details.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Details), err) - } - return nil -} - -func (p *GetJobUpdateDetailsResult_) readField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*JobUpdateDetails, 0, size) - p.DetailsList = tSlice - for i := 0; i < size; i++ { - _elem43 := &JobUpdateDetails{} - if err := _elem43.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem43), err) - } - p.DetailsList = append(p.DetailsList, _elem43) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *GetJobUpdateDetailsResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("GetJobUpdateDetailsResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *GetJobUpdateDetailsResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("details", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:details: ", p), err) - } - if err := p.Details.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Details), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:details: ", p), err) - } - return err -} - -func (p *GetJobUpdateDetailsResult_) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("detailsList", thrift.LIST, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:detailsList: ", p), err) - } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.DetailsList)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.DetailsList { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:detailsList: ", p), err) - } - return err -} - -func (p *GetJobUpdateDetailsResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("GetJobUpdateDetailsResult_(%+v)", *p) -} - -// Result of the pulseJobUpdate call. -// -// Attributes: -// - Status -type PulseJobUpdateResult_ struct { - Status JobUpdatePulseStatus `thrift:"status,1" json:"status"` -} - -func NewPulseJobUpdateResult_() *PulseJobUpdateResult_ { - return &PulseJobUpdateResult_{} -} - -func (p *PulseJobUpdateResult_) GetStatus() JobUpdatePulseStatus { - return p.Status -} -func (p *PulseJobUpdateResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *PulseJobUpdateResult_) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := JobUpdatePulseStatus(v) - p.Status = temp - } - return nil -} - -func (p *PulseJobUpdateResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("PulseJobUpdateResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *PulseJobUpdateResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("status", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:status: ", p), err) - } - if err := oprot.WriteI32(int32(p.Status)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.status (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:status: ", p), err) - } - return err -} - -func (p *PulseJobUpdateResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("PulseJobUpdateResult_(%+v)", *p) -} - -// Attributes: -// - Add: Instance addition diff details. -// - Remove: Instance removal diff details. -// - Update: Instance update diff details. -// - Unchanged: Instances unchanged by the update. -type GetJobUpdateDiffResult_ struct { - Add map[*ConfigGroup]bool `thrift:"add,1" json:"add"` - Remove map[*ConfigGroup]bool `thrift:"remove,2" json:"remove"` - Update map[*ConfigGroup]bool `thrift:"update,3" json:"update"` - Unchanged map[*ConfigGroup]bool `thrift:"unchanged,4" json:"unchanged"` -} - -func NewGetJobUpdateDiffResult_() *GetJobUpdateDiffResult_ { - return &GetJobUpdateDiffResult_{} -} - -func (p *GetJobUpdateDiffResult_) GetAdd() map[*ConfigGroup]bool { - return p.Add -} - -func (p *GetJobUpdateDiffResult_) GetRemove() map[*ConfigGroup]bool { - return p.Remove -} - -func (p *GetJobUpdateDiffResult_) GetUpdate() map[*ConfigGroup]bool { - return p.Update -} - -func (p *GetJobUpdateDiffResult_) GetUnchanged() map[*ConfigGroup]bool { - return p.Unchanged -} -func (p *GetJobUpdateDiffResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetJobUpdateDiffResult_) readField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*ConfigGroup]bool, size) - p.Add = tSet - for i := 0; i < size; i++ { - _elem44 := &ConfigGroup{} - if err := _elem44.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem44), err) - } - p.Add[_elem44] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *GetJobUpdateDiffResult_) readField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*ConfigGroup]bool, size) - p.Remove = tSet - for i := 0; i < size; i++ { - _elem45 := &ConfigGroup{} - if err := _elem45.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem45), err) - } - p.Remove[_elem45] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *GetJobUpdateDiffResult_) readField3(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*ConfigGroup]bool, size) - p.Update = tSet - for i := 0; i < size; i++ { - _elem46 := &ConfigGroup{} - if err := _elem46.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem46), err) - } - p.Update[_elem46] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *GetJobUpdateDiffResult_) readField4(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*ConfigGroup]bool, size) - p.Unchanged = tSet - for i := 0; i < size; i++ { - _elem47 := &ConfigGroup{} - if err := _elem47.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem47), err) - } - p.Unchanged[_elem47] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *GetJobUpdateDiffResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("GetJobUpdateDiffResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *GetJobUpdateDiffResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("add", thrift.SET, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:add: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Add)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Add { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:add: ", p), err) - } - return err -} - -func (p *GetJobUpdateDiffResult_) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("remove", thrift.SET, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:remove: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Remove)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Remove { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:remove: ", p), err) - } - return err -} - -func (p *GetJobUpdateDiffResult_) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("update", thrift.SET, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:update: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Update)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Update { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:update: ", p), err) - } - return err -} - -func (p *GetJobUpdateDiffResult_) writeField4(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("unchanged", thrift.SET, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:unchanged: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Unchanged)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Unchanged { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:unchanged: ", p), err) - } - return err -} - -func (p *GetJobUpdateDiffResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("GetJobUpdateDiffResult_(%+v)", *p) -} - -// Tier information. -// -// Attributes: -// - Name: Name of tier. -// - Settings: Tier attributes. -type TierConfig struct { - Name string `thrift:"name,1" json:"name"` - Settings map[string]string `thrift:"settings,2" json:"settings"` -} - -func NewTierConfig() *TierConfig { - return &TierConfig{} -} - -func (p *TierConfig) GetName() string { - return p.Name -} - -func (p *TierConfig) GetSettings() map[string]string { - return p.Settings -} -func (p *TierConfig) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *TierConfig) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Name = v - } - return nil -} - -func (p *TierConfig) readField2(iprot thrift.TProtocol) error { - _, _, size, err := iprot.ReadMapBegin() - if err != nil { - return thrift.PrependError("error reading map begin: ", err) - } - tMap := make(map[string]string, size) - p.Settings = tMap - for i := 0; i < size; i++ { - var _key48 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _key48 = v - } - var _val49 string - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 0: ", err) - } else { - _val49 = v - } - p.Settings[_key48] = _val49 - } - if err := iprot.ReadMapEnd(); err != nil { - return thrift.PrependError("error reading map end: ", err) - } - return nil -} - -func (p *TierConfig) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("TierConfig"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *TierConfig) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("name", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:name: ", p), err) - } - if err := oprot.WriteString(string(p.Name)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.name (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:name: ", p), err) - } - return err -} - -func (p *TierConfig) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("settings", thrift.MAP, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:settings: ", p), err) - } - if err := oprot.WriteMapBegin(thrift.STRING, thrift.STRING, len(p.Settings)); err != nil { - return thrift.PrependError("error writing map begin: ", err) - } - for k, v := range p.Settings { - if err := oprot.WriteString(string(k)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - if err := oprot.WriteString(string(v)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) - } - } - if err := oprot.WriteMapEnd(); err != nil { - return thrift.PrependError("error writing map end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:settings: ", p), err) - } - return err -} - -func (p *TierConfig) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("TierConfig(%+v)", *p) -} - -// Result of the getTierConfigResult call. -// -// Attributes: -// - DefaultTierName: Name of the default tier. -// - Tiers: Set of tier configurations. -type GetTierConfigResult_ struct { - DefaultTierName string `thrift:"defaultTierName,1" json:"defaultTierName"` - Tiers map[*TierConfig]bool `thrift:"tiers,2" json:"tiers"` -} - -func NewGetTierConfigResult_() *GetTierConfigResult_ { - return &GetTierConfigResult_{} -} - -func (p *GetTierConfigResult_) GetDefaultTierName() string { - return p.DefaultTierName -} - -func (p *GetTierConfigResult_) GetTiers() map[*TierConfig]bool { - return p.Tiers -} -func (p *GetTierConfigResult_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *GetTierConfigResult_) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.DefaultTierName = v - } - return nil -} - -func (p *GetTierConfigResult_) readField2(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadSetBegin() - if err != nil { - return thrift.PrependError("error reading set begin: ", err) - } - tSet := make(map[*TierConfig]bool, size) - p.Tiers = tSet - for i := 0; i < size; i++ { - _elem50 := &TierConfig{} - if err := _elem50.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem50), err) - } - p.Tiers[_elem50] = true - } - if err := iprot.ReadSetEnd(); err != nil { - return thrift.PrependError("error reading set end: ", err) - } - return nil -} - -func (p *GetTierConfigResult_) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("GetTierConfigResult"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *GetTierConfigResult_) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("defaultTierName", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:defaultTierName: ", p), err) - } - if err := oprot.WriteString(string(p.DefaultTierName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.defaultTierName (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:defaultTierName: ", p), err) - } - return err -} - -func (p *GetTierConfigResult_) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("tiers", thrift.SET, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:tiers: ", p), err) - } - if err := oprot.WriteSetBegin(thrift.STRUCT, len(p.Tiers)); err != nil { - return thrift.PrependError("error writing set begin: ", err) - } - for v, _ := range p.Tiers { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteSetEnd(); err != nil { - return thrift.PrependError("error writing set end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:tiers: ", p), err) - } - return err -} - -func (p *GetTierConfigResult_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("GetTierConfigResult_(%+v)", *p) -} - -// Information about the scheduler. -// -// Attributes: -// - ClusterName -// - StatsUrlPrefix: A url prefix for job container stats. -type ServerInfo struct { - ClusterName string `thrift:"clusterName,1" json:"clusterName"` - // unused field # 2 - StatsUrlPrefix string `thrift:"statsUrlPrefix,3" json:"statsUrlPrefix"` -} - -func NewServerInfo() *ServerInfo { - return &ServerInfo{} -} - -func (p *ServerInfo) GetClusterName() string { - return p.ClusterName -} - -func (p *ServerInfo) GetStatsUrlPrefix() string { - return p.StatsUrlPrefix -} -func (p *ServerInfo) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ServerInfo) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.ClusterName = v - } - return nil -} - -func (p *ServerInfo) readField3(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 3: ", err) - } else { - p.StatsUrlPrefix = v - } - return nil -} - -func (p *ServerInfo) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ServerInfo"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ServerInfo) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("clusterName", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:clusterName: ", p), err) - } - if err := oprot.WriteString(string(p.ClusterName)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.clusterName (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:clusterName: ", p), err) - } - return err -} - -func (p *ServerInfo) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("statsUrlPrefix", thrift.STRING, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:statsUrlPrefix: ", p), err) - } - if err := oprot.WriteString(string(p.StatsUrlPrefix)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.statsUrlPrefix (3) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:statsUrlPrefix: ", p), err) - } - return err -} - -func (p *ServerInfo) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ServerInfo(%+v)", *p) -} - -// Attributes: -// - PopulateJobResult_ -// - ScheduleStatusResult_ -// - GetJobsResult_ -// - GetQuotaResult_ -// - ListBackupsResult_ -// - StartMaintenanceResult_ -// - DrainHostsResult_ -// - QueryRecoveryResult_ -// - MaintenanceStatusResult_ -// - EndMaintenanceResult_ -// - RoleSummaryResult_ -// - JobSummaryResult_ -// - ConfigSummaryResult_ -// - GetPendingReasonResult_ -// - StartJobUpdateResult_ -// - GetJobUpdateSummariesResult_ -// - GetJobUpdateDetailsResult_ -// - PulseJobUpdateResult_ -// - GetJobUpdateDiffResult_ -// - GetTierConfigResult_ -type Result_ struct { - PopulateJobResult_ *PopulateJobResult_ `thrift:"populateJobResult,1" json:"populateJobResult,omitempty"` - // unused field # 2 - ScheduleStatusResult_ *ScheduleStatusResult_ `thrift:"scheduleStatusResult,3" json:"scheduleStatusResult,omitempty"` - GetJobsResult_ *GetJobsResult_ `thrift:"getJobsResult,4" json:"getJobsResult,omitempty"` - GetQuotaResult_ *GetQuotaResult_ `thrift:"getQuotaResult,5" json:"getQuotaResult,omitempty"` - ListBackupsResult_ *ListBackupsResult_ `thrift:"listBackupsResult,6" json:"listBackupsResult,omitempty"` - StartMaintenanceResult_ *StartMaintenanceResult_ `thrift:"startMaintenanceResult,7" json:"startMaintenanceResult,omitempty"` - DrainHostsResult_ *DrainHostsResult_ `thrift:"drainHostsResult,8" json:"drainHostsResult,omitempty"` - QueryRecoveryResult_ *QueryRecoveryResult_ `thrift:"queryRecoveryResult,9" json:"queryRecoveryResult,omitempty"` - MaintenanceStatusResult_ *MaintenanceStatusResult_ `thrift:"maintenanceStatusResult,10" json:"maintenanceStatusResult,omitempty"` - EndMaintenanceResult_ *EndMaintenanceResult_ `thrift:"endMaintenanceResult,11" json:"endMaintenanceResult,omitempty"` - // unused fields # 12 to 16 - RoleSummaryResult_ *RoleSummaryResult_ `thrift:"roleSummaryResult,17" json:"roleSummaryResult,omitempty"` - JobSummaryResult_ *JobSummaryResult_ `thrift:"jobSummaryResult,18" json:"jobSummaryResult,omitempty"` - // unused field # 19 - ConfigSummaryResult_ *ConfigSummaryResult_ `thrift:"configSummaryResult,20" json:"configSummaryResult,omitempty"` - GetPendingReasonResult_ *GetPendingReasonResult_ `thrift:"getPendingReasonResult,21" json:"getPendingReasonResult,omitempty"` - StartJobUpdateResult_ *StartJobUpdateResult_ `thrift:"startJobUpdateResult,22" json:"startJobUpdateResult,omitempty"` - GetJobUpdateSummariesResult_ *GetJobUpdateSummariesResult_ `thrift:"getJobUpdateSummariesResult,23" json:"getJobUpdateSummariesResult,omitempty"` - GetJobUpdateDetailsResult_ *GetJobUpdateDetailsResult_ `thrift:"getJobUpdateDetailsResult,24" json:"getJobUpdateDetailsResult,omitempty"` - PulseJobUpdateResult_ *PulseJobUpdateResult_ `thrift:"pulseJobUpdateResult,25" json:"pulseJobUpdateResult,omitempty"` - GetJobUpdateDiffResult_ *GetJobUpdateDiffResult_ `thrift:"getJobUpdateDiffResult,26" json:"getJobUpdateDiffResult,omitempty"` - GetTierConfigResult_ *GetTierConfigResult_ `thrift:"getTierConfigResult,27" json:"getTierConfigResult,omitempty"` -} - -func NewResult_() *Result_ { - return &Result_{} -} - -var Result__PopulateJobResult__DEFAULT *PopulateJobResult_ - -func (p *Result_) GetPopulateJobResult_() *PopulateJobResult_ { - if !p.IsSetPopulateJobResult_() { - return Result__PopulateJobResult__DEFAULT - } - return p.PopulateJobResult_ -} - -var Result__ScheduleStatusResult__DEFAULT *ScheduleStatusResult_ - -func (p *Result_) GetScheduleStatusResult_() *ScheduleStatusResult_ { - if !p.IsSetScheduleStatusResult_() { - return Result__ScheduleStatusResult__DEFAULT - } - return p.ScheduleStatusResult_ -} - -var Result__GetJobsResult__DEFAULT *GetJobsResult_ - -func (p *Result_) GetGetJobsResult_() *GetJobsResult_ { - if !p.IsSetGetJobsResult_() { - return Result__GetJobsResult__DEFAULT - } - return p.GetJobsResult_ -} - -var Result__GetQuotaResult__DEFAULT *GetQuotaResult_ - -func (p *Result_) GetGetQuotaResult_() *GetQuotaResult_ { - if !p.IsSetGetQuotaResult_() { - return Result__GetQuotaResult__DEFAULT - } - return p.GetQuotaResult_ -} - -var Result__ListBackupsResult__DEFAULT *ListBackupsResult_ - -func (p *Result_) GetListBackupsResult_() *ListBackupsResult_ { - if !p.IsSetListBackupsResult_() { - return Result__ListBackupsResult__DEFAULT - } - return p.ListBackupsResult_ -} - -var Result__StartMaintenanceResult__DEFAULT *StartMaintenanceResult_ - -func (p *Result_) GetStartMaintenanceResult_() *StartMaintenanceResult_ { - if !p.IsSetStartMaintenanceResult_() { - return Result__StartMaintenanceResult__DEFAULT - } - return p.StartMaintenanceResult_ -} - -var Result__DrainHostsResult__DEFAULT *DrainHostsResult_ - -func (p *Result_) GetDrainHostsResult_() *DrainHostsResult_ { - if !p.IsSetDrainHostsResult_() { - return Result__DrainHostsResult__DEFAULT - } - return p.DrainHostsResult_ -} - -var Result__QueryRecoveryResult__DEFAULT *QueryRecoveryResult_ - -func (p *Result_) GetQueryRecoveryResult_() *QueryRecoveryResult_ { - if !p.IsSetQueryRecoveryResult_() { - return Result__QueryRecoveryResult__DEFAULT - } - return p.QueryRecoveryResult_ -} - -var Result__MaintenanceStatusResult__DEFAULT *MaintenanceStatusResult_ - -func (p *Result_) GetMaintenanceStatusResult_() *MaintenanceStatusResult_ { - if !p.IsSetMaintenanceStatusResult_() { - return Result__MaintenanceStatusResult__DEFAULT - } - return p.MaintenanceStatusResult_ -} - -var Result__EndMaintenanceResult__DEFAULT *EndMaintenanceResult_ - -func (p *Result_) GetEndMaintenanceResult_() *EndMaintenanceResult_ { - if !p.IsSetEndMaintenanceResult_() { - return Result__EndMaintenanceResult__DEFAULT - } - return p.EndMaintenanceResult_ -} - -var Result__RoleSummaryResult__DEFAULT *RoleSummaryResult_ - -func (p *Result_) GetRoleSummaryResult_() *RoleSummaryResult_ { - if !p.IsSetRoleSummaryResult_() { - return Result__RoleSummaryResult__DEFAULT - } - return p.RoleSummaryResult_ -} - -var Result__JobSummaryResult__DEFAULT *JobSummaryResult_ - -func (p *Result_) GetJobSummaryResult_() *JobSummaryResult_ { - if !p.IsSetJobSummaryResult_() { - return Result__JobSummaryResult__DEFAULT - } - return p.JobSummaryResult_ -} - -var Result__ConfigSummaryResult__DEFAULT *ConfigSummaryResult_ - -func (p *Result_) GetConfigSummaryResult_() *ConfigSummaryResult_ { - if !p.IsSetConfigSummaryResult_() { - return Result__ConfigSummaryResult__DEFAULT - } - return p.ConfigSummaryResult_ -} - -var Result__GetPendingReasonResult__DEFAULT *GetPendingReasonResult_ - -func (p *Result_) GetGetPendingReasonResult_() *GetPendingReasonResult_ { - if !p.IsSetGetPendingReasonResult_() { - return Result__GetPendingReasonResult__DEFAULT - } - return p.GetPendingReasonResult_ -} - -var Result__StartJobUpdateResult__DEFAULT *StartJobUpdateResult_ - -func (p *Result_) GetStartJobUpdateResult_() *StartJobUpdateResult_ { - if !p.IsSetStartJobUpdateResult_() { - return Result__StartJobUpdateResult__DEFAULT - } - return p.StartJobUpdateResult_ -} - -var Result__GetJobUpdateSummariesResult__DEFAULT *GetJobUpdateSummariesResult_ - -func (p *Result_) GetGetJobUpdateSummariesResult_() *GetJobUpdateSummariesResult_ { - if !p.IsSetGetJobUpdateSummariesResult_() { - return Result__GetJobUpdateSummariesResult__DEFAULT - } - return p.GetJobUpdateSummariesResult_ -} - -var Result__GetJobUpdateDetailsResult__DEFAULT *GetJobUpdateDetailsResult_ - -func (p *Result_) GetGetJobUpdateDetailsResult_() *GetJobUpdateDetailsResult_ { - if !p.IsSetGetJobUpdateDetailsResult_() { - return Result__GetJobUpdateDetailsResult__DEFAULT - } - return p.GetJobUpdateDetailsResult_ -} - -var Result__PulseJobUpdateResult__DEFAULT *PulseJobUpdateResult_ - -func (p *Result_) GetPulseJobUpdateResult_() *PulseJobUpdateResult_ { - if !p.IsSetPulseJobUpdateResult_() { - return Result__PulseJobUpdateResult__DEFAULT - } - return p.PulseJobUpdateResult_ -} - -var Result__GetJobUpdateDiffResult__DEFAULT *GetJobUpdateDiffResult_ - -func (p *Result_) GetGetJobUpdateDiffResult_() *GetJobUpdateDiffResult_ { - if !p.IsSetGetJobUpdateDiffResult_() { - return Result__GetJobUpdateDiffResult__DEFAULT - } - return p.GetJobUpdateDiffResult_ -} - -var Result__GetTierConfigResult__DEFAULT *GetTierConfigResult_ - -func (p *Result_) GetGetTierConfigResult_() *GetTierConfigResult_ { - if !p.IsSetGetTierConfigResult_() { - return Result__GetTierConfigResult__DEFAULT - } - return p.GetTierConfigResult_ -} -func (p *Result_) CountSetFieldsResult_() int { - count := 0 - if p.IsSetPopulateJobResult_() { - count++ - } - if p.IsSetScheduleStatusResult_() { - count++ - } - if p.IsSetGetJobsResult_() { - count++ - } - if p.IsSetGetQuotaResult_() { - count++ - } - if p.IsSetListBackupsResult_() { - count++ - } - if p.IsSetStartMaintenanceResult_() { - count++ - } - if p.IsSetDrainHostsResult_() { - count++ - } - if p.IsSetQueryRecoveryResult_() { - count++ - } - if p.IsSetMaintenanceStatusResult_() { - count++ - } - if p.IsSetEndMaintenanceResult_() { - count++ - } - if p.IsSetRoleSummaryResult_() { - count++ - } - if p.IsSetJobSummaryResult_() { - count++ - } - if p.IsSetConfigSummaryResult_() { - count++ - } - if p.IsSetGetPendingReasonResult_() { - count++ - } - if p.IsSetStartJobUpdateResult_() { - count++ - } - if p.IsSetGetJobUpdateSummariesResult_() { - count++ - } - if p.IsSetGetJobUpdateDetailsResult_() { - count++ - } - if p.IsSetPulseJobUpdateResult_() { - count++ - } - if p.IsSetGetJobUpdateDiffResult_() { - count++ - } - if p.IsSetGetTierConfigResult_() { - count++ - } - return count - -} - -func (p *Result_) IsSetPopulateJobResult_() bool { - return p.PopulateJobResult_ != nil -} - -func (p *Result_) IsSetScheduleStatusResult_() bool { - return p.ScheduleStatusResult_ != nil -} - -func (p *Result_) IsSetGetJobsResult_() bool { - return p.GetJobsResult_ != nil -} - -func (p *Result_) IsSetGetQuotaResult_() bool { - return p.GetQuotaResult_ != nil -} - -func (p *Result_) IsSetListBackupsResult_() bool { - return p.ListBackupsResult_ != nil -} - -func (p *Result_) IsSetStartMaintenanceResult_() bool { - return p.StartMaintenanceResult_ != nil -} - -func (p *Result_) IsSetDrainHostsResult_() bool { - return p.DrainHostsResult_ != nil -} - -func (p *Result_) IsSetQueryRecoveryResult_() bool { - return p.QueryRecoveryResult_ != nil -} - -func (p *Result_) IsSetMaintenanceStatusResult_() bool { - return p.MaintenanceStatusResult_ != nil -} - -func (p *Result_) IsSetEndMaintenanceResult_() bool { - return p.EndMaintenanceResult_ != nil -} - -func (p *Result_) IsSetRoleSummaryResult_() bool { - return p.RoleSummaryResult_ != nil -} - -func (p *Result_) IsSetJobSummaryResult_() bool { - return p.JobSummaryResult_ != nil -} - -func (p *Result_) IsSetConfigSummaryResult_() bool { - return p.ConfigSummaryResult_ != nil -} - -func (p *Result_) IsSetGetPendingReasonResult_() bool { - return p.GetPendingReasonResult_ != nil -} - -func (p *Result_) IsSetStartJobUpdateResult_() bool { - return p.StartJobUpdateResult_ != nil -} - -func (p *Result_) IsSetGetJobUpdateSummariesResult_() bool { - return p.GetJobUpdateSummariesResult_ != nil -} - -func (p *Result_) IsSetGetJobUpdateDetailsResult_() bool { - return p.GetJobUpdateDetailsResult_ != nil -} - -func (p *Result_) IsSetPulseJobUpdateResult_() bool { - return p.PulseJobUpdateResult_ != nil -} - -func (p *Result_) IsSetGetJobUpdateDiffResult_() bool { - return p.GetJobUpdateDiffResult_ != nil -} - -func (p *Result_) IsSetGetTierConfigResult_() bool { - return p.GetTierConfigResult_ != nil -} - -func (p *Result_) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 4: - if err := p.readField4(iprot); err != nil { - return err - } - case 5: - if err := p.readField5(iprot); err != nil { - return err - } - case 6: - if err := p.readField6(iprot); err != nil { - return err - } - case 7: - if err := p.readField7(iprot); err != nil { - return err - } - case 8: - if err := p.readField8(iprot); err != nil { - return err - } - case 9: - if err := p.readField9(iprot); err != nil { - return err - } - case 10: - if err := p.readField10(iprot); err != nil { - return err - } - case 11: - if err := p.readField11(iprot); err != nil { - return err - } - case 17: - if err := p.readField17(iprot); err != nil { - return err - } - case 18: - if err := p.readField18(iprot); err != nil { - return err - } - case 20: - if err := p.readField20(iprot); err != nil { - return err - } - case 21: - if err := p.readField21(iprot); err != nil { - return err - } - case 22: - if err := p.readField22(iprot); err != nil { - return err - } - case 23: - if err := p.readField23(iprot); err != nil { - return err - } - case 24: - if err := p.readField24(iprot); err != nil { - return err - } - case 25: - if err := p.readField25(iprot); err != nil { - return err - } - case 26: - if err := p.readField26(iprot); err != nil { - return err - } - case 27: - if err := p.readField27(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Result_) readField1(iprot thrift.TProtocol) error { - p.PopulateJobResult_ = &PopulateJobResult_{} - if err := p.PopulateJobResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PopulateJobResult_), err) - } - return nil -} - -func (p *Result_) readField3(iprot thrift.TProtocol) error { - p.ScheduleStatusResult_ = &ScheduleStatusResult_{} - if err := p.ScheduleStatusResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ScheduleStatusResult_), err) - } - return nil -} - -func (p *Result_) readField4(iprot thrift.TProtocol) error { - p.GetJobsResult_ = &GetJobsResult_{} - if err := p.GetJobsResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetJobsResult_), err) - } - return nil -} - -func (p *Result_) readField5(iprot thrift.TProtocol) error { - p.GetQuotaResult_ = &GetQuotaResult_{} - if err := p.GetQuotaResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetQuotaResult_), err) - } - return nil -} - -func (p *Result_) readField6(iprot thrift.TProtocol) error { - p.ListBackupsResult_ = &ListBackupsResult_{} - if err := p.ListBackupsResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ListBackupsResult_), err) - } - return nil -} - -func (p *Result_) readField7(iprot thrift.TProtocol) error { - p.StartMaintenanceResult_ = &StartMaintenanceResult_{} - if err := p.StartMaintenanceResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StartMaintenanceResult_), err) - } - return nil -} - -func (p *Result_) readField8(iprot thrift.TProtocol) error { - p.DrainHostsResult_ = &DrainHostsResult_{} - if err := p.DrainHostsResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.DrainHostsResult_), err) - } - return nil -} - -func (p *Result_) readField9(iprot thrift.TProtocol) error { - p.QueryRecoveryResult_ = &QueryRecoveryResult_{} - if err := p.QueryRecoveryResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.QueryRecoveryResult_), err) - } - return nil -} - -func (p *Result_) readField10(iprot thrift.TProtocol) error { - p.MaintenanceStatusResult_ = &MaintenanceStatusResult_{} - if err := p.MaintenanceStatusResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.MaintenanceStatusResult_), err) - } - return nil -} - -func (p *Result_) readField11(iprot thrift.TProtocol) error { - p.EndMaintenanceResult_ = &EndMaintenanceResult_{} - if err := p.EndMaintenanceResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.EndMaintenanceResult_), err) - } - return nil -} - -func (p *Result_) readField17(iprot thrift.TProtocol) error { - p.RoleSummaryResult_ = &RoleSummaryResult_{} - if err := p.RoleSummaryResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.RoleSummaryResult_), err) - } - return nil -} - -func (p *Result_) readField18(iprot thrift.TProtocol) error { - p.JobSummaryResult_ = &JobSummaryResult_{} - if err := p.JobSummaryResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.JobSummaryResult_), err) - } - return nil -} - -func (p *Result_) readField20(iprot thrift.TProtocol) error { - p.ConfigSummaryResult_ = &ConfigSummaryResult_{} - if err := p.ConfigSummaryResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ConfigSummaryResult_), err) - } - return nil -} - -func (p *Result_) readField21(iprot thrift.TProtocol) error { - p.GetPendingReasonResult_ = &GetPendingReasonResult_{} - if err := p.GetPendingReasonResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetPendingReasonResult_), err) - } - return nil -} - -func (p *Result_) readField22(iprot thrift.TProtocol) error { - p.StartJobUpdateResult_ = &StartJobUpdateResult_{} - if err := p.StartJobUpdateResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.StartJobUpdateResult_), err) - } - return nil -} - -func (p *Result_) readField23(iprot thrift.TProtocol) error { - p.GetJobUpdateSummariesResult_ = &GetJobUpdateSummariesResult_{} - if err := p.GetJobUpdateSummariesResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetJobUpdateSummariesResult_), err) - } - return nil -} - -func (p *Result_) readField24(iprot thrift.TProtocol) error { - p.GetJobUpdateDetailsResult_ = &GetJobUpdateDetailsResult_{} - if err := p.GetJobUpdateDetailsResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetJobUpdateDetailsResult_), err) - } - return nil -} - -func (p *Result_) readField25(iprot thrift.TProtocol) error { - p.PulseJobUpdateResult_ = &PulseJobUpdateResult_{} - if err := p.PulseJobUpdateResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.PulseJobUpdateResult_), err) - } - return nil -} - -func (p *Result_) readField26(iprot thrift.TProtocol) error { - p.GetJobUpdateDiffResult_ = &GetJobUpdateDiffResult_{} - if err := p.GetJobUpdateDiffResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetJobUpdateDiffResult_), err) - } - return nil -} - -func (p *Result_) readField27(iprot thrift.TProtocol) error { - p.GetTierConfigResult_ = &GetTierConfigResult_{} - if err := p.GetTierConfigResult_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.GetTierConfigResult_), err) - } - return nil -} - -func (p *Result_) Write(oprot thrift.TProtocol) error { - if c := p.CountSetFieldsResult_(); c != 1 { - return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("Result"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField4(oprot); err != nil { - return err - } - if err := p.writeField5(oprot); err != nil { - return err - } - if err := p.writeField6(oprot); err != nil { - return err - } - if err := p.writeField7(oprot); err != nil { - return err - } - if err := p.writeField8(oprot); err != nil { - return err - } - if err := p.writeField9(oprot); err != nil { - return err - } - if err := p.writeField10(oprot); err != nil { - return err - } - if err := p.writeField11(oprot); err != nil { - return err - } - if err := p.writeField17(oprot); err != nil { - return err - } - if err := p.writeField18(oprot); err != nil { - return err - } - if err := p.writeField20(oprot); err != nil { - return err - } - if err := p.writeField21(oprot); err != nil { - return err - } - if err := p.writeField22(oprot); err != nil { - return err - } - if err := p.writeField23(oprot); err != nil { - return err - } - if err := p.writeField24(oprot); err != nil { - return err - } - if err := p.writeField25(oprot); err != nil { - return err - } - if err := p.writeField26(oprot); err != nil { - return err - } - if err := p.writeField27(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *Result_) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetPopulateJobResult_() { - if err := oprot.WriteFieldBegin("populateJobResult", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:populateJobResult: ", p), err) - } - if err := p.PopulateJobResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PopulateJobResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:populateJobResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField3(oprot thrift.TProtocol) (err error) { - if p.IsSetScheduleStatusResult_() { - if err := oprot.WriteFieldBegin("scheduleStatusResult", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:scheduleStatusResult: ", p), err) - } - if err := p.ScheduleStatusResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ScheduleStatusResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:scheduleStatusResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField4(oprot thrift.TProtocol) (err error) { - if p.IsSetGetJobsResult_() { - if err := oprot.WriteFieldBegin("getJobsResult", thrift.STRUCT, 4); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 4:getJobsResult: ", p), err) - } - if err := p.GetJobsResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetJobsResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 4:getJobsResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField5(oprot thrift.TProtocol) (err error) { - if p.IsSetGetQuotaResult_() { - if err := oprot.WriteFieldBegin("getQuotaResult", thrift.STRUCT, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:getQuotaResult: ", p), err) - } - if err := p.GetQuotaResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetQuotaResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:getQuotaResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField6(oprot thrift.TProtocol) (err error) { - if p.IsSetListBackupsResult_() { - if err := oprot.WriteFieldBegin("listBackupsResult", thrift.STRUCT, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:listBackupsResult: ", p), err) - } - if err := p.ListBackupsResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ListBackupsResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:listBackupsResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField7(oprot thrift.TProtocol) (err error) { - if p.IsSetStartMaintenanceResult_() { - if err := oprot.WriteFieldBegin("startMaintenanceResult", thrift.STRUCT, 7); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 7:startMaintenanceResult: ", p), err) - } - if err := p.StartMaintenanceResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StartMaintenanceResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 7:startMaintenanceResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField8(oprot thrift.TProtocol) (err error) { - if p.IsSetDrainHostsResult_() { - if err := oprot.WriteFieldBegin("drainHostsResult", thrift.STRUCT, 8); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 8:drainHostsResult: ", p), err) - } - if err := p.DrainHostsResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.DrainHostsResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 8:drainHostsResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField9(oprot thrift.TProtocol) (err error) { - if p.IsSetQueryRecoveryResult_() { - if err := oprot.WriteFieldBegin("queryRecoveryResult", thrift.STRUCT, 9); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 9:queryRecoveryResult: ", p), err) - } - if err := p.QueryRecoveryResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.QueryRecoveryResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 9:queryRecoveryResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField10(oprot thrift.TProtocol) (err error) { - if p.IsSetMaintenanceStatusResult_() { - if err := oprot.WriteFieldBegin("maintenanceStatusResult", thrift.STRUCT, 10); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 10:maintenanceStatusResult: ", p), err) - } - if err := p.MaintenanceStatusResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.MaintenanceStatusResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 10:maintenanceStatusResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField11(oprot thrift.TProtocol) (err error) { - if p.IsSetEndMaintenanceResult_() { - if err := oprot.WriteFieldBegin("endMaintenanceResult", thrift.STRUCT, 11); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 11:endMaintenanceResult: ", p), err) - } - if err := p.EndMaintenanceResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.EndMaintenanceResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 11:endMaintenanceResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField17(oprot thrift.TProtocol) (err error) { - if p.IsSetRoleSummaryResult_() { - if err := oprot.WriteFieldBegin("roleSummaryResult", thrift.STRUCT, 17); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 17:roleSummaryResult: ", p), err) - } - if err := p.RoleSummaryResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.RoleSummaryResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 17:roleSummaryResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField18(oprot thrift.TProtocol) (err error) { - if p.IsSetJobSummaryResult_() { - if err := oprot.WriteFieldBegin("jobSummaryResult", thrift.STRUCT, 18); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 18:jobSummaryResult: ", p), err) - } - if err := p.JobSummaryResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.JobSummaryResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 18:jobSummaryResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField20(oprot thrift.TProtocol) (err error) { - if p.IsSetConfigSummaryResult_() { - if err := oprot.WriteFieldBegin("configSummaryResult", thrift.STRUCT, 20); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 20:configSummaryResult: ", p), err) - } - if err := p.ConfigSummaryResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ConfigSummaryResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 20:configSummaryResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField21(oprot thrift.TProtocol) (err error) { - if p.IsSetGetPendingReasonResult_() { - if err := oprot.WriteFieldBegin("getPendingReasonResult", thrift.STRUCT, 21); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 21:getPendingReasonResult: ", p), err) - } - if err := p.GetPendingReasonResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetPendingReasonResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 21:getPendingReasonResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField22(oprot thrift.TProtocol) (err error) { - if p.IsSetStartJobUpdateResult_() { - if err := oprot.WriteFieldBegin("startJobUpdateResult", thrift.STRUCT, 22); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 22:startJobUpdateResult: ", p), err) - } - if err := p.StartJobUpdateResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.StartJobUpdateResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 22:startJobUpdateResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField23(oprot thrift.TProtocol) (err error) { - if p.IsSetGetJobUpdateSummariesResult_() { - if err := oprot.WriteFieldBegin("getJobUpdateSummariesResult", thrift.STRUCT, 23); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 23:getJobUpdateSummariesResult: ", p), err) - } - if err := p.GetJobUpdateSummariesResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetJobUpdateSummariesResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 23:getJobUpdateSummariesResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField24(oprot thrift.TProtocol) (err error) { - if p.IsSetGetJobUpdateDetailsResult_() { - if err := oprot.WriteFieldBegin("getJobUpdateDetailsResult", thrift.STRUCT, 24); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 24:getJobUpdateDetailsResult: ", p), err) - } - if err := p.GetJobUpdateDetailsResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetJobUpdateDetailsResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 24:getJobUpdateDetailsResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField25(oprot thrift.TProtocol) (err error) { - if p.IsSetPulseJobUpdateResult_() { - if err := oprot.WriteFieldBegin("pulseJobUpdateResult", thrift.STRUCT, 25); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 25:pulseJobUpdateResult: ", p), err) - } - if err := p.PulseJobUpdateResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.PulseJobUpdateResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 25:pulseJobUpdateResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField26(oprot thrift.TProtocol) (err error) { - if p.IsSetGetJobUpdateDiffResult_() { - if err := oprot.WriteFieldBegin("getJobUpdateDiffResult", thrift.STRUCT, 26); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 26:getJobUpdateDiffResult: ", p), err) - } - if err := p.GetJobUpdateDiffResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetJobUpdateDiffResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 26:getJobUpdateDiffResult: ", p), err) - } - } - return err -} - -func (p *Result_) writeField27(oprot thrift.TProtocol) (err error) { - if p.IsSetGetTierConfigResult_() { - if err := oprot.WriteFieldBegin("getTierConfigResult", thrift.STRUCT, 27); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 27:getTierConfigResult: ", p), err) - } - if err := p.GetTierConfigResult_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.GetTierConfigResult_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 27:getTierConfigResult: ", p), err) - } - } - return err -} - -func (p *Result_) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Result_(%+v)", *p) -} - -// Attributes: -// - Message -type ResponseDetail struct { - Message string `thrift:"message,1" json:"message"` -} - -func NewResponseDetail() *ResponseDetail { - return &ResponseDetail{} -} - -func (p *ResponseDetail) GetMessage() string { - return p.Message -} -func (p *ResponseDetail) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ResponseDetail) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadString(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.Message = v - } - return nil -} - -func (p *ResponseDetail) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ResponseDetail"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ResponseDetail) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("message", thrift.STRING, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:message: ", p), err) - } - if err := oprot.WriteString(string(p.Message)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.message (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:message: ", p), err) - } - return err -} - -func (p *ResponseDetail) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ResponseDetail(%+v)", *p) -} - -// Attributes: -// - ResponseCode -// - ServerInfo -// - Result_: Payload from the invoked RPC. -// - Details: Messages from the server relevant to the request, such as warnings or use of deprecated -// features. -type Response struct { - ResponseCode ResponseCode `thrift:"responseCode,1" json:"responseCode"` - // unused field # 2 - Result_ *Result_ `thrift:"result,3" json:"result,omitempty"` - // unused field # 4 - ServerInfo *ServerInfo `thrift:"serverInfo,5" json:"serverInfo"` - Details []*ResponseDetail `thrift:"details,6" json:"details"` -} - -func NewResponse() *Response { - return &Response{} -} - -func (p *Response) GetResponseCode() ResponseCode { - return p.ResponseCode -} - -var Response_ServerInfo_DEFAULT *ServerInfo - -func (p *Response) GetServerInfo() *ServerInfo { - if !p.IsSetServerInfo() { - return Response_ServerInfo_DEFAULT - } - return p.ServerInfo -} - -var Response_Result__DEFAULT *Result_ - -func (p *Response) GetResult_() *Result_ { - if !p.IsSetResult_() { - return Response_Result__DEFAULT - } - return p.Result_ -} - -func (p *Response) GetDetails() []*ResponseDetail { - return p.Details -} -func (p *Response) IsSetServerInfo() bool { - return p.ServerInfo != nil -} - -func (p *Response) IsSetResult_() bool { - return p.Result_ != nil -} - -func (p *Response) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 5: - if err := p.readField5(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - case 6: - if err := p.readField6(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *Response) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - temp := ResponseCode(v) - p.ResponseCode = temp - } - return nil -} - -func (p *Response) readField5(iprot thrift.TProtocol) error { - p.ServerInfo = &ServerInfo{} - if err := p.ServerInfo.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.ServerInfo), err) - } - return nil -} - -func (p *Response) readField3(iprot thrift.TProtocol) error { - p.Result_ = &Result_{} - if err := p.Result_.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.Result_), err) - } - return nil -} - -func (p *Response) readField6(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*ResponseDetail, 0, size) - p.Details = tSlice - for i := 0; i < size; i++ { - _elem51 := &ResponseDetail{} - if err := _elem51.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem51), err) - } - p.Details = append(p.Details, _elem51) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *Response) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("Response"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := p.writeField5(oprot); err != nil { - return err - } - if err := p.writeField6(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *Response) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("responseCode", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:responseCode: ", p), err) - } - if err := oprot.WriteI32(int32(p.ResponseCode)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.responseCode (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:responseCode: ", p), err) - } - return err -} - -func (p *Response) writeField3(oprot thrift.TProtocol) (err error) { - if p.IsSetResult_() { - if err := oprot.WriteFieldBegin("result", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:result: ", p), err) - } - if err := p.Result_.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.Result_), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:result: ", p), err) - } - } - return err -} - -func (p *Response) writeField5(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("serverInfo", thrift.STRUCT, 5); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 5:serverInfo: ", p), err) - } - if err := p.ServerInfo.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.ServerInfo), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 5:serverInfo: ", p), err) - } - return err -} - -func (p *Response) writeField6(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("details", thrift.LIST, 6); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 6:details: ", p), err) - } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.Details)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.Details { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 6:details: ", p), err) - } - return err -} - -func (p *Response) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("Response(%+v)", *p) -} - -// Attributes: -// - InstanceKey: Key for the task to rewrite. -// - OldTask: The original configuration. -// - RewrittenTask: The rewritten configuration. -type InstanceConfigRewrite struct { - InstanceKey *InstanceKey `thrift:"instanceKey,1" json:"instanceKey"` - OldTask *TaskConfig `thrift:"oldTask,2" json:"oldTask"` - RewrittenTask *TaskConfig `thrift:"rewrittenTask,3" json:"rewrittenTask"` -} - -func NewInstanceConfigRewrite() *InstanceConfigRewrite { - return &InstanceConfigRewrite{} -} - -var InstanceConfigRewrite_InstanceKey_DEFAULT *InstanceKey - -func (p *InstanceConfigRewrite) GetInstanceKey() *InstanceKey { - if !p.IsSetInstanceKey() { - return InstanceConfigRewrite_InstanceKey_DEFAULT - } - return p.InstanceKey -} - -var InstanceConfigRewrite_OldTask_DEFAULT *TaskConfig - -func (p *InstanceConfigRewrite) GetOldTask() *TaskConfig { - if !p.IsSetOldTask() { - return InstanceConfigRewrite_OldTask_DEFAULT - } - return p.OldTask -} - -var InstanceConfigRewrite_RewrittenTask_DEFAULT *TaskConfig - -func (p *InstanceConfigRewrite) GetRewrittenTask() *TaskConfig { - if !p.IsSetRewrittenTask() { - return InstanceConfigRewrite_RewrittenTask_DEFAULT - } - return p.RewrittenTask -} -func (p *InstanceConfigRewrite) IsSetInstanceKey() bool { - return p.InstanceKey != nil -} - -func (p *InstanceConfigRewrite) IsSetOldTask() bool { - return p.OldTask != nil -} - -func (p *InstanceConfigRewrite) IsSetRewrittenTask() bool { - return p.RewrittenTask != nil -} - -func (p *InstanceConfigRewrite) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - case 3: - if err := p.readField3(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *InstanceConfigRewrite) readField1(iprot thrift.TProtocol) error { - p.InstanceKey = &InstanceKey{} - if err := p.InstanceKey.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.InstanceKey), err) - } - return nil -} - -func (p *InstanceConfigRewrite) readField2(iprot thrift.TProtocol) error { - p.OldTask = &TaskConfig{} - if err := p.OldTask.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OldTask), err) - } - return nil -} - -func (p *InstanceConfigRewrite) readField3(iprot thrift.TProtocol) error { - p.RewrittenTask = &TaskConfig{} - if err := p.RewrittenTask.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.RewrittenTask), err) - } - return nil -} - -func (p *InstanceConfigRewrite) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("InstanceConfigRewrite"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := p.writeField3(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *InstanceConfigRewrite) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("instanceKey", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:instanceKey: ", p), err) - } - if err := p.InstanceKey.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.InstanceKey), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:instanceKey: ", p), err) - } - return err -} - -func (p *InstanceConfigRewrite) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("oldTask", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:oldTask: ", p), err) - } - if err := p.OldTask.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OldTask), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:oldTask: ", p), err) - } - return err -} - -func (p *InstanceConfigRewrite) writeField3(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("rewrittenTask", thrift.STRUCT, 3); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 3:rewrittenTask: ", p), err) - } - if err := p.RewrittenTask.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.RewrittenTask), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 3:rewrittenTask: ", p), err) - } - return err -} - -func (p *InstanceConfigRewrite) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("InstanceConfigRewrite(%+v)", *p) -} - -// Attributes: -// - OldJob: The original job configuration. -// - RewrittenJob: The rewritten job configuration. -type JobConfigRewrite struct { - OldJob *JobConfiguration `thrift:"oldJob,1" json:"oldJob"` - RewrittenJob *JobConfiguration `thrift:"rewrittenJob,2" json:"rewrittenJob"` -} - -func NewJobConfigRewrite() *JobConfigRewrite { - return &JobConfigRewrite{} -} - -var JobConfigRewrite_OldJob_DEFAULT *JobConfiguration - -func (p *JobConfigRewrite) GetOldJob() *JobConfiguration { - if !p.IsSetOldJob() { - return JobConfigRewrite_OldJob_DEFAULT - } - return p.OldJob -} - -var JobConfigRewrite_RewrittenJob_DEFAULT *JobConfiguration - -func (p *JobConfigRewrite) GetRewrittenJob() *JobConfiguration { - if !p.IsSetRewrittenJob() { - return JobConfigRewrite_RewrittenJob_DEFAULT - } - return p.RewrittenJob -} -func (p *JobConfigRewrite) IsSetOldJob() bool { - return p.OldJob != nil -} - -func (p *JobConfigRewrite) IsSetRewrittenJob() bool { - return p.RewrittenJob != nil -} - -func (p *JobConfigRewrite) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *JobConfigRewrite) readField1(iprot thrift.TProtocol) error { - p.OldJob = &JobConfiguration{} - if err := p.OldJob.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.OldJob), err) - } - return nil -} - -func (p *JobConfigRewrite) readField2(iprot thrift.TProtocol) error { - p.RewrittenJob = &JobConfiguration{} - if err := p.RewrittenJob.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.RewrittenJob), err) - } - return nil -} - -func (p *JobConfigRewrite) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("JobConfigRewrite"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *JobConfigRewrite) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("oldJob", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:oldJob: ", p), err) - } - if err := p.OldJob.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.OldJob), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:oldJob: ", p), err) - } - return err -} - -func (p *JobConfigRewrite) writeField2(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("rewrittenJob", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:rewrittenJob: ", p), err) - } - if err := p.RewrittenJob.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.RewrittenJob), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:rewrittenJob: ", p), err) - } - return err -} - -func (p *JobConfigRewrite) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("JobConfigRewrite(%+v)", *p) -} - -// Attributes: -// - JobRewrite -// - InstanceRewrite -type ConfigRewrite struct { - JobRewrite *JobConfigRewrite `thrift:"jobRewrite,1" json:"jobRewrite,omitempty"` - InstanceRewrite *InstanceConfigRewrite `thrift:"instanceRewrite,2" json:"instanceRewrite,omitempty"` -} - -func NewConfigRewrite() *ConfigRewrite { - return &ConfigRewrite{} -} - -var ConfigRewrite_JobRewrite_DEFAULT *JobConfigRewrite - -func (p *ConfigRewrite) GetJobRewrite() *JobConfigRewrite { - if !p.IsSetJobRewrite() { - return ConfigRewrite_JobRewrite_DEFAULT - } - return p.JobRewrite -} - -var ConfigRewrite_InstanceRewrite_DEFAULT *InstanceConfigRewrite - -func (p *ConfigRewrite) GetInstanceRewrite() *InstanceConfigRewrite { - if !p.IsSetInstanceRewrite() { - return ConfigRewrite_InstanceRewrite_DEFAULT - } - return p.InstanceRewrite -} -func (p *ConfigRewrite) CountSetFieldsConfigRewrite() int { - count := 0 - if p.IsSetJobRewrite() { - count++ - } - if p.IsSetInstanceRewrite() { - count++ - } - return count - -} - -func (p *ConfigRewrite) IsSetJobRewrite() bool { - return p.JobRewrite != nil -} - -func (p *ConfigRewrite) IsSetInstanceRewrite() bool { - return p.InstanceRewrite != nil -} - -func (p *ConfigRewrite) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - case 2: - if err := p.readField2(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ConfigRewrite) readField1(iprot thrift.TProtocol) error { - p.JobRewrite = &JobConfigRewrite{} - if err := p.JobRewrite.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.JobRewrite), err) - } - return nil -} - -func (p *ConfigRewrite) readField2(iprot thrift.TProtocol) error { - p.InstanceRewrite = &InstanceConfigRewrite{} - if err := p.InstanceRewrite.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", p.InstanceRewrite), err) - } - return nil -} - -func (p *ConfigRewrite) Write(oprot thrift.TProtocol) error { - if c := p.CountSetFieldsConfigRewrite(); c != 1 { - return fmt.Errorf("%T write union: exactly one field must be set (%d set).", p, c) - } - if err := oprot.WriteStructBegin("ConfigRewrite"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := p.writeField2(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ConfigRewrite) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetJobRewrite() { - if err := oprot.WriteFieldBegin("jobRewrite", thrift.STRUCT, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:jobRewrite: ", p), err) - } - if err := p.JobRewrite.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.JobRewrite), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:jobRewrite: ", p), err) - } - } - return err -} - -func (p *ConfigRewrite) writeField2(oprot thrift.TProtocol) (err error) { - if p.IsSetInstanceRewrite() { - if err := oprot.WriteFieldBegin("instanceRewrite", thrift.STRUCT, 2); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 2:instanceRewrite: ", p), err) - } - if err := p.InstanceRewrite.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", p.InstanceRewrite), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 2:instanceRewrite: ", p), err) - } - } - return err -} - -func (p *ConfigRewrite) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ConfigRewrite(%+v)", *p) -} - -// Attributes: -// - RewriteCommands -type RewriteConfigsRequest struct { - RewriteCommands []*ConfigRewrite `thrift:"rewriteCommands,1" json:"rewriteCommands"` -} - -func NewRewriteConfigsRequest() *RewriteConfigsRequest { - return &RewriteConfigsRequest{} -} - -func (p *RewriteConfigsRequest) GetRewriteCommands() []*ConfigRewrite { - return p.RewriteCommands -} -func (p *RewriteConfigsRequest) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *RewriteConfigsRequest) readField1(iprot thrift.TProtocol) error { - _, size, err := iprot.ReadListBegin() - if err != nil { - return thrift.PrependError("error reading list begin: ", err) - } - tSlice := make([]*ConfigRewrite, 0, size) - p.RewriteCommands = tSlice - for i := 0; i < size; i++ { - _elem52 := &ConfigRewrite{} - if err := _elem52.Read(iprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error reading struct: ", _elem52), err) - } - p.RewriteCommands = append(p.RewriteCommands, _elem52) - } - if err := iprot.ReadListEnd(); err != nil { - return thrift.PrependError("error reading list end: ", err) - } - return nil -} - -func (p *RewriteConfigsRequest) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("RewriteConfigsRequest"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *RewriteConfigsRequest) writeField1(oprot thrift.TProtocol) (err error) { - if err := oprot.WriteFieldBegin("rewriteCommands", thrift.LIST, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:rewriteCommands: ", p), err) - } - if err := oprot.WriteListBegin(thrift.STRUCT, len(p.RewriteCommands)); err != nil { - return thrift.PrependError("error writing list begin: ", err) - } - for _, v := range p.RewriteCommands { - if err := v.Write(oprot); err != nil { - return thrift.PrependError(fmt.Sprintf("%T error writing struct: ", v), err) - } - } - if err := oprot.WriteListEnd(); err != nil { - return thrift.PrependError("error writing list end: ", err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:rewriteCommands: ", p), err) - } - return err -} - -func (p *RewriteConfigsRequest) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("RewriteConfigsRequest(%+v)", *p) -} - -// Attributes: -// - BatchSize -type ExplicitReconciliationSettings struct { - BatchSize *int32 `thrift:"batchSize,1" json:"batchSize,omitempty"` -} - -func NewExplicitReconciliationSettings() *ExplicitReconciliationSettings { - return &ExplicitReconciliationSettings{} -} - -var ExplicitReconciliationSettings_BatchSize_DEFAULT int32 - -func (p *ExplicitReconciliationSettings) GetBatchSize() int32 { - if !p.IsSetBatchSize() { - return ExplicitReconciliationSettings_BatchSize_DEFAULT - } - return *p.BatchSize -} -func (p *ExplicitReconciliationSettings) IsSetBatchSize() bool { - return p.BatchSize != nil -} - -func (p *ExplicitReconciliationSettings) Read(iprot thrift.TProtocol) error { - if _, err := iprot.ReadStructBegin(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read error: ", p), err) - } - - for { - _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() - if err != nil { - return thrift.PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) - } - if fieldTypeId == thrift.STOP { - break - } - switch fieldId { - case 1: - if err := p.readField1(iprot); err != nil { - return err - } - default: - if err := iprot.Skip(fieldTypeId); err != nil { - return err - } - } - if err := iprot.ReadFieldEnd(); err != nil { - return err - } - } - if err := iprot.ReadStructEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err) - } - return nil -} - -func (p *ExplicitReconciliationSettings) readField1(iprot thrift.TProtocol) error { - if v, err := iprot.ReadI32(); err != nil { - return thrift.PrependError("error reading field 1: ", err) - } else { - p.BatchSize = &v - } - return nil -} - -func (p *ExplicitReconciliationSettings) Write(oprot thrift.TProtocol) error { - if err := oprot.WriteStructBegin("ExplicitReconciliationSettings"); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) - } - if err := p.writeField1(oprot); err != nil { - return err - } - if err := oprot.WriteFieldStop(); err != nil { - return thrift.PrependError("write field stop error: ", err) - } - if err := oprot.WriteStructEnd(); err != nil { - return thrift.PrependError("write struct stop error: ", err) - } - return nil -} - -func (p *ExplicitReconciliationSettings) writeField1(oprot thrift.TProtocol) (err error) { - if p.IsSetBatchSize() { - if err := oprot.WriteFieldBegin("batchSize", thrift.I32, 1); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field begin error 1:batchSize: ", p), err) - } - if err := oprot.WriteI32(int32(*p.BatchSize)); err != nil { - return thrift.PrependError(fmt.Sprintf("%T.batchSize (1) field write error: ", p), err) - } - if err := oprot.WriteFieldEnd(); err != nil { - return thrift.PrependError(fmt.Sprintf("%T write field end error 1:batchSize: ", p), err) - } - } - return err -} - -func (p *ExplicitReconciliationSettings) String() string { - if p == nil { - return "" - } - return fmt.Sprintf("ExplicitReconciliationSettings(%+v)", *p) -} diff --git a/generateBindings.sh b/generateBindings.sh index c876ef9..8cb5b9d 100755 --- a/generateBindings.sh +++ b/generateBindings.sh @@ -1,6 +1,6 @@ #! /bin/bash -THRIFT_VER=0.9.3 +THRIFT_VER=0.14.0 if [[ $(thrift -version | grep -e $THRIFT_VER -c) -ne 1 ]]; then echo "Warning: This wrapper has only been tested with version" $THRIFT_VER; diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..9497185 --- /dev/null +++ b/go.mod @@ -0,0 +1,12 @@ +module github.com/paypal/gorealis + +go 1.13 + +require ( + github.com/apache/thrift v0.14.0 + github.com/davecgh/go-spew v1.1.0 // indirect + github.com/pkg/errors v0.9.1 + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/samuel/go-zookeeper v0.0.0-20171117190445-471cd4e61d7a + github.com/stretchr/testify v1.7.0 +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..f3f5eb6 --- /dev/null +++ b/go.sum @@ -0,0 +1,30 @@ +github.com/apache/thrift v0.13.0 h1:5hryIiq9gtn+MiLVn0wP37kb/uTeRZgN08WoCsAhIhI= +github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/apache/thrift v0.14.0 h1:vqZ2DP42i8th2OsgCcYZkirtbzvpZEFx53LiWDJXIAs= +github.com/apache/thrift v0.14.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pkg/errors v0.0.0-20171216070316-e881fd58d78e h1:+RHxT/gm0O3UF7nLJbdNzAmULvCFt4XfXHWzh3XI/zs= +github.com/pkg/errors v0.0.0-20171216070316-e881fd58d78e/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/ridv/thrift v0.12.1 h1:b80V1Oa2Mbd++jrlJZbJsIybO5/MCfbXKzd1A5v4aSo= +github.com/ridv/thrift v0.12.1/go.mod h1:yTMRF94RCZjO1fY1xt69yncvMbQCPdRL8BhbwIrjPx8= +github.com/ridv/thrift v0.13.1 h1:/8XnTRUqJJeiuqoL7mfnJQmXQa4GJn9tUCiP7+i6Y9o= +github.com/ridv/thrift v0.13.1/go.mod h1:yTMRF94RCZjO1fY1xt69yncvMbQCPdRL8BhbwIrjPx8= +github.com/ridv/thrift v0.13.2 h1:Q3Smr8poXd7VkWZPHvdJZzlQCJO+b5W37ECfoUL4qHc= +github.com/ridv/thrift v0.13.2/go.mod h1:yTMRF94RCZjO1fY1xt69yncvMbQCPdRL8BhbwIrjPx8= +github.com/samuel/go-zookeeper v0.0.0-20171117190445-471cd4e61d7a h1:EYL2xz/Zdo0hyqdZMXR4lmT2O11jDLTPCEqIe/FR6W4= +github.com/samuel/go-zookeeper v0.0.0-20171117190445-471cd4e61d7a/go.mod h1:gi+0XIa01GRL2eRQVjQkKGqKF3SF9vZR/HnPullcV2E= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.0 h1:LThGCOvhuJic9Gyd1VBCkhyUXmO8vKaBFvBsJ2k03rg= +github.com/stretchr/testify v1.2.0/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/helpers.go b/helpers.go new file mode 100644 index 0000000..56821c1 --- /dev/null +++ b/helpers.go @@ -0,0 +1,21 @@ +package realis + +import ( + "context" + + "github.com/paypal/gorealis/gen-go/apache/aurora" +) + +func (r *realisClient) jobExists(key aurora.JobKey) (bool, error) { + resp, err := r.client.GetConfigSummary(context.TODO(), &key) + if err != nil { + return false, err + } + + return resp == nil || + resp.GetResult_() == nil || + resp.GetResult_().GetConfigSummaryResult_() == nil || + resp.GetResult_().GetConfigSummaryResult_().GetSummary() == nil || + resp.GetResponseCode() != aurora.ResponseCode_OK, + nil +} diff --git a/job.go b/job.go index 256066b..8470546 100644 --- a/job.go +++ b/job.go @@ -15,20 +15,25 @@ package realis import ( - "github.com/rdelval/gorealis/gen-go/apache/aurora" "strconv" + + "github.com/paypal/gorealis/gen-go/apache/aurora" ) +// Job inteface is used to define a set of functions an Aurora Job object +// must implemement. +// TODO(rdelvalle): Consider getting rid of the Job interface type Job interface { // Set Job Key environment. Environment(env string) Job Role(role string) Job Name(name string) Job - CPU(cpus float64) Job CronSchedule(cron string) Job CronCollisionPolicy(policy aurora.CronCollisionPolicy) Job + CPU(cpus float64) Job Disk(disk int64) Job RAM(ram int64) Job + GPU(gpu int64) Job ExecutorName(name string) Job ExecutorData(data string) Job AddPorts(num int) Job @@ -36,6 +41,15 @@ type Job interface { AddNamedPorts(names ...string) Job AddLimitConstraint(name string, limit int32) Job AddValueConstraint(name string, negated bool, values ...string) Job + + // From Aurora Docs: + // dedicated attribute. Aurora treats this specially, and only allows matching jobs + // to run on these machines, and will only schedule matching jobs on these machines. + // When a job is created, the scheduler requires that the $role component matches + // the role field in the job configuration, and will reject the job creation otherwise. + // A wildcard (*) may be used for the role portion of the dedicated attribute, which + // will allow any owner to elect for a job to run on the host(s) + AddDedicatedConstraint(role, name string) Job AddURIs(extract bool, cache bool, values ...string) Job JobKey() *aurora.JobKey JobConfig() *aurora.JobConfiguration @@ -45,76 +59,93 @@ type Job interface { GetInstanceCount() int32 MaxFailure(maxFail int32) Job Container(container Container) Job + PartitionPolicy(policy *aurora.PartitionPolicy) Job + Tier(tier string) Job + SlaPolicy(policy *aurora.SlaPolicy) Job + Priority(priority int32) Job } -// Structure to collect all information pertaining to an Aurora job. +type resourceType int + +const ( + CPU resourceType = iota + RAM + DISK + GPU +) + +const portNamePrefix = "org.apache.aurora.port." + +// AuroraJob is a structure to collect all information pertaining to an Aurora job. type AuroraJob struct { - jobConfig *aurora.JobConfiguration - resources map[string]*aurora.Resource - portCount int + jobConfig *aurora.JobConfiguration + resources map[resourceType]*aurora.Resource + metadata map[string]*aurora.Metadata + constraints map[string]*aurora.Constraint + portCount int } -// Create a Job object with everything initialized. +// NewJob is used to create a Job object with everything initialized. func NewJob() Job { jobConfig := aurora.NewJobConfiguration() taskConfig := aurora.NewTaskConfig() jobKey := aurora.NewJobKey() - //Job Config + // Job Config jobConfig.Key = jobKey jobConfig.TaskConfig = taskConfig - //Task Config + // Task Config taskConfig.Job = jobKey taskConfig.Container = aurora.NewContainer() taskConfig.Container.Mesos = aurora.NewMesosContainer() - taskConfig.MesosFetcherUris = make(map[*aurora.MesosFetcherURI]bool) - taskConfig.Metadata = make(map[*aurora.Metadata]bool) - taskConfig.Constraints = make(map[*aurora.Constraint]bool) - //Resources + // Resources numCpus := aurora.NewResource() ramMb := aurora.NewResource() diskMb := aurora.NewResource() - resources := make(map[string]*aurora.Resource) - resources["cpu"] = numCpus - resources["ram"] = ramMb - resources["disk"] = diskMb + resources := map[resourceType]*aurora.Resource{CPU: numCpus, RAM: ramMb, DISK: diskMb} + taskConfig.Resources = []*aurora.Resource{numCpus, ramMb, diskMb} - taskConfig.Resources = make(map[*aurora.Resource]bool) - taskConfig.Resources[numCpus] = true - taskConfig.Resources[ramMb] = true - taskConfig.Resources[diskMb] = true + numCpus.NumCpus = new(float64) + ramMb.RamMb = new(int64) + diskMb.DiskMb = new(int64) - return AuroraJob{jobConfig, resources, 0} + return &AuroraJob{ + jobConfig: jobConfig, + resources: resources, + metadata: make(map[string]*aurora.Metadata), + constraints: make(map[string]*aurora.Constraint), + portCount: 0, + } } -// Set Job Key environment. -func (j AuroraJob) Environment(env string) Job { +// Environment sets the Job Key environment. +func (j *AuroraJob) Environment(env string) Job { j.jobConfig.Key.Environment = env return j } -// Set Job Key Role. -func (j AuroraJob) Role(role string) Job { +// Role sets the Job Key role. +func (j *AuroraJob) Role(role string) Job { j.jobConfig.Key.Role = role - //Will be deprecated - identity := &aurora.Identity{role} + // Will be deprecated + identity := &aurora.Identity{User: role} j.jobConfig.Owner = identity j.jobConfig.TaskConfig.Owner = identity return j } -// Set Job Key Name. -func (j AuroraJob) Name(name string) Job { +// Name sets the Job Key Name. +func (j *AuroraJob) Name(name string) Job { j.jobConfig.Key.Name = name return j } -// Set name of the executor that will the task will be configured to. -func (j AuroraJob) ExecutorName(name string) Job { +// ExecutorName sets the name of the executor that will the task will be configured to. +func (j *AuroraJob) ExecutorName(name string) Job { if j.jobConfig.TaskConfig.ExecutorConfig == nil { j.jobConfig.TaskConfig.ExecutorConfig = aurora.NewExecutorConfig() @@ -124,8 +155,8 @@ func (j AuroraJob) ExecutorName(name string) Job { return j } -// Will be included as part of entire task inside the scheduler that will be serialized. -func (j AuroraJob) ExecutorData(data string) Job { +// ExecutorData sets the data blob that will be passed to the Mesos executor. +func (j *AuroraJob) ExecutorData(data string) Job { if j.jobConfig.TaskConfig.ExecutorConfig == nil { j.jobConfig.TaskConfig.ExecutorConfig = aurora.NewExecutorConfig() @@ -135,148 +166,226 @@ func (j AuroraJob) ExecutorData(data string) Job { return j } -func (j AuroraJob) CPU(cpus float64) Job { - j.resources["cpu"].NumCpus = &cpus - j.jobConfig.TaskConfig.NumCpus = cpus //Will be deprecated soon - +// CPU sets the amount of CPU each task will use in an Aurora Job. +func (j *AuroraJob) CPU(cpus float64) Job { + *j.resources[CPU].NumCpus = cpus return j } -func (j AuroraJob) RAM(ram int64) Job { - j.resources["ram"].RamMb = &ram - j.jobConfig.TaskConfig.RamMb = ram //Will be deprecated soon - +// RAM sets the amount of RAM each task will use in an Aurora Job. +func (j *AuroraJob) RAM(ram int64) Job { + *j.resources[RAM].RamMb = ram return j } -func (j AuroraJob) Disk(disk int64) Job { - j.resources["disk"].DiskMb = &disk - j.jobConfig.TaskConfig.DiskMb = disk //Will be deprecated - +// Disk sets the amount of Disk each task will use in an Aurora Job. +func (j *AuroraJob) Disk(disk int64) Job { + *j.resources[DISK].DiskMb = disk return j } -// How many failures to tolerate before giving up. -func (j AuroraJob) MaxFailure(maxFail int32) Job { +// GPU sets the amount of GPU each task will use in an Aurora Job. +func (j *AuroraJob) GPU(gpu int64) Job { + // GPU resource must be set explicitly since the scheduler by default + // rejects jobs with GPU resources attached to it. + if _, ok := j.resources[GPU]; !ok { + j.resources[GPU] = &aurora.Resource{} + j.JobConfig().GetTaskConfig().Resources = append( + j.JobConfig().GetTaskConfig().Resources, + j.resources[GPU]) + } + + j.resources[GPU].NumGpus = &gpu + return j +} + +// MaxFailure sets how many failures to tolerate before giving up per Job. +func (j *AuroraJob) MaxFailure(maxFail int32) Job { j.jobConfig.TaskConfig.MaxTaskFailures = maxFail return j } -// How many instances of the job to run -func (j AuroraJob) InstanceCount(instCount int32) Job { +// InstanceCount sets how many instances of the task to run for this Job. +func (j *AuroraJob) InstanceCount(instCount int32) Job { j.jobConfig.InstanceCount = instCount return j } -func (j AuroraJob) CronSchedule(cron string) Job { +// CronSchedule allows the user to configure a cron schedule for this job to run in. +func (j *AuroraJob) CronSchedule(cron string) Job { j.jobConfig.CronSchedule = &cron return j } -func (j AuroraJob) CronCollisionPolicy(policy aurora.CronCollisionPolicy) Job { +// CronCollisionPolicy allows the user to decide what happens if two or more instances +// of the same Cron job need to run. +func (j *AuroraJob) CronCollisionPolicy(policy aurora.CronCollisionPolicy) Job { j.jobConfig.CronCollisionPolicy = policy return j } -// How many instances of the job to run -func (j AuroraJob) GetInstanceCount() int32 { +// GetInstanceCount returns how many tasks this Job contains. +func (j *AuroraJob) GetInstanceCount() int32 { return j.jobConfig.InstanceCount } -// Restart the job's tasks if they fail -func (j AuroraJob) IsService(isService bool) Job { +// IsService returns true if the job is a long term running job or false if it is an ad-hoc job. +func (j *AuroraJob) IsService(isService bool) Job { j.jobConfig.TaskConfig.IsService = isService return j } -// Get the current job configurations key to use for some realis calls. -func (j AuroraJob) JobKey() *aurora.JobKey { +// JobKey returns the job's configuration key. +func (j *AuroraJob) JobKey() *aurora.JobKey { return j.jobConfig.Key } -// Get the current job configurations key to use for some realis calls. -func (j AuroraJob) JobConfig() *aurora.JobConfiguration { +// JobConfig returns the job's configuration. +func (j *AuroraJob) JobConfig() *aurora.JobConfiguration { return j.jobConfig } -func (j AuroraJob) TaskConfig() *aurora.TaskConfig { +// TaskConfig returns the job's task(shard) configuration. +func (j *AuroraJob) TaskConfig() *aurora.TaskConfig { return j.jobConfig.TaskConfig } -// Add a list of URIs with the same extract and cache configuration. Scheduler must have +// AddURIs adds a list of URIs with the same extract and cache configuration. Scheduler must have // --enable_mesos_fetcher flag enabled. Currently there is no duplicate detection. -func (j AuroraJob) AddURIs(extract bool, cache bool, values ...string) Job { +func (j *AuroraJob) AddURIs(extract bool, cache bool, values ...string) Job { for _, value := range values { - j.jobConfig. - TaskConfig. - MesosFetcherUris[&aurora.MesosFetcherURI{value, &extract, &cache}] = true + j.jobConfig.TaskConfig.MesosFetcherUris = append(j.jobConfig.TaskConfig.MesosFetcherUris, + &aurora.MesosFetcherURI{Value: value, Extract: &extract, Cache: &cache}) } return j } -// Adds a Mesos label to the job. Note that Aurora will add the +// AddLabel adds a Mesos label to the job. Note that Aurora will add the // prefix "org.apache.aurora.metadata." to the beginning of each key. -func (j AuroraJob) AddLabel(key string, value string) Job { - j.jobConfig.TaskConfig.Metadata[&aurora.Metadata{key, value}] = true +func (j *AuroraJob) AddLabel(key string, value string) Job { + if _, ok := j.metadata[key]; !ok { + j.metadata[key] = &aurora.Metadata{Key: key} + j.jobConfig.TaskConfig.Metadata = append(j.jobConfig.TaskConfig.Metadata, j.metadata[key]) + } + + j.metadata[key].Value = value return j } -// Add a named port to the job configuration These are random ports as it's +// AddNamedPorts adds a named port to the job configuration These are random ports as it's // not currently possible to request specific ports using Aurora. -func (j AuroraJob) AddNamedPorts(names ...string) Job { +func (j *AuroraJob) AddNamedPorts(names ...string) Job { j.portCount += len(names) for _, name := range names { - j.jobConfig.TaskConfig.Resources[&aurora.Resource{NamedPort: &name}] = true + j.jobConfig.TaskConfig.Resources = append( + j.jobConfig.TaskConfig.Resources, + &aurora.Resource{NamedPort: &name}) } return j } -// Adds a request for a number of ports to the job configuration. The names chosen for these ports +// AddPorts adds a request for a number of ports to the job configuration. The names chosen for these ports // will be org.apache.aurora.port.X, where X is the current port count for the job configuration // starting at 0. These are random ports as it's not currently possible to request // specific ports using Aurora. -func (j AuroraJob) AddPorts(num int) Job { +func (j *AuroraJob) AddPorts(num int) Job { start := j.portCount j.portCount += num for i := start; i < j.portCount; i++ { - portName := "org.apache.aurora.port." + strconv.Itoa(i) - j.jobConfig.TaskConfig.Resources[&aurora.Resource{NamedPort: &portName}] = true + portName := portNamePrefix + strconv.Itoa(i) + j.jobConfig.TaskConfig.Resources = append( + j.jobConfig.TaskConfig.Resources, + &aurora.Resource{NamedPort: &portName}) } return j } +// AddValueConstraint allows the user to add a value constrain to the job to limit which agents the job's +// tasks can be run on. If the name matches a constraint that was previously set, the previous value will be +// overwritten. In case the previous constraint attached to the name was of type limit, the constraint will be clobbered +// by this new Value constraint. // From Aurora Docs: // Add a Value constraint // name - Mesos slave attribute that the constraint is matched against. // If negated = true , treat this as a 'not' - to avoid specific values. // Values - list of values we look for in attribute name -func (j AuroraJob) AddValueConstraint(name string, negated bool, values ...string) Job { - constraintValues := make(map[string]bool) - for _, value := range values { - constraintValues[value] = true +func (j *AuroraJob) AddValueConstraint(name string, negated bool, values ...string) Job { + if _, ok := j.constraints[name]; !ok { + j.constraints[name] = &aurora.Constraint{Name: name} + j.jobConfig.TaskConfig.Constraints = append(j.jobConfig.TaskConfig.Constraints, j.constraints[name]) + } + + j.constraints[name].Constraint = &aurora.TaskConstraint{ + Value: &aurora.ValueConstraint{ + Negated: negated, + Values: values, + }, + Limit: nil, } - j.jobConfig.TaskConfig.Constraints[&aurora.Constraint{name, - &aurora.TaskConstraint{&aurora.ValueConstraint{negated, constraintValues}, nil}}] = true return j } +// AddLimitConstraint allows the user to limit how many tasks form the same Job are run on a single host. +// If the name matches a constraint that was previously set, the previous value will be +// overwritten. In case the previous constraint attached to the name was of type Value, the constraint will be clobbered +// by this new Limit constraint. // From Aurora Docs: // A constraint that specifies the maximum number of active tasks on a host with // a matching attribute that may be scheduled simultaneously. -func (j AuroraJob) AddLimitConstraint(name string, limit int32) Job { - j.jobConfig.TaskConfig.Constraints[&aurora.Constraint{name, - &aurora.TaskConstraint{nil, &aurora.LimitConstraint{limit}}}] = true +func (j *AuroraJob) AddLimitConstraint(name string, limit int32) Job { + if _, ok := j.constraints[name]; !ok { + j.constraints[name] = &aurora.Constraint{Name: name} + j.jobConfig.TaskConfig.Constraints = append(j.jobConfig.TaskConfig.Constraints, j.constraints[name]) + } + + j.constraints[name].Constraint = &aurora.TaskConstraint{ + Value: nil, + Limit: &aurora.LimitConstraint{Limit: limit}, + } return j } -// Set a container to run for the job configuration to run. -// TODO (rdelvalle): Add no thermos mode where container is launched as a task and not an executor. -func (j AuroraJob) Container(container Container) Job { +// AddDedicatedConstraint is a convenience function that allows the user to +// add a dedicated constraint to a Job configuration. +// In case a previous dedicated constraint was set, it will be clobbered by this new value. +func (j *AuroraJob) AddDedicatedConstraint(role, name string) Job { + j.AddValueConstraint("dedicated", false, role+"/"+name) + + return j +} + +// Container sets a container to run for the job configuration to run. +func (j *AuroraJob) Container(container Container) Job { j.jobConfig.TaskConfig.Container = container.Build() return j } + +// PartitionPolicy sets a partition policy for the job configuration to implement. +func (j *AuroraJob) PartitionPolicy(policy *aurora.PartitionPolicy) Job { + j.jobConfig.TaskConfig.PartitionPolicy = policy + return j +} + +// Tier sets the Tier for the Job. +func (j *AuroraJob) Tier(tier string) Job { + j.jobConfig.TaskConfig.Tier = &tier + + return j +} + +// SlaPolicy sets an SlaPolicy for the Job. +func (j *AuroraJob) SlaPolicy(policy *aurora.SlaPolicy) Job { + j.jobConfig.TaskConfig.SlaPolicy = policy + + return j +} + +func (j *AuroraJob) Priority(priority int32) Job { + j.jobConfig.TaskConfig.Priority = priority + return j +} diff --git a/logger.go b/logger.go new file mode 100644 index 0000000..340171f --- /dev/null +++ b/logger.go @@ -0,0 +1,87 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package realis + +type logger interface { + Println(v ...interface{}) + Printf(format string, v ...interface{}) + Print(v ...interface{}) +} + +// NoopLogger is a logger that can be attached to the client which will not print anything. +type NoopLogger struct{} + +// Printf is a NOOP function here. +func (NoopLogger) Printf(format string, a ...interface{}) {} + +// Print is a NOOP function here. +func (NoopLogger) Print(a ...interface{}) {} + +// Println is a NOOP function here. +func (NoopLogger) Println(a ...interface{}) {} + +// LevelLogger is a logger that can be configured to output different levels of information: Debug and Trace. +// Trace should only be enabled when very in depth information about the sequence of events a function took is needed. +type LevelLogger struct { + logger + debug bool + trace bool +} + +// EnableDebug enables debug level logging for the LevelLogger +func (l *LevelLogger) EnableDebug(enable bool) { + l.debug = enable +} + +// EnableTrace enables trace level logging for the LevelLogger +func (l *LevelLogger) EnableTrace(enable bool) { + l.trace = enable +} + +func (l LevelLogger) debugPrintf(format string, a ...interface{}) { + if l.debug { + l.Printf("[DEBUG] "+format, a...) + } +} + +func (l LevelLogger) debugPrint(a ...interface{}) { + if l.debug { + l.Print(append([]interface{}{"[DEBUG] "}, a...)...) + } +} + +func (l LevelLogger) debugPrintln(a ...interface{}) { + if l.debug { + l.Println(append([]interface{}{"[DEBUG] "}, a...)...) + } +} + +func (l LevelLogger) tracePrintf(format string, a ...interface{}) { + if l.trace { + l.Printf("[TRACE] "+format, a...) + } +} + +func (l LevelLogger) tracePrint(a ...interface{}) { + if l.trace { + l.Print(append([]interface{}{"[TRACE] "}, a...)...) + } +} + +func (l LevelLogger) tracePrintln(a ...interface{}) { + if l.trace { + l.Println(append([]interface{}{"[TRACE] "}, a...)...) + } +} diff --git a/monitors.go b/monitors.go index f1acb52..edbe4e4 100644 --- a/monitors.go +++ b/monitors.go @@ -12,84 +12,285 @@ * limitations under the License. */ -// Collection of monitors to create synchronicity package realis import ( - "fmt" - "github.com/pkg/errors" - "github.com/rdelval/gorealis/gen-go/apache/aurora" - "github.com/rdelval/gorealis/response" - "os" "time" + + "github.com/paypal/gorealis/gen-go/apache/aurora" + "github.com/pkg/errors" ) +// Monitor is a wrapper for the Realis client which allows us to have functions +// with the same name for Monitoring purposes. +// TODO(rdelvalle): Deprecate monitors and instead add prefix Monitor to +// all functions in this file like it is done in V2. type Monitor struct { Client Realis } -// Polls the scheduler every certain amount of time to see if the update has succeeded -func (m *Monitor) JobUpdate(updateKey aurora.JobUpdateKey, interval int, timeout int) bool { +// JobUpdate polls the scheduler every certain amount of time to see if the update has entered a terminal state. +func (m *Monitor) JobUpdate( + updateKey aurora.JobUpdateKey, + interval int, + timeout int) (bool, error) { updateQ := aurora.JobUpdateQuery{ - Key: &updateKey, - Limit: 1, + Key: &updateKey, + Limit: 1, + UpdateStatuses: TerminalUpdateStates(), + } + updateSummaries, err := m.JobUpdateQuery( + updateQ, + time.Duration(interval)*time.Second, + time.Duration(timeout)*time.Second) + + status := updateSummaries[0].State.Status + + if err != nil { + return false, err } - for i := 0; i*interval <= timeout; i++ { - respDetail, err := m.Client.JobUpdateDetails(updateQ) - if err != nil { - fmt.Println(err) - os.Exit(1) - } + m.Client.RealisConfig().logger.Printf("job update status: %v\n", status) - updateDetail := response.JobUpdateDetails(respDetail) + // Rolled forward is the only state in which an update has been successfully updated + // if we encounter an inactive state and it is not at rolled forward, update failed + switch status { + case aurora.JobUpdateStatus_ROLLED_FORWARD: + return true, nil + case aurora.JobUpdateStatus_ROLLED_BACK, + aurora.JobUpdateStatus_ABORTED, + aurora.JobUpdateStatus_ERROR, + aurora.JobUpdateStatus_FAILED: + return false, errors.Errorf("bad terminal state for update: %v", status) + default: + return false, errors.Errorf("unexpected update state: %v", status) + } +} - if len(updateDetail) == 0 { - fmt.Println("No update found") - return false - } - status := updateDetail[0].Update.Summary.State.Status +// JobUpdateStatus polls the scheduler every certain amount of time to see if the update has entered a specified state. +func (m *Monitor) JobUpdateStatus(updateKey aurora.JobUpdateKey, + desiredStatuses []aurora.JobUpdateStatus, + interval, timeout time.Duration) (aurora.JobUpdateStatus, error) { + updateQ := aurora.JobUpdateQuery{ + Key: &updateKey, + Limit: 1, + UpdateStatuses: desiredStatuses, + } + summary, err := m.JobUpdateQuery(updateQ, interval, timeout) + if err != nil { + return 0, err + } - if _, ok := aurora.ACTIVE_JOB_UPDATE_STATES[status]; !ok { + return summary[0].State.Status, nil +} - // Rolled forward is the only state in which an update has been successfully updated - // if we encounter an inactive state and it is not at rolled forward, update failed - if status == aurora.JobUpdateStatus_ROLLED_FORWARD { - fmt.Println("Update succeded") - return true - } else { - fmt.Println("Update failed") - return false +// JobUpdateQuery polls the scheduler every certain amount of time to see if the query call returns any results. +func (m *Monitor) JobUpdateQuery( + updateQuery aurora.JobUpdateQuery, + interval time.Duration, + timeout time.Duration) ([]*aurora.JobUpdateSummary, error) { + + ticker := time.NewTicker(interval) + defer ticker.Stop() + timer := time.NewTimer(timeout) + defer timer.Stop() + + var cliErr error + var respDetail *aurora.Response + for { + select { + case <-ticker.C: + respDetail, cliErr = m.Client.GetJobUpdateSummaries(&updateQuery) + if cliErr != nil { + return nil, cliErr } + + updateSummaries := respDetail.Result_.GetJobUpdateSummariesResult_.UpdateSummaries + if len(updateSummaries) >= 1 { + return updateSummaries, nil + } + + case <-timer.C: + return nil, newTimedoutError(errors.New("job update monitor timed out")) } - - fmt.Println("Polling, update still active...") - time.Sleep(time.Duration(interval) * time.Second) } - - fmt.Println("Timed out") - return false } -func (m *Monitor) Instances(key *aurora.JobKey, instances int32, interval int, timeout int) (bool, error) { - - for i := 0; i*interval < timeout; i++ { - - live, err := m.Client.GetInstanceIds(key, aurora.LIVE_STATES) - - if err != nil { - return false, errors.Wrap(err, "Unable to communicate with Aurora") - } - - if len(live) == int(instances) { - return true, nil - } - - fmt.Println("Polling, instances running: ", len(live)) - time.Sleep(time.Duration(interval) * time.Second) +// AutoPausedUpdateMonitor is a special monitor for auto pause enabled batch updates. This monitor ensures that the update +// being monitored is capable of auto pausing and has auto pausing enabled. After verifying this information, +// the monitor watches for the job to enter the ROLL_FORWARD_PAUSED state and calculates the current batch +// the update is in using information from the update configuration. +func (m *Monitor) AutoPausedUpdateMonitor(key aurora.JobUpdateKey, interval, timeout time.Duration) (int, error) { + key.Job = &aurora.JobKey{ + Role: key.Job.Role, + Environment: key.Job.Environment, + Name: key.Job.Name, + } + query := aurora.JobUpdateQuery{ + UpdateStatuses: aurora.ACTIVE_JOB_UPDATE_STATES, + Limit: 1, + Key: &key, } - fmt.Println("Timed out") - return false, nil + response, err := m.Client.JobUpdateDetails(query) + if err != nil { + return -1, errors.Wrap(err, "unable to get information about update") + } + + // TODO (rdelvalle): check for possible nil values when going down the list of structs + updateDetails := response.Result_.GetJobUpdateDetailsResult_.DetailsList + if len(updateDetails) == 0 { + return -1, errors.Errorf("details for update could not be found") + } + + updateStrategy := updateDetails[0].Update.Instructions.Settings.UpdateStrategy + + var batchSizes []int32 + switch { + case updateStrategy.IsSetVarBatchStrategy(): + batchSizes = updateStrategy.VarBatchStrategy.GroupSizes + if !updateStrategy.VarBatchStrategy.AutopauseAfterBatch { + return -1, errors.Errorf("update does not have auto pause enabled") + } + case updateStrategy.IsSetBatchStrategy(): + batchSizes = []int32{updateStrategy.BatchStrategy.GroupSize} + if !updateStrategy.BatchStrategy.AutopauseAfterBatch { + return -1, errors.Errorf("update does not have auto pause enabled") + } + default: + return -1, errors.Errorf("update is not using a batch update strategy") + } + + query.UpdateStatuses = append(TerminalUpdateStates(), aurora.JobUpdateStatus_ROLL_FORWARD_PAUSED) + summary, err := m.JobUpdateQuery(query, interval, timeout) + if err != nil { + return -1, err + } + + if !(summary[0].State.Status == aurora.JobUpdateStatus_ROLL_FORWARD_PAUSED || + summary[0].State.Status == aurora.JobUpdateStatus_ROLLED_FORWARD) { + return -1, errors.Errorf("update is in a terminal state %v", summary[0].State.Status) + } + + updatingInstances := make(map[int32]struct{}) + for _, e := range updateDetails[0].InstanceEvents { + // We only care about INSTANCE_UPDATING actions because we only care that they've been attempted + if e != nil && e.GetAction() == aurora.JobUpdateAction_INSTANCE_UPDATING { + updatingInstances[e.GetInstanceId()] = struct{}{} + } + } + + return calculateCurrentBatch(int32(len(updatingInstances)), batchSizes), nil +} + +// Instances will monitor a Job until all instances enter one of the LIVE_STATES +func (m *Monitor) Instances(key *aurora.JobKey, instances int32, interval, timeout int) (bool, error) { + return m.ScheduleStatus(key, instances, LiveStates, interval, timeout) +} + +// ScheduleStatus will monitor a Job until all instances enter a desired status. +// Defaults sets of desired statuses provided by the thrift API include: +// ACTIVE_STATES, SLAVE_ASSIGNED_STATES, LIVE_STATES, and TERMINAL_STATES +func (m *Monitor) ScheduleStatus( + key *aurora.JobKey, + instanceCount int32, + desiredStatuses map[aurora.ScheduleStatus]bool, + interval int, + timeout int) (bool, error) { + + ticker := time.NewTicker(time.Second * time.Duration(interval)) + defer ticker.Stop() + timer := time.NewTimer(time.Second * time.Duration(timeout)) + defer timer.Stop() + + wantedStatuses := make([]aurora.ScheduleStatus, 0) + + for status := range desiredStatuses { + wantedStatuses = append(wantedStatuses, status) + } + + for { + select { + case <-ticker.C: + + // Query Aurora for the state of the job key ever interval + instCount, cliErr := m.Client.GetInstanceIds(key, wantedStatuses) + if cliErr != nil { + return false, errors.Wrap(cliErr, "Unable to communicate with Aurora") + } + if len(instCount) == int(instanceCount) { + return true, nil + } + case <-timer.C: + + // If the timer runs out, return a timeout error to user + return false, newTimedoutError(errors.New("schedule status monitor timed out")) + } + } +} + +// HostMaintenance will monitor host status until all hosts match the status provided. +// Returns a map where the value is true if the host +// is in one of the desired mode(s) or false if it is not as of the time when the monitor exited. +func (m *Monitor) HostMaintenance( + hosts []string, + modes []aurora.MaintenanceMode, + interval, timeout int) (map[string]bool, error) { + + // Transform modes to monitor for into a set for easy lookup + desiredMode := make(map[aurora.MaintenanceMode]struct{}) + for _, mode := range modes { + desiredMode[mode] = struct{}{} + } + + // Turn slice into a host set to eliminate duplicates. + // We also can't use a simple count because multiple modes means + // we can have multiple matches for a single host. + // I.e. host A transitions from ACTIVE to DRAINING to DRAINED while monitored + remainingHosts := make(map[string]struct{}) + for _, host := range hosts { + remainingHosts[host] = struct{}{} + } + + hostResult := make(map[string]bool) + + ticker := time.NewTicker(time.Second * time.Duration(interval)) + defer ticker.Stop() + timer := time.NewTimer(time.Second * time.Duration(timeout)) + defer timer.Stop() + + for { + select { + case <-ticker.C: + // Client call has multiple retries internally + _, result, err := m.Client.MaintenanceStatus(hosts...) + if err != nil { + // Error is either a payload error or a severe connection error + for host := range remainingHosts { + hostResult[host] = false + } + return hostResult, errors.Wrap(err, "client error in monitor") + } + + for _, status := range result.GetStatuses() { + + if _, ok := desiredMode[status.GetMode()]; ok { + hostResult[status.GetHost()] = true + delete(remainingHosts, status.GetHost()) + + if len(remainingHosts) == 0 { + return hostResult, nil + } + } + } + + case <-timer.C: + for host := range remainingHosts { + hostResult[host] = false + } + + return hostResult, newTimedoutError(errors.New("host maintenance monitor timed out")) + } + } } diff --git a/realis.go b/realis.go index d8a477e..0464908 100644 --- a/realis.go +++ b/realis.go @@ -16,87 +16,492 @@ package realis import ( + "context" + "crypto/tls" "encoding/base64" "fmt" - "git.apache.org/thrift.git/lib/go/thrift" - "github.com/pkg/errors" - "github.com/rdelval/gorealis/gen-go/apache/aurora" - "github.com/rdelval/gorealis/response" + "log" "net/http" - "net/http/cookiejar" "os" + "sort" + "strings" + "sync" "time" + + "github.com/apache/thrift/lib/go/thrift" + "github.com/pkg/errors" + + "github.com/paypal/gorealis/gen-go/apache/aurora" + "github.com/paypal/gorealis/response" ) +const version = "1.24.1" + +// Realis is an interface that defines the various APIs that may be used to communicate with +// the Apache Aurora scheduler. +// TODO(rdelvalle): Move documentation to interface in order to make godoc look better accessible +// Or get rid of the interface type Realis interface { AbortJobUpdate(updateKey aurora.JobUpdateKey, message string) (*aurora.Response, error) AddInstances(instKey aurora.InstanceKey, count int32) (*aurora.Response, error) CreateJob(auroraJob Job) (*aurora.Response, error) + CreateService( + auroraJob Job, + settings *aurora.JobUpdateSettings) (*aurora.Response, *aurora.StartJobUpdateResult_, error) DescheduleCronJob(key *aurora.JobKey) (*aurora.Response, error) FetchTaskConfig(instKey aurora.InstanceKey) (*aurora.TaskConfig, error) - GetInstanceIds(key *aurora.JobKey, states map[aurora.ScheduleStatus]bool) (map[int32]bool, error) + GetInstanceIds(key *aurora.JobKey, states []aurora.ScheduleStatus) ([]int32, error) + GetJobUpdateSummaries(jobUpdateQuery *aurora.JobUpdateQuery) (*aurora.Response, error) + GetTaskStatus(query *aurora.TaskQuery) ([]*aurora.ScheduledTask, error) + GetTasksWithoutConfigs(query *aurora.TaskQuery) ([]*aurora.ScheduledTask, error) + GetJobs(role string) (*aurora.Response, *aurora.GetJobsResult_, error) + GetPendingReason(query *aurora.TaskQuery) (pendingReasons []*aurora.PendingReason, e error) JobUpdateDetails(updateQuery aurora.JobUpdateQuery) (*aurora.Response, error) KillJob(key *aurora.JobKey) (*aurora.Response, error) KillInstances(key *aurora.JobKey, instances ...int32) (*aurora.Response, error) + RemoveInstances(key *aurora.JobKey, count int32) (*aurora.Response, error) RestartInstances(key *aurora.JobKey, instances ...int32) (*aurora.Response, error) RestartJob(key *aurora.JobKey) (*aurora.Response, error) RollbackJobUpdate(key aurora.JobUpdateKey, message string) (*aurora.Response, error) ScheduleCronJob(auroraJob Job) (*aurora.Response, error) StartJobUpdate(updateJob *UpdateJob, message string) (*aurora.Response, error) + PauseJobUpdate(key *aurora.JobUpdateKey, message string) (*aurora.Response, error) + ResumeJobUpdate(key *aurora.JobUpdateKey, message string) (*aurora.Response, error) + PulseJobUpdate(key *aurora.JobUpdateKey) (*aurora.Response, error) StartCronJob(key *aurora.JobKey) (*aurora.Response, error) + // TODO: Remove this method and make it private to avoid race conditions + ReestablishConn() error + RealisConfig() *config Close() + + // Admin functions + DrainHosts(hosts ...string) (*aurora.Response, *aurora.DrainHostsResult_, error) + SLADrainHosts(policy *aurora.SlaPolicy, timeout int64, hosts ...string) (*aurora.DrainHostsResult_, error) + StartMaintenance(hosts ...string) (*aurora.Response, *aurora.StartMaintenanceResult_, error) + EndMaintenance(hosts ...string) (*aurora.Response, *aurora.EndMaintenanceResult_, error) + MaintenanceStatus(hosts ...string) (*aurora.Response, *aurora.MaintenanceStatusResult_, error) + SetQuota(role string, cpu *float64, ram *int64, disk *int64) (*aurora.Response, error) + GetQuota(role string) (*aurora.Response, error) + Snapshot() error + PerformBackup() error + // Force an Implicit reconciliation between Mesos and Aurora + ForceImplicitTaskReconciliation() error + // Force an Explicit reconciliation between Mesos and Aurora + ForceExplicitTaskReconciliation(batchSize *int32) error } type realisClient struct { - client *aurora.AuroraSchedulerManagerClient + config *config + client *aurora.AuroraSchedulerManagerClient + readonlyClient *aurora.ReadOnlySchedulerClient + adminClient *aurora.AuroraAdminClient + logger LevelLogger + lock *sync.Mutex + debug bool + transport thrift.TTransport } -// Wrap object to provide future flexibility -type RealisConfig struct { - transport thrift.TTransport +type config struct { + username, password string + url string + timeoutms int + binTransport, jsonTransport bool + cluster *Cluster + backoff Backoff + transport thrift.TTransport + protoFactory thrift.TProtocolFactory + logger *LevelLogger + insecureSkipVerify bool + certspath string + certExtensions map[string]struct{} + clientKey, clientCert string + options []ClientOption + debug bool + trace bool + zkOptions []ZKOpt + failOnPermanentErrors bool } -// Create a new Client with a default transport layer -func NewClient(config RealisConfig) Realis { - - httpTrans := (config.transport).(*thrift.THttpClient) - httpTrans.SetHeader("User-Agent", "GoRealis v1.0.4") - - protocolFactory := thrift.NewTJSONProtocolFactory() - - return realisClient{ - client: aurora.NewAuroraSchedulerManagerClientFactory(config.transport, protocolFactory)} +var defaultBackoff = Backoff{ + Steps: 3, + Duration: 10 * time.Second, + Factor: 5.0, + Jitter: 0.1, } -// Create a default configuration of the transport layer, requires a URL to test connection with. -func NewDefaultConfig(url string) (RealisConfig, error) { - jar, err := cookiejar.New(nil) +var defaultSlaPolicy = aurora.SlaPolicy{ + PercentageSlaPolicy: &aurora.PercentageSlaPolicy{ + Percentage: 66, + DurationSecs: 300, + }, +} +const defaultSlaDrainTimeoutSecs = 900 + +// ClientOption is an alias for a function that modifies the realis config object +type ClientOption func(*config) + +// BasicAuth sets authentication used against Apache Shiro in the Aurora scheduler +func BasicAuth(username, password string) ClientOption { + return func(config *config) { + config.username = username + config.password = password + } +} + +// SchedulerUrl sets the immediate location of the current Aurora scheduler leader +func SchedulerUrl(url string) ClientOption { + return func(config *config) { + config.url = url + } +} + +// TimeoutMS sets the connection timeout for an HTTP post request in Miliseconds +func TimeoutMS(timeout int) ClientOption { + return func(config *config) { + config.timeoutms = timeout + } +} + +// ZKCluster sets a clusters.json provided cluster configuration to the client +func ZKCluster(cluster *Cluster) ClientOption { + return func(config *config) { + config.cluster = cluster + } +} + +// ZKUrl sets the direct location of a Zookeeper node on which the Aurora leader registers itself +func ZKUrl(url string) ClientOption { + opts := []ZKOpt{ZKEndpoints(strings.Split(url, ",")...), ZKPath("/aurora/scheduler")} + + return func(config *config) { + if config.zkOptions == nil { + config.zkOptions = opts + } else { + config.zkOptions = append(config.zkOptions, opts...) + } + } +} + +// Retries configures the retry mechanism for the client +func Retries(backoff Backoff) ClientOption { + return func(config *config) { + config.backoff = backoff + } +} + +// ThriftJSON configures the client to use the Thrift JSON protocol. +func ThriftJSON() ClientOption { + return func(config *config) { + config.jsonTransport = true + } +} + +// ThriftBinary configures the client to use the Thrift Binary protocol. +func ThriftBinary() ClientOption { + return func(config *config) { + config.binTransport = true + } +} + +// BackOff is an alternative name for the Retry mechanism configuration. +func BackOff(b Backoff) ClientOption { + return func(config *config) { + config.backoff = b + } +} + +// InsecureSkipVerify configures the client to not check for matching hosts names on certificates +// when using an SSL enabled Aurora scheduler. +func InsecureSkipVerify(insecureSkipVerify bool) ClientOption { + return func(config *config) { + config.insecureSkipVerify = insecureSkipVerify + } +} + +// Certspath sets the directory where the server certificates to be used when connecting to an SSL enabled +// Aurora scheduler are stored. +func Certspath(certspath string) ClientOption { + return func(config *config) { + config.certspath = certspath + } +} + +// ClientCerts allows users to set client key and certificate when connecting to an SSL enabled +// Aurora scheduler. +func ClientCerts(clientKey, clientCert string) ClientOption { + return func(config *config) { + config.clientKey, config.clientCert = clientKey, clientCert + } +} + +// CertExtensions configures gorealis to consider files with the given extensions when +// loading certificates from the cert path. +func CertExtensions(extensions ...string) ClientOption { + extensionsLookup := make(map[string]struct{}) + for _, ext := range extensions { + extensionsLookup[ext] = struct{}{} + } + return func(config *config) { + config.certExtensions = extensionsLookup + } +} + +// ZookeeperOptions allows users to override default settings for connecting to Zookeeper. +// See zk.go for what is possible to set as an option. +func ZookeeperOptions(opts ...ZKOpt) ClientOption { + return func(config *config) { + config.zkOptions = opts + } +} + +// SetLogger allows the user to attach a logger that implements the logger interface in logger.go +// to the client. +func SetLogger(l logger) ClientOption { + return func(config *config) { + config.logger = &LevelLogger{logger: l} + } +} + +// Debug enables debug statements in the client. +func Debug() ClientOption { + return func(config *config) { + config.debug = true + } +} + +// Trace enables debug statements in the client. +func Trace() ClientOption { + return func(config *config) { + config.trace = true + } +} + +// FailOnPermanentErrors allows the client to stop upon encountering a connection error the standard library +// considers permanent and return an error to the user. +func FailOnPermanentErrors() ClientOption { + return func(config *config) { + config.failOnPermanentErrors = true + } +} + +func newTJSONTransport(url string, timeout int, config *config) (thrift.TTransport, error) { + trans, err := defaultTTransport(url, timeout, config) if err != nil { - return RealisConfig{}, errors.Wrap(err, "Error creating Cookie Jar") + return nil, errors.Wrap(err, "unable to create transport") + } + httpTrans, ok := (trans).(*thrift.THttpClient) + if !ok { + return nil, errors.Wrap(err, "transport does not contain a thrift client") } - //Custom client to timeout after 10 seconds to avoid hanging - trans, err := thrift.NewTHttpPostClientWithOptions(url+"/api", - thrift.THttpClientOptions{Client: &http.Client{Timeout: time.Second * 10, Jar: jar}}) + httpTrans.SetHeader("Content-Type", "application/x-thrift") + httpTrans.SetHeader("User-Agent", "gorealis v"+version) + return trans, err +} + +func newTBinTransport(url string, timeout int, config *config) (thrift.TTransport, error) { + trans, err := defaultTTransport(url, timeout, config) + if err != nil { + return nil, errors.Wrap(err, "unable to create transport") + } + httpTrans, ok := (trans).(*thrift.THttpClient) + if !ok { + return nil, errors.Wrap(err, "transport does not contain a thrift client") + } + + httpTrans.DelHeader("Content-Type") // Workaround for using thrift HttpPostClient + httpTrans.SetHeader("Accept", "application/vnd.apache.thrift.binary") + httpTrans.SetHeader("Content-Type", "application/vnd.apache.thrift.binary") + httpTrans.SetHeader("User-Agent", "gorealis v"+version) + + return trans, err +} + +// NewRealisClient is a client implementation of the realis interface uses a retry mechanism for all Thrift Calls. +// It will retry all calls which result in a temporary failure as well as calls that fail due to an EOF +// being returned by the http client. Most permanent failures are now being caught by the thriftCallWithRetries +// function and not being retried but there may be corner cases not yet handled. +func NewRealisClient(options ...ClientOption) (Realis, error) { + config := &config{} + + // Default configs + config.timeoutms = 10000 + config.backoff = defaultBackoff + config.logger = &LevelLogger{logger: log.New(os.Stdout, "realis: ", log.Ltime|log.Ldate|log.LUTC)} + config.certExtensions = map[string]struct{}{".crt": {}, ".pem": {}, ".key": {}} + + // Save options to recreate client if a connection error happens + config.options = options + + // Override default configs where necessary + for _, opt := range options { + opt(config) + } + + // TODO(rdelvalle): Move this logic to it's own function to make initialization code easier to read. + + // Turn off all logging (including debug) + if config.logger == nil { + config.logger = &LevelLogger{logger: NoopLogger{}} + } + + // Set a logger if debug has been set to true but no logger has been set + if config.logger == nil && config.debug { + config.logger = &LevelLogger{ + logger: log.New(os.Stdout, "realis: ", log.Ltime|log.Ldate|log.LUTC), + debug: true, + } + } + + config.logger.debug = config.debug + config.logger.trace = config.trace + + // Note, by this point, a LevelLogger should have been created. + config.logger.EnableDebug(config.debug) + config.logger.EnableTrace(config.trace) + + config.logger.debugPrintln("Number of options applied to config: ", len(options)) + + // Set default Transport to JSON if needed. + if !config.jsonTransport && !config.binTransport { + config.jsonTransport = true + } + + var url string + var err error + + // Find the leader using custom Zookeeper options if options are provided + if config.zkOptions != nil { + url, err = LeaderFromZKOpts(config.zkOptions...) + if err != nil { + return nil, NewTemporaryError(errors.Wrap(err, "unable to use zk to get leader")) + } + config.logger.Println("Scheduler URL from ZK: ", url) + } else if config.cluster != nil { + // Determine how to get information to connect to the scheduler. + // Prioritize getting leader from ZK over using a direct URL. + url, err = LeaderFromZK(*config.cluster) + // If ZK is configured, throw an error if the leader is unable to be determined + if err != nil { + return nil, NewTemporaryError(errors.Wrap(err, "unable to use zk to get leader")) + } + config.logger.Println("Scheduler URL from ZK: ", url) + } else if config.url != "" { + url = config.url + config.logger.Println("Scheduler URL: ", url) + } else { + return nil, errors.New("incomplete Options -- url, cluster.json, or Zookeeper address required") + } + + config.logger.Println("Address obtained: ", url) + url, err = validateAuroraURL(url) + if err != nil { + return nil, errors.Wrap(err, "invalid Aurora url") + } + config.logger.Println("Corrected address: ", url) + + if config.jsonTransport { + trans, err := newTJSONTransport(url, config.timeoutms, config) + if err != nil { + return nil, NewTemporaryError(err) + } + config.transport = trans + config.protoFactory = thrift.NewTJSONProtocolFactory() + + } else if config.binTransport { + trans, err := newTBinTransport(url, config.timeoutms, config) + if err != nil { + return nil, NewTemporaryError(err) + } + config.transport = trans + config.protoFactory = thrift.NewTBinaryProtocolFactoryDefault() + } + + config.logger.Printf("gorealis config url: %+v\n", url) + + // Adding Basic Authentication. + if config.username != "" && config.password != "" { + httpTrans, ok := (config.transport).(*thrift.THttpClient) + if !ok { + return nil, errors.New("transport provided does not contain an THttpClient") + } + httpTrans.SetHeader("Authorization", "Basic "+basicAuth(config.username, config.password)) + } + + return &realisClient{ + config: config, + client: aurora.NewAuroraSchedulerManagerClientFactory(config.transport, config.protoFactory), + readonlyClient: aurora.NewReadOnlySchedulerClientFactory(config.transport, config.protoFactory), + adminClient: aurora.NewAuroraAdminClientFactory(config.transport, config.protoFactory), + logger: LevelLogger{logger: config.logger, debug: config.debug, trace: config.trace}, + lock: &sync.Mutex{}, + transport: config.transport, + }, nil +} + +// GetDefaultClusterFromZKUrl creates a cluster object from a Zoookeper url. This is deprecated in favor of using +// Zookeeper options. +func GetDefaultClusterFromZKUrl(zkurl string) *Cluster { + return &Cluster{ + Name: "defaultCluster", + AuthMechanism: "UNAUTHENTICATED", + ZK: zkurl, + SchedZKPath: "/aurora/scheduler", + AgentRunDir: "latest", + AgentRoot: "/var/lib/mesos", + } +} + +// Creates a default Thrift Transport object for communications in gorealis using an HTTP Post Client +func defaultTTransport(url string, timeoutMs int, config *config) (thrift.TTransport, error) { + var transport http.Transport + if config != nil { + tlsConfig := &tls.Config{InsecureSkipVerify: config.insecureSkipVerify} + + if config.certspath != "" { + rootCAs, err := createCertPool(config.certspath, config.certExtensions) + if err != nil { + config.logger.Println("error occurred couldn't fetch certs") + return nil, err + } + tlsConfig.RootCAs = rootCAs + } + if config.clientKey != "" && config.clientCert == "" { + return nil, fmt.Errorf("have to provide both client key, cert. Only client key provided ") + } + if config.clientKey == "" && config.clientCert != "" { + return nil, fmt.Errorf("have to provide both client key, cert. Only client cert provided ") + } + if config.clientKey != "" && config.clientCert != "" { + cert, err := tls.LoadX509KeyPair(config.clientCert, config.clientKey) + if err != nil { + config.logger.Println("error occurred loading client certs and keys") + return nil, err + } + tlsConfig.Certificates = []tls.Certificate{cert} + } + transport.TLSClientConfig = tlsConfig + } + + trans, err := thrift.NewTHttpClientWithOptions( + url, + thrift.THttpClientOptions{ + Client: &http.Client{ + Timeout: time.Millisecond * time.Duration(timeoutMs), + Transport: &transport, + }, + }) if err != nil { - return RealisConfig{}, errors.Wrap(err, "Error creating transport") + return nil, errors.Wrap(err, "error creating transport") } if err := trans.Open(); err != nil { - fmt.Fprintln(os.Stderr) - return RealisConfig{}, errors.Wrapf(err, "Error opening connection to %s", url) + return nil, errors.Wrapf(err, "error opening connection to %s", url) } - return RealisConfig{transport: trans}, nil - -} - -// Helper function to add basic authorization needed to communicate with Apache Aurora. -func AddBasicAuth(config *RealisConfig, username string, password string) { - httpTrans := (config.transport).(*thrift.THttpClient) - httpTrans.SetHeader("Authorization", "Basic "+basicAuth(username, password)) + return trans, nil } func basicAuth(username, password string) string { @@ -104,233 +509,656 @@ func basicAuth(username, password string) string { return base64.StdEncoding.EncodeToString([]byte(auth)) } -// Releases resources associated with the realis client. -func (r realisClient) Close() { - r.client.Transport.Close() -} +func (r *realisClient) ReestablishConn() error { + // Close existing connection + r.logger.Println("Re-establishing Connection to Aurora") -// Uses predefined set of states to retrieve a set of active jobs in Apache Aurora. -func (r realisClient) GetInstanceIds(key *aurora.JobKey, states map[aurora.ScheduleStatus]bool) (map[int32]bool, error) { - taskQ := &aurora.TaskQuery{Role: key.Role, - Environment: key.Environment, - JobName: key.Name, - Statuses: states} + // This call must happen before we lock as it also uses + // the same lock from the client since close can be called + // by anyone from anywhere. + r.Close() - resp, err := r.client.GetTasksWithoutConfigs(taskQ) + r.lock.Lock() + defer r.lock.Unlock() + + // Recreate connection from scratch using original options + newRealis, err := NewRealisClient(r.config.options...) if err != nil { - return nil, errors.Wrap(err, "Error querying Aurora Scheduler for active IDs") + // This could be a temporary network hiccup + return NewTemporaryError(err) } + // If we are able to successfully re-connect, make receiver + // point to newly established connections. + if newClient, ok := newRealis.(*realisClient); ok { + r.config = newClient.config + r.client = newClient.client + r.readonlyClient = newClient.readonlyClient + r.adminClient = newClient.adminClient + r.logger = newClient.logger + } + + return nil +} + +// Close releases resources associated with the realis client. +func (r *realisClient) Close() { + + r.lock.Lock() + defer r.lock.Unlock() + + // The return value of Close here is ignored on purpose because there's nothing that can be done if it fails. + _ = r.transport.Close() +} + +// GetInstanceIds uses a predefined set of states to retrieve a set of active jobs in the Aurora Scheduler. +func (r *realisClient) GetInstanceIds(key *aurora.JobKey, states []aurora.ScheduleStatus) ([]int32, error) { + taskQ := &aurora.TaskQuery{ + JobKeys: []*aurora.JobKey{{Environment: key.Environment, Role: key.Role, Name: key.Name}}, + Statuses: states, + } + + r.logger.debugPrintf("GetTasksWithoutConfigs Thrift Payload: %+v\n", taskQ) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.GetTasksWithoutConfigs(context.TODO(), taskQ) + }, + nil, + ) + + // If we encountered an error we couldn't recover from by retrying, return an error to the user + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error querying Aurora Scheduler for active IDs") + } + + // Construct instance id map to stay in line with thrift's representation of sets tasks := response.ScheduleStatusResult(resp).GetTasks() - - jobInstanceIds := make(map[int32]bool) + jobInstanceIds := make([]int32, 0, len(tasks)) for _, task := range tasks { - jobInstanceIds[task.GetAssignedTask().GetInstanceId()] = true + jobInstanceIds = append(jobInstanceIds, task.GetAssignedTask().GetInstanceId()) } - return jobInstanceIds, nil + } -// Kill specific instances of a job. -func (r realisClient) KillInstances(key *aurora.JobKey, instances ...int32) (*aurora.Response, error) { +func (r *realisClient) GetJobUpdateSummaries(jobUpdateQuery *aurora.JobUpdateQuery) (*aurora.Response, error) { - instanceIds := make(map[int32]bool) + r.logger.debugPrintf("GetJobUpdateSummaries Thrift Payload: %+v\n", jobUpdateQuery) - for _, instId := range instances { - instanceIds[instId] = true + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.readonlyClient.GetJobUpdateSummaries(context.TODO(), jobUpdateQuery) + }, + nil, + ) + + if retryErr != nil { + return resp, errors.Wrap(retryErr, "error getting job update summaries from Aurora Scheduler") } - resp, err := r.client.KillTasks(key, instanceIds) - if err != nil { - return nil, errors.Wrap(err, "Error sending Kill command to Aurora Scheduler") + if resp.GetResult_() == nil || resp.GetResult_().GetGetJobUpdateSummariesResult_() == nil { + return nil, errors.New("unexpected response from scheduler") } - return response.ResponseCodeCheck(resp) + return resp, nil } -// Sends a kill message to the scheduler for all active tasks under a job. -func (r realisClient) KillJob(key *aurora.JobKey) (*aurora.Response, error) { +func (r *realisClient) GetJobs(role string) (*aurora.Response, *aurora.GetJobsResult_, error) { - instanceIds, err := r.GetInstanceIds(key, aurora.ACTIVE_STATES) - if err != nil { - return nil, errors.Wrap(err, "Could not retrieve relevant task instance IDs") + var result *aurora.GetJobsResult_ + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.readonlyClient.GetJobs(context.TODO(), role) + }, + nil, + ) + + if retryErr != nil { + return nil, result, errors.Wrap(retryErr, "error getting Jobs from Aurora Scheduler") } + if resp.GetResult_() != nil { + result = resp.GetResult_().GetJobsResult_ + } + + return resp, result, nil +} + +// KillInstances kills specific instances of a job. +func (r *realisClient) KillInstances(key *aurora.JobKey, instances ...int32) (*aurora.Response, error) { + r.logger.debugPrintf("KillTasks Thrift Payload: %+v %v\n", key, instances) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.KillTasks(context.TODO(), key, instances, "") + }, + nil, + ) + + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error sending Kill command to Aurora Scheduler") + } + return resp, nil +} + +func (r *realisClient) RealisConfig() *config { + return r.config +} + +// KillJob kills all instances of a job. +func (r *realisClient) KillJob(key *aurora.JobKey) (*aurora.Response, error) { + + r.logger.debugPrintf("KillTasks Thrift Payload: %+v\n", key) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + // Giving the KillTasks thrift call an empty set tells the Aurora scheduler to kill all active shards + return r.client.KillTasks(context.TODO(), key, nil, "") + }, + nil, + ) + + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error sending Kill command to Aurora Scheduler") + } + return resp, nil +} + +// CreateJob sends a create job message to the scheduler with a specific job configuration. +// Although this API is able to create service jobs, it is better to use CreateService instead +// as that API uses the update thrift call which has a few extra features available. +// Use this API to create ad-hoc jobs. +func (r *realisClient) CreateJob(auroraJob Job) (*aurora.Response, error) { + + r.logger.debugPrintf("CreateJob Thrift Payload: %+v\n", auroraJob.JobConfig()) + + // Response is checked by the thrift retry code + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.CreateJob(context.TODO(), auroraJob.JobConfig()) + }, + // On a client timeout, attempt to verify that payload made to the Scheduler by + // trying to get the config summary for the job key + func() (*aurora.Response, bool) { + exists, err := r.jobExists(*auroraJob.JobKey()) + if err != nil { + r.logger.Print("verification failed ", err) + } + + if exists { + return &aurora.Response{ResponseCode: aurora.ResponseCode_OK}, true + } + + return nil, false + }, + ) + + if retryErr != nil { + return resp, errors.Wrap(retryErr, "error sending Create command to Aurora Scheduler") + } + + return resp, nil +} + +// CreateService uses the scheduler's updating mechanism to create a job. +func (r *realisClient) CreateService( + auroraJob Job, + settings *aurora.JobUpdateSettings) (*aurora.Response, *aurora.StartJobUpdateResult_, error) { + // Create a new job update object and ship it to the StartJobUpdate api + update := NewUpdateJob(auroraJob.TaskConfig(), settings) + update.InstanceCount(auroraJob.GetInstanceCount()) + + resp, err := r.StartJobUpdate(update, "") + if err != nil { + if IsTimeout(err) { + return nil, nil, err + } + return resp, nil, errors.Wrap(err, "unable to create service") + } + + return resp, resp.GetResult_().StartJobUpdateResult_, nil +} + +func (r *realisClient) ScheduleCronJob(auroraJob Job) (*aurora.Response, error) { + r.logger.debugPrintf("ScheduleCronJob Thrift Payload: %+v\n", auroraJob.JobConfig()) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.ScheduleCronJob(context.TODO(), auroraJob.JobConfig()) + }, + nil, + ) + + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error sending Cron Job Schedule message to Aurora Scheduler") + } + return resp, nil +} + +func (r *realisClient) DescheduleCronJob(key *aurora.JobKey) (*aurora.Response, error) { + + r.logger.debugPrintf("DescheduleCronJob Thrift Payload: %+v\n", key) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.DescheduleCronJob(context.TODO(), key) + }, + nil, + ) + + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error sending Cron Job De-schedule message to Aurora Scheduler") + + } + return resp, nil + +} + +func (r *realisClient) StartCronJob(key *aurora.JobKey) (*aurora.Response, error) { + + r.logger.debugPrintf("StartCronJob Thrift Payload: %+v\n", key) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.StartCronJob(context.TODO(), key) + }, + nil, + ) + + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error sending Start Cron Job message to Aurora Scheduler") + } + return resp, nil + +} + +// RestartInstances restarts the specified instances of a Job. +func (r *realisClient) RestartInstances(key *aurora.JobKey, instances ...int32) (*aurora.Response, error) { + r.logger.debugPrintf("RestartShards Thrift Payload: %+v %v\n", key, instances) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.RestartShards(context.TODO(), key, instances) + }, + nil, + ) + + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error sending Restart command to Aurora Scheduler") + } + return resp, nil +} + +// RestartJob restarts all active instances of a Job. +func (r *realisClient) RestartJob(key *aurora.JobKey) (*aurora.Response, error) { + + instanceIds, err1 := r.GetInstanceIds(key, aurora.ACTIVE_STATES) + if err1 != nil { + return nil, errors.Wrap(err1, "could not retrieve relevant task instance IDs") + } + + r.logger.debugPrintf("RestartShards Thrift Payload: %+v %v\n", key, instanceIds) + if len(instanceIds) > 0 { - resp, err := r.client.KillTasks(key, instanceIds) + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.RestartShards(context.TODO(), key, instanceIds) + }, + nil, + ) - if err != nil { - return nil, errors.Wrap(err, "Error sending Kill command to Aurora Scheduler") + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error sending Restart command to Aurora Scheduler") } - return response.ResponseCodeCheck(resp) - } else { - return nil, errors.New("No tasks in the Active state") + return resp, nil } + + return nil, errors.New("No tasks in the Active state") } -// Sends a create job message to the scheduler with a specific job configuration. -func (r realisClient) CreateJob(auroraJob Job) (*aurora.Response, error) { - resp, err := r.client.CreateJob(auroraJob.JobConfig()) +// StartJobUpdate updates all instances under a job configuration. +func (r *realisClient) StartJobUpdate(updateJob *UpdateJob, message string) (*aurora.Response, error) { - if err != nil { - return nil, errors.Wrap(err, "Error sending Create command to Aurora Scheduler") + r.logger.debugPrintf("StartJobUpdate Thrift Payload: %+v %v\n", updateJob, message) + + resp, retryErr := r.thriftCallWithRetries( + true, + func() (*aurora.Response, error) { + return r.client.StartJobUpdate(context.TODO(), updateJob.req, message) + }, + func() (*aurora.Response, bool) { + summariesResp, err := r.readonlyClient.GetJobUpdateSummaries( + context.TODO(), + &aurora.JobUpdateQuery{ + JobKey: updateJob.JobKey(), + UpdateStatuses: aurora.ACTIVE_JOB_UPDATE_STATES, + Limit: 1, + }) + + if err != nil { + r.logger.Print("verification failed ", err) + return nil, false + } + + summaries := response.JobUpdateSummaries(summariesResp) + if len(summaries) == 0 { + return nil, false + } + + return &aurora.Response{ + ResponseCode: aurora.ResponseCode_OK, + Result_: &aurora.Result_{ + StartJobUpdateResult_: &aurora.StartJobUpdateResult_{ + UpdateSummary: summaries[0], + Key: summaries[0].Key, + }, + }, + }, true + }, + ) + + if retryErr != nil { + // A timeout took place when attempting this call, attempt to recover + if IsTimeout(retryErr) { + return nil, retryErr + } + + return resp, errors.Wrap(retryErr, "error sending StartJobUpdate command to Aurora Scheduler") } - return response.ResponseCodeCheck(resp) + if resp.GetResult_() == nil { + return resp, errors.New("no result in response") + } + + return resp, nil } -func (r realisClient) ScheduleCronJob(auroraJob Job) (*aurora.Response, error) { - resp, err := r.client.ScheduleCronJob(auroraJob.JobConfig()) +// AbortJobUpdate terminates a job update in the scheduler. +// It requires the updateId which can be obtained on the Aurora web UI. +// This API is meant to be synchronous. It will attempt to wait until the update transitions to the aborted state. +// However, if the job update does not transition to the ABORT state an error will be returned. +func (r *realisClient) AbortJobUpdate(updateKey aurora.JobUpdateKey, message string) (*aurora.Response, error) { - if err != nil { - return nil, errors.Wrap(err, "Error sending Cron Job Schedule message to Aurora Scheduler") + r.logger.debugPrintf("AbortJobUpdate Thrift Payload: %+v %v\n", updateKey, message) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.AbortJobUpdate(context.TODO(), &updateKey, message) + }, + nil, + ) + + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error sending AbortJobUpdate command to Aurora Scheduler") } - return response.ResponseCodeCheck(resp) + // Make this call synchronous by blocking until it job has successfully transitioned to aborted + m := Monitor{Client: r} + _, err := m.JobUpdateStatus( + updateKey, + []aurora.JobUpdateStatus{aurora.JobUpdateStatus_ABORTED}, + time.Second*5, + time.Minute) + + return resp, err } -func (r realisClient) DescheduleCronJob(key *aurora.JobKey) (*aurora.Response, error) { - resp, err := r.client.DescheduleCronJob(key) +// PauseJobUpdate pauses the progress of an ongoing update. +// The UpdateID value needed for this function is returned from StartJobUpdate or can be obtained from the Aurora web UI. +func (r *realisClient) PauseJobUpdate(updateKey *aurora.JobUpdateKey, message string) (*aurora.Response, error) { - if err != nil { - return nil, errors.Wrap(err, "Error sending Cron Job De-schedule message to Aurora Scheduler") + r.logger.debugPrintf("PauseJobUpdate Thrift Payload: %+v %v\n", updateKey, message) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.PauseJobUpdate(context.TODO(), updateKey, message) + }, + nil, + ) + + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error sending PauseJobUpdate command to Aurora Scheduler") } - return response.ResponseCodeCheck(resp) + return resp, nil } -func (r realisClient) StartCronJob(key *aurora.JobKey) (*aurora.Response, error) { - resp, err := r.client.StartCronJob(key) +// ResumeJobUpdate resumes a previously Paused Job update. +func (r *realisClient) ResumeJobUpdate(updateKey *aurora.JobUpdateKey, message string) (*aurora.Response, error) { - if err != nil { - return nil, errors.Wrap(err, "Error sending Start Cron Job message to Aurora Scheduler") + r.logger.debugPrintf("ResumeJobUpdate Thrift Payload: %+v %v\n", updateKey, message) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.ResumeJobUpdate(context.TODO(), updateKey, message) + }, + nil, + ) + + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error sending ResumeJobUpdate command to Aurora Scheduler") } - return response.ResponseCodeCheck(resp) + return resp, nil } -// Restarts specific instances specified -func (r realisClient) RestartInstances(key *aurora.JobKey, instances ...int32) (*aurora.Response, error) { - instanceIds := make(map[int32]bool) +// PulseJobUpdate sends a pulse to an ongoing Job update. +func (r *realisClient) PulseJobUpdate(updateKey *aurora.JobUpdateKey) (*aurora.Response, error) { - for _, instId := range instances { - instanceIds[instId] = true + r.logger.debugPrintf("PulseJobUpdate Thrift Payload: %+v\n", updateKey) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.PulseJobUpdate(context.TODO(), updateKey) + }, + nil, + ) + + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error sending PulseJobUpdate command to Aurora Scheduler") } - resp, err := r.client.RestartShards(key, instanceIds) - if err != nil { - return nil, errors.Wrap(err, "Error sending Restart command to Aurora Scheduler") - } - - return response.ResponseCodeCheck(resp) + return resp, nil } -// Restarts all active tasks under a job configuration. -func (r realisClient) RestartJob(key *aurora.JobKey) (*aurora.Response, error) { +// AddInstances scales up the number of instances for a Job. +func (r *realisClient) AddInstances(instKey aurora.InstanceKey, count int32) (*aurora.Response, error) { + r.logger.debugPrintf("AddInstances Thrift Payload: %+v %v\n", instKey, count) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.AddInstances(context.TODO(), &instKey, count) + }, + nil, + ) + + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error sending AddInstances command to Aurora Scheduler") + } + return resp, nil + +} + +// RemoveInstances scales down the number of instances for a Job. +func (r *realisClient) RemoveInstances(key *aurora.JobKey, count int32) (*aurora.Response, error) { instanceIds, err := r.GetInstanceIds(key, aurora.ACTIVE_STATES) if err != nil { - return nil, errors.Wrap(err, "Could not retrieve relevant task instance IDs") + return nil, errors.Wrap(err, "could not retrieve relevant instance IDs") } - if len(instanceIds) > 0 { - resp, err := r.client.RestartShards(key, instanceIds) - - if err != nil { - return nil, errors.Wrap(err, "Error sending Restart command to Aurora Scheduler") - } - - return response.ResponseCodeCheck(resp) - } else { - return nil, errors.New("No tasks in the Active state") + if len(instanceIds) < int(count) { + return nil, errors.Errorf("insufficient active instances available for killing: "+ + " Instances to be killed %d Active instances %d", count, len(instanceIds)) } + + // Sort instanceIds in ** decreasing ** order + sort.Slice(instanceIds, func(i, j int) bool { + return instanceIds[i] > instanceIds[j] + }) + + // Kill the instances with the highest ID number first + return r.KillInstances(key, instanceIds[:count]...) } -// Update all tasks under a job configuration. Currently gorealis doesn't support for canary deployments. -func (r realisClient) StartJobUpdate(updateJob *UpdateJob, message string) (*aurora.Response, error) { +// GetTaskStatus gets information about task including a fully hydrated task configuration object. +func (r *realisClient) GetTaskStatus(query *aurora.TaskQuery) ([]*aurora.ScheduledTask, error) { - resp, err := r.client.StartJobUpdate(updateJob.req, message) + r.logger.debugPrintf("GetTasksStatus Thrift Payload: %+v\n", query) - if err != nil { - return nil, errors.Wrap(err, "Error sending StartJobUpdate command to Aurora Scheduler") + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.GetTasksStatus(context.TODO(), query) + }, + nil, + ) + + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error querying Aurora Scheduler for task status") } - return response.ResponseCodeCheck(resp) + return response.ScheduleStatusResult(resp).GetTasks(), nil } -// Abort Job Update on Aurora. Requires the updateId which can be obtained on the Aurora web UI. -func (r realisClient) AbortJobUpdate( - updateKey aurora.JobUpdateKey, - message string) (*aurora.Response, error) { +// GetPendingReason returns the reason why the an instance of a Job has not been scheduled. +func (r *realisClient) GetPendingReason(query *aurora.TaskQuery) ([]*aurora.PendingReason, error) { - resp, err := r.client.AbortJobUpdate(&updateKey, message) + r.logger.debugPrintf("GetPendingReason Thrift Payload: %+v\n", query) - if err != nil { - return nil, errors.Wrap(err, "Error sending AbortJobUpdate command to Aurora Scheduler") + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.GetPendingReason(context.TODO(), query) + }, + nil, + ) + + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error querying Aurora Scheduler for pending Reasons") } - return response.ResponseCodeCheck(resp) -} + var pendingReasons []*aurora.PendingReason -// Scale up the number of instances under a job configuration using the configuration for specific -// instance to scale up. -func (r realisClient) AddInstances(instKey aurora.InstanceKey, count int32) (*aurora.Response, error) { - - resp, err := r.client.AddInstances(&instKey, count) - - if err != nil { - return nil, errors.Wrap(err, "Error sending AddInstances command to Aurora Scheduler") + if resp.GetResult_() != nil { + pendingReasons = resp.GetResult_().GetGetPendingReasonResult_().GetReasons() } - return response.ResponseCodeCheck(resp) + return pendingReasons, nil } -func (r realisClient) FetchTaskConfig(instKey aurora.InstanceKey) (*aurora.TaskConfig, error) { +// GetTasksWithoutConfigs gets information about task including without a task configuration object. +// This is a more lightweight version of GetTaskStatus but contains less information as a result. +func (r *realisClient) GetTasksWithoutConfigs(query *aurora.TaskQuery) ([]*aurora.ScheduledTask, error) { - ids := make(map[int32]bool) + r.logger.debugPrintf("GetTasksWithoutConfigs Thrift Payload: %+v\n", query) - ids[instKey.InstanceId] = true - taskQ := &aurora.TaskQuery{Role: instKey.JobKey.Role, - Environment: instKey.JobKey.Environment, - JobName: instKey.JobKey.Name, - InstanceIds: ids, - Statuses: aurora.ACTIVE_STATES} + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.GetTasksWithoutConfigs(context.TODO(), query) + }, + nil, + ) - resp, err := r.client.GetTasksStatus(taskQ) - if err != nil { - return nil, errors.Wrap(err, "Error querying Aurora Scheduler for task configuration") + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error querying Aurora Scheduler for task status without configs") + } + + return response.ScheduleStatusResult(resp).GetTasks(), nil + +} + +// FetchTaskConfig gets the task configuration from the aurora scheduler for a job. +func (r *realisClient) FetchTaskConfig(instKey aurora.InstanceKey) (*aurora.TaskConfig, error) { + taskQ := &aurora.TaskQuery{ + Role: &instKey.JobKey.Role, + Environment: &instKey.JobKey.Environment, + JobName: &instKey.JobKey.Name, + InstanceIds: []int32{instKey.InstanceId}, + Statuses: aurora.ACTIVE_STATES, + } + + r.logger.debugPrintf("GetTasksStatus Thrift Payload: %+v\n", taskQ) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.GetTasksStatus(context.TODO(), taskQ) + }, + nil, + ) + + if retryErr != nil { + return nil, errors.Wrap(retryErr, "error querying Aurora Scheduler for task configuration") } tasks := response.ScheduleStatusResult(resp).GetTasks() if len(tasks) == 0 { - return nil, errors.Errorf("Instance %d for jobkey %s/%s/%s doesn't exist", + return nil, errors.Errorf("instance %d for jobkey %s/%s/%s doesn't exist", instKey.InstanceId, instKey.JobKey.Environment, instKey.JobKey.Role, instKey.JobKey.Name) } - // Currently, instance 0 is always picked + // Currently, instance 0 is always picked.. return tasks[0].AssignedTask.Task, nil } -func (r realisClient) JobUpdateDetails(updateQuery aurora.JobUpdateQuery) (*aurora.Response, error) { +func (r *realisClient) JobUpdateDetails(updateQuery aurora.JobUpdateQuery) (*aurora.Response, error) { - resp, err := r.client.GetJobUpdateDetails(&updateQuery) - if err != nil { - return nil, errors.Wrap(err, "Unable to get job update details") + r.logger.debugPrintf("GetJobUpdateDetails Thrift Payload: %+v\n", updateQuery) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.GetJobUpdateDetails(context.TODO(), &updateQuery) + }, + nil, + ) + + if retryErr != nil { + return nil, errors.Wrap(retryErr, "unable to get job update details") } + return resp, nil - return response.ResponseCodeCheck(resp) } -func (r realisClient) RollbackJobUpdate(key aurora.JobUpdateKey, message string) (*aurora.Response, error) { - resp, err := r.client.RollbackJobUpdate(&key, message) - if err != nil { - return nil, errors.Wrap(err, "Unable to roll back job update") +func (r *realisClient) RollbackJobUpdate(key aurora.JobUpdateKey, message string) (*aurora.Response, error) { + + r.logger.debugPrintf("RollbackJobUpdate Thrift Payload: %+v %v\n", key, message) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.client.RollbackJobUpdate(context.TODO(), &key, message) + }, + nil, + ) + + if retryErr != nil { + return nil, errors.Wrap(retryErr, "unable to roll back job update") } - - return response.ResponseCodeCheck(resp) + return resp, nil } diff --git a/realis_admin.go b/realis_admin.go new file mode 100644 index 0000000..9c58081 --- /dev/null +++ b/realis_admin.go @@ -0,0 +1,309 @@ +package realis + +import ( + "context" + + "github.com/paypal/gorealis/gen-go/apache/aurora" + "github.com/pkg/errors" +) + +// TODO(rdelvalle): Consider moving these functions to another interface. It would be a backwards incompatible change, +// but would add safety. + +// Set a list of nodes to DRAINING. This means nothing will be able to be scheduled on them and any existing +// tasks will be killed and re-scheduled elsewhere in the cluster. Tasks from DRAINING nodes are not guaranteed +// to return to running unless there is enough capacity in the cluster to run them. +func (r *realisClient) DrainHosts(hosts ...string) (*aurora.Response, *aurora.DrainHostsResult_, error) { + + var result *aurora.DrainHostsResult_ + + if len(hosts) == 0 { + return nil, nil, errors.New("no hosts provided to drain") + } + + drainList := aurora.NewHosts() + drainList.HostNames = hosts + + r.logger.debugPrintf("DrainHosts Thrift Payload: %v\n", drainList) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.adminClient.DrainHosts(context.TODO(), drainList) + }, + nil, + ) + + if retryErr != nil { + return resp, result, errors.Wrap(retryErr, "Unable to recover connection") + } + + if resp.GetResult_() != nil { + result = resp.GetResult_().GetDrainHostsResult_() + } + + return resp, result, nil +} + +// Start SLA Aware Drain. +// defaultSlaPolicy is the fallback SlaPolicy to use if a task does not have an SlaPolicy. +// After timeoutSecs, tasks will be forcefully drained without checking SLA. +func (r *realisClient) SLADrainHosts( + policy *aurora.SlaPolicy, + timeout int64, + hosts ...string) (*aurora.DrainHostsResult_, error) { + var result *aurora.DrainHostsResult_ + + if len(hosts) == 0 { + return nil, errors.New("no hosts provided to drain") + } + + if policy == nil || policy.CountSetFieldsSlaPolicy() == 0 { + policy = &defaultSlaPolicy + r.logger.Printf("Warning: start draining with default sla policy %v", policy) + } + + if timeout < 0 { + r.logger.Printf("Warning: timeout %d secs is invalid, draining with default timeout %d secs", + timeout, + defaultSlaDrainTimeoutSecs) + timeout = defaultSlaDrainTimeoutSecs + } + + drainList := aurora.NewHosts() + drainList.HostNames = hosts + + r.logger.debugPrintf("SLADrainHosts Thrift Payload: %v\n", drainList) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.adminClient.SlaDrainHosts(context.TODO(), drainList, policy, timeout) + }, + nil, + ) + + if retryErr != nil { + return result, errors.Wrap(retryErr, "Unable to recover connection") + } + + if resp.GetResult_() != nil { + result = resp.GetResult_().GetDrainHostsResult_() + } + + return result, nil +} + +func (r *realisClient) StartMaintenance(hosts ...string) (*aurora.Response, *aurora.StartMaintenanceResult_, error) { + + var result *aurora.StartMaintenanceResult_ + + if len(hosts) == 0 { + return nil, nil, errors.New("no hosts provided to start maintenance on") + } + + hostList := aurora.NewHosts() + hostList.HostNames = hosts + + r.logger.debugPrintf("StartMaintenance Thrift Payload: %v\n", hostList) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.adminClient.StartMaintenance(context.TODO(), hostList) + }, + nil, + ) + + if retryErr != nil { + return resp, result, errors.Wrap(retryErr, "Unable to recover connection") + } + + if resp.GetResult_() != nil { + result = resp.GetResult_().GetStartMaintenanceResult_() + } + + return resp, result, nil +} + +func (r *realisClient) EndMaintenance(hosts ...string) (*aurora.Response, *aurora.EndMaintenanceResult_, error) { + + var result *aurora.EndMaintenanceResult_ + + if len(hosts) == 0 { + return nil, nil, errors.New("no hosts provided to end maintenance on") + } + + hostList := aurora.NewHosts() + hostList.HostNames = hosts + + r.logger.debugPrintf("EndMaintenance Thrift Payload: %v\n", hostList) + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.adminClient.EndMaintenance(context.TODO(), hostList) + }, + nil, + ) + + if retryErr != nil { + return resp, result, errors.Wrap(retryErr, "Unable to recover connection") + } + + if resp.GetResult_() != nil { + result = resp.GetResult_().GetEndMaintenanceResult_() + } + + return resp, result, nil +} + +func (r *realisClient) MaintenanceStatus(hosts ...string) (*aurora.Response, *aurora.MaintenanceStatusResult_, error) { + + var result *aurora.MaintenanceStatusResult_ + + if len(hosts) == 0 { + return nil, nil, errors.New("no hosts provided to get maintenance status from") + } + + hostList := aurora.NewHosts() + hostList.HostNames = hosts + + r.logger.debugPrintf("MaintenanceStatus Thrift Payload: %v\n", hostList) + + // Make thrift call. If we encounter an error sending the call, attempt to reconnect + // and continue trying to resend command until we run out of retries. + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.adminClient.MaintenanceStatus(context.TODO(), hostList) + }, + nil, + ) + + if retryErr != nil { + return resp, result, errors.Wrap(retryErr, "Unable to recover connection") + } + + if resp.GetResult_() != nil { + result = resp.GetResult_().GetMaintenanceStatusResult_() + } + + return resp, result, nil +} + +// SetQuota sets a quota aggregate for the given role +// TODO(zircote) Currently investigating an error that is returned +// from thrift calls that include resources for `NamedPort` and `NumGpu` +func (r *realisClient) SetQuota(role string, cpu *float64, ramMb *int64, diskMb *int64) (*aurora.Response, error) { + quota := &aurora.ResourceAggregate{ + Resources: []*aurora.Resource{{NumCpus: cpu}, {RamMb: ramMb}, {DiskMb: diskMb}}, + } + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.adminClient.SetQuota(context.TODO(), role, quota) + }, + nil, + ) + + if retryErr != nil { + return resp, errors.Wrap(retryErr, "Unable to set role quota") + } + return resp, retryErr + +} + +// GetQuota returns the resource aggregate for the given role +func (r *realisClient) GetQuota(role string) (*aurora.Response, error) { + + resp, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.adminClient.GetQuota(context.TODO(), role) + }, + nil, + ) + + if retryErr != nil { + return resp, errors.Wrap(retryErr, "Unable to get role quota") + } + return resp, retryErr +} + +// Force Aurora Scheduler to perform a snapshot and write to Mesos log +func (r *realisClient) Snapshot() error { + + _, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.adminClient.Snapshot(context.TODO()) + }, + nil, + ) + + if retryErr != nil { + return errors.Wrap(retryErr, "Unable to recover connection") + } + + return nil +} + +// Force Aurora Scheduler to write backup file to a file in the backup directory +func (r *realisClient) PerformBackup() error { + + _, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.adminClient.PerformBackup(context.TODO()) + }, + nil, + ) + + if retryErr != nil { + return errors.Wrap(retryErr, "Unable to recover connection") + } + + return nil +} + +func (r *realisClient) ForceImplicitTaskReconciliation() error { + + _, retryErr := r.thriftCallWithRetries( + false, + func() (*aurora.Response, error) { + return r.adminClient.TriggerImplicitTaskReconciliation(context.TODO()) + }, + nil, + ) + + if retryErr != nil { + return errors.Wrap(retryErr, "Unable to recover connection") + } + + return nil +} + +func (r *realisClient) ForceExplicitTaskReconciliation(batchSize *int32) error { + + if batchSize != nil && *batchSize < 1 { + return errors.New("invalid batch size") + } + settings := aurora.NewExplicitReconciliationSettings() + + settings.BatchSize = batchSize + + _, retryErr := r.thriftCallWithRetries(false, + func() (*aurora.Response, error) { + return r.adminClient.TriggerExplicitTaskReconciliation(context.TODO(), settings) + }, + nil, + ) + + if retryErr != nil { + return errors.Wrap(retryErr, "Unable to recover connection") + } + + return nil +} diff --git a/realis_e2e_test.go b/realis_e2e_test.go new file mode 100644 index 0000000..78d8f0e --- /dev/null +++ b/realis_e2e_test.go @@ -0,0 +1,1117 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package realis_test + +import ( + "fmt" + "io/ioutil" + "os" + "sync" + "testing" + "time" + + "github.com/apache/thrift/lib/go/thrift" + realis "github.com/paypal/gorealis" + "github.com/paypal/gorealis/gen-go/apache/aurora" + "github.com/paypal/gorealis/response" + "github.com/pkg/errors" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +var r realis.Realis +var monitor *realis.Monitor +var thermosPayload []byte + +const auroraURL = "http://192.168.33.7:8081" + +func TestMain(m *testing.M) { + var err error + + // New configuration to connect to docker container + r, err = realis.NewRealisClient(realis.SchedulerUrl(auroraURL), + realis.BasicAuth("aurora", "secret"), + realis.TimeoutMS(20000)) + + if err != nil { + fmt.Println("Please run docker-compose up -d before running test suite") + os.Exit(1) + } + + defer r.Close() + + // Create monitor + monitor = &realis.Monitor{Client: r} + + thermosPayload, err = ioutil.ReadFile("examples/thermos_payload.json") + if err != nil { + fmt.Println("Error reading thermos payload file: ", err) + os.Exit(1) + } + + os.Exit(m.Run()) +} + +func TestNonExistentEndpoint(t *testing.T) { + // Reduce penalties for this test to make it quick + backoff := realis.Backoff{ + Steps: 3, + Duration: 200 * time.Millisecond, + Factor: 1.0, + Jitter: 0.1} + + taskQ := &aurora.TaskQuery{} + badEndpoint := "http://idontexist.local:8081/api" + + t.Run("WithRetries", func(t *testing.T) { + // Attempt to connect to a bad endpoint + badClient, err := realis.NewRealisClient( + realis.SchedulerUrl(badEndpoint), + realis.TimeoutMS(200000), + realis.BackOff(backoff), + ) + + require.NoError(t, err) + require.NotNil(t, badClient) + defer badClient.Close() + + _, err = badClient.GetTasksWithoutConfigs(taskQ) + + // Check that we do error out of retrying + require.Error(t, err) + // Check that the error before this one was a a retry error + // TODO: Consider bubbling up timeout behaving error all the way up to the user. + retryErr := realis.ToRetryCount(errors.Cause(err)) + require.NotNil(t, retryErr, "error passed in is not a retry error") + + assert.Equal(t, backoff.Steps, retryErr.RetryCount(), "retry count is incorrect") + }) + + t.Run("FailOnLookup", func(t *testing.T) { + // Attempt to connect to a bad endpoint + badClient, err := realis.NewRealisClient( + realis.SchedulerUrl(badEndpoint), + realis.TimeoutMS(200000), + realis.BackOff(backoff), + realis.FailOnPermanentErrors(), + ) + + require.NoError(t, err) + require.NotNil(t, badClient) + defer badClient.Close() + + _, err = badClient.GetTasksWithoutConfigs(taskQ) + + // Check that we do error out of retrying + require.Error(t, err) + }) + +} + +func TestThriftBinary(t *testing.T) { + r, err := realis.NewRealisClient(realis.SchedulerUrl(auroraURL), + realis.BasicAuth("aurora", "secret"), + realis.TimeoutMS(20000), + realis.ThriftBinary()) + + require.NoError(t, err) + defer r.Close() + + role := "all" + taskQ := &aurora.TaskQuery{ + Role: &role, + } + + // Perform a simple API call to test Thrift Binary + _, err = r.GetTasksWithoutConfigs(taskQ) + assert.NoError(t, err) +} + +func TestThriftJSON(t *testing.T) { + r, err := realis.NewRealisClient(realis.SchedulerUrl(auroraURL), + realis.BasicAuth("aurora", "secret"), + realis.TimeoutMS(20000), + realis.ThriftJSON()) + + require.NoError(t, err) + defer r.Close() + + role := "all" + taskQ := &aurora.TaskQuery{ + Role: &role, + } + + // Perform a simple API call to test Thrift Binary + _, err = r.GetTasksWithoutConfigs(taskQ) + + assert.NoError(t, err) + +} + +func TestNoopLogger(t *testing.T) { + r, err := realis.NewRealisClient(realis.SchedulerUrl(auroraURL), + realis.BasicAuth("aurora", "secret"), + realis.SetLogger(realis.NoopLogger{})) + + require.NoError(t, err) + defer r.Close() + + role := "all" + taskQ := &aurora.TaskQuery{ + Role: &role, + } + + // Perform a simple API call to test Thrift Binary + _, err = r.GetTasksWithoutConfigs(taskQ) + assert.NoError(t, err) +} + +func TestLeaderFromZK(t *testing.T) { + cluster := realis.GetDefaultClusterFromZKUrl("192.168.33.2:2181") + url, err := realis.LeaderFromZK(*cluster) + + require.NoError(t, err) + + // Address stored inside of ZK might be different than the one we connect to in our tests. + assert.Equal(t, "http://192.168.33.7:8081", url) +} + +func TestRealisClient_ReestablishConn(t *testing.T) { + // Test that we're able to tear down the old connection and create a new one. + err := r.ReestablishConn() + + assert.NoError(t, err) +} + +func TestRealisClient_CreateJob_Thermos(t *testing.T) { + + role := "vagrant" + job := realis.NewJob(). + Environment("prod"). + Role(role). + Name("create_thermos_job_test"). + ExecutorName(aurora.AURORA_EXECUTOR_NAME). + ExecutorData(string(thermosPayload)). + CPU(.1). + RAM(16). + Disk(50). + IsService(true). + InstanceCount(2). + AddPorts(1) + + _, err := r.CreateJob(job) + require.NoError(t, err) + + // Test Instances Monitor + success, err := monitor.Instances(job.JobKey(), job.GetInstanceCount(), 1, 50) + assert.True(t, success) + assert.NoError(t, err) + + // Fetch all Jobs + _, result, err := r.GetJobs(role) + assert.Len(t, result.Configs, 1) + assert.NoError(t, err) + + // Test asking the scheduler to perform a Snpshot + t.Run("Snapshot", func(t *testing.T) { + err := r.Snapshot() + assert.NoError(t, err) + }) + + // Test asking the scheduler to backup a Snapshot + t.Run("PerformBackup", func(t *testing.T) { + err := r.PerformBackup() + assert.NoError(t, err) + }) + + t.Run("GetTaskStatus", func(t *testing.T) { + status, err := r.GetTaskStatus(&aurora.TaskQuery{ + JobKeys: []*aurora.JobKey{job.JobKey()}, + Statuses: []aurora.ScheduleStatus{aurora.ScheduleStatus_RUNNING}}) + require.NoError(t, err) + assert.NotNil(t, status) + assert.Len(t, status, 2) + + // TODO: Assert that assigned task matches the configuration of the task scheduled + }) + + t.Run("AddInstances", func(t *testing.T) { + _, err := r.AddInstances(aurora.InstanceKey{JobKey: job.JobKey(), InstanceId: 0}, 2) + require.NoError(t, err) + success, err := monitor.Instances(job.JobKey(), 4, 1, 50) + assert.True(t, success) + assert.NoError(t, err) + }) + + t.Run("KillInstances", func(t *testing.T) { + _, err := r.KillInstances(job.JobKey(), 2, 3) + require.NoError(t, err) + success, err := monitor.Instances(job.JobKey(), 2, 1, 50) + assert.True(t, success) + assert.NoError(t, err) + }) + + t.Run("RestartInstances", func(t *testing.T) { + _, err := r.RestartInstances(job.JobKey(), 0) + require.NoError(t, err) + success, err := monitor.Instances(job.JobKey(), 2, 1, 50) + assert.True(t, success) + assert.NoError(t, err) + }) + + t.Run("RestartJobs", func(t *testing.T) { + _, err := r.RestartJob(job.JobKey()) + require.NoError(t, err) + success, err := monitor.Instances(job.JobKey(), 2, 1, 50) + assert.True(t, success) + assert.NoError(t, err) + }) + + // Tasks must exist for it to, be killed + t.Run("KillJob", func(t *testing.T) { + _, err := r.KillJob(job.JobKey()) + require.NoError(t, err) + success, err := monitor.Instances(job.JobKey(), 0, 1, 50) + assert.True(t, success) + assert.NoError(t, err) + }) + + t.Run("Duplicate_Metadata", func(t *testing.T) { + job.Name("thermos_duplicate_metadata"). + AddLabel("hostname", "cookie"). + AddLabel("hostname", "candy"). + AddLabel("hostname", "popcorn"). + AddLabel("hostname", "chips"). + AddLabel("chips", "chips") + + _, err := r.CreateJob(job) + require.NoError(t, err) + + success, err := monitor.Instances(job.JobKey(), 2, 1, 50) + assert.True(t, success) + assert.NoError(t, err) + + _, err = r.KillJob(job.JobKey()) + assert.NoError(t, err) + }) + + t.Run("Duplicate_constraints", func(t *testing.T) { + job.Name("thermos_duplicate_constraints"). + AddValueConstraint("zone", false, "east", "west"). + AddValueConstraint("zone", false, "east"). + AddValueConstraint("zone", true, "west") + + _, err := r.CreateJob(job) + require.NoError(t, err) + + success, err := monitor.Instances(job.JobKey(), 2, 1, 50) + assert.True(t, success) + assert.NoError(t, err) + + _, err = r.KillJob(job.JobKey()) + assert.NoError(t, err) + }) + + t.Run("Overwrite_constraints", func(t *testing.T) { + job.Name("thermos_overwrite_constraints"). + AddLimitConstraint("zone", 1). + AddValueConstraint("zone", true, "west", "east"). + AddLimitConstraint("zone", 2) + + _, err := r.CreateJob(job) + require.NoError(t, err) + + success, err := monitor.Instances(job.JobKey(), 2, 1, 50) + assert.True(t, success) + assert.NoError(t, err) + + _, err = r.KillJob(job.JobKey()) + assert.NoError(t, err) + }) +} + +// Test configuring an executor that doesn't exist for CreateJob API +func TestRealisClient_CreateJob_ExecutorDoesNotExist(t *testing.T) { + // Create a single job + job := realis.NewJob(). + Environment("prod"). + Role("vagrant"). + Name("executordoesntexist"). + ExecutorName("idontexist"). + ExecutorData(""). + CPU(.25). + RAM(4). + Disk(10). + InstanceCount(1) + + resp, err := r.CreateJob(job) + assert.Error(t, err) + assert.Equal(t, aurora.ResponseCode_INVALID_REQUEST, resp.GetResponseCode()) +} + +// Test configuring an executor that doesn't exist for CreateJob API +func TestRealisClient_GetPendingReason(t *testing.T) { + + env := "prod" + role := "vagrant" + name := "pending_reason_test" + + // Create a single job + job := realis.NewJob(). + Environment(env). + Role(role). + Name(name). + ExecutorName(aurora.AURORA_EXECUTOR_NAME). + ExecutorData(string(thermosPayload)). + CPU(1000). + RAM(64). + Disk(100). + InstanceCount(1) + + resp, err := r.CreateJob(job) + require.NoError(t, err) + assert.Equal(t, aurora.ResponseCode_OK, resp.ResponseCode) + + taskQ := &aurora.TaskQuery{ + Role: &role, + Environment: &env, + JobName: &name, + } + + reasons, err := r.GetPendingReason(taskQ) + assert.NoError(t, err) + assert.Len(t, reasons, 1) + + _, err = r.KillJob(job.JobKey()) + assert.NoError(t, err) +} + +func TestRealisClient_CreateService_WithPulse_Thermos(t *testing.T) { + + fmt.Println("Creating service") + role := "vagrant" + job := realis.NewJob(). + Environment("prod"). + Role(role). + Name("create_thermos_job_test"). + ExecutorName(aurora.AURORA_EXECUTOR_NAME). + ExecutorData(string(thermosPayload)). + CPU(.5). + RAM(64). + Disk(100). + IsService(true). + InstanceCount(1). + AddPorts(1). + AddLabel("currentTime", time.Now().String()) + + settings := realis.NewUpdateSettings() + settings.BlockIfNoPulsesAfterMs = thrift.Int32Ptr(500) + settings.UpdateGroupSize = 1 + settings.MinWaitInInstanceRunningMs = 5000 + settings.WaitForBatchCompletion = true + job.InstanceCount(2) + + _, result, err := r.CreateService(job, settings) + require.NoError(t, err) + + updateQ := aurora.JobUpdateQuery{ + Key: result.GetKey(), + Limit: 1, + } + + var updateDetails []*aurora.JobUpdateDetails + + ticker := time.NewTicker(time.Second * 1) + timer := time.NewTimer(time.Minute * 6) + defer ticker.Stop() + defer timer.Stop() + +pulseLoop: + for { + select { + case <-ticker.C: + + _, err = r.PulseJobUpdate(result.GetKey()) + assert.NoError(t, err, "unable to pulse job update") + + respDetail, err := r.JobUpdateDetails(updateQ) + assert.NoError(t, err) + + updateDetails = response.JobUpdateDetails(respDetail) + require.Len(t, updateDetails, 1, "No update found") + + status := updateDetails[0].Update.Summary.State.Status + if _, ok := realis.ActiveJobUpdateStates[status]; !ok { + + // Rolled forward is the only state in which an update has been successfully updated + // if we encounter an inactive state and it is not at rolled forward, update failed + if status == aurora.JobUpdateStatus_ROLLED_FORWARD { + fmt.Println("update succeed") + break pulseLoop + } else { + fmt.Println("update failed") + break pulseLoop + } + } + case <-timer.C: + _, err := r.AbortJobUpdate(*updateDetails[0].GetUpdate().GetSummary().GetKey(), "") + assert.NoError(t, err) + _, err = r.KillJob(job.JobKey()) + assert.NoError(t, err, "timed out during pulse update test") + t.FailNow() + } + } + + _, err = r.KillJob(job.JobKey()) + assert.NoError(t, err) +} + +// Test configuring an executor that doesn't exist for CreateJob API +func TestRealisClient_CreateService(t *testing.T) { + + // Create a single job + job := realis.NewJob(). + Environment("prod"). + Role("vagrant"). + Name("create_service_test"). + ExecutorName(aurora.AURORA_EXECUTOR_NAME). + ExecutorData(string(thermosPayload)). + CPU(.25). + RAM(4). + Disk(10). + InstanceCount(3). + IsService(true) + + settings := realis.NewUpdateSettings() + settings.UpdateGroupSize = 2 + settings.MinWaitInInstanceRunningMs = 5000 + job.InstanceCount(3) + + _, result, err := r.CreateService(job, settings) + require.NoError(t, err) + assert.NotNil(t, result) + + // Test asking the scheduler to backup a Snapshot + t.Run("PauseJobUpdate", func(t *testing.T) { + _, err = r.PauseJobUpdate(result.GetKey(), "") + assert.NoError(t, err) + }) + + t.Run("ResumeJobUpdate", func(t *testing.T) { + _, err = r.ResumeJobUpdate(result.GetKey(), "") + assert.NoError(t, err) + }) + + var ok bool + var mErr error + + if ok, mErr = monitor.JobUpdate(*result.GetKey(), 5, 240); !ok || mErr != nil { + // Update may already be in a terminal state so don't check for error + _, err := r.AbortJobUpdate(*result.GetKey(), "Monitor timed out.") + _, err = r.KillJob(job.JobKey()) + assert.NoError(t, err) + } + + require.NoError(t, mErr) + assert.True(t, ok) + + // Kill task test task after confirming it came up fine + _, err = r.KillJob(job.JobKey()) + assert.NoError(t, err) + + success, err := monitor.Instances(job.JobKey(), 0, 1, 50) + require.NoError(t, mErr) + assert.True(t, success) + + // Create a client which will timeout and close the connection before receiving an answer + timeoutClient, err := realis.NewRealisClient( + realis.SchedulerUrl(auroraURL), + realis.BasicAuth("aurora", "secret"), + realis.TimeoutMS(5), + ) + require.NoError(t, err) + defer timeoutClient.Close() + + // Test case where http connection timeouts out. + t.Run("TimeoutError", func(t *testing.T) { + job.Name("createService_timeout") + + // Make sure a timedout error was returned + _, _, err = timeoutClient.CreateService(job, settings) + require.Error(t, err) + assert.True(t, realis.IsTimeout(err)) + + updateReceivedQuery := aurora.JobUpdateQuery{ + Role: &job.JobKey().Role, + JobKey: job.JobKey(), + UpdateStatuses: aurora.ACTIVE_JOB_UPDATE_STATES, + Limit: 1} + + updateSummaries, err := monitor.JobUpdateQuery(updateReceivedQuery, time.Second*1, time.Second*50) + require.NoError(t, err) + + require.Len(t, updateSummaries, 1) + + r.AbortJobUpdate(*updateSummaries[0].Key, "Cleaning up") + _, err = r.KillJob(job.JobKey()) + assert.NoError(t, err) + + }) + + // Test case where http connection timeouts out. + t.Run("TimeoutError_BadPayload", func(t *testing.T) { + // Illegal payload + job.InstanceCount(-1) + job.Name("createService_timeout_bad_payload") + + // Make sure a timedout error was returned + _, _, err = timeoutClient.CreateService(job, settings) + require.Error(t, err) + assert.True(t, realis.IsTimeout(err)) + + summary, err := r.GetJobUpdateSummaries( + &aurora.JobUpdateQuery{ + Role: &job.JobKey().Role, + JobKey: job.JobKey(), + UpdateStatuses: aurora.ACTIVE_JOB_UPDATE_STATES}) + assert.NoError(t, err) + + // Payload should have been rejected, no update should exist + require.Len(t, summary.GetResult_().GetGetJobUpdateSummariesResult_().GetUpdateSummaries(), 0) + }) +} + +// Test configuring an executor that doesn't exist for CreateJob API +func TestRealisClient_CreateService_ExecutorDoesNotExist(t *testing.T) { + + // Create a single job + job := realis.NewJob(). + Environment("prod"). + Role("vagrant"). + Name("executordoesntexist"). + ExecutorName("idontexist"). + ExecutorData(""). + CPU(.25). + RAM(4). + Disk(10). + InstanceCount(1) + + settings := realis.NewUpdateSettings() + job.InstanceCount(3) + + resp, result, err := r.CreateService(job, settings) + require.Error(t, err) + assert.Nil(t, result) + require.Equal(t, aurora.ResponseCode_INVALID_REQUEST, resp.GetResponseCode()) +} + +func TestRealisClient_ScheduleCronJob_Thermos(t *testing.T) { + + thermosCronPayload, err := ioutil.ReadFile("examples/thermos_cron_payload.json") + assert.NoError(t, err) + + job := realis.NewJob(). + Environment("prod"). + Role("vagrant"). + Name("cronsched_job_test"). + ExecutorName(aurora.AURORA_EXECUTOR_NAME). + ExecutorData(string(thermosCronPayload)). + CPU(1). + RAM(64). + Disk(100). + IsService(true). + InstanceCount(1). + AddPorts(1). + CronSchedule("* * * * *"). + IsService(false) + + _, err = r.ScheduleCronJob(job) + require.NoError(t, err) + + t.Run("Start", func(t *testing.T) { + _, err := r.StartCronJob(job.JobKey()) + require.NoError(t, err) + }) + + t.Run("Deschedule", func(t *testing.T) { + _, err := r.DescheduleCronJob(job.JobKey()) + require.NoError(t, err) + }) +} +func TestRealisClient_StartMaintenance(t *testing.T) { + hosts := []string{"localhost"} + + _, _, err := r.StartMaintenance(hosts...) + require.NoError(t, err, "unable to start maintenance") + + // Monitor change to DRAINING and DRAINED mode + hostResults, err := monitor.HostMaintenance( + hosts, + []aurora.MaintenanceMode{aurora.MaintenanceMode_SCHEDULED}, + 1, + 50) + assert.NoError(t, err) + assert.Equal(t, map[string]bool{"localhost": true}, hostResults) + + _, _, err = r.EndMaintenance(hosts...) + require.NoError(t, err) + + // Monitor change to DRAINING and DRAINED mode + _, err = monitor.HostMaintenance( + hosts, + []aurora.MaintenanceMode{aurora.MaintenanceMode_NONE}, + 5, + 10) + assert.NoError(t, err) +} + +func TestRealisClient_DrainHosts(t *testing.T) { + hosts := []string{"localhost"} + + t.Run("DrainHosts", func(t *testing.T) { + _, _, err := r.DrainHosts(hosts...) + assert.NoError(t, err, "unable to drain host") + }) + + t.Run("MonitorTransitionToDrained", func(t *testing.T) { + // Monitor change to DRAINING and DRAINED mode + hostResults, err := monitor.HostMaintenance( + hosts, + []aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED, aurora.MaintenanceMode_DRAINING}, + 1, + 50) + require.NoError(t, err) + assert.Equal(t, map[string]bool{"localhost": true}, hostResults) + }) + + t.Run("MonitorNonExistentHost", func(t *testing.T) { + // Monitor change to DRAINING and DRAINED mode + hostResults, err := monitor.HostMaintenance( + append(hosts, "IMAGINARY_HOST"), + []aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED, aurora.MaintenanceMode_DRAINING}, + 1, + 1) + + // Assert monitor returned an error that was not nil, and also a list of the non-transitioned hosts + require.Error(t, err) + assert.Equal(t, map[string]bool{"localhost": true, "IMAGINARY_HOST": false}, hostResults) + }) + + t.Run("EndMaintenance", func(t *testing.T) { + _, _, err := r.EndMaintenance(hosts...) + require.NoError(t, err) + + // Monitor change to DRAINING and DRAINED mode + _, err = monitor.HostMaintenance( + hosts, + []aurora.MaintenanceMode{aurora.MaintenanceMode_NONE}, + 5, + 10) + assert.NoError(t, err) + }) + +} + +func TestRealisClient_SLADrainHosts(t *testing.T) { + hosts := []string{"localhost"} + policy := aurora.SlaPolicy{PercentageSlaPolicy: &aurora.PercentageSlaPolicy{Percentage: 50.0}} + + _, err := r.SLADrainHosts(&policy, 30, hosts...) + require.NoError(t, err, "unable to drain host with SLA policy") + + // Monitor change to DRAINING and DRAINED mode + hostResults, err := monitor.HostMaintenance( + hosts, + []aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED, aurora.MaintenanceMode_DRAINING}, + 1, + 50) + assert.NoError(t, err) + assert.Equal(t, map[string]bool{"localhost": true}, hostResults) + + _, _, err = r.EndMaintenance(hosts...) + require.NoError(t, err) + + // Monitor change to DRAINING and DRAINED mode + _, err = monitor.HostMaintenance( + hosts, + []aurora.MaintenanceMode{aurora.MaintenanceMode_NONE}, + 5, + 10) + assert.NoError(t, err) + + // slaDrainHosts goes with default policy if no policy is specified + _, err = r.SLADrainHosts(nil, 30, hosts...) + require.NoError(t, err, "unable to drain host with SLA policy") + + // Monitor change to DRAINING and DRAINED mode + hostResults, err = monitor.HostMaintenance( + hosts, + []aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED, aurora.MaintenanceMode_DRAINING}, + 1, + 50) + assert.NoError(t, err) + assert.Equal(t, map[string]bool{"localhost": true}, hostResults) + + _, _, err = r.EndMaintenance(hosts...) + require.NoError(t, err) + + // Monitor change to DRAINING and DRAINED mode + _, err = monitor.HostMaintenance( + hosts, + []aurora.MaintenanceMode{aurora.MaintenanceMode_NONE}, + 5, + 10) + assert.NoError(t, err) + + _, err = r.SLADrainHosts(&aurora.SlaPolicy{}, 30, hosts...) + require.NoError(t, err, "unable to drain host with SLA policy") + + // Monitor change to DRAINING and DRAINED mode + hostResults, err = monitor.HostMaintenance( + hosts, + []aurora.MaintenanceMode{aurora.MaintenanceMode_DRAINED, aurora.MaintenanceMode_DRAINING}, + 1, + 50) + assert.NoError(t, err) + assert.Equal(t, map[string]bool{"localhost": true}, hostResults) + + _, _, err = r.EndMaintenance(hosts...) + require.NoError(t, err) + + // Monitor change to DRAINING and DRAINED mode + _, err = monitor.HostMaintenance( + hosts, + []aurora.MaintenanceMode{aurora.MaintenanceMode_NONE}, + 5, + 10) + assert.NoError(t, err) +} + +// Test multiple go routines using a single connection +func TestRealisClient_SessionThreadSafety(t *testing.T) { + + // Create a single job + job := realis.NewJob(). + Environment("prod"). + Role("vagrant"). + Name("create_thermos_job_test_multi"). + ExecutorName(aurora.AURORA_EXECUTOR_NAME). + ExecutorData(string(thermosPayload)). + CPU(.25). + RAM(4). + Disk(10). + InstanceCount(1000) // Impossible amount to go live in any sane machine + + _, err := r.CreateJob(job) + assert.NoError(t, err) + + wg := sync.WaitGroup{} + threadCount := 20 + wg.Add(threadCount) + for i := 0; i < threadCount; i++ { + + // Launch multiple monitors that will poll every second + go func() { + defer wg.Done() + + // Test Schedule status monitor for terminal state and timing out after 30 seconds + success, err := monitor.ScheduleStatus(job.JobKey(), job.GetInstanceCount(), realis.LiveStates, 1, 30) + assert.False(t, success) + assert.Error(t, err) + + _, err = r.KillJob(job.JobKey()) + assert.NoError(t, err) + }() + } + + wg.Wait() +} + +// Test setting and getting the quota +func TestRealisClient_Quota(t *testing.T) { + var resp *aurora.Response + var err error + + cpu := 3.5 + ram := int64(20480) + disk := int64(10240) + + t.Run("Set", func(t *testing.T) { + resp, err = r.SetQuota("vagrant", &cpu, &ram, &disk) + assert.NoError(t, err) + }) + + t.Run("Get", func(t *testing.T) { + // Test GetQuota based on previously set values + var result *aurora.GetQuotaResult_ + resp, err = r.GetQuota("vagrant") + if resp.GetResult_() != nil { + result = resp.GetResult_().GetQuotaResult_ + } + assert.NoError(t, err) + + for _, res := range result.Quota.GetResources() { + switch true { + case res.DiskMb != nil: + assert.Equal(t, disk, *res.DiskMb) + case res.NumCpus != nil: + assert.Equal(t, cpu, *res.NumCpus) + case res.RamMb != nil: + assert.Equal(t, ram, *res.RamMb) + } + } + }) +} + +func TestRealisClient_ForceImplicitTaskReconciliation(t *testing.T) { + err := r.ForceImplicitTaskReconciliation() + assert.NoError(t, err) +} + +func TestRealisClient_ForceExplicitTaskReconciliation(t *testing.T) { + // Default value + err := r.ForceExplicitTaskReconciliation(nil) + assert.NoError(t, err) + + // Custom batch value + err = r.ForceExplicitTaskReconciliation(thrift.Int32Ptr(32)) + assert.NoError(t, err) +} + +func TestRealisClient_PartitionPolicy(t *testing.T) { + + role := "vagrant" + job := realis.NewJob(). + Environment("prod"). + Role(role). + Name("create_thermos_job_partition_policy_test"). + ExecutorName(aurora.AURORA_EXECUTOR_NAME). + ExecutorData(string(thermosPayload)). + CPU(.5). + RAM(64). + Disk(100). + IsService(true). + InstanceCount(2). + PartitionPolicy(&aurora.PartitionPolicy{Reschedule: true, DelaySecs: thrift.Int64Ptr(30)}) + + settings := realis.NewUpdateSettings() + settings.UpdateGroupSize = 2 + + _, result, err := r.CreateService(job, settings) + assert.NoError(t, err) + + var ok bool + var mErr error + + if ok, mErr = monitor.JobUpdate(*result.GetKey(), 5, 180); !ok || mErr != nil { + // Update may already be in a terminal state so don't check for error + _, err := r.AbortJobUpdate(*result.GetKey(), "Monitor timed out.") + assert.NoError(t, err) + } + + // Clean up after finishing test + r.KillJob(job.JobKey()) +} + +func TestAuroraJob_UpdateSlaPolicy(t *testing.T) { + + tests := []struct { + name string + args aurora.SlaPolicy + }{ + { + "create_service_with_sla_count_policy_test", + aurora.SlaPolicy{CountSlaPolicy: &aurora.CountSlaPolicy{Count: 1, DurationSecs: 15}}, + }, + { + "create_service_with_sla_percentage_policy_test", + aurora.SlaPolicy{PercentageSlaPolicy: &aurora.PercentageSlaPolicy{Percentage: 0.25, DurationSecs: 15}}, + }, + { + "create_service_with_sla_coordinator_policy_test", + aurora.SlaPolicy{CoordinatorSlaPolicy: &aurora.CoordinatorSlaPolicy{ + CoordinatorUrl: "http://localhost/endpoint", StatusKey: "aurora_test"}}, + }, + } + role := "vagrant" + + _, err := r.SetQuota(role, thrift.Float64Ptr(6.0), thrift.Int64Ptr(1024), thrift.Int64Ptr(1024)) + assert.NoError(t, err) + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + + // Create a single job + job := realis.NewJob(). + Environment("prod"). + Role(role). + Name(tt.name). + ExecutorName(aurora.AURORA_EXECUTOR_NAME). + ExecutorData(string(thermosPayload)). + CPU(.01). + RAM(2). + Disk(5). + InstanceCount(4). + IsService(true). + SlaPolicy(&tt.args). + Tier("preferred") + + settings := realis.NewUpdateSettings() + settings.UpdateGroupSize = 2 + settings.MinWaitInInstanceRunningMs = 5 * 1000 + + _, result, err := r.CreateService(job, settings) + require.NoError(t, err) + assert.NotNil(t, result) + + var ok bool + var mErr error + + if ok, mErr = monitor.JobUpdate(*result.GetKey(), 5, 240); !ok || mErr != nil { + // Update may already be in a terminal state so don't check for error + _, err := r.AbortJobUpdate(*result.GetKey(), "Monitor timed out.") + + _, err = r.KillJob(job.JobKey()) + + assert.NoError(t, err) + } + assert.NoError(t, mErr) + assert.True(t, ok) + + // Kill task test task after confirming it came up fine + _, err = r.KillJob(job.JobKey()) + + assert.NoError(t, err) + }) + } +} + +func TestRealisClient_UpdateStrategies(t *testing.T) { + + // Create a single job + job := realis.NewJob(). + Environment("prod"). + Role("vagrant"). + ExecutorName(aurora.AURORA_EXECUTOR_NAME). + ExecutorData(string(thermosPayload)). + CPU(.01). + RAM(4). + Disk(10). + InstanceCount(6). + IsService(true) + + strategies := []struct { + UpdateJob *realis.UpdateJob + Name string + }{ + { + UpdateJob: realis.NewDefaultUpdateJob(job.TaskConfig()). + QueueUpdateStrategy(aurora.QueueJobUpdateStrategy{GroupSize: 2}). + InstanceCount(6). + WatchTime(1000), + Name: "Queue", + }, + { + UpdateJob: realis.NewDefaultUpdateJob(job.TaskConfig()). + BatchUpdateStrategy(aurora.BatchJobUpdateStrategy{GroupSize: 2}). + InstanceCount(6). + WatchTime(1000), + Name: "Batch", + }, + { + UpdateJob: realis.NewDefaultUpdateJob(job.TaskConfig()). + VariableBatchStrategy(aurora.VariableBatchJobUpdateStrategy{GroupSizes: []int32{1, 2, 3}}). + InstanceCount(6). + WatchTime(1000), + Name: "VarBatch", + }, + } + + for _, strategy := range strategies { + t.Run("TestRealisClient_UpdateStrategies_"+strategy.Name, func(t *testing.T) { + job.Name("update_strategies_" + strategy.Name) + resp, err := r.StartJobUpdate(strategy.UpdateJob, "") + + assert.NoError(t, err) + assert.NotNil(t, resp) + assert.NotNil(t, resp.GetResult_()) + assert.NotNil(t, resp.GetResult_().GetStartJobUpdateResult_()) + assert.NotNil(t, resp.GetResult_().GetStartJobUpdateResult_().GetKey()) + + var ok bool + var mErr error + key := *resp.GetResult_().GetStartJobUpdateResult_().GetKey() + + if ok, mErr = monitor.JobUpdate(key, 5, 240); !ok || mErr != nil { + // Update may already be in a terminal state so don't check for error + _, err := r.AbortJobUpdate(key, "Monitor timed out.") + assert.NoError(t, err) + } + _, err = r.KillJob(job.JobKey()) + assert.NoError(t, err) + }) + } +} + +func TestRealisClient_BatchAwareAutoPause(t *testing.T) { + // Create a single job + job := realis.NewJob(). + Environment("prod"). + Role("vagrant"). + Name("BatchAwareAutoPauseTest"). + ExecutorName(aurora.AURORA_EXECUTOR_NAME). + ExecutorData(string(thermosPayload)). + CPU(.01). + RAM(4). + Disk(10). + InstanceCount(6). + IsService(true) + updateGroups := []int32{1, 2, 3} + strategy := realis.NewDefaultUpdateJob(job.TaskConfig()). + VariableBatchStrategy(aurora.VariableBatchJobUpdateStrategy{ + GroupSizes: updateGroups, + AutopauseAfterBatch: true, + }). + InstanceCount(6). + WatchTime(1000) + + resp, err := r.StartJobUpdate(strategy, "") + require.NoError(t, err) + require.NotNil(t, resp) + require.NotNil(t, resp.GetResult_()) + require.NotNil(t, resp.GetResult_().GetStartJobUpdateResult_()) + require.NotNil(t, resp.GetResult_().GetStartJobUpdateResult_().GetKey()) + + key := *resp.GetResult_().GetStartJobUpdateResult_().GetKey() + + for i := range updateGroups { + curStep, mErr := monitor.AutoPausedUpdateMonitor(key, time.Second*5, time.Second*240) + if mErr != nil { + // Update may already be in a terminal state so don't check for error + _, err := r.AbortJobUpdate(key, "Monitor timed out.") + assert.NoError(t, err) + } + + assert.Equal(t, i, curStep) + + if i != len(updateGroups)-1 { + _, err = r.ResumeJobUpdate(&key, "auto resuming test") + require.NoError(t, err) + } + } + + _, err = r.KillJob(job.JobKey()) + assert.NoError(t, err) +} diff --git a/realis_test.go b/realis_test.go deleted file mode 100644 index 329abbf..0000000 --- a/realis_test.go +++ /dev/null @@ -1,135 +0,0 @@ -/** - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package realis - -import ( - "fmt" - "github.com/rdelval/gorealis/gen-go/apache/aurora" - "github.com/stretchr/testify/assert" - "io/ioutil" - "os" - "testing" -) - -var r Realis -var thermosPayload []byte - -func TestMain(m *testing.M) { - // New configuration to connect to Vagrant image - config, err := NewDefaultConfig("http://192.168.33.7:8081") - if err != nil { - fmt.Println("Please run vagrant box before running test suite") - os.Exit(1) - } - - thermosPayload, err = ioutil.ReadFile("examples/thermos_payload.json") - if err != nil { - fmt.Println("Error reading thermos payload file: ", err) - os.Exit(1) - } - - // Configured for vagrant - AddBasicAuth(&config, "aurora", "secret") - r = NewClient(config) - - os.Exit(m.Run()) -} - -func TestRealisClient_CreateJob_Thermos(t *testing.T) { - - job := NewJob(). - Environment("prod"). - Role("vagrant"). - Name("create_job_test"). - ExecutorName(aurora.AURORA_EXECUTOR_NAME). - ExecutorData(string(thermosPayload)). - CPU(1). - RAM(64). - Disk(100). - IsService(true). - InstanceCount(1). - AddPorts(1) - - resp, err := r.CreateJob(job) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - assert.Equal(t, aurora.ResponseCode_OK, resp.ResponseCode) - - // Tasks must exist for it to be killed - t.Run("TestRealisClient_KillJob_Thermos", func(t *testing.T) { - resp, err := r.KillJob(job.JobKey()) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - assert.Equal(t, aurora.ResponseCode_OK, resp.ResponseCode) - }) -} - -func TestRealisClient_ScheduleCronJob_Thermos(t *testing.T) { - - thermosCronPayload, err := ioutil.ReadFile("examples/thermos_cron_payload.json") - if err != nil { - fmt.Println("Error reading thermos payload file: ", err) - os.Exit(1) - } - - job := NewJob(). - Environment("prod"). - Role("vagrant"). - Name("cronsched_job_test"). - ExecutorName(aurora.AURORA_EXECUTOR_NAME). - ExecutorData(string(thermosCronPayload)). - CPU(1). - RAM(64). - Disk(100). - IsService(true). - InstanceCount(1). - AddPorts(1). - CronSchedule("* * * * *"). - IsService(false) - - resp, err := r.ScheduleCronJob(job) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - assert.Equal(t, aurora.ResponseCode_OK, resp.ResponseCode) - - t.Run("TestRealisClient_StartCronJob_Thermos", func(t *testing.T) { - resp, err := r.StartCronJob(job.JobKey()) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - assert.Equal(t, aurora.ResponseCode_OK, resp.ResponseCode) - }) - - t.Run("TestRealisClient_DeschedulerCronJob_Thermos", func(t *testing.T) { - resp, err := r.DescheduleCronJob(job.JobKey()) - if err != nil { - fmt.Println(err) - os.Exit(1) - } - - assert.Equal(t, aurora.ResponseCode_OK, resp.ResponseCode) - }) -} diff --git a/response/response.go b/response/response.go index c9da05e..4a67ca0 100644 --- a/response/response.go +++ b/response/response.go @@ -17,24 +17,37 @@ package response import ( "bytes" - "github.com/rdelval/gorealis/gen-go/apache/aurora" - "github.com/pkg/errors" + "errors" + + "github.com/paypal/gorealis/gen-go/apache/aurora" ) // Get key from a response created by a StartJobUpdate call func JobUpdateKey(resp *aurora.Response) *aurora.JobUpdateKey { - return resp.Result_.StartJobUpdateResult_.GetKey() + return resp.GetResult_().GetStartJobUpdateResult_().GetKey() } func JobUpdateDetails(resp *aurora.Response) []*aurora.JobUpdateDetails { - return resp.Result_.GetJobUpdateDetailsResult_.DetailsList + return resp.GetResult_().GetGetJobUpdateDetailsResult_().GetDetailsList() } func ScheduleStatusResult(resp *aurora.Response) *aurora.ScheduleStatusResult_ { return resp.GetResult_().GetScheduleStatusResult_() } +func JobUpdateSummaries(resp *aurora.Response) []*aurora.JobUpdateSummary { + if resp.GetResult_() == nil || resp.GetResult_().GetGetJobUpdateSummariesResult_() == nil { + return nil + } + + return resp.GetResult_().GetGetJobUpdateSummariesResult_().GetUpdateSummaries() +} + +// Deprecated: Replaced by checks done inside of thriftCallHelper func ResponseCodeCheck(resp *aurora.Response) (*aurora.Response, error) { + if resp == nil { + return resp, errors.New("Response is nil") + } if resp.GetResponseCode() != aurora.ResponseCode_OK { return resp, errors.New(CombineMessage(resp)) } @@ -50,7 +63,7 @@ func CombineMessage(resp *aurora.Response) string { } if buffer.Len() > 0 { - buffer.Truncate(buffer.Len()-2) // Get rid of trailing comma + space + buffer.Truncate(buffer.Len() - 2) // Get rid of trailing comma + space } return buffer.String() } diff --git a/retry.go b/retry.go new file mode 100644 index 0000000..eefcf2a --- /dev/null +++ b/retry.go @@ -0,0 +1,294 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package realis + +import ( + "io" + "math/rand" + "net/url" + "time" + + "github.com/apache/thrift/lib/go/thrift" + "github.com/paypal/gorealis/gen-go/apache/aurora" + "github.com/paypal/gorealis/response" + "github.com/pkg/errors" +) + +// Backoff determines how the retry mechanism should react after each failure and how many failures it should +// tolerate. +type Backoff struct { + Duration time.Duration // the base duration + Factor float64 // Duration is multiplied by a factor each iteration + Jitter float64 // The amount of jitter applied each iteration + Steps int // Exit with error after this many steps +} + +// Jitter returns a time.Duration between duration and duration + maxFactor * +// duration. +// +// This allows clients to avoid converging on periodic behavior. If maxFactor +// is 0.0, a suggested default value will be chosen. +func Jitter(duration time.Duration, maxFactor float64) time.Duration { + if maxFactor <= 0.0 { + maxFactor = 1.0 + } + wait := duration + time.Duration(rand.Float64()*maxFactor*float64(duration)) + return wait +} + +// ConditionFunc returns true if the condition is satisfied, or an error +// if the loop should be aborted. +type ConditionFunc func() (done bool, err error) + +// ExponentialBackoff is a modified version of the Kubernetes exponential-backoff code. +// It repeats a condition check with exponential backoff and checks the condition up to +// Steps times, increasing the wait by multiplying the previous duration by Factor. +// +// If Jitter is greater than zero, a random amount of each duration is added +// (between duration and duration*(1+jitter)). +// +// If the condition never returns true, ErrWaitTimeout is returned. Errors +// do not cause the function to return. +func ExponentialBackoff(backoff Backoff, logger logger, condition ConditionFunc) error { + var err error + var ok bool + var curStep int + duration := backoff.Duration + + for curStep = 0; curStep < backoff.Steps; curStep++ { + + // Only sleep if it's not the first iteration. + if curStep != 0 { + adjusted := duration + if backoff.Jitter > 0.0 { + adjusted = Jitter(duration, backoff.Jitter) + } + + logger.Printf( + "A retryable error occurred during function call, backing off for %v before retrying\n", adjusted) + time.Sleep(adjusted) + duration = time.Duration(float64(duration) * backoff.Factor) + } + + // Execute function passed in. + ok, err = condition() + + // If the function executed says it succeeded, stop retrying + if ok { + return nil + } + + if err != nil { + // If the error is temporary, continue retrying. + if !IsTemporary(err) { + return err + } + // Print out the temporary error we experienced. + logger.Println(err) + } + } + + if curStep > 1 { + logger.Printf("retried this function call %d time(s)", curStep) + } + + // Provide more information to the user wherever possible + if err != nil { + return newRetryError(errors.Wrap(err, "ran out of retries"), curStep) + } + + return newRetryError(errors.New("ran out of retries"), curStep) +} + +type auroraThriftCall func() (resp *aurora.Response, err error) + +// verifyOntimeout defines the type of function that will be used to verify whether a Thirft call to the Scheduler +// made it to the scheduler or not. In general, these types of functions will have to interact with the scheduler +// through the very same Thrift API which previously encountered a time out from the client. +// This means that the functions themselves should be kept to a minimum number of Thrift calls. +// It should also be noted that this is a best effort mechanism and +// is likely to fail for the same reasons that the original call failed. +type verifyOnTimeout func() (*aurora.Response, bool) + +// Duplicates the functionality of ExponentialBackoff but is specifically targeted towards ThriftCalls. +func (r *realisClient) thriftCallWithRetries( + returnOnTimeout bool, + thriftCall auroraThriftCall, + verifyOnTimeout verifyOnTimeout) (*aurora.Response, error) { + + var resp *aurora.Response + var clientErr error + var curStep int + timeouts := 0 + + backoff := r.config.backoff + duration := backoff.Duration + + for curStep = 0; curStep < backoff.Steps; curStep++ { + + // If this isn't our first try, backoff before the next try. + if curStep != 0 { + adjusted := duration + if backoff.Jitter > 0.0 { + adjusted = Jitter(duration, backoff.Jitter) + } + + r.logger.Printf( + "A retryable error occurred during thrift call, backing off for %v before retry %v", + adjusted, + curStep) + + time.Sleep(adjusted) + duration = time.Duration(float64(duration) * backoff.Factor) + } + + // Only allow one go-routine make use or modify the thrift client connection. + // Placing this in an anonymous function in order to create a new, short-lived stack allowing unlock + // to be run in case of a panic inside of thriftCall. + func() { + r.lock.Lock() + defer r.lock.Unlock() + + resp, clientErr = thriftCall() + + r.logger.tracePrintf("Aurora Thrift Call ended resp: %v clientErr: %v", resp, clientErr) + }() + + // Check if our thrift call is returning an error. + if clientErr != nil { + // Print out the error to the user + r.logger.Printf("Client Error: %v", clientErr) + + temporary, timedout := isConnectionError(clientErr) + if !temporary && r.RealisConfig().failOnPermanentErrors { + return nil, errors.Wrap(clientErr, "permanent connection error") + } + + // There exists a corner case where thrift payload was received by Aurora but + // connection timed out before Aurora was able to reply. + // Users can take special action on a timeout by using IsTimedout and reacting accordingly + // if they have configured the client to return on a timeout. + if timedout && returnOnTimeout { + return resp, newTimedoutError(errors.New("client connection closed before server answer")) + } + + // In the future, reestablish connection should be able to check if it is actually possible + // to make a thrift call to Aurora. For now, a reconnect should always lead to a retry. + // Ignoring error due to the fact that an error should be retried regardless + reestablishErr := r.ReestablishConn() + if reestablishErr != nil { + r.logger.debugPrintf("error re-establishing connection ", reestablishErr) + } + + // If users did not opt for a return on timeout in order to react to a timedout error, + // attempt to verify that the call made it to the scheduler after the connection was re-established. + if timedout { + timeouts++ + r.logger.debugPrintf( + "Client closed connection %d times before server responded, "+ + "consider increasing connection timeout", + timeouts) + + // Allow caller to provide a function which checks if the original call was successful before + // it timed out. + if verifyOnTimeout != nil { + if verifyResp, ok := verifyOnTimeout(); ok { + r.logger.Print("verified that the call went through successfully after a client timeout") + // Response here might be different than the original as it is no longer constructed + // by the scheduler but mimicked. + // This is OK since the scheduler is very unlikely to change responses at this point in its + // development cycle but we must be careful to not return an incorrectly constructed response. + return verifyResp, nil + } + } + } + + // Retry the thrift payload + continue + } + + // If there was no client error, but the response is nil, something went wrong. + // Ideally, we'll never encounter this but we're placing a safeguard here. + if resp == nil { + return nil, errors.New("response from aurora is nil") + } + + // Check Response Code from thrift and make a decision to continue retrying or not. + switch responseCode := resp.GetResponseCode(); responseCode { + + // If the thrift call succeeded, stop retrying + case aurora.ResponseCode_OK: + return resp, nil + + // If the response code is transient, continue retrying + case aurora.ResponseCode_ERROR_TRANSIENT: + r.logger.Println("Aurora replied with Transient error code, retrying") + continue + + // Failure scenarios, these indicate a bad payload or a bad config. Stop retrying. + case aurora.ResponseCode_INVALID_REQUEST, + aurora.ResponseCode_ERROR, + aurora.ResponseCode_AUTH_FAILED, + aurora.ResponseCode_JOB_UPDATING_ERROR: + r.logger.Printf("Terminal Response Code %v from Aurora, won't retry\n", resp.GetResponseCode().String()) + return resp, errors.New(response.CombineMessage(resp)) + + // The only case that should fall down to here is a WARNING response code. + // It is currently not used as a response in the scheduler so it is unknown how to handle it. + default: + r.logger.debugPrintf("unhandled response code %v received from Aurora\n", responseCode) + return nil, errors.Errorf("unhandled response code from Aurora %v", responseCode.String()) + } + + } + + if curStep > 1 { + r.config.logger.Printf("this thrift call was retried %d time(s)", curStep) + } + + // Provide more information to the user wherever possible. + if clientErr != nil { + return nil, newRetryError(errors.Wrap(clientErr, "ran out of retries, including latest error"), curStep) + } + + return nil, newRetryError(errors.New("ran out of retries"), curStep) +} + +// isConnectionError processes the error received by the client. +// The return values indicate weather this was determined to be a temporary error +// and weather it was determined to be a timeout error +func isConnectionError(err error) (bool, bool) { + + // Determine if error is a temporary URL error by going up the stack + transportException, ok := err.(thrift.TTransportException) + if !ok { + return false, false + } + + urlError, ok := transportException.Err().(*url.Error) + if !ok { + return false, false + } + + // EOF error occurs when the server closes the read buffer of the client. This is common + // when the server is overloaded and we consider it temporary. + // All other which are not temporary as per the member function Temporary(), + // are considered not temporary (permanent). + if urlError.Err != io.EOF && !urlError.Temporary() { + return false, false + } + + return true, urlError.Timeout() +} diff --git a/runTests.sh b/runTests.sh new file mode 100755 index 0000000..e213972 --- /dev/null +++ b/runTests.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +docker-compose up -d + +# If running docker-compose up gives any error, don't do anything. +if [ $? -ne 0 ]; then + exit +fi + +# Since we run our docker compose setup in bridge mode to be able to run on MacOS, we have to launch a Docker container within the bridge network in order to avoid any routing issues. +docker run --rm -t -v $(pwd):/go/src/github.com/paypal/gorealis --network gorealis_aurora_cluster golang:1.10-stretch go test -v github.com/paypal/gorealis $@ + +docker-compose down diff --git a/runTestsMac.sh b/runTestsMac.sh new file mode 100644 index 0000000..6a09931 --- /dev/null +++ b/runTestsMac.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +# Since we run our docker compose setup in bridge mode to be able to run on MacOS, we have to launch a Docker container within the bridge network in order to avoid any routing issues. +docker run --rm -t -w /gorealis -v $GOPATH/pkg:/go/pkg -v $(pwd):/gorealis --network gorealis_aurora_cluster golang:1.16-buster go test -v github.com/paypal/gorealis $@ diff --git a/updatejob.go b/updatejob.go index cb2d8c6..09e69c9 100644 --- a/updatejob.go +++ b/updatejob.go @@ -15,95 +15,174 @@ package realis import ( - "github.com/rdelval/gorealis/gen-go/apache/aurora" + "github.com/paypal/gorealis/gen-go/apache/aurora" ) -// Structure to collect all information required to create job update +// UpdateJob is a structure to collect all information required to create job update. type UpdateJob struct { Job // SetInstanceCount for job is hidden, access via full qualifier req *aurora.JobUpdateRequest } -// Create a default UpdateJob object. -func NewUpdateJob(config *aurora.TaskConfig) *UpdateJob { +// NewDefaultUpdateJob creates an UpdateJob object with opinionated default settings. +func NewDefaultUpdateJob(config *aurora.TaskConfig) *UpdateJob { req := aurora.NewJobUpdateRequest() req.TaskConfig = config - req.Settings = aurora.NewJobUpdateSettings() + req.Settings = NewUpdateSettings() + + job, ok := NewJob().(*AuroraJob) + if !ok { + // This should never happen but it is here as a safeguard + return nil + } - job := NewJob().(AuroraJob) job.jobConfig.TaskConfig = config // Rebuild resource map from TaskConfig - for ptr := range config.Resources { + for _, ptr := range config.Resources { if ptr.NumCpus != nil { - job.resources["cpu"].NumCpus = ptr.NumCpus + job.resources[CPU].NumCpus = ptr.NumCpus continue // Guard against Union violations that Go won't enforce } if ptr.RamMb != nil { - job.resources["ram"].RamMb = ptr.RamMb + job.resources[RAM].RamMb = ptr.RamMb continue } if ptr.DiskMb != nil { - job.resources["disk"].DiskMb = ptr.DiskMb + job.resources[DISK].DiskMb = ptr.DiskMb + continue + } + + if ptr.NumGpus != nil { + job.resources[GPU] = &aurora.Resource{NumGpus: ptr.NumGpus} continue } } // Mirrors defaults set by Pystachio - req.Settings.UpdateOnlyTheseInstances = make(map[*aurora.Range]bool) req.Settings.UpdateGroupSize = 1 req.Settings.WaitForBatchCompletion = false - req.Settings.MinWaitInInstanceRunningMs = 45000 // Deprecated + req.Settings.MinWaitInInstanceRunningMs = 45000 req.Settings.MaxPerInstanceFailures = 0 req.Settings.MaxFailedInstances = 0 req.Settings.RollbackOnFailure = true - req.Settings.WaitForBatchCompletion = false //TODO(rdelvalle): Deep copy job struct to avoid unexpected behavior - return &UpdateJob{job, req} + return &UpdateJob{Job: job, req: req} } -// Set instance count the job will have after the update. +// NewUpdateJob creates an UpdateJob object wihtout default settings. +func NewUpdateJob(config *aurora.TaskConfig, settings *aurora.JobUpdateSettings) *UpdateJob { + + req := aurora.NewJobUpdateRequest() + req.TaskConfig = config + req.Settings = settings + + job, ok := NewJob().(*AuroraJob) + if !ok { + // This should never happen but it is here as a safeguard + return nil + } + job.jobConfig.TaskConfig = config + + // Rebuild resource map from TaskConfig + for _, ptr := range config.Resources { + if ptr.NumCpus != nil { + job.resources[CPU].NumCpus = ptr.NumCpus + continue // Guard against Union violations that Go won't enforce + } + + if ptr.RamMb != nil { + job.resources[RAM].RamMb = ptr.RamMb + continue + } + + if ptr.DiskMb != nil { + job.resources[DISK].DiskMb = ptr.DiskMb + continue + } + + if ptr.NumGpus != nil { + job.resources[GPU] = &aurora.Resource{} + job.resources[GPU].NumGpus = ptr.NumGpus + continue // Guard against Union violations that Go won't enforce + } + } + + //TODO(rdelvalle): Deep copy job struct to avoid unexpected behavior + return &UpdateJob{Job: job, req: req} +} + +// InstanceCount sets instance count the job will have after the update. func (u *UpdateJob) InstanceCount(inst int32) *UpdateJob { u.req.InstanceCount = inst return u } -// Max number of instances being updated at any given moment. +// BatchSize sets the max number of instances being updated at any given moment. func (u *UpdateJob) BatchSize(size int32) *UpdateJob { u.req.Settings.UpdateGroupSize = size return u } -// Minimum number of seconds a shard must remain in RUNNING state before considered a success. -func (u *UpdateJob) WatchTime(milliseconds int32) *UpdateJob { - u.req.Settings.MaxPerInstanceFailures = milliseconds +// WatchTime sets the minimum number of seconds a shard must remain in RUNNING state before considered a success. +func (u *UpdateJob) WatchTime(ms int32) *UpdateJob { + u.req.Settings.MinWaitInInstanceRunningMs = ms return u } -// Wait for all instances in a group to be done before moving on. +// WaitForBatchCompletion configures the job update to wait for all instances in a group to be done before moving on. func (u *UpdateJob) WaitForBatchCompletion(batchWait bool) *UpdateJob { u.req.Settings.WaitForBatchCompletion = batchWait return u } -// Max number of instance failures to tolerate before marking instance as FAILED. +// MaxPerInstanceFailures sets the max number of instance failures to tolerate before marking instance as FAILED. func (u *UpdateJob) MaxPerInstanceFailures(inst int32) *UpdateJob { u.req.Settings.MaxPerInstanceFailures = inst return u } -// Max number of FAILED instances to tolerate before terminating the update. +// MaxFailedInstances sets the max number of FAILED instances to tolerate before terminating the update. func (u *UpdateJob) MaxFailedInstances(inst int32) *UpdateJob { u.req.Settings.MaxFailedInstances = inst return u } -// When False, prevents auto rollback of a failed update. +// RollbackOnFail configure the job to rollback automatically after a job update fails. func (u *UpdateJob) RollbackOnFail(rollback bool) *UpdateJob { u.req.Settings.RollbackOnFailure = rollback return u } + +// NewUpdateSettings return an opinionated set of job update settings. +func (u *UpdateJob) BatchUpdateStrategy(strategy aurora.BatchJobUpdateStrategy) *UpdateJob { + u.req.Settings.UpdateStrategy = &aurora.JobUpdateStrategy{BatchStrategy: &strategy} + return u +} + +func (u *UpdateJob) QueueUpdateStrategy(strategy aurora.QueueJobUpdateStrategy) *UpdateJob { + u.req.Settings.UpdateStrategy = &aurora.JobUpdateStrategy{QueueStrategy: &strategy} + return u +} + +func (u *UpdateJob) VariableBatchStrategy(strategy aurora.VariableBatchJobUpdateStrategy) *UpdateJob { + u.req.Settings.UpdateStrategy = &aurora.JobUpdateStrategy{VarBatchStrategy: &strategy} + return u +} + +func NewUpdateSettings() *aurora.JobUpdateSettings { + us := new(aurora.JobUpdateSettings) + // Mirrors defaults set by Pystachio + us.UpdateGroupSize = 1 + us.WaitForBatchCompletion = false + us.MinWaitInInstanceRunningMs = 45000 + us.MaxPerInstanceFailures = 0 + us.MaxFailedInstances = 0 + us.RollbackOnFailure = true + + return us +} diff --git a/util.go b/util.go new file mode 100644 index 0000000..4307d1c --- /dev/null +++ b/util.go @@ -0,0 +1,167 @@ +package realis + +import ( + "crypto/x509" + "io/ioutil" + "net/url" + "os" + "path/filepath" + "strings" + + "github.com/paypal/gorealis/gen-go/apache/aurora" + "github.com/pkg/errors" +) + +const apiPath = "/api" + +// ActiveStates - States a task may be in when active. +var ActiveStates = make(map[aurora.ScheduleStatus]bool) + +// SlaveAssignedStates - States a task may be in when it has already been assigned to a Mesos agent. +var SlaveAssignedStates = make(map[aurora.ScheduleStatus]bool) + +// LiveStates - States a task may be in when it is live (e.g. able to take traffic) +var LiveStates = make(map[aurora.ScheduleStatus]bool) + +// TerminalStates - Set of states a task may not transition away from. +var TerminalStates = make(map[aurora.ScheduleStatus]bool) + +// ActiveJobUpdateStates - States a Job Update may be in where it is considered active. +var ActiveJobUpdateStates = make(map[aurora.JobUpdateStatus]bool) + +// TerminalUpdateStates returns a slice containing all the terminal states an update may be in. +// This is a function in order to avoid having a slice that can be accidentally mutated. +func TerminalUpdateStates() []aurora.JobUpdateStatus { + return []aurora.JobUpdateStatus{ + aurora.JobUpdateStatus_ROLLED_FORWARD, + aurora.JobUpdateStatus_ROLLED_BACK, + aurora.JobUpdateStatus_ABORTED, + aurora.JobUpdateStatus_ERROR, + aurora.JobUpdateStatus_FAILED, + } +} + +// AwaitingPulseJobUpdateStates - States a job update may be in where it is waiting for a pulse. +var AwaitingPulseJobUpdateStates = make(map[aurora.JobUpdateStatus]bool) + +func init() { + for _, status := range aurora.ACTIVE_STATES { + ActiveStates[status] = true + } + + for _, status := range aurora.SLAVE_ASSIGNED_STATES { + SlaveAssignedStates[status] = true + } + + for _, status := range aurora.LIVE_STATES { + LiveStates[status] = true + } + + for _, status := range aurora.TERMINAL_STATES { + TerminalStates[status] = true + } + + for _, status := range aurora.ACTIVE_JOB_UPDATE_STATES { + ActiveJobUpdateStates[status] = true + } + for _, status := range aurora.AWAITNG_PULSE_JOB_UPDATE_STATES { + AwaitingPulseJobUpdateStates[status] = true + } +} + +// createCertPool will attempt to load certificates into a certificate pool from a given directory. +// Only files with an extension contained in the extension map are considered. +// This function ignores any files that cannot be read successfully or cannot be added to the certPool +// successfully. +func createCertPool(path string, extensions map[string]struct{}) (*x509.CertPool, error) { + _, err := os.Stat(path) + if err != nil { + return nil, errors.Wrap(err, "unable to load certificates") + } + + caFiles, err := ioutil.ReadDir(path) + if err != nil { + return nil, err + } + + certPool := x509.NewCertPool() + loadedCerts := 0 + for _, cert := range caFiles { + // Skip directories + if cert.IsDir() { + continue + } + + // Skip any files that do not contain the right extension + if _, ok := extensions[filepath.Ext(cert.Name())]; !ok { + continue + } + + pem, err := ioutil.ReadFile(filepath.Join(path, cert.Name())) + if err != nil { + continue + } + + if certPool.AppendCertsFromPEM(pem) { + loadedCerts++ + } + } + if loadedCerts == 0 { + return nil, errors.New("no certificates were able to be successfully loaded") + } + return certPool, nil +} + +func validateAuroraURL(location string) (string, error) { + + // If no protocol defined, assume http + if !strings.Contains(location, "://") { + location = "http://" + location + } + + u, err := url.Parse(location) + + if err != nil { + return "", errors.Wrap(err, "error parsing url") + } + + // If no path provided assume /api + if u.Path == "" { + u.Path = "/api" + } + + // If no port provided, assume default 8081 + if u.Port() == "" { + u.Host = u.Host + ":8081" + } + + if !(u.Scheme == "http" || u.Scheme == "https") { + return "", errors.Errorf("only protocols http and https are supported %v\n", u.Scheme) + } + + // This could theoretically be elsewhere but we'll be strict for the sake of simplicity + if u.Path != apiPath { + return "", errors.Errorf("expected /api path %v\n", u.Path) + } + + return u.String(), nil +} + +func calculateCurrentBatch(updatingInstances int32, batchSizes []int32) int { + for i, size := range batchSizes { + updatingInstances -= size + if updatingInstances <= 0 { + return i + } + } + + // Overflow batches + batchCount := len(batchSizes) - 1 + lastBatchIndex := len(batchSizes) - 1 + batchCount += int(updatingInstances / batchSizes[lastBatchIndex]) + + if updatingInstances%batchSizes[lastBatchIndex] != 0 { + batchCount++ + } + return batchCount +} diff --git a/util_test.go b/util_test.go new file mode 100644 index 0000000..2906c42 --- /dev/null +++ b/util_test.go @@ -0,0 +1,114 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package realis + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestAuroraURLValidator(t *testing.T) { + t.Run("badURL", func(t *testing.T) { + url, err := validateAuroraURL("http://badurl.com/badpath") + assert.Empty(t, url) + assert.Error(t, err) + }) + + t.Run("URLHttp", func(t *testing.T) { + url, err := validateAuroraURL("http://goodurl.com:8081/api") + assert.Equal(t, "http://goodurl.com:8081/api", url) + assert.NoError(t, err) + }) + + t.Run("URLHttps", func(t *testing.T) { + url, err := validateAuroraURL("https://goodurl.com:8081/api") + assert.Equal(t, "https://goodurl.com:8081/api", url) + assert.NoError(t, err) + }) + + t.Run("URLNoPath", func(t *testing.T) { + url, err := validateAuroraURL("http://goodurl.com:8081") + assert.Equal(t, "http://goodurl.com:8081/api", url) + assert.NoError(t, err) + }) + + t.Run("ipAddrNoPath", func(t *testing.T) { + url, err := validateAuroraURL("http://192.168.1.33:8081") + assert.Equal(t, "http://192.168.1.33:8081/api", url) + assert.NoError(t, err) + }) + + t.Run("URLNoProtocol", func(t *testing.T) { + url, err := validateAuroraURL("goodurl.com:8081/api") + assert.Equal(t, "http://goodurl.com:8081/api", url) + assert.NoError(t, err) + }) + + t.Run("URLNoProtocolNoPathNoPort", func(t *testing.T) { + url, err := validateAuroraURL("goodurl.com") + assert.Equal(t, "http://goodurl.com:8081/api", url) + assert.NoError(t, err) + }) +} + +func TestCurrentBatchCalculator(t *testing.T) { + t.Run("singleBatchOverflow", func(t *testing.T) { + curBatch := calculateCurrentBatch(10, []int32{2}) + assert.Equal(t, 4, curBatch) + }) + + t.Run("noInstancesUpdating", func(t *testing.T) { + curBatch := calculateCurrentBatch(0, []int32{2}) + assert.Equal(t, 0, curBatch) + }) + + t.Run("evenMatchSingleBatch", func(t *testing.T) { + curBatch := calculateCurrentBatch(2, []int32{2}) + assert.Equal(t, 0, curBatch) + }) + + t.Run("moreInstancesThanBatches", func(t *testing.T) { + curBatch := calculateCurrentBatch(5, []int32{1, 2}) + assert.Equal(t, 2, curBatch) + }) + + t.Run("moreInstancesThanBatchesDecreasing", func(t *testing.T) { + curBatch := calculateCurrentBatch(5, []int32{2, 1}) + assert.Equal(t, 3, curBatch) + }) + + t.Run("unevenFit", func(t *testing.T) { + curBatch := calculateCurrentBatch(2, []int32{1, 2}) + assert.Equal(t, 1, curBatch) + }) + + t.Run("halfWay", func(t *testing.T) { + curBatch := calculateCurrentBatch(1, []int32{1, 2}) + assert.Equal(t, 0, curBatch) + }) +} + +func TestCertPoolCreator(t *testing.T) { + extensions := map[string]struct{}{".crt": {}} + + _, err := createCertPool("examples/certs", extensions) + assert.NoError(t, err) + + t.Run("badDir", func(t *testing.T) { + _, err := createCertPool("idontexist", extensions) + assert.Error(t, err) + }) +} diff --git a/vendor/git.apache.org/thrift.git/LICENSE b/vendor/git.apache.org/thrift.git/LICENSE deleted file mode 100644 index 3b6d7d7..0000000 --- a/vendor/git.apache.org/thrift.git/LICENSE +++ /dev/null @@ -1,239 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - --------------------------------------------------- -SOFTWARE DISTRIBUTED WITH THRIFT: - -The Apache Thrift software includes a number of subcomponents with -separate copyright notices and license terms. Your use of the source -code for the these subcomponents is subject to the terms and -conditions of the following licenses. - --------------------------------------------------- -Portions of the following files are licensed under the MIT License: - - lib/erl/src/Makefile.am - -Please see doc/otp-base-license.txt for the full terms of this license. - --------------------------------------------------- -For the aclocal/ax_boost_base.m4 and contrib/fb303/aclocal/ax_boost_base.m4 components: - -# Copyright (c) 2007 Thomas Porschberg -# -# Copying and distribution of this file, with or without -# modification, are permitted in any medium without royalty provided -# the copyright notice and this notice are preserved. - --------------------------------------------------- -For the lib/nodejs/lib/thrift/json_parse.js: - -/* - json_parse.js - 2015-05-02 - Public Domain. - NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK. - -*/ -(By Douglas Crockford ) --------------------------------------------------- diff --git a/vendor/git.apache.org/thrift.git/NOTICE b/vendor/git.apache.org/thrift.git/NOTICE deleted file mode 100644 index c23995a..0000000 --- a/vendor/git.apache.org/thrift.git/NOTICE +++ /dev/null @@ -1,5 +0,0 @@ -Apache Thrift -Copyright 2006-2010 The Apache Software Foundation. - -This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). \ No newline at end of file diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/application_exception.go b/vendor/github.com/apache/thrift/lib/go/thrift/application_exception.go similarity index 74% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/application_exception.go rename to vendor/github.com/apache/thrift/lib/go/thrift/application_exception.go index 6655cc5..b9d7eed 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/application_exception.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/application_exception.go @@ -30,11 +30,22 @@ const ( PROTOCOL_ERROR = 7 ) +var defaultApplicationExceptionMessage = map[int32]string{ + UNKNOWN_APPLICATION_EXCEPTION: "unknown application exception", + UNKNOWN_METHOD: "unknown method", + INVALID_MESSAGE_TYPE_EXCEPTION: "invalid message type", + WRONG_METHOD_NAME: "wrong method name", + BAD_SEQUENCE_ID: "bad sequence ID", + MISSING_RESULT: "missing result", + INTERNAL_ERROR: "unknown internal error", + PROTOCOL_ERROR: "unknown protocol error", +} + // Application level Thrift exception type TApplicationException interface { TException TypeId() int32 - Read(iprot TProtocol) (TApplicationException, error) + Read(iprot TProtocol) error Write(oprot TProtocol) error } @@ -44,7 +55,10 @@ type tApplicationException struct { } func (e tApplicationException) Error() string { - return e.message + if e.message != "" { + return e.message + } + return defaultApplicationExceptionMessage[e.type_] } func NewTApplicationException(type_ int32, message string) TApplicationException { @@ -55,10 +69,11 @@ func (p *tApplicationException) TypeId() int32 { return p.type_ } -func (p *tApplicationException) Read(iprot TProtocol) (TApplicationException, error) { +func (p *tApplicationException) Read(iprot TProtocol) error { + // TODO: this should really be generated by the compiler _, err := iprot.ReadStructBegin() if err != nil { - return nil, err + return err } message := "" @@ -67,7 +82,7 @@ func (p *tApplicationException) Read(iprot TProtocol) (TApplicationException, er for { _, ttype, id, err := iprot.ReadFieldBegin() if err != nil { - return nil, err + return err } if ttype == STOP { break @@ -76,33 +91,40 @@ func (p *tApplicationException) Read(iprot TProtocol) (TApplicationException, er case 1: if ttype == STRING { if message, err = iprot.ReadString(); err != nil { - return nil, err + return err } } else { if err = SkipDefaultDepth(iprot, ttype); err != nil { - return nil, err + return err } } case 2: if ttype == I32 { if type_, err = iprot.ReadI32(); err != nil { - return nil, err + return err } } else { if err = SkipDefaultDepth(iprot, ttype); err != nil { - return nil, err + return err } } default: if err = SkipDefaultDepth(iprot, ttype); err != nil { - return nil, err + return err } } if err = iprot.ReadFieldEnd(); err != nil { - return nil, err + return err } } - return NewTApplicationException(type_, message), iprot.ReadStructEnd() + if err := iprot.ReadStructEnd(); err != nil { + return err + } + + p.message = message + p.type_ = type_ + + return nil } func (p *tApplicationException) Write(oprot TProtocol) (err error) { diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/application_exception_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/application_exception_test.go new file mode 100644 index 0000000..7743357 --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/application_exception_test.go @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "testing" +) + +func TestTApplicationException(t *testing.T) { + exc := NewTApplicationException(UNKNOWN_APPLICATION_EXCEPTION, "") + if exc.Error() != defaultApplicationExceptionMessage[UNKNOWN_APPLICATION_EXCEPTION] { + t.Fatalf("Expected empty string for exception but found '%s'", exc.Error()) + } + if exc.TypeId() != UNKNOWN_APPLICATION_EXCEPTION { + t.Fatalf("Expected type UNKNOWN for exception but found '%v'", exc.TypeId()) + } + exc = NewTApplicationException(WRONG_METHOD_NAME, "junk_method") + if exc.Error() != "junk_method" { + t.Fatalf("Expected 'junk_method' for exception but found '%s'", exc.Error()) + } + if exc.TypeId() != WRONG_METHOD_NAME { + t.Fatalf("Expected type WRONG_METHOD_NAME for exception but found '%v'", exc.TypeId()) + } +} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/binary_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol.go similarity index 97% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/binary_protocol.go rename to vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol.go index 690d341..1f90bf4 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/binary_protocol.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol.go @@ -21,6 +21,7 @@ package thrift import ( "bytes" + "context" "encoding/binary" "errors" "fmt" @@ -447,9 +448,6 @@ func (p *TBinaryProtocol) ReadBinary() ([]byte, error) { if size < 0 { return nil, invalidDataLength } - if uint64(size) > p.trans.RemainingBytes() { - return nil, invalidDataLength - } isize := int(size) buf := make([]byte, isize) @@ -457,8 +455,8 @@ func (p *TBinaryProtocol) ReadBinary() ([]byte, error) { return buf, NewTProtocolException(err) } -func (p *TBinaryProtocol) Flush() (err error) { - return NewTProtocolException(p.trans.Flush()) +func (p *TBinaryProtocol) Flush(ctx context.Context) (err error) { + return NewTProtocolException(p.trans.Flush(ctx)) } func (p *TBinaryProtocol) Skip(fieldType TType) (err error) { @@ -480,9 +478,6 @@ func (p *TBinaryProtocol) readStringBody(size int32) (value string, err error) { if size < 0 { return "", nil } - if uint64(size) > p.trans.RemainingBytes() { - return "", invalidDataLength - } var ( buf bytes.Buffer diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol_test.go new file mode 100644 index 0000000..0462cc7 --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/binary_protocol_test.go @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "testing" +) + +func TestReadWriteBinaryProtocol(t *testing.T) { + ReadWriteProtocolTest(t, NewTBinaryProtocolFactoryDefault()) +} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/buffered_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport.go similarity index 92% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/buffered_transport.go rename to vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport.go index f73a98b..9670206 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/buffered_transport.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport.go @@ -21,6 +21,7 @@ package thrift import ( "bufio" + "context" ) type TBufferedTransportFactory struct { @@ -32,8 +33,8 @@ type TBufferedTransport struct { tp TTransport } -func (p *TBufferedTransportFactory) GetTransport(trans TTransport) TTransport { - return NewTBufferedTransport(trans, p.size) +func (p *TBufferedTransportFactory) GetTransport(trans TTransport) (TTransport, error) { + return NewTBufferedTransport(trans, p.size), nil } func NewTBufferedTransportFactory(bufferSize int) *TBufferedTransportFactory { @@ -78,12 +79,12 @@ func (p *TBufferedTransport) Write(b []byte) (int, error) { return n, err } -func (p *TBufferedTransport) Flush() error { +func (p *TBufferedTransport) Flush(ctx context.Context) error { if err := p.ReadWriter.Flush(); err != nil { p.ReadWriter.Writer.Reset(p.tp) return err } - return p.tp.Flush() + return p.tp.Flush(ctx) } func (p *TBufferedTransport) RemainingBytes() (num_bytes uint64) { diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport_test.go new file mode 100644 index 0000000..95ec0cb --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/buffered_transport_test.go @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "testing" +) + +func TestBufferedTransport(t *testing.T) { + trans := NewTBufferedTransport(NewTMemoryBuffer(), 10240) + TransportTest(t, trans, trans) +} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/client.go b/vendor/github.com/apache/thrift/lib/go/thrift/client.go new file mode 100644 index 0000000..28791cc --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/client.go @@ -0,0 +1,85 @@ +package thrift + +import ( + "context" + "fmt" +) + +type TClient interface { + Call(ctx context.Context, method string, args, result TStruct) error +} + +type TStandardClient struct { + seqId int32 + iprot, oprot TProtocol +} + +// TStandardClient implements TClient, and uses the standard message format for Thrift. +// It is not safe for concurrent use. +func NewTStandardClient(inputProtocol, outputProtocol TProtocol) *TStandardClient { + return &TStandardClient{ + iprot: inputProtocol, + oprot: outputProtocol, + } +} + +func (p *TStandardClient) Send(ctx context.Context, oprot TProtocol, seqId int32, method string, args TStruct) error { + if err := oprot.WriteMessageBegin(method, CALL, seqId); err != nil { + return err + } + if err := args.Write(oprot); err != nil { + return err + } + if err := oprot.WriteMessageEnd(); err != nil { + return err + } + return oprot.Flush(ctx) +} + +func (p *TStandardClient) Recv(iprot TProtocol, seqId int32, method string, result TStruct) error { + rMethod, rTypeId, rSeqId, err := iprot.ReadMessageBegin() + if err != nil { + return err + } + + if method != rMethod { + return NewTApplicationException(WRONG_METHOD_NAME, fmt.Sprintf("%s: wrong method name", method)) + } else if seqId != rSeqId { + return NewTApplicationException(BAD_SEQUENCE_ID, fmt.Sprintf("%s: out of order sequence response", method)) + } else if rTypeId == EXCEPTION { + var exception tApplicationException + if err := exception.Read(iprot); err != nil { + return err + } + + if err := iprot.ReadMessageEnd(); err != nil { + return err + } + + return &exception + } else if rTypeId != REPLY { + return NewTApplicationException(INVALID_MESSAGE_TYPE_EXCEPTION, fmt.Sprintf("%s: invalid message type", method)) + } + + if err := result.Read(iprot); err != nil { + return err + } + + return iprot.ReadMessageEnd() +} + +func (p *TStandardClient) Call(ctx context.Context, method string, args, result TStruct) error { + p.seqId++ + seqId := p.seqId + + if err := p.Send(ctx, p.oprot, seqId, method, args); err != nil { + return err + } + + // method is oneway + if result == nil { + return nil + } + + return p.Recv(p.iprot, seqId, method, result) +} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/processor.go b/vendor/github.com/apache/thrift/lib/go/thrift/common_test.go similarity index 74% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/processor.go rename to vendor/github.com/apache/thrift/lib/go/thrift/common_test.go index ca0d3fa..93597ff 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/processor.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/common_test.go @@ -19,12 +19,12 @@ package thrift -// A processor is a generic object which operates upon an input stream and -// writes to some output stream. -type TProcessor interface { - Process(in, out TProtocol) (bool, TException) +import "context" + +type mockProcessor struct { + ProcessFunc func(in, out TProtocol) (bool, TException) } -type TProcessorFunction interface { - Process(seqId int32, in, out TProtocol) (bool, TException) +func (m *mockProcessor) Process(ctx context.Context, in, out TProtocol) (bool, TException) { + return m.ProcessFunc(in, out) } diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/compact_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol.go similarity index 98% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/compact_protocol.go rename to vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol.go index 0bc5fdd..1900d50 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/compact_protocol.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol.go @@ -20,6 +20,7 @@ package thrift import ( + "context" "encoding/binary" "fmt" "io" @@ -561,9 +562,6 @@ func (p *TCompactProtocol) ReadString() (value string, err error) { if length < 0 { return "", invalidDataLength } - if uint64(length) > p.trans.RemainingBytes() { - return "", invalidDataLength - } if length == 0 { return "", nil @@ -590,17 +588,14 @@ func (p *TCompactProtocol) ReadBinary() (value []byte, err error) { if length < 0 { return nil, invalidDataLength } - if uint64(length) > p.trans.RemainingBytes() { - return nil, invalidDataLength - } buf := make([]byte, length) _, e = io.ReadFull(p.trans, buf) return buf, NewTProtocolException(e) } -func (p *TCompactProtocol) Flush() (err error) { - return NewTProtocolException(p.trans.Flush()) +func (p *TCompactProtocol) Flush(ctx context.Context) (err error) { + return NewTProtocolException(p.trans.Flush(ctx)) } func (p *TCompactProtocol) Skip(fieldType TType) (err error) { @@ -806,7 +801,7 @@ func (p *TCompactProtocol) getTType(t tCompactType) (TType, error) { case COMPACT_STRUCT: return STRUCT, nil } - return STOP, TException(fmt.Errorf("don't know what type: %s", t&0x0f)) + return STOP, TException(fmt.Errorf("don't know what type: %v", t&0x0f)) } // Given a TType value, find the appropriate TCompactProtocol.Types constant. diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol_test.go new file mode 100644 index 0000000..65f77f2 --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/compact_protocol_test.go @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "bytes" + "testing" +) + +func TestReadWriteCompactProtocol(t *testing.T) { + ReadWriteProtocolTest(t, NewTCompactProtocolFactory()) + + transports := []TTransport{ + NewTMemoryBuffer(), + NewStreamTransportRW(bytes.NewBuffer(make([]byte, 0, 16384))), + NewTFramedTransport(NewTMemoryBuffer()), + } + + zlib0, _ := NewTZlibTransport(NewTMemoryBuffer(), 0) + zlib6, _ := NewTZlibTransport(NewTMemoryBuffer(), 6) + zlib9, _ := NewTZlibTransport(NewTFramedTransport(NewTMemoryBuffer()), 9) + transports = append(transports, zlib0, zlib6, zlib9) + + for _, trans := range transports { + p := NewTCompactProtocol(trans) + ReadWriteBool(t, p, trans) + p = NewTCompactProtocol(trans) + ReadWriteByte(t, p, trans) + p = NewTCompactProtocol(trans) + ReadWriteI16(t, p, trans) + p = NewTCompactProtocol(trans) + ReadWriteI32(t, p, trans) + p = NewTCompactProtocol(trans) + ReadWriteI64(t, p, trans) + p = NewTCompactProtocol(trans) + ReadWriteDouble(t, p, trans) + p = NewTCompactProtocol(trans) + ReadWriteString(t, p, trans) + p = NewTCompactProtocol(trans) + ReadWriteBinary(t, p, trans) + trans.Close() + } +} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/context.go b/vendor/github.com/apache/thrift/lib/go/thrift/context.go new file mode 100644 index 0000000..d15c1bc --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/context.go @@ -0,0 +1,24 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import "context" + +var defaultCtx = context.Background() diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/debug_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/debug_protocol.go similarity index 98% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/debug_protocol.go rename to vendor/github.com/apache/thrift/lib/go/thrift/debug_protocol.go index d37252c..57943e0 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/debug_protocol.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/debug_protocol.go @@ -20,6 +20,7 @@ package thrift import ( + "context" "log" ) @@ -258,8 +259,8 @@ func (tdp *TDebugProtocol) Skip(fieldType TType) (err error) { log.Printf("%sSkip(fieldType=%#v) (err=%#v)", tdp.LogPrefix, fieldType, err) return } -func (tdp *TDebugProtocol) Flush() (err error) { - err = tdp.Delegate.Flush() +func (tdp *TDebugProtocol) Flush(ctx context.Context) (err error) { + err = tdp.Delegate.Flush(ctx) log.Printf("%sFlush() (err=%#v)", tdp.LogPrefix, err) return } diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/deserializer.go b/vendor/github.com/apache/thrift/lib/go/thrift/deserializer.go similarity index 100% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/deserializer.go rename to vendor/github.com/apache/thrift/lib/go/thrift/deserializer.go diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/exception.go b/vendor/github.com/apache/thrift/lib/go/thrift/exception.go similarity index 100% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/exception.go rename to vendor/github.com/apache/thrift/lib/go/thrift/exception.go diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/exception_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/exception_test.go new file mode 100644 index 0000000..71f5e2c --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/exception_test.go @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "errors" + "testing" +) + +func TestPrependError(t *testing.T) { + err := NewTApplicationException(INTERNAL_ERROR, "original error") + err2, ok := PrependError("Prepend: ", err).(TApplicationException) + if !ok { + t.Fatal("Couldn't cast error TApplicationException") + } + if err2.Error() != "Prepend: original error" { + t.Fatal("Unexpected error string") + } + if err2.TypeId() != INTERNAL_ERROR { + t.Fatal("Unexpected type error") + } + + err3 := NewTProtocolExceptionWithType(INVALID_DATA, errors.New("original error")) + err4, ok := PrependError("Prepend: ", err3).(TProtocolException) + if !ok { + t.Fatal("Couldn't cast error TProtocolException") + } + if err4.Error() != "Prepend: original error" { + t.Fatal("Unexpected error string") + } + if err4.TypeId() != INVALID_DATA { + t.Fatal("Unexpected type error") + } + + err5 := NewTTransportException(TIMED_OUT, "original error") + err6, ok := PrependError("Prepend: ", err5).(TTransportException) + if !ok { + t.Fatal("Couldn't cast error TTransportException") + } + if err6.Error() != "Prepend: original error" { + t.Fatal("Unexpected error string") + } + if err6.TypeId() != TIMED_OUT { + t.Fatal("Unexpected type error") + } + + err7 := errors.New("original error") + err8 := PrependError("Prepend: ", err7) + if err8.Error() != "Prepend: original error" { + t.Fatal("Unexpected error string") + } +} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/field.go b/vendor/github.com/apache/thrift/lib/go/thrift/field.go similarity index 100% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/field.go rename to vendor/github.com/apache/thrift/lib/go/thrift/field.go diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/framed_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport.go similarity index 93% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/framed_transport.go rename to vendor/github.com/apache/thrift/lib/go/thrift/framed_transport.go index c8bb887..81fa65a 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/framed_transport.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport.go @@ -22,6 +22,7 @@ package thrift import ( "bufio" "bytes" + "context" "encoding/binary" "fmt" "io" @@ -51,8 +52,12 @@ func NewTFramedTransportFactoryMaxLength(factory TTransportFactory, maxLength ui return &tFramedTransportFactory{factory: factory, maxLength: maxLength} } -func (p *tFramedTransportFactory) GetTransport(base TTransport) TTransport { - return NewTFramedTransportMaxLength(p.factory.GetTransport(base), p.maxLength) +func (p *tFramedTransportFactory) GetTransport(base TTransport) (TTransport, error) { + tt, err := p.factory.GetTransport(base) + if err != nil { + return nil, err + } + return NewTFramedTransportMaxLength(tt, p.maxLength), nil } func NewTFramedTransport(transport TTransport) *TFramedTransport { @@ -131,21 +136,23 @@ func (p *TFramedTransport) WriteString(s string) (n int, err error) { return p.buf.WriteString(s) } -func (p *TFramedTransport) Flush() error { +func (p *TFramedTransport) Flush(ctx context.Context) error { size := p.buf.Len() buf := p.buffer[:4] binary.BigEndian.PutUint32(buf, uint32(size)) _, err := p.transport.Write(buf) if err != nil { + p.buf.Truncate(0) return NewTTransportExceptionFromError(err) } if size > 0 { if n, err := p.buf.WriteTo(p.transport); err != nil { print("Error while flushing write buffer of size ", size, " to transport, only wrote ", n, " bytes: ", err.Error(), "\n") + p.buf.Truncate(0) return NewTTransportExceptionFromError(err) } } - err = p.transport.Flush() + err = p.transport.Flush(ctx) return NewTTransportExceptionFromError(err) } diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport_test.go new file mode 100644 index 0000000..8f683ef --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/framed_transport_test.go @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "testing" +) + +func TestFramedTransport(t *testing.T) { + trans := NewTFramedTransport(NewTMemoryBuffer()) + TransportTest(t, trans, trans) +} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/http_client.go b/vendor/github.com/apache/thrift/lib/go/thrift/http_client.go similarity index 84% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/http_client.go rename to vendor/github.com/apache/thrift/lib/go/thrift/http_client.go index 88eb2c1..5c82bf5 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/http_client.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/http_client.go @@ -21,6 +21,7 @@ package thrift import ( "bytes" + "context" "io" "io/ioutil" "net/http" @@ -46,27 +47,16 @@ type THttpClient struct { type THttpClientTransportFactory struct { options THttpClientOptions url string - isPost bool } -func (p *THttpClientTransportFactory) GetTransport(trans TTransport) TTransport { +func (p *THttpClientTransportFactory) GetTransport(trans TTransport) (TTransport, error) { if trans != nil { t, ok := trans.(*THttpClient) if ok && t.url != nil { - if t.requestBuffer != nil { - t2, _ := NewTHttpPostClientWithOptions(t.url.String(), p.options) - return t2 - } - t2, _ := NewTHttpClientWithOptions(t.url.String(), p.options) - return t2 + return NewTHttpClientWithOptions(t.url.String(), p.options) } } - if p.isPost { - s, _ := NewTHttpPostClientWithOptions(p.url, p.options) - return s - } - s, _ := NewTHttpClientWithOptions(p.url, p.options) - return s + return NewTHttpClientWithOptions(p.url, p.options) } type THttpClientOptions struct { @@ -79,39 +69,10 @@ func NewTHttpClientTransportFactory(url string) *THttpClientTransportFactory { } func NewTHttpClientTransportFactoryWithOptions(url string, options THttpClientOptions) *THttpClientTransportFactory { - return &THttpClientTransportFactory{url: url, isPost: false, options: options} -} - -func NewTHttpPostClientTransportFactory(url string) *THttpClientTransportFactory { - return NewTHttpPostClientTransportFactoryWithOptions(url, THttpClientOptions{}) -} - -func NewTHttpPostClientTransportFactoryWithOptions(url string, options THttpClientOptions) *THttpClientTransportFactory { - return &THttpClientTransportFactory{url: url, isPost: true, options: options} + return &THttpClientTransportFactory{url: url, options: options} } func NewTHttpClientWithOptions(urlstr string, options THttpClientOptions) (TTransport, error) { - parsedURL, err := url.Parse(urlstr) - if err != nil { - return nil, err - } - response, err := http.Get(urlstr) - if err != nil { - return nil, err - } - client := options.Client - if client == nil { - client = DefaultHttpClient - } - httpHeader := map[string][]string{"Content-Type": []string{"application/x-thrift"}} - return &THttpClient{client: client, response: response, url: parsedURL, header: httpHeader}, nil -} - -func NewTHttpClient(urlstr string) (TTransport, error) { - return NewTHttpClientWithOptions(urlstr, THttpClientOptions{}) -} - -func NewTHttpPostClientWithOptions(urlstr string, options THttpClientOptions) (TTransport, error) { parsedURL, err := url.Parse(urlstr) if err != nil { return nil, err @@ -121,12 +82,12 @@ func NewTHttpPostClientWithOptions(urlstr string, options THttpClientOptions) (T if client == nil { client = DefaultHttpClient } - httpHeader := map[string][]string{"Content-Type": []string{"application/x-thrift"}} + httpHeader := map[string][]string{"Content-Type": {"application/x-thrift"}} return &THttpClient{client: client, url: parsedURL, requestBuffer: bytes.NewBuffer(buf), header: httpHeader}, nil } -func NewTHttpPostClient(urlstr string) (TTransport, error) { - return NewTHttpPostClientWithOptions(urlstr, THttpClientOptions{}) +func NewTHttpClient(urlstr string) (TTransport, error) { + return NewTHttpClientWithOptions(urlstr, THttpClientOptions{}) } // Set the HTTP Header for this specific Thrift Transport @@ -221,7 +182,7 @@ func (p *THttpClient) WriteString(s string) (n int, err error) { return p.requestBuffer.WriteString(s) } -func (p *THttpClient) Flush() error { +func (p *THttpClient) Flush(ctx context.Context) error { // Close any previous response body to avoid leaking connections. p.closeResponse() @@ -230,6 +191,9 @@ func (p *THttpClient) Flush() error { return NewTTransportExceptionFromError(err) } req.Header = p.header + if ctx != nil { + req = req.WithContext(ctx) + } response, err := p.client.Do(req) if err != nil { return NewTTransportExceptionFromError(err) @@ -256,3 +220,23 @@ func (p *THttpClient) RemainingBytes() (num_bytes uint64) { const maxSize = ^uint64(0) return maxSize // the thruth is, we just don't know unless framed is used } + +// Deprecated: Use NewTHttpClientTransportFactory instead. +func NewTHttpPostClientTransportFactory(url string) *THttpClientTransportFactory { + return NewTHttpClientTransportFactoryWithOptions(url, THttpClientOptions{}) +} + +// Deprecated: Use NewTHttpClientTransportFactoryWithOptions instead. +func NewTHttpPostClientTransportFactoryWithOptions(url string, options THttpClientOptions) *THttpClientTransportFactory { + return NewTHttpClientTransportFactoryWithOptions(url, options) +} + +// Deprecated: Use NewTHttpClientWithOptions instead. +func NewTHttpPostClientWithOptions(urlstr string, options THttpClientOptions) (TTransport, error) { + return NewTHttpClientWithOptions(urlstr, options) +} + +// Deprecated: Use NewTHttpClient instead. +func NewTHttpPostClient(urlstr string) (TTransport, error) { + return NewTHttpClientWithOptions(urlstr, THttpClientOptions{}) +} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/http_client_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/http_client_test.go new file mode 100644 index 0000000..453680a --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/http_client_test.go @@ -0,0 +1,106 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "net/http" + "testing" +) + +func TestHttpClient(t *testing.T) { + l, addr := HttpClientSetupForTest(t) + if l != nil { + defer l.Close() + } + trans, err := NewTHttpPostClient("http://" + addr.String()) + if err != nil { + l.Close() + t.Fatalf("Unable to connect to %s: %s", addr.String(), err) + } + TransportTest(t, trans, trans) +} + +func TestHttpClientHeaders(t *testing.T) { + l, addr := HttpClientSetupForTest(t) + if l != nil { + defer l.Close() + } + trans, err := NewTHttpPostClient("http://" + addr.String()) + if err != nil { + l.Close() + t.Fatalf("Unable to connect to %s: %s", addr.String(), err) + } + TransportHeaderTest(t, trans, trans) +} + +func TestHttpCustomClient(t *testing.T) { + l, addr := HttpClientSetupForTest(t) + if l != nil { + defer l.Close() + } + + httpTransport := &customHttpTransport{} + + trans, err := NewTHttpPostClientWithOptions("http://"+addr.String(), THttpClientOptions{ + Client: &http.Client{ + Transport: httpTransport, + }, + }) + if err != nil { + l.Close() + t.Fatalf("Unable to connect to %s: %s", addr.String(), err) + } + TransportHeaderTest(t, trans, trans) + + if !httpTransport.hit { + t.Fatalf("Custom client was not used") + } +} + +func TestHttpCustomClientPackageScope(t *testing.T) { + l, addr := HttpClientSetupForTest(t) + if l != nil { + defer l.Close() + } + httpTransport := &customHttpTransport{} + DefaultHttpClient = &http.Client{ + Transport: httpTransport, + } + + trans, err := NewTHttpPostClient("http://" + addr.String()) + if err != nil { + l.Close() + t.Fatalf("Unable to connect to %s: %s", addr.String(), err) + } + TransportHeaderTest(t, trans, trans) + + if !httpTransport.hit { + t.Fatalf("Custom client was not used") + } +} + +type customHttpTransport struct { + hit bool +} + +func (c *customHttpTransport) RoundTrip(req *http.Request) (*http.Response, error) { + c.hit = true + return http.DefaultTransport.RoundTrip(req) +} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/http_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/http_transport.go new file mode 100644 index 0000000..66f0f38 --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/http_transport.go @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "compress/gzip" + "io" + "net/http" + "strings" +) + +// NewThriftHandlerFunc is a function that create a ready to use Apache Thrift Handler function +func NewThriftHandlerFunc(processor TProcessor, + inPfactory, outPfactory TProtocolFactory) func(w http.ResponseWriter, r *http.Request) { + + return gz(func(w http.ResponseWriter, r *http.Request) { + w.Header().Add("Content-Type", "application/x-thrift") + + transport := NewStreamTransport(r.Body, w) + processor.Process(r.Context(), inPfactory.GetProtocol(transport), outPfactory.GetProtocol(transport)) + }) +} + +// gz transparently compresses the HTTP response if the client supports it. +func gz(handler http.HandlerFunc) http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + if !strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") { + handler(w, r) + return + } + w.Header().Set("Content-Encoding", "gzip") + gz := gzip.NewWriter(w) + defer gz.Close() + gzw := gzipResponseWriter{Writer: gz, ResponseWriter: w} + handler(gzw, r) + } +} + +type gzipResponseWriter struct { + io.Writer + http.ResponseWriter +} + +func (w gzipResponseWriter) Write(b []byte) (int, error) { + return w.Writer.Write(b) +} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/iostream_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport.go similarity index 89% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/iostream_transport.go rename to vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport.go index 70bede9..fea93bc 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/iostream_transport.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport.go @@ -21,6 +21,7 @@ package thrift import ( "bufio" + "context" "io" ) @@ -38,38 +39,38 @@ type StreamTransportFactory struct { isReadWriter bool } -func (p *StreamTransportFactory) GetTransport(trans TTransport) TTransport { +func (p *StreamTransportFactory) GetTransport(trans TTransport) (TTransport, error) { if trans != nil { t, ok := trans.(*StreamTransport) if ok { if t.isReadWriter { - return NewStreamTransportRW(t.Reader.(io.ReadWriter)) + return NewStreamTransportRW(t.Reader.(io.ReadWriter)), nil } if t.Reader != nil && t.Writer != nil { - return NewStreamTransport(t.Reader, t.Writer) + return NewStreamTransport(t.Reader, t.Writer), nil } if t.Reader != nil && t.Writer == nil { - return NewStreamTransportR(t.Reader) + return NewStreamTransportR(t.Reader), nil } if t.Reader == nil && t.Writer != nil { - return NewStreamTransportW(t.Writer) + return NewStreamTransportW(t.Writer), nil } - return &StreamTransport{} + return &StreamTransport{}, nil } } if p.isReadWriter { - return NewStreamTransportRW(p.Reader.(io.ReadWriter)) + return NewStreamTransportRW(p.Reader.(io.ReadWriter)), nil } if p.Reader != nil && p.Writer != nil { - return NewStreamTransport(p.Reader, p.Writer) + return NewStreamTransport(p.Reader, p.Writer), nil } if p.Reader != nil && p.Writer == nil { - return NewStreamTransportR(p.Reader) + return NewStreamTransportR(p.Reader), nil } if p.Reader == nil && p.Writer != nil { - return NewStreamTransportW(p.Writer) + return NewStreamTransportW(p.Writer), nil } - return &StreamTransport{} + return &StreamTransport{}, nil } func NewStreamTransportFactory(reader io.Reader, writer io.Writer, isReadWriter bool) *StreamTransportFactory { @@ -138,7 +139,7 @@ func (p *StreamTransport) Close() error { } // Flushes the underlying output stream if not null. -func (p *StreamTransport) Flush() error { +func (p *StreamTransport) Flush(ctx context.Context) error { if p.Writer == nil { return NewTTransportException(NOT_OPEN, "Cannot flush null outputStream") } diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport_test.go new file mode 100644 index 0000000..15a6116 --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/iostream_transport_test.go @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "bytes" + "testing" +) + +func TestStreamTransport(t *testing.T) { + trans := NewStreamTransportRW(bytes.NewBuffer(make([]byte, 0, 1024))) + TransportTest(t, trans, trans) +} + +func TestStreamTransportOpenClose(t *testing.T) { + trans := NewStreamTransportRW(bytes.NewBuffer(make([]byte, 0, 1024))) + if !trans.IsOpen() { + t.Fatal("StreamTransport should be already open") + } + if trans.Open() == nil { + t.Fatal("StreamTransport should return error when open twice") + } + if trans.Close() != nil { + t.Fatal("StreamTransport should not return error when closing open transport") + } + if trans.IsOpen() { + t.Fatal("StreamTransport should not be open after close") + } + if trans.Close() == nil { + t.Fatal("StreamTransport should return error when closing a non open transport") + } + if trans.Open() == nil { + t.Fatal("StreamTransport should not be able to reopen") + } +} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/json_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol.go similarity index 99% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/json_protocol.go rename to vendor/github.com/apache/thrift/lib/go/thrift/json_protocol.go index 442fa91..7be685d 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/json_protocol.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol.go @@ -20,6 +20,7 @@ package thrift import ( + "context" "encoding/base64" "fmt" ) @@ -438,10 +439,10 @@ func (p *TJSONProtocol) ReadBinary() ([]byte, error) { return v, p.ParsePostValue() } -func (p *TJSONProtocol) Flush() (err error) { +func (p *TJSONProtocol) Flush(ctx context.Context) (err error) { err = p.writer.Flush() if err == nil { - err = p.trans.Flush() + err = p.trans.Flush(ctx) } return NewTProtocolException(err) } diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol_test.go new file mode 100644 index 0000000..59c4d64 --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/json_protocol_test.go @@ -0,0 +1,650 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "context" + "encoding/base64" + "encoding/json" + "fmt" + "math" + "strconv" + "testing" +) + +func TestWriteJSONProtocolBool(t *testing.T) { + thetype := "boolean" + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + for _, value := range BOOL_VALUES { + if e := p.WriteBool(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) + } + s := trans.String() + expected := "" + if value { + expected = "1" + } else { + expected = "0" + } + if s != expected { + t.Fatalf("Bad value for %s %v: %s expected", thetype, value, s) + } + v := -1 + if err := json.Unmarshal([]byte(s), &v); err != nil || (v != 0) != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + } + trans.Close() +} + +func TestReadJSONProtocolBool(t *testing.T) { + thetype := "boolean" + for _, value := range BOOL_VALUES { + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + if value { + trans.Write([]byte{'1'}) // not JSON_TRUE + } else { + trans.Write([]byte{'0'}) // not JSON_FALSE + } + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadBool() + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if v != value { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + vv := -1 + if err := json.Unmarshal([]byte(s), &vv); err != nil || (vv != 0) != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, vv) + } + trans.Reset() + trans.Close() + } +} + +func TestWriteJSONProtocolByte(t *testing.T) { + thetype := "byte" + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + for _, value := range BYTE_VALUES { + if e := p.WriteByte(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) + } + s := trans.String() + if s != fmt.Sprint(value) { + t.Fatalf("Bad value for %s %v: %s", thetype, value, s) + } + v := int8(0) + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + } + trans.Close() +} + +func TestReadJSONProtocolByte(t *testing.T) { + thetype := "byte" + for _, value := range BYTE_VALUES { + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + trans.WriteString(strconv.Itoa(int(value))) + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadByte() + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if v != value { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + trans.Close() + } +} + +func TestWriteJSONProtocolI16(t *testing.T) { + thetype := "int16" + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + for _, value := range INT16_VALUES { + if e := p.WriteI16(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) + } + s := trans.String() + if s != fmt.Sprint(value) { + t.Fatalf("Bad value for %s %v: %s", thetype, value, s) + } + v := int16(0) + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + } + trans.Close() +} + +func TestReadJSONProtocolI16(t *testing.T) { + thetype := "int16" + for _, value := range INT16_VALUES { + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + trans.WriteString(strconv.Itoa(int(value))) + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadI16() + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if v != value { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + trans.Close() + } +} + +func TestWriteJSONProtocolI32(t *testing.T) { + thetype := "int32" + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + for _, value := range INT32_VALUES { + if e := p.WriteI32(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) + } + s := trans.String() + if s != fmt.Sprint(value) { + t.Fatalf("Bad value for %s %v: %s", thetype, value, s) + } + v := int32(0) + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + } + trans.Close() +} + +func TestReadJSONProtocolI32(t *testing.T) { + thetype := "int32" + for _, value := range INT32_VALUES { + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + trans.WriteString(strconv.Itoa(int(value))) + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadI32() + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if v != value { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + trans.Close() + } +} + +func TestWriteJSONProtocolI64(t *testing.T) { + thetype := "int64" + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + for _, value := range INT64_VALUES { + if e := p.WriteI64(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) + } + s := trans.String() + if s != fmt.Sprint(value) { + t.Fatalf("Bad value for %s %v: %s", thetype, value, s) + } + v := int64(0) + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + } + trans.Close() +} + +func TestReadJSONProtocolI64(t *testing.T) { + thetype := "int64" + for _, value := range INT64_VALUES { + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + trans.WriteString(strconv.FormatInt(value, 10)) + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadI64() + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if v != value { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + trans.Close() + } +} + +func TestWriteJSONProtocolDouble(t *testing.T) { + thetype := "double" + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + for _, value := range DOUBLE_VALUES { + if e := p.WriteDouble(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) + } + s := trans.String() + if math.IsInf(value, 1) { + if s != jsonQuote(JSON_INFINITY) { + t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_INFINITY)) + } + } else if math.IsInf(value, -1) { + if s != jsonQuote(JSON_NEGATIVE_INFINITY) { + t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_NEGATIVE_INFINITY)) + } + } else if math.IsNaN(value) { + if s != jsonQuote(JSON_NAN) { + t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_NAN)) + } + } else { + if s != fmt.Sprint(value) { + t.Fatalf("Bad value for %s %v: %s", thetype, value, s) + } + v := float64(0) + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + } + trans.Reset() + } + trans.Close() +} + +func TestReadJSONProtocolDouble(t *testing.T) { + thetype := "double" + for _, value := range DOUBLE_VALUES { + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + n := NewNumericFromDouble(value) + trans.WriteString(n.String()) + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadDouble() + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if math.IsInf(value, 1) { + if !math.IsInf(v, 1) { + t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) + } + } else if math.IsInf(value, -1) { + if !math.IsInf(v, -1) { + t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) + } + } else if math.IsNaN(value) { + if !math.IsNaN(v) { + t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) + } + } else { + if v != value { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + } + trans.Reset() + trans.Close() + } +} + +func TestWriteJSONProtocolString(t *testing.T) { + thetype := "string" + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + for _, value := range STRING_VALUES { + if e := p.WriteString(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) + } + s := trans.String() + if s[0] != '"' || s[len(s)-1] != '"' { + t.Fatalf("Bad value for %s '%v', wrote '%v', expected: %v", thetype, value, s, fmt.Sprint("\"", value, "\"")) + } + v := new(string) + if err := json.Unmarshal([]byte(s), v); err != nil || *v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v) + } + trans.Reset() + } + trans.Close() +} + +func TestReadJSONProtocolString(t *testing.T) { + thetype := "string" + for _, value := range STRING_VALUES { + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + trans.WriteString(jsonQuote(value)) + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadString() + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if v != value { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + v1 := new(string) + if err := json.Unmarshal([]byte(s), v1); err != nil || *v1 != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v1) + } + trans.Reset() + trans.Close() + } +} + +func TestWriteJSONProtocolBinary(t *testing.T) { + thetype := "binary" + value := protocol_bdata + b64value := make([]byte, base64.StdEncoding.EncodedLen(len(protocol_bdata))) + base64.StdEncoding.Encode(b64value, value) + b64String := string(b64value) + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + if e := p.WriteBinary(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) + } + s := trans.String() + expectedString := fmt.Sprint("\"", b64String, "\"") + if s != expectedString { + t.Fatalf("Bad value for %s %v\n wrote: \"%v\"\nexpected: \"%v\"", thetype, value, s, expectedString) + } + v1, err := p.ReadBinary() + if err != nil { + t.Fatalf("Unable to read binary: %s", err.Error()) + } + if len(v1) != len(value) { + t.Fatalf("Invalid value for binary\nexpected: \"%v\"\n read: \"%v\"", value, v1) + } + for k, v := range value { + if v1[k] != v { + t.Fatalf("Invalid value for binary at %v\nexpected: \"%v\"\n read: \"%v\"", k, v, v1[k]) + } + } + trans.Close() +} + +func TestReadJSONProtocolBinary(t *testing.T) { + thetype := "binary" + value := protocol_bdata + b64value := make([]byte, base64.StdEncoding.EncodedLen(len(protocol_bdata))) + base64.StdEncoding.Encode(b64value, value) + b64String := string(b64value) + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + trans.WriteString(jsonQuote(b64String)) + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadBinary() + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if len(v) != len(value) { + t.Fatalf("Bad value for %s value length %v, wrote: %v, received length: %v", thetype, len(value), s, len(v)) + } + for i := 0; i < len(v); i++ { + if v[i] != value[i] { + t.Fatalf("Bad value for %s at index %d value %v, wrote: %v, received: %v", thetype, i, value[i], s, v[i]) + } + } + v1 := new(string) + if err := json.Unmarshal([]byte(s), v1); err != nil || *v1 != b64String { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v1) + } + trans.Reset() + trans.Close() +} + +func TestWriteJSONProtocolList(t *testing.T) { + thetype := "list" + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + p.WriteListBegin(TType(DOUBLE), len(DOUBLE_VALUES)) + for _, value := range DOUBLE_VALUES { + if e := p.WriteDouble(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + } + p.WriteListEnd() + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) + } + str := trans.String() + str1 := new([]interface{}) + err := json.Unmarshal([]byte(str), str1) + if err != nil { + t.Fatalf("Unable to decode %s, wrote: %s", thetype, str) + } + l := *str1 + if len(l) < 2 { + t.Fatalf("List must be at least of length two to include metadata") + } + if l[0] != "dbl" { + t.Fatal("Invalid type for list, expected: ", STRING, ", but was: ", l[0]) + } + if int(l[1].(float64)) != len(DOUBLE_VALUES) { + t.Fatal("Invalid length for list, expected: ", len(DOUBLE_VALUES), ", but was: ", l[1]) + } + for k, value := range DOUBLE_VALUES { + s := l[k+2] + if math.IsInf(value, 1) { + if s.(string) != JSON_INFINITY { + t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_INFINITY), str) + } + } else if math.IsInf(value, 0) { + if s.(string) != JSON_NEGATIVE_INFINITY { + t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY), str) + } + } else if math.IsNaN(value) { + if s.(string) != JSON_NAN { + t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NAN), str) + } + } else { + if s.(float64) != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s'", thetype, value, s) + } + } + trans.Reset() + } + trans.Close() +} + +func TestWriteJSONProtocolSet(t *testing.T) { + thetype := "set" + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + p.WriteSetBegin(TType(DOUBLE), len(DOUBLE_VALUES)) + for _, value := range DOUBLE_VALUES { + if e := p.WriteDouble(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + } + p.WriteSetEnd() + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) + } + str := trans.String() + str1 := new([]interface{}) + err := json.Unmarshal([]byte(str), str1) + if err != nil { + t.Fatalf("Unable to decode %s, wrote: %s", thetype, str) + } + l := *str1 + if len(l) < 2 { + t.Fatalf("Set must be at least of length two to include metadata") + } + if l[0] != "dbl" { + t.Fatal("Invalid type for set, expected: ", DOUBLE, ", but was: ", l[0]) + } + if int(l[1].(float64)) != len(DOUBLE_VALUES) { + t.Fatal("Invalid length for set, expected: ", len(DOUBLE_VALUES), ", but was: ", l[1]) + } + for k, value := range DOUBLE_VALUES { + s := l[k+2] + if math.IsInf(value, 1) { + if s.(string) != JSON_INFINITY { + t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_INFINITY), str) + } + } else if math.IsInf(value, 0) { + if s.(string) != JSON_NEGATIVE_INFINITY { + t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY), str) + } + } else if math.IsNaN(value) { + if s.(string) != JSON_NAN { + t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NAN), str) + } + } else { + if s.(float64) != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s'", thetype, value, s) + } + } + trans.Reset() + } + trans.Close() +} + +func TestWriteJSONProtocolMap(t *testing.T) { + thetype := "map" + trans := NewTMemoryBuffer() + p := NewTJSONProtocol(trans) + p.WriteMapBegin(TType(I32), TType(DOUBLE), len(DOUBLE_VALUES)) + for k, value := range DOUBLE_VALUES { + if e := p.WriteI32(int32(k)); e != nil { + t.Fatalf("Unable to write %s key int32 value %v due to error: %s", thetype, k, e.Error()) + } + if e := p.WriteDouble(value); e != nil { + t.Fatalf("Unable to write %s value float64 value %v due to error: %s", thetype, value, e.Error()) + } + } + p.WriteMapEnd() + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) + } + str := trans.String() + if str[0] != '[' || str[len(str)-1] != ']' { + t.Fatalf("Bad value for %s, wrote: %v, in go: %v", thetype, str, DOUBLE_VALUES) + } + expectedKeyType, expectedValueType, expectedSize, err := p.ReadMapBegin() + if err != nil { + t.Fatalf("Error while reading map begin: %s", err.Error()) + } + if expectedKeyType != I32 { + t.Fatal("Expected map key type ", I32, ", but was ", expectedKeyType) + } + if expectedValueType != DOUBLE { + t.Fatal("Expected map value type ", DOUBLE, ", but was ", expectedValueType) + } + if expectedSize != len(DOUBLE_VALUES) { + t.Fatal("Expected map size of ", len(DOUBLE_VALUES), ", but was ", expectedSize) + } + for k, value := range DOUBLE_VALUES { + ik, err := p.ReadI32() + if err != nil { + t.Fatalf("Bad key for %s index %v, wrote: %v, expected: %v, error: %s", thetype, k, ik, string(k), err.Error()) + } + if int(ik) != k { + t.Fatalf("Bad key for %s index %v, wrote: %v, expected: %v", thetype, k, ik, k) + } + dv, err := p.ReadDouble() + if err != nil { + t.Fatalf("Bad value for %s index %v, wrote: %v, expected: %v, error: %s", thetype, k, dv, value, err.Error()) + } + s := strconv.FormatFloat(dv, 'g', 10, 64) + if math.IsInf(value, 1) { + if !math.IsInf(dv, 1) { + t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_INFINITY)) + } + } else if math.IsInf(value, 0) { + if !math.IsInf(dv, 0) { + t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY)) + } + } else if math.IsNaN(value) { + if !math.IsNaN(dv) { + t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_NAN)) + } + } else { + expected := strconv.FormatFloat(value, 'g', 10, 64) + if s != expected { + t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected %v", thetype, k, value, s, expected) + } + v := float64(0) + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + } + } + err = p.ReadMapEnd() + if err != nil { + t.Fatalf("Error while reading map end: %s", err.Error()) + } + trans.Close() +} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/lowlevel_benchmarks_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/lowlevel_benchmarks_test.go new file mode 100644 index 0000000..e173655 --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/lowlevel_benchmarks_test.go @@ -0,0 +1,540 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "bytes" + "testing" +) + +var binaryProtoF = NewTBinaryProtocolFactoryDefault() +var compactProtoF = NewTCompactProtocolFactory() + +var buf = bytes.NewBuffer(make([]byte, 0, 1024)) + +var tfv = []TTransportFactory{ + NewTMemoryBufferTransportFactory(1024), + NewStreamTransportFactory(buf, buf, true), + NewTFramedTransportFactory(NewTMemoryBufferTransportFactory(1024)), +} + +func BenchmarkBinaryBool_0(b *testing.B) { + trans, err := tfv[0].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteBool(b, p, trans) + } +} + +func BenchmarkBinaryByte_0(b *testing.B) { + trans, err := tfv[0].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteByte(b, p, trans) + } +} + +func BenchmarkBinaryI16_0(b *testing.B) { + trans, err := tfv[0].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI16(b, p, trans) + } +} + +func BenchmarkBinaryI32_0(b *testing.B) { + trans, err := tfv[0].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI32(b, p, trans) + } +} +func BenchmarkBinaryI64_0(b *testing.B) { + trans, err := tfv[0].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI64(b, p, trans) + } +} +func BenchmarkBinaryDouble_0(b *testing.B) { + trans, err := tfv[0].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteDouble(b, p, trans) + } +} +func BenchmarkBinaryString_0(b *testing.B) { + trans, err := tfv[0].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteString(b, p, trans) + } +} +func BenchmarkBinaryBinary_0(b *testing.B) { + trans, err := tfv[0].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteBinary(b, p, trans) + } +} + +func BenchmarkBinaryBool_1(b *testing.B) { + trans, err := tfv[1].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteBool(b, p, trans) + } +} + +func BenchmarkBinaryByte_1(b *testing.B) { + trans, err := tfv[1].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteByte(b, p, trans) + } +} + +func BenchmarkBinaryI16_1(b *testing.B) { + trans, err := tfv[1].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI16(b, p, trans) + } +} + +func BenchmarkBinaryI32_1(b *testing.B) { + trans, err := tfv[1].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI32(b, p, trans) + } +} +func BenchmarkBinaryI64_1(b *testing.B) { + trans, err := tfv[1].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI64(b, p, trans) + } +} +func BenchmarkBinaryDouble_1(b *testing.B) { + trans, err := tfv[1].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteDouble(b, p, trans) + } +} +func BenchmarkBinaryString_1(b *testing.B) { + trans, err := tfv[1].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteString(b, p, trans) + } +} +func BenchmarkBinaryBinary_1(b *testing.B) { + trans, err := tfv[1].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteBinary(b, p, trans) + } +} + +func BenchmarkBinaryBool_2(b *testing.B) { + trans, err := tfv[2].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteBool(b, p, trans) + } +} + +func BenchmarkBinaryByte_2(b *testing.B) { + trans, err := tfv[2].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteByte(b, p, trans) + } +} + +func BenchmarkBinaryI16_2(b *testing.B) { + trans, err := tfv[2].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI16(b, p, trans) + } +} + +func BenchmarkBinaryI32_2(b *testing.B) { + trans, err := tfv[2].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI32(b, p, trans) + } +} +func BenchmarkBinaryI64_2(b *testing.B) { + trans, err := tfv[2].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI64(b, p, trans) + } +} +func BenchmarkBinaryDouble_2(b *testing.B) { + trans, err := tfv[2].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteDouble(b, p, trans) + } +} +func BenchmarkBinaryString_2(b *testing.B) { + trans, err := tfv[2].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteString(b, p, trans) + } +} +func BenchmarkBinaryBinary_2(b *testing.B) { + trans, err := tfv[2].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := binaryProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteBinary(b, p, trans) + } +} + +func BenchmarkCompactBool_0(b *testing.B) { + trans, err := tfv[0].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteBool(b, p, trans) + } +} + +func BenchmarkCompactByte_0(b *testing.B) { + trans, err := tfv[0].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteByte(b, p, trans) + } +} + +func BenchmarkCompactI16_0(b *testing.B) { + trans, err := tfv[0].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI16(b, p, trans) + } +} + +func BenchmarkCompactI32_0(b *testing.B) { + trans, err := tfv[0].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI32(b, p, trans) + } +} +func BenchmarkCompactI64_0(b *testing.B) { + trans, err := tfv[0].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI64(b, p, trans) + } +} +func BenchmarkCompactDouble0(b *testing.B) { + trans, err := tfv[0].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteDouble(b, p, trans) + } +} +func BenchmarkCompactString0(b *testing.B) { + trans, err := tfv[0].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteString(b, p, trans) + } +} +func BenchmarkCompactBinary0(b *testing.B) { + trans, err := tfv[0].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteBinary(b, p, trans) + } +} + +func BenchmarkCompactBool_1(b *testing.B) { + trans, err := tfv[1].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteBool(b, p, trans) + } +} + +func BenchmarkCompactByte_1(b *testing.B) { + trans, err := tfv[1].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteByte(b, p, trans) + } +} + +func BenchmarkCompactI16_1(b *testing.B) { + trans, err := tfv[1].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI16(b, p, trans) + } +} + +func BenchmarkCompactI32_1(b *testing.B) { + trans, err := tfv[1].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI32(b, p, trans) + } +} +func BenchmarkCompactI64_1(b *testing.B) { + trans, err := tfv[1].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI64(b, p, trans) + } +} +func BenchmarkCompactDouble1(b *testing.B) { + trans, err := tfv[1].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteDouble(b, p, trans) + } +} +func BenchmarkCompactString1(b *testing.B) { + trans, err := tfv[1].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteString(b, p, trans) + } +} +func BenchmarkCompactBinary1(b *testing.B) { + trans, err := tfv[1].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteBinary(b, p, trans) + } +} + +func BenchmarkCompactBool_2(b *testing.B) { + trans, err := tfv[2].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteBool(b, p, trans) + } +} + +func BenchmarkCompactByte_2(b *testing.B) { + trans, err := tfv[2].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteByte(b, p, trans) + } +} + +func BenchmarkCompactI16_2(b *testing.B) { + trans, err := tfv[2].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI16(b, p, trans) + } +} + +func BenchmarkCompactI32_2(b *testing.B) { + trans, err := tfv[2].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI32(b, p, trans) + } +} +func BenchmarkCompactI64_2(b *testing.B) { + trans, err := tfv[2].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteI64(b, p, trans) + } +} +func BenchmarkCompactDouble2(b *testing.B) { + trans, err := tfv[2].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteDouble(b, p, trans) + } +} +func BenchmarkCompactString2(b *testing.B) { + trans, err := tfv[2].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteString(b, p, trans) + } +} +func BenchmarkCompactBinary2(b *testing.B) { + trans, err := tfv[2].GetTransport(nil) + if err != nil { + b.Fatal(err) + } + p := compactProtoF.GetProtocol(trans) + for i := 0; i < b.N; i++ { + ReadWriteBinary(b, p, trans) + } +} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/memory_buffer.go b/vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer.go similarity index 91% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/memory_buffer.go rename to vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer.go index b62fd56..5936d27 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/memory_buffer.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer.go @@ -21,6 +21,7 @@ package thrift import ( "bytes" + "context" ) // Memory buffer-based implementation of the TTransport interface. @@ -33,14 +34,14 @@ type TMemoryBufferTransportFactory struct { size int } -func (p *TMemoryBufferTransportFactory) GetTransport(trans TTransport) TTransport { +func (p *TMemoryBufferTransportFactory) GetTransport(trans TTransport) (TTransport, error) { if trans != nil { t, ok := trans.(*TMemoryBuffer) if ok && t.size > 0 { - return NewTMemoryBufferLen(t.size) + return NewTMemoryBufferLen(t.size), nil } } - return NewTMemoryBufferLen(p.size) + return NewTMemoryBufferLen(p.size), nil } func NewTMemoryBufferTransportFactory(size int) *TMemoryBufferTransportFactory { @@ -70,7 +71,7 @@ func (p *TMemoryBuffer) Close() error { } // Flushing a memory buffer is a no-op -func (p *TMemoryBuffer) Flush() error { +func (p *TMemoryBuffer) Flush(ctx context.Context) error { return nil } diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer_test.go new file mode 100644 index 0000000..af2e8bf --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/memory_buffer_test.go @@ -0,0 +1,29 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "testing" +) + +func TestMemoryBuffer(t *testing.T) { + trans := NewTMemoryBufferLen(1024) + TransportTest(t, trans, trans) +} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/messagetype.go b/vendor/github.com/apache/thrift/lib/go/thrift/messagetype.go similarity index 100% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/messagetype.go rename to vendor/github.com/apache/thrift/lib/go/thrift/messagetype.go diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/multiplexed_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol.go similarity index 96% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/multiplexed_protocol.go rename to vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol.go index 3157e0d..d028a30 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/multiplexed_protocol.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/multiplexed_protocol.go @@ -20,6 +20,7 @@ package thrift import ( + "context" "fmt" "strings" ) @@ -127,7 +128,7 @@ func (t *TMultiplexedProcessor) RegisterProcessor(name string, processor TProces t.serviceProcessorMap[name] = processor } -func (t *TMultiplexedProcessor) Process(in, out TProtocol) (bool, TException) { +func (t *TMultiplexedProcessor) Process(ctx context.Context, in, out TProtocol) (bool, TException) { name, typeId, seqid, err := in.ReadMessageBegin() if err != nil { return false, err @@ -140,7 +141,7 @@ func (t *TMultiplexedProcessor) Process(in, out TProtocol) (bool, TException) { if len(v) != 2 { if t.DefaultProcessor != nil { smb := NewStoredMessageProtocol(in, name, typeId, seqid) - return t.DefaultProcessor.Process(smb, out) + return t.DefaultProcessor.Process(ctx, smb, out) } return false, fmt.Errorf("Service name not found in message name: %s. Did you forget to use a TMultiplexProtocol in your client?", name) } @@ -149,7 +150,7 @@ func (t *TMultiplexedProcessor) Process(in, out TProtocol) (bool, TException) { return false, fmt.Errorf("Service name not found: %s. Did you forget to call registerProcessor()?", v[0]) } smb := NewStoredMessageProtocol(in, v[1], typeId, seqid) - return actualProcessor.Process(smb, out) + return actualProcessor.Process(ctx, smb, out) } //Protocol that use stored message for ReadMessageBegin diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/numeric.go b/vendor/github.com/apache/thrift/lib/go/thrift/numeric.go similarity index 100% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/numeric.go rename to vendor/github.com/apache/thrift/lib/go/thrift/numeric.go diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/pointerize.go b/vendor/github.com/apache/thrift/lib/go/thrift/pointerize.go similarity index 100% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/pointerize.go rename to vendor/github.com/apache/thrift/lib/go/thrift/pointerize.go diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/processor_factory.go b/vendor/github.com/apache/thrift/lib/go/thrift/processor_factory.go similarity index 83% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/processor_factory.go rename to vendor/github.com/apache/thrift/lib/go/thrift/processor_factory.go index 9d645df..e4b132b 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/processor_factory.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/processor_factory.go @@ -19,6 +19,18 @@ package thrift +import "context" + +// A processor is a generic object which operates upon an input stream and +// writes to some output stream. +type TProcessor interface { + Process(ctx context.Context, in, out TProtocol) (bool, TException) +} + +type TProcessorFunction interface { + Process(ctx context.Context, seqId int32, in, out TProtocol) (bool, TException) +} + // The default processor factory just returns a singleton // instance. type TProcessorFactory interface { diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/protocol.go similarity index 96% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/protocol.go rename to vendor/github.com/apache/thrift/lib/go/thrift/protocol.go index 5b77363..615b7a4 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/protocol.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/protocol.go @@ -20,7 +20,9 @@ package thrift import ( + "context" "errors" + "fmt" ) const ( @@ -73,7 +75,7 @@ type TProtocol interface { ReadBinary() (value []byte, err error) Skip(fieldType TType) (err error) - Flush() (err error) + Flush(ctx context.Context) (err error) Transport() TTransport } @@ -170,6 +172,8 @@ func Skip(self TProtocol, fieldType TType, maxDepth int) (err error) { } } return self.ReadListEnd() + default: + return NewTProtocolExceptionWithType(INVALID_DATA, errors.New(fmt.Sprintf("Unknown data type %d", fieldType))) } return nil } diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/protocol_exception.go b/vendor/github.com/apache/thrift/lib/go/thrift/protocol_exception.go similarity index 100% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/protocol_exception.go rename to vendor/github.com/apache/thrift/lib/go/thrift/protocol_exception.go diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/protocol_factory.go b/vendor/github.com/apache/thrift/lib/go/thrift/protocol_factory.go similarity index 100% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/protocol_factory.go rename to vendor/github.com/apache/thrift/lib/go/thrift/protocol_factory.go diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/protocol_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/protocol_test.go new file mode 100644 index 0000000..944055c --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/protocol_test.go @@ -0,0 +1,517 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "bytes" + "context" + "io/ioutil" + "math" + "net" + "net/http" + "testing" +) + +const PROTOCOL_BINARY_DATA_SIZE = 155 + +var ( + protocol_bdata []byte // test data for writing; same as data + BOOL_VALUES []bool + BYTE_VALUES []int8 + INT16_VALUES []int16 + INT32_VALUES []int32 + INT64_VALUES []int64 + DOUBLE_VALUES []float64 + STRING_VALUES []string +) + +func init() { + protocol_bdata = make([]byte, PROTOCOL_BINARY_DATA_SIZE) + for i := 0; i < PROTOCOL_BINARY_DATA_SIZE; i++ { + protocol_bdata[i] = byte((i + 'a') % 255) + } + BOOL_VALUES = []bool{false, true, false, false, true} + BYTE_VALUES = []int8{117, 0, 1, 32, 127, -128, -1} + INT16_VALUES = []int16{459, 0, 1, -1, -128, 127, 32767, -32768} + INT32_VALUES = []int32{459, 0, 1, -1, -128, 127, 32767, 2147483647, -2147483535} + INT64_VALUES = []int64{459, 0, 1, -1, -128, 127, 32767, 2147483647, -2147483535, 34359738481, -35184372088719, -9223372036854775808, 9223372036854775807} + DOUBLE_VALUES = []float64{459.3, 0.0, -1.0, 1.0, 0.5, 0.3333, 3.14159, 1.537e-38, 1.673e25, 6.02214179e23, -6.02214179e23, INFINITY.Float64(), NEGATIVE_INFINITY.Float64(), NAN.Float64()} + STRING_VALUES = []string{"", "a", "st[uf]f", "st,u:ff with spaces", "stuff\twith\nescape\\characters'...\"lots{of}fun"} +} + +type HTTPEchoServer struct{} +type HTTPHeaderEchoServer struct{} + +func (p *HTTPEchoServer) ServeHTTP(w http.ResponseWriter, req *http.Request) { + buf, err := ioutil.ReadAll(req.Body) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + w.Write(buf) + } else { + w.WriteHeader(http.StatusOK) + w.Write(buf) + } +} + +func (p *HTTPHeaderEchoServer) ServeHTTP(w http.ResponseWriter, req *http.Request) { + buf, err := ioutil.ReadAll(req.Body) + if err != nil { + w.WriteHeader(http.StatusBadRequest) + w.Write(buf) + } else { + w.WriteHeader(http.StatusOK) + w.Write(buf) + } +} + +func HttpClientSetupForTest(t *testing.T) (net.Listener, net.Addr) { + addr, err := FindAvailableTCPServerPort(40000) + if err != nil { + t.Fatalf("Unable to find available tcp port addr: %s", err) + return nil, addr + } + l, err := net.Listen(addr.Network(), addr.String()) + if err != nil { + t.Fatalf("Unable to setup tcp listener on %s: %s", addr.String(), err) + return l, addr + } + go http.Serve(l, &HTTPEchoServer{}) + return l, addr +} + +func HttpClientSetupForHeaderTest(t *testing.T) (net.Listener, net.Addr) { + addr, err := FindAvailableTCPServerPort(40000) + if err != nil { + t.Fatalf("Unable to find available tcp port addr: %s", err) + return nil, addr + } + l, err := net.Listen(addr.Network(), addr.String()) + if err != nil { + t.Fatalf("Unable to setup tcp listener on %s: %s", addr.String(), err) + return l, addr + } + go http.Serve(l, &HTTPHeaderEchoServer{}) + return l, addr +} + +func ReadWriteProtocolTest(t *testing.T, protocolFactory TProtocolFactory) { + buf := bytes.NewBuffer(make([]byte, 0, 1024)) + l, addr := HttpClientSetupForTest(t) + defer l.Close() + transports := []TTransportFactory{ + NewTMemoryBufferTransportFactory(1024), + NewStreamTransportFactory(buf, buf, true), + NewTFramedTransportFactory(NewTMemoryBufferTransportFactory(1024)), + NewTZlibTransportFactoryWithFactory(0, NewTMemoryBufferTransportFactory(1024)), + NewTZlibTransportFactoryWithFactory(6, NewTMemoryBufferTransportFactory(1024)), + NewTZlibTransportFactoryWithFactory(9, NewTFramedTransportFactory(NewTMemoryBufferTransportFactory(1024))), + NewTHttpPostClientTransportFactory("http://" + addr.String()), + } + for _, tf := range transports { + trans, err := tf.GetTransport(nil) + if err != nil { + t.Error(err) + continue + } + p := protocolFactory.GetProtocol(trans) + ReadWriteBool(t, p, trans) + trans.Close() + } + for _, tf := range transports { + trans, err := tf.GetTransport(nil) + if err != nil { + t.Error(err) + continue + } + p := protocolFactory.GetProtocol(trans) + ReadWriteByte(t, p, trans) + trans.Close() + } + for _, tf := range transports { + trans, err := tf.GetTransport(nil) + if err != nil { + t.Error(err) + continue + } + p := protocolFactory.GetProtocol(trans) + ReadWriteI16(t, p, trans) + trans.Close() + } + for _, tf := range transports { + trans, err := tf.GetTransport(nil) + if err != nil { + t.Error(err) + continue + } + p := protocolFactory.GetProtocol(trans) + ReadWriteI32(t, p, trans) + trans.Close() + } + for _, tf := range transports { + trans, err := tf.GetTransport(nil) + if err != nil { + t.Error(err) + continue + } + p := protocolFactory.GetProtocol(trans) + ReadWriteI64(t, p, trans) + trans.Close() + } + for _, tf := range transports { + trans, err := tf.GetTransport(nil) + if err != nil { + t.Error(err) + continue + } + p := protocolFactory.GetProtocol(trans) + ReadWriteDouble(t, p, trans) + trans.Close() + } + for _, tf := range transports { + trans, err := tf.GetTransport(nil) + if err != nil { + t.Error(err) + continue + } + p := protocolFactory.GetProtocol(trans) + ReadWriteString(t, p, trans) + trans.Close() + } + for _, tf := range transports { + trans, err := tf.GetTransport(nil) + if err != nil { + t.Error(err) + continue + } + p := protocolFactory.GetProtocol(trans) + ReadWriteBinary(t, p, trans) + trans.Close() + } + for _, tf := range transports { + trans, err := tf.GetTransport(nil) + if err != nil { + t.Error(err) + continue + } + p := protocolFactory.GetProtocol(trans) + ReadWriteI64(t, p, trans) + ReadWriteDouble(t, p, trans) + ReadWriteBinary(t, p, trans) + ReadWriteByte(t, p, trans) + trans.Close() + } +} + +func ReadWriteBool(t testing.TB, p TProtocol, trans TTransport) { + thetype := TType(BOOL) + thelen := len(BOOL_VALUES) + err := p.WriteListBegin(thetype, thelen) + if err != nil { + t.Errorf("%s: %T %T %q Error writing list begin: %q", "ReadWriteBool", p, trans, err, thetype) + } + for k, v := range BOOL_VALUES { + err = p.WriteBool(v) + if err != nil { + t.Errorf("%s: %T %T %v Error writing bool in list at index %v: %v", "ReadWriteBool", p, trans, err, k, v) + } + } + p.WriteListEnd() + if err != nil { + t.Errorf("%s: %T %T %v Error writing list end: %v", "ReadWriteBool", p, trans, err, BOOL_VALUES) + } + p.Flush(context.Background()) + thetype2, thelen2, err := p.ReadListBegin() + if err != nil { + t.Errorf("%s: %T %T %v Error reading list: %v", "ReadWriteBool", p, trans, err, BOOL_VALUES) + } + _, ok := p.(*TSimpleJSONProtocol) + if !ok { + if thetype != thetype2 { + t.Errorf("%s: %T %T type %s != type %s", "ReadWriteBool", p, trans, thetype, thetype2) + } + if thelen != thelen2 { + t.Errorf("%s: %T %T len %v != len %v", "ReadWriteBool", p, trans, thelen, thelen2) + } + } + for k, v := range BOOL_VALUES { + value, err := p.ReadBool() + if err != nil { + t.Errorf("%s: %T %T %v Error reading bool at index %v: %v", "ReadWriteBool", p, trans, err, k, v) + } + if v != value { + t.Errorf("%s: index %v %v %v %v != %v", "ReadWriteBool", k, p, trans, v, value) + } + } + err = p.ReadListEnd() + if err != nil { + t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteBool", p, trans, err) + } +} + +func ReadWriteByte(t testing.TB, p TProtocol, trans TTransport) { + thetype := TType(BYTE) + thelen := len(BYTE_VALUES) + err := p.WriteListBegin(thetype, thelen) + if err != nil { + t.Errorf("%s: %T %T %q Error writing list begin: %q", "ReadWriteByte", p, trans, err, thetype) + } + for k, v := range BYTE_VALUES { + err = p.WriteByte(v) + if err != nil { + t.Errorf("%s: %T %T %q Error writing byte in list at index %d: %q", "ReadWriteByte", p, trans, err, k, v) + } + } + err = p.WriteListEnd() + if err != nil { + t.Errorf("%s: %T %T %q Error writing list end: %q", "ReadWriteByte", p, trans, err, BYTE_VALUES) + } + err = p.Flush(context.Background()) + if err != nil { + t.Errorf("%s: %T %T %q Error flushing list of bytes: %q", "ReadWriteByte", p, trans, err, BYTE_VALUES) + } + thetype2, thelen2, err := p.ReadListBegin() + if err != nil { + t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteByte", p, trans, err, BYTE_VALUES) + } + _, ok := p.(*TSimpleJSONProtocol) + if !ok { + if thetype != thetype2 { + t.Errorf("%s: %T %T type %s != type %s", "ReadWriteByte", p, trans, thetype, thetype2) + } + if thelen != thelen2 { + t.Errorf("%s: %T %T len %v != len %v", "ReadWriteByte", p, trans, thelen, thelen2) + } + } + for k, v := range BYTE_VALUES { + value, err := p.ReadByte() + if err != nil { + t.Errorf("%s: %T %T %q Error reading byte at index %d: %q", "ReadWriteByte", p, trans, err, k, v) + } + if v != value { + t.Errorf("%s: %T %T %d != %d", "ReadWriteByte", p, trans, v, value) + } + } + err = p.ReadListEnd() + if err != nil { + t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteByte", p, trans, err) + } +} + +func ReadWriteI16(t testing.TB, p TProtocol, trans TTransport) { + thetype := TType(I16) + thelen := len(INT16_VALUES) + p.WriteListBegin(thetype, thelen) + for _, v := range INT16_VALUES { + p.WriteI16(v) + } + p.WriteListEnd() + p.Flush(context.Background()) + thetype2, thelen2, err := p.ReadListBegin() + if err != nil { + t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteI16", p, trans, err, INT16_VALUES) + } + _, ok := p.(*TSimpleJSONProtocol) + if !ok { + if thetype != thetype2 { + t.Errorf("%s: %T %T type %s != type %s", "ReadWriteI16", p, trans, thetype, thetype2) + } + if thelen != thelen2 { + t.Errorf("%s: %T %T len %v != len %v", "ReadWriteI16", p, trans, thelen, thelen2) + } + } + for k, v := range INT16_VALUES { + value, err := p.ReadI16() + if err != nil { + t.Errorf("%s: %T %T %q Error reading int16 at index %d: %q", "ReadWriteI16", p, trans, err, k, v) + } + if v != value { + t.Errorf("%s: %T %T %d != %d", "ReadWriteI16", p, trans, v, value) + } + } + err = p.ReadListEnd() + if err != nil { + t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteI16", p, trans, err) + } +} + +func ReadWriteI32(t testing.TB, p TProtocol, trans TTransport) { + thetype := TType(I32) + thelen := len(INT32_VALUES) + p.WriteListBegin(thetype, thelen) + for _, v := range INT32_VALUES { + p.WriteI32(v) + } + p.WriteListEnd() + p.Flush(context.Background()) + thetype2, thelen2, err := p.ReadListBegin() + if err != nil { + t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteI32", p, trans, err, INT32_VALUES) + } + _, ok := p.(*TSimpleJSONProtocol) + if !ok { + if thetype != thetype2 { + t.Errorf("%s: %T %T type %s != type %s", "ReadWriteI32", p, trans, thetype, thetype2) + } + if thelen != thelen2 { + t.Errorf("%s: %T %T len %v != len %v", "ReadWriteI32", p, trans, thelen, thelen2) + } + } + for k, v := range INT32_VALUES { + value, err := p.ReadI32() + if err != nil { + t.Errorf("%s: %T %T %q Error reading int32 at index %d: %q", "ReadWriteI32", p, trans, err, k, v) + } + if v != value { + t.Errorf("%s: %T %T %d != %d", "ReadWriteI32", p, trans, v, value) + } + } + if err != nil { + t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteI32", p, trans, err) + } +} + +func ReadWriteI64(t testing.TB, p TProtocol, trans TTransport) { + thetype := TType(I64) + thelen := len(INT64_VALUES) + p.WriteListBegin(thetype, thelen) + for _, v := range INT64_VALUES { + p.WriteI64(v) + } + p.WriteListEnd() + p.Flush(context.Background()) + thetype2, thelen2, err := p.ReadListBegin() + if err != nil { + t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteI64", p, trans, err, INT64_VALUES) + } + _, ok := p.(*TSimpleJSONProtocol) + if !ok { + if thetype != thetype2 { + t.Errorf("%s: %T %T type %s != type %s", "ReadWriteI64", p, trans, thetype, thetype2) + } + if thelen != thelen2 { + t.Errorf("%s: %T %T len %v != len %v", "ReadWriteI64", p, trans, thelen, thelen2) + } + } + for k, v := range INT64_VALUES { + value, err := p.ReadI64() + if err != nil { + t.Errorf("%s: %T %T %q Error reading int64 at index %d: %q", "ReadWriteI64", p, trans, err, k, v) + } + if v != value { + t.Errorf("%s: %T %T %q != %q", "ReadWriteI64", p, trans, v, value) + } + } + if err != nil { + t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteI64", p, trans, err) + } +} + +func ReadWriteDouble(t testing.TB, p TProtocol, trans TTransport) { + thetype := TType(DOUBLE) + thelen := len(DOUBLE_VALUES) + p.WriteListBegin(thetype, thelen) + for _, v := range DOUBLE_VALUES { + p.WriteDouble(v) + } + p.WriteListEnd() + p.Flush(context.Background()) + thetype2, thelen2, err := p.ReadListBegin() + if err != nil { + t.Errorf("%s: %T %T %v Error reading list: %v", "ReadWriteDouble", p, trans, err, DOUBLE_VALUES) + } + if thetype != thetype2 { + t.Errorf("%s: %T %T type %s != type %s", "ReadWriteDouble", p, trans, thetype, thetype2) + } + if thelen != thelen2 { + t.Errorf("%s: %T %T len %v != len %v", "ReadWriteDouble", p, trans, thelen, thelen2) + } + for k, v := range DOUBLE_VALUES { + value, err := p.ReadDouble() + if err != nil { + t.Errorf("%s: %T %T %q Error reading double at index %d: %v", "ReadWriteDouble", p, trans, err, k, v) + } + if math.IsNaN(v) { + if !math.IsNaN(value) { + t.Errorf("%s: %T %T math.IsNaN(%v) != math.IsNaN(%v)", "ReadWriteDouble", p, trans, v, value) + } + } else if v != value { + t.Errorf("%s: %T %T %v != %v", "ReadWriteDouble", p, trans, v, value) + } + } + err = p.ReadListEnd() + if err != nil { + t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteDouble", p, trans, err) + } +} + +func ReadWriteString(t testing.TB, p TProtocol, trans TTransport) { + thetype := TType(STRING) + thelen := len(STRING_VALUES) + p.WriteListBegin(thetype, thelen) + for _, v := range STRING_VALUES { + p.WriteString(v) + } + p.WriteListEnd() + p.Flush(context.Background()) + thetype2, thelen2, err := p.ReadListBegin() + if err != nil { + t.Errorf("%s: %T %T %q Error reading list: %q", "ReadWriteString", p, trans, err, STRING_VALUES) + } + _, ok := p.(*TSimpleJSONProtocol) + if !ok { + if thetype != thetype2 { + t.Errorf("%s: %T %T type %s != type %s", "ReadWriteString", p, trans, thetype, thetype2) + } + if thelen != thelen2 { + t.Errorf("%s: %T %T len %v != len %v", "ReadWriteString", p, trans, thelen, thelen2) + } + } + for k, v := range STRING_VALUES { + value, err := p.ReadString() + if err != nil { + t.Errorf("%s: %T %T %q Error reading string at index %d: %q", "ReadWriteString", p, trans, err, k, v) + } + if v != value { + t.Errorf("%s: %T %T %v != %v", "ReadWriteString", p, trans, v, value) + } + } + if err != nil { + t.Errorf("%s: %T %T Unable to read list end: %q", "ReadWriteString", p, trans, err) + } +} + +func ReadWriteBinary(t testing.TB, p TProtocol, trans TTransport) { + v := protocol_bdata + p.WriteBinary(v) + p.Flush(context.Background()) + value, err := p.ReadBinary() + if err != nil { + t.Errorf("%s: %T %T Unable to read binary: %s", "ReadWriteBinary", p, trans, err.Error()) + } + if len(v) != len(value) { + t.Errorf("%s: %T %T len(v) != len(value)... %d != %d", "ReadWriteBinary", p, trans, len(v), len(value)) + } else { + for i := 0; i < len(v); i++ { + if v[i] != value[i] { + t.Errorf("%s: %T %T %s != %s", "ReadWriteBinary", p, trans, v, value) + } + } + } +} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/rich_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/rich_transport.go similarity index 100% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/rich_transport.go rename to vendor/github.com/apache/thrift/lib/go/thrift/rich_transport.go diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/rich_transport_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/rich_transport_test.go new file mode 100644 index 0000000..25c3fd5 --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/rich_transport_test.go @@ -0,0 +1,89 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "bytes" + "errors" + "io" + "reflect" + "testing" +) + +func TestEnsureTransportsAreRich(t *testing.T) { + buf := bytes.NewBuffer(make([]byte, 0, 1024)) + + transports := []TTransportFactory{ + NewTMemoryBufferTransportFactory(1024), + NewStreamTransportFactory(buf, buf, true), + NewTFramedTransportFactory(NewTMemoryBufferTransportFactory(1024)), + NewTHttpPostClientTransportFactory("http://127.0.0.1"), + } + for _, tf := range transports { + trans, err := tf.GetTransport(nil) + if err != nil { + t.Error(err) + continue + } + _, ok := trans.(TRichTransport) + if !ok { + t.Errorf("Transport %s does not implement TRichTransport interface", reflect.ValueOf(trans)) + } + } +} + +// TestReadByte tests whether readByte handles error cases correctly. +func TestReadByte(t *testing.T) { + for i, test := range readByteTests { + v, err := readByte(test.r) + if v != test.v { + t.Fatalf("TestReadByte %d: value differs. Expected %d, got %d", i, test.v, test.r.v) + } + if err != test.err { + t.Fatalf("TestReadByte %d: error differs. Expected %s, got %s", i, test.err, test.r.err) + } + } +} + +var someError = errors.New("Some error") +var readByteTests = []struct { + r *mockReader + v byte + err error +}{ + {&mockReader{0, 55, io.EOF}, 0, io.EOF}, // reader sends EOF w/o data + {&mockReader{0, 55, someError}, 0, someError}, // reader sends some other error + {&mockReader{1, 55, nil}, 55, nil}, // reader sends data w/o error + {&mockReader{1, 55, io.EOF}, 55, nil}, // reader sends data with EOF + {&mockReader{1, 55, someError}, 55, someError}, // reader sends data withsome error +} + +type mockReader struct { + n int + v byte + err error +} + +func (r *mockReader) Read(p []byte) (n int, err error) { + if r.n > 0 { + p[0] = r.v + } + return r.n, r.err +} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/serializer.go b/vendor/github.com/apache/thrift/lib/go/thrift/serializer.go similarity index 79% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/serializer.go rename to vendor/github.com/apache/thrift/lib/go/thrift/serializer.go index 7712229..1ff4d37 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/serializer.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/serializer.go @@ -19,6 +19,10 @@ package thrift +import ( + "context" +) + type TSerializer struct { Transport *TMemoryBuffer Protocol TProtocol @@ -38,35 +42,35 @@ func NewTSerializer() *TSerializer { protocol} } -func (t *TSerializer) WriteString(msg TStruct) (s string, err error) { +func (t *TSerializer) WriteString(ctx context.Context, msg TStruct) (s string, err error) { t.Transport.Reset() if err = msg.Write(t.Protocol); err != nil { return } - if err = t.Protocol.Flush(); err != nil { + if err = t.Protocol.Flush(ctx); err != nil { return } - if err = t.Transport.Flush(); err != nil { + if err = t.Transport.Flush(ctx); err != nil { return } return t.Transport.String(), nil } -func (t *TSerializer) Write(msg TStruct) (b []byte, err error) { +func (t *TSerializer) Write(ctx context.Context, msg TStruct) (b []byte, err error) { t.Transport.Reset() if err = msg.Write(t.Protocol); err != nil { return } - if err = t.Protocol.Flush(); err != nil { + if err = t.Protocol.Flush(ctx); err != nil { return } - if err = t.Transport.Flush(); err != nil { + if err = t.Transport.Flush(ctx); err != nil { return } diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/serializer_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/serializer_test.go new file mode 100644 index 0000000..32227ef --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/serializer_test.go @@ -0,0 +1,170 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "context" + "errors" + "fmt" + "testing" +) + +type ProtocolFactory interface { + GetProtocol(t TTransport) TProtocol +} + +func compareStructs(m, m1 MyTestStruct) (bool, error) { + switch { + case m.On != m1.On: + return false, errors.New("Boolean not equal") + case m.B != m1.B: + return false, errors.New("Byte not equal") + case m.Int16 != m1.Int16: + return false, errors.New("Int16 not equal") + case m.Int32 != m1.Int32: + return false, errors.New("Int32 not equal") + case m.Int64 != m1.Int64: + return false, errors.New("Int64 not equal") + case m.D != m1.D: + return false, errors.New("Double not equal") + case m.St != m1.St: + return false, errors.New("String not equal") + + case len(m.Bin) != len(m1.Bin): + return false, errors.New("Binary size not equal") + case len(m.Bin) == len(m1.Bin): + for i := range m.Bin { + if m.Bin[i] != m1.Bin[i] { + return false, errors.New("Binary not equal") + } + } + case len(m.StringMap) != len(m1.StringMap): + return false, errors.New("StringMap size not equal") + case len(m.StringList) != len(m1.StringList): + return false, errors.New("StringList size not equal") + case len(m.StringSet) != len(m1.StringSet): + return false, errors.New("StringSet size not equal") + + case m.E != m1.E: + return false, errors.New("MyTestEnum not equal") + + default: + return true, nil + + } + return true, nil +} + +func ProtocolTest1(test *testing.T, pf ProtocolFactory) (bool, error) { + t := NewTSerializer() + t.Protocol = pf.GetProtocol(t.Transport) + var m = MyTestStruct{} + m.On = true + m.B = int8(0) + m.Int16 = 1 + m.Int32 = 2 + m.Int64 = 3 + m.D = 4.1 + m.St = "Test" + m.Bin = make([]byte, 10) + m.StringMap = make(map[string]string, 5) + m.StringList = make([]string, 5) + m.StringSet = make(map[string]struct{}, 5) + m.E = 2 + + s, err := t.WriteString(context.Background(), &m) + if err != nil { + return false, errors.New(fmt.Sprintf("Unable to Serialize struct\n\t %s", err)) + } + + t1 := NewTDeserializer() + t1.Protocol = pf.GetProtocol(t1.Transport) + var m1 = MyTestStruct{} + if err = t1.ReadString(&m1, s); err != nil { + return false, errors.New(fmt.Sprintf("Unable to Deserialize struct\n\t %s", err)) + + } + + return compareStructs(m, m1) + +} + +func ProtocolTest2(test *testing.T, pf ProtocolFactory) (bool, error) { + t := NewTSerializer() + t.Protocol = pf.GetProtocol(t.Transport) + var m = MyTestStruct{} + m.On = false + m.B = int8(0) + m.Int16 = 1 + m.Int32 = 2 + m.Int64 = 3 + m.D = 4.1 + m.St = "Test" + m.Bin = make([]byte, 10) + m.StringMap = make(map[string]string, 5) + m.StringList = make([]string, 5) + m.StringSet = make(map[string]struct{}, 5) + m.E = 2 + + s, err := t.WriteString(context.Background(), &m) + if err != nil { + return false, errors.New(fmt.Sprintf("Unable to Serialize struct\n\t %s", err)) + + } + + t1 := NewTDeserializer() + t1.Protocol = pf.GetProtocol(t1.Transport) + var m1 = MyTestStruct{} + if err = t1.ReadString(&m1, s); err != nil { + return false, errors.New(fmt.Sprintf("Unable to Deserialize struct\n\t %s", err)) + + } + + return compareStructs(m, m1) + +} + +func TestSerializer(t *testing.T) { + + var protocol_factories map[string]ProtocolFactory + protocol_factories = make(map[string]ProtocolFactory) + protocol_factories["Binary"] = NewTBinaryProtocolFactoryDefault() + protocol_factories["Compact"] = NewTCompactProtocolFactory() + //protocol_factories["SimpleJSON"] = NewTSimpleJSONProtocolFactory() - write only, can't be read back by design + protocol_factories["JSON"] = NewTJSONProtocolFactory() + + var tests map[string]func(*testing.T, ProtocolFactory) (bool, error) + tests = make(map[string]func(*testing.T, ProtocolFactory) (bool, error)) + tests["Test 1"] = ProtocolTest1 + tests["Test 2"] = ProtocolTest2 + //tests["Test 3"] = ProtocolTest3 // Example of how to add additional tests + + for name, pf := range protocol_factories { + + for test, f := range tests { + + if s, err := f(t, pf); !s || err != nil { + t.Errorf("%s Failed for %s protocol\n\t %s", test, name, err) + } + + } + } + +} diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/serializer_types_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/serializer_types_test.go new file mode 100644 index 0000000..ef7cc3a --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/serializer_types_test.go @@ -0,0 +1,633 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +// Autogenerated by Thrift Compiler (0.12.0) +// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING + +/* THE FOLLOWING THRIFT FILE WAS USED TO CREATE THIS + +enum MyTestEnum { + FIRST = 1, + SECOND = 2, + THIRD = 3, + FOURTH = 4, +} + +struct MyTestStruct { + 1: bool on, + 2: byte b, + 3: i16 int16, + 4: i32 int32, + 5: i64 int64, + 6: double d, + 7: string st, + 8: binary bin, + 9: map stringMap, + 10: list stringList, + 11: set stringSet, + 12: MyTestEnum e, +} +*/ + +import ( + "fmt" +) + +// (needed to ensure safety because of naive import list construction.) +var _ = ZERO +var _ = fmt.Printf + +var GoUnusedProtection__ int + +type MyTestEnum int64 + +const ( + MyTestEnum_FIRST MyTestEnum = 1 + MyTestEnum_SECOND MyTestEnum = 2 + MyTestEnum_THIRD MyTestEnum = 3 + MyTestEnum_FOURTH MyTestEnum = 4 +) + +func (p MyTestEnum) String() string { + switch p { + case MyTestEnum_FIRST: + return "FIRST" + case MyTestEnum_SECOND: + return "SECOND" + case MyTestEnum_THIRD: + return "THIRD" + case MyTestEnum_FOURTH: + return "FOURTH" + } + return "" +} + +func MyTestEnumFromString(s string) (MyTestEnum, error) { + switch s { + case "FIRST": + return MyTestEnum_FIRST, nil + case "SECOND": + return MyTestEnum_SECOND, nil + case "THIRD": + return MyTestEnum_THIRD, nil + case "FOURTH": + return MyTestEnum_FOURTH, nil + } + return MyTestEnum(0), fmt.Errorf("not a valid MyTestEnum string") +} + +func MyTestEnumPtr(v MyTestEnum) *MyTestEnum { return &v } + +type MyTestStruct struct { + On bool `thrift:"on,1" json:"on"` + B int8 `thrift:"b,2" json:"b"` + Int16 int16 `thrift:"int16,3" json:"int16"` + Int32 int32 `thrift:"int32,4" json:"int32"` + Int64 int64 `thrift:"int64,5" json:"int64"` + D float64 `thrift:"d,6" json:"d"` + St string `thrift:"st,7" json:"st"` + Bin []byte `thrift:"bin,8" json:"bin"` + StringMap map[string]string `thrift:"stringMap,9" json:"stringMap"` + StringList []string `thrift:"stringList,10" json:"stringList"` + StringSet map[string]struct{} `thrift:"stringSet,11" json:"stringSet"` + E MyTestEnum `thrift:"e,12" json:"e"` +} + +func NewMyTestStruct() *MyTestStruct { + return &MyTestStruct{} +} + +func (p *MyTestStruct) GetOn() bool { + return p.On +} + +func (p *MyTestStruct) GetB() int8 { + return p.B +} + +func (p *MyTestStruct) GetInt16() int16 { + return p.Int16 +} + +func (p *MyTestStruct) GetInt32() int32 { + return p.Int32 +} + +func (p *MyTestStruct) GetInt64() int64 { + return p.Int64 +} + +func (p *MyTestStruct) GetD() float64 { + return p.D +} + +func (p *MyTestStruct) GetSt() string { + return p.St +} + +func (p *MyTestStruct) GetBin() []byte { + return p.Bin +} + +func (p *MyTestStruct) GetStringMap() map[string]string { + return p.StringMap +} + +func (p *MyTestStruct) GetStringList() []string { + return p.StringList +} + +func (p *MyTestStruct) GetStringSet() map[string]struct{} { + return p.StringSet +} + +func (p *MyTestStruct) GetE() MyTestEnum { + return p.E +} +func (p *MyTestStruct) Read(iprot TProtocol) error { + if _, err := iprot.ReadStructBegin(); err != nil { + return PrependError(fmt.Sprintf("%T read error: ", p), err) + } + for { + _, fieldTypeId, fieldId, err := iprot.ReadFieldBegin() + if err != nil { + return PrependError(fmt.Sprintf("%T field %d read error: ", p, fieldId), err) + } + if fieldTypeId == STOP { + break + } + switch fieldId { + case 1: + if err := p.readField1(iprot); err != nil { + return err + } + case 2: + if err := p.readField2(iprot); err != nil { + return err + } + case 3: + if err := p.readField3(iprot); err != nil { + return err + } + case 4: + if err := p.readField4(iprot); err != nil { + return err + } + case 5: + if err := p.readField5(iprot); err != nil { + return err + } + case 6: + if err := p.readField6(iprot); err != nil { + return err + } + case 7: + if err := p.readField7(iprot); err != nil { + return err + } + case 8: + if err := p.readField8(iprot); err != nil { + return err + } + case 9: + if err := p.readField9(iprot); err != nil { + return err + } + case 10: + if err := p.readField10(iprot); err != nil { + return err + } + case 11: + if err := p.readField11(iprot); err != nil { + return err + } + case 12: + if err := p.readField12(iprot); err != nil { + return err + } + default: + if err := iprot.Skip(fieldTypeId); err != nil { + return err + } + } + if err := iprot.ReadFieldEnd(); err != nil { + return err + } + } + if err := iprot.ReadStructEnd(); err != nil { + return PrependError(fmt.Sprintf("%T read struct end error: ", p), err) + } + return nil +} + +func (p *MyTestStruct) readField1(iprot TProtocol) error { + if v, err := iprot.ReadBool(); err != nil { + return PrependError("error reading field 1: ", err) + } else { + p.On = v + } + return nil +} + +func (p *MyTestStruct) readField2(iprot TProtocol) error { + if v, err := iprot.ReadByte(); err != nil { + return PrependError("error reading field 2: ", err) + } else { + temp := int8(v) + p.B = temp + } + return nil +} + +func (p *MyTestStruct) readField3(iprot TProtocol) error { + if v, err := iprot.ReadI16(); err != nil { + return PrependError("error reading field 3: ", err) + } else { + p.Int16 = v + } + return nil +} + +func (p *MyTestStruct) readField4(iprot TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return PrependError("error reading field 4: ", err) + } else { + p.Int32 = v + } + return nil +} + +func (p *MyTestStruct) readField5(iprot TProtocol) error { + if v, err := iprot.ReadI64(); err != nil { + return PrependError("error reading field 5: ", err) + } else { + p.Int64 = v + } + return nil +} + +func (p *MyTestStruct) readField6(iprot TProtocol) error { + if v, err := iprot.ReadDouble(); err != nil { + return PrependError("error reading field 6: ", err) + } else { + p.D = v + } + return nil +} + +func (p *MyTestStruct) readField7(iprot TProtocol) error { + if v, err := iprot.ReadString(); err != nil { + return PrependError("error reading field 7: ", err) + } else { + p.St = v + } + return nil +} + +func (p *MyTestStruct) readField8(iprot TProtocol) error { + if v, err := iprot.ReadBinary(); err != nil { + return PrependError("error reading field 8: ", err) + } else { + p.Bin = v + } + return nil +} + +func (p *MyTestStruct) readField9(iprot TProtocol) error { + _, _, size, err := iprot.ReadMapBegin() + if err != nil { + return PrependError("error reading map begin: ", err) + } + tMap := make(map[string]string, size) + p.StringMap = tMap + for i := 0; i < size; i++ { + var _key0 string + if v, err := iprot.ReadString(); err != nil { + return PrependError("error reading field 0: ", err) + } else { + _key0 = v + } + var _val1 string + if v, err := iprot.ReadString(); err != nil { + return PrependError("error reading field 0: ", err) + } else { + _val1 = v + } + p.StringMap[_key0] = _val1 + } + if err := iprot.ReadMapEnd(); err != nil { + return PrependError("error reading map end: ", err) + } + return nil +} + +func (p *MyTestStruct) readField10(iprot TProtocol) error { + _, size, err := iprot.ReadListBegin() + if err != nil { + return PrependError("error reading list begin: ", err) + } + tSlice := make([]string, 0, size) + p.StringList = tSlice + for i := 0; i < size; i++ { + var _elem2 string + if v, err := iprot.ReadString(); err != nil { + return PrependError("error reading field 0: ", err) + } else { + _elem2 = v + } + p.StringList = append(p.StringList, _elem2) + } + if err := iprot.ReadListEnd(); err != nil { + return PrependError("error reading list end: ", err) + } + return nil +} + +func (p *MyTestStruct) readField11(iprot TProtocol) error { + _, size, err := iprot.ReadSetBegin() + if err != nil { + return PrependError("error reading set begin: ", err) + } + tSet := make(map[string]struct{}, size) + p.StringSet = tSet + for i := 0; i < size; i++ { + var _elem3 string + if v, err := iprot.ReadString(); err != nil { + return PrependError("error reading field 0: ", err) + } else { + _elem3 = v + } + p.StringSet[_elem3] = struct{}{} + } + if err := iprot.ReadSetEnd(); err != nil { + return PrependError("error reading set end: ", err) + } + return nil +} + +func (p *MyTestStruct) readField12(iprot TProtocol) error { + if v, err := iprot.ReadI32(); err != nil { + return PrependError("error reading field 12: ", err) + } else { + temp := MyTestEnum(v) + p.E = temp + } + return nil +} + +func (p *MyTestStruct) Write(oprot TProtocol) error { + if err := oprot.WriteStructBegin("MyTestStruct"); err != nil { + return PrependError(fmt.Sprintf("%T write struct begin error: ", p), err) + } + if err := p.writeField1(oprot); err != nil { + return err + } + if err := p.writeField2(oprot); err != nil { + return err + } + if err := p.writeField3(oprot); err != nil { + return err + } + if err := p.writeField4(oprot); err != nil { + return err + } + if err := p.writeField5(oprot); err != nil { + return err + } + if err := p.writeField6(oprot); err != nil { + return err + } + if err := p.writeField7(oprot); err != nil { + return err + } + if err := p.writeField8(oprot); err != nil { + return err + } + if err := p.writeField9(oprot); err != nil { + return err + } + if err := p.writeField10(oprot); err != nil { + return err + } + if err := p.writeField11(oprot); err != nil { + return err + } + if err := p.writeField12(oprot); err != nil { + return err + } + if err := oprot.WriteFieldStop(); err != nil { + return PrependError("write field stop error: ", err) + } + if err := oprot.WriteStructEnd(); err != nil { + return PrependError("write struct stop error: ", err) + } + return nil +} + +func (p *MyTestStruct) writeField1(oprot TProtocol) (err error) { + if err := oprot.WriteFieldBegin("on", BOOL, 1); err != nil { + return PrependError(fmt.Sprintf("%T write field begin error 1:on: ", p), err) + } + if err := oprot.WriteBool(bool(p.On)); err != nil { + return PrependError(fmt.Sprintf("%T.on (1) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return PrependError(fmt.Sprintf("%T write field end error 1:on: ", p), err) + } + return err +} + +func (p *MyTestStruct) writeField2(oprot TProtocol) (err error) { + if err := oprot.WriteFieldBegin("b", BYTE, 2); err != nil { + return PrependError(fmt.Sprintf("%T write field begin error 2:b: ", p), err) + } + if err := oprot.WriteByte(int8(p.B)); err != nil { + return PrependError(fmt.Sprintf("%T.b (2) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return PrependError(fmt.Sprintf("%T write field end error 2:b: ", p), err) + } + return err +} + +func (p *MyTestStruct) writeField3(oprot TProtocol) (err error) { + if err := oprot.WriteFieldBegin("int16", I16, 3); err != nil { + return PrependError(fmt.Sprintf("%T write field begin error 3:int16: ", p), err) + } + if err := oprot.WriteI16(int16(p.Int16)); err != nil { + return PrependError(fmt.Sprintf("%T.int16 (3) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return PrependError(fmt.Sprintf("%T write field end error 3:int16: ", p), err) + } + return err +} + +func (p *MyTestStruct) writeField4(oprot TProtocol) (err error) { + if err := oprot.WriteFieldBegin("int32", I32, 4); err != nil { + return PrependError(fmt.Sprintf("%T write field begin error 4:int32: ", p), err) + } + if err := oprot.WriteI32(int32(p.Int32)); err != nil { + return PrependError(fmt.Sprintf("%T.int32 (4) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return PrependError(fmt.Sprintf("%T write field end error 4:int32: ", p), err) + } + return err +} + +func (p *MyTestStruct) writeField5(oprot TProtocol) (err error) { + if err := oprot.WriteFieldBegin("int64", I64, 5); err != nil { + return PrependError(fmt.Sprintf("%T write field begin error 5:int64: ", p), err) + } + if err := oprot.WriteI64(int64(p.Int64)); err != nil { + return PrependError(fmt.Sprintf("%T.int64 (5) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return PrependError(fmt.Sprintf("%T write field end error 5:int64: ", p), err) + } + return err +} + +func (p *MyTestStruct) writeField6(oprot TProtocol) (err error) { + if err := oprot.WriteFieldBegin("d", DOUBLE, 6); err != nil { + return PrependError(fmt.Sprintf("%T write field begin error 6:d: ", p), err) + } + if err := oprot.WriteDouble(float64(p.D)); err != nil { + return PrependError(fmt.Sprintf("%T.d (6) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return PrependError(fmt.Sprintf("%T write field end error 6:d: ", p), err) + } + return err +} + +func (p *MyTestStruct) writeField7(oprot TProtocol) (err error) { + if err := oprot.WriteFieldBegin("st", STRING, 7); err != nil { + return PrependError(fmt.Sprintf("%T write field begin error 7:st: ", p), err) + } + if err := oprot.WriteString(string(p.St)); err != nil { + return PrependError(fmt.Sprintf("%T.st (7) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return PrependError(fmt.Sprintf("%T write field end error 7:st: ", p), err) + } + return err +} + +func (p *MyTestStruct) writeField8(oprot TProtocol) (err error) { + if err := oprot.WriteFieldBegin("bin", STRING, 8); err != nil { + return PrependError(fmt.Sprintf("%T write field begin error 8:bin: ", p), err) + } + if err := oprot.WriteBinary(p.Bin); err != nil { + return PrependError(fmt.Sprintf("%T.bin (8) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return PrependError(fmt.Sprintf("%T write field end error 8:bin: ", p), err) + } + return err +} + +func (p *MyTestStruct) writeField9(oprot TProtocol) (err error) { + if err := oprot.WriteFieldBegin("stringMap", MAP, 9); err != nil { + return PrependError(fmt.Sprintf("%T write field begin error 9:stringMap: ", p), err) + } + if err := oprot.WriteMapBegin(STRING, STRING, len(p.StringMap)); err != nil { + return PrependError("error writing map begin: ", err) + } + for k, v := range p.StringMap { + if err := oprot.WriteString(string(k)); err != nil { + return PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) + } + if err := oprot.WriteString(string(v)); err != nil { + return PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) + } + } + if err := oprot.WriteMapEnd(); err != nil { + return PrependError("error writing map end: ", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return PrependError(fmt.Sprintf("%T write field end error 9:stringMap: ", p), err) + } + return err +} + +func (p *MyTestStruct) writeField10(oprot TProtocol) (err error) { + if err := oprot.WriteFieldBegin("stringList", LIST, 10); err != nil { + return PrependError(fmt.Sprintf("%T write field begin error 10:stringList: ", p), err) + } + if err := oprot.WriteListBegin(STRING, len(p.StringList)); err != nil { + return PrependError("error writing list begin: ", err) + } + for _, v := range p.StringList { + if err := oprot.WriteString(string(v)); err != nil { + return PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) + } + } + if err := oprot.WriteListEnd(); err != nil { + return PrependError("error writing list end: ", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return PrependError(fmt.Sprintf("%T write field end error 10:stringList: ", p), err) + } + return err +} + +func (p *MyTestStruct) writeField11(oprot TProtocol) (err error) { + if err := oprot.WriteFieldBegin("stringSet", SET, 11); err != nil { + return PrependError(fmt.Sprintf("%T write field begin error 11:stringSet: ", p), err) + } + if err := oprot.WriteSetBegin(STRING, len(p.StringSet)); err != nil { + return PrependError("error writing set begin: ", err) + } + for v := range p.StringSet { + if err := oprot.WriteString(string(v)); err != nil { + return PrependError(fmt.Sprintf("%T. (0) field write error: ", p), err) + } + } + if err := oprot.WriteSetEnd(); err != nil { + return PrependError("error writing set end: ", err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return PrependError(fmt.Sprintf("%T write field end error 11:stringSet: ", p), err) + } + return err +} + +func (p *MyTestStruct) writeField12(oprot TProtocol) (err error) { + if err := oprot.WriteFieldBegin("e", I32, 12); err != nil { + return PrependError(fmt.Sprintf("%T write field begin error 12:e: ", p), err) + } + if err := oprot.WriteI32(int32(p.E)); err != nil { + return PrependError(fmt.Sprintf("%T.e (12) field write error: ", p), err) + } + if err := oprot.WriteFieldEnd(); err != nil { + return PrependError(fmt.Sprintf("%T write field end error 12:e: ", p), err) + } + return err +} + +func (p *MyTestStruct) String() string { + if p == nil { + return "" + } + return fmt.Sprintf("MyTestStruct(%+v)", *p) +} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/server.go b/vendor/github.com/apache/thrift/lib/go/thrift/server.go similarity index 100% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/server.go rename to vendor/github.com/apache/thrift/lib/go/thrift/server.go diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/server_socket.go b/vendor/github.com/apache/thrift/lib/go/thrift/server_socket.go similarity index 85% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/server_socket.go rename to vendor/github.com/apache/thrift/lib/go/thrift/server_socket.go index d6e9495..7dd24ae 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/server_socket.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/server_socket.go @@ -47,7 +47,14 @@ func NewTServerSocketTimeout(listenAddr string, clientTimeout time.Duration) (*T return &TServerSocket{addr: addr, clientTimeout: clientTimeout}, nil } +// Creates a TServerSocket from a net.Addr +func NewTServerSocketFromAddrTimeout(addr net.Addr, clientTimeout time.Duration) *TServerSocket { + return &TServerSocket{addr: addr, clientTimeout: clientTimeout} +} + func (p *TServerSocket) Listen() error { + p.mu.Lock() + defer p.mu.Unlock() if p.IsListening() { return nil } @@ -67,10 +74,15 @@ func (p *TServerSocket) Accept() (TTransport, error) { if interrupted { return nil, errTransportInterrupted } - if p.listener == nil { + + p.mu.Lock() + listener := p.listener + p.mu.Unlock() + if listener == nil { return nil, NewTTransportException(NOT_OPEN, "No underlying server socket") } - conn, err := p.listener.Accept() + + conn, err := listener.Accept() if err != nil { return nil, NewTTransportExceptionFromError(err) } @@ -84,6 +96,8 @@ func (p *TServerSocket) IsListening() bool { // Connects the socket, creating a new socket object if necessary. func (p *TServerSocket) Open() error { + p.mu.Lock() + defer p.mu.Unlock() if p.IsListening() { return NewTTransportException(ALREADY_OPEN, "Server socket already open") } @@ -103,20 +117,21 @@ func (p *TServerSocket) Addr() net.Addr { } func (p *TServerSocket) Close() error { - defer func() { - p.listener = nil - }() + var err error + p.mu.Lock() if p.IsListening() { - return p.listener.Close() + err = p.listener.Close() + p.listener = nil } - return nil + p.mu.Unlock() + return err } func (p *TServerSocket) Interrupt() error { p.mu.Lock() p.interrupted = true - p.Close() p.mu.Unlock() + p.Close() return nil } diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/server_socket_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/server_socket_test.go new file mode 100644 index 0000000..f1e1983 --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/server_socket_test.go @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "fmt" + "testing" +) + +func TestSocketIsntListeningAfterInterrupt(t *testing.T) { + host := "127.0.0.1" + port := 9090 + addr := fmt.Sprintf("%s:%d", host, port) + + socket := CreateServerSocket(t, addr) + socket.Listen() + socket.Interrupt() + + newSocket := CreateServerSocket(t, addr) + err := newSocket.Listen() + defer newSocket.Interrupt() + if err != nil { + t.Fatalf("Failed to rebinds: %s", err) + } +} + +func TestSocketConcurrency(t *testing.T) { + host := "127.0.0.1" + port := 9090 + addr := fmt.Sprintf("%s:%d", host, port) + + socket := CreateServerSocket(t, addr) + go func() { socket.Listen() }() + go func() { socket.Interrupt() }() +} + +func CreateServerSocket(t *testing.T, addr string) *TServerSocket { + socket, err := NewTServerSocket(addr) + if err != nil { + t.Fatalf("Failed to create server socket: %s", err) + } + return socket +} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/http_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/server_test.go similarity index 62% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/http_transport.go rename to vendor/github.com/apache/thrift/lib/go/thrift/server_test.go index f6d7458..ffaf457 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/http_transport.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/server_test.go @@ -19,16 +19,10 @@ package thrift -import "net/http" +import ( + "testing" +) -// NewThriftHandlerFunc is a function that create a ready to use Apache Thrift Handler function -func NewThriftHandlerFunc(processor TProcessor, - inPfactory, outPfactory TProtocolFactory) func(w http.ResponseWriter, r *http.Request) { +func TestNothing(t *testing.T) { - return func(w http.ResponseWriter, r *http.Request) { - w.Header().Add("Content-Type", "application/x-thrift") - - transport := NewStreamTransport(r.Body, w) - processor.Process(inPfactory.GetProtocol(transport), outPfactory.GetProtocol(transport)) - } } diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/server_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/server_transport.go similarity index 100% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/server_transport.go rename to vendor/github.com/apache/thrift/lib/go/thrift/server_transport.go diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/simple_json_protocol.go b/vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol.go similarity index 99% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/simple_json_protocol.go rename to vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol.go index 7353322..2e8a711 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/simple_json_protocol.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol.go @@ -22,6 +22,7 @@ package thrift import ( "bufio" "bytes" + "context" "encoding/base64" "encoding/json" "fmt" @@ -552,7 +553,7 @@ func (p *TSimpleJSONProtocol) ReadBinary() ([]byte, error) { return v, p.ParsePostValue() } -func (p *TSimpleJSONProtocol) Flush() (err error) { +func (p *TSimpleJSONProtocol) Flush(ctx context.Context) (err error) { return NewTProtocolException(p.writer.Flush()) } @@ -1064,7 +1065,7 @@ func (p *TSimpleJSONProtocol) ParseListEnd() error { for _, char := range line { switch char { default: - e := fmt.Errorf("Expecting end of list \"]\", but found: \"", line, "\"") + e := fmt.Errorf("Expecting end of list \"]\", but found: \"%v\"", line) return NewTProtocolExceptionWithType(INVALID_DATA, e) case ' ', '\n', '\r', '\t', rune(JSON_RBRACKET[0]): break diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol_test.go new file mode 100644 index 0000000..7b98082 --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/simple_json_protocol_test.go @@ -0,0 +1,716 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "context" + "encoding/base64" + "encoding/json" + "fmt" + "math" + "strconv" + "strings" + "testing" +) + +func TestWriteSimpleJSONProtocolBool(t *testing.T) { + thetype := "boolean" + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + for _, value := range BOOL_VALUES { + if e := p.WriteBool(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) + } + s := trans.String() + if s != fmt.Sprint(value) { + t.Fatalf("Bad value for %s %v: %s", thetype, value, s) + } + v := false + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + } + trans.Close() +} + +func TestReadSimpleJSONProtocolBool(t *testing.T) { + thetype := "boolean" + for _, value := range BOOL_VALUES { + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + if value { + trans.Write(JSON_TRUE) + } else { + trans.Write(JSON_FALSE) + } + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadBool() + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if v != value { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + trans.Close() + } +} + +func TestWriteSimpleJSONProtocolByte(t *testing.T) { + thetype := "byte" + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + for _, value := range BYTE_VALUES { + if e := p.WriteByte(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) + } + s := trans.String() + if s != fmt.Sprint(value) { + t.Fatalf("Bad value for %s %v: %s", thetype, value, s) + } + v := int8(0) + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + } + trans.Close() +} + +func TestReadSimpleJSONProtocolByte(t *testing.T) { + thetype := "byte" + for _, value := range BYTE_VALUES { + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + trans.WriteString(strconv.Itoa(int(value))) + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadByte() + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if v != value { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + trans.Close() + } +} + +func TestWriteSimpleJSONProtocolI16(t *testing.T) { + thetype := "int16" + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + for _, value := range INT16_VALUES { + if e := p.WriteI16(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) + } + s := trans.String() + if s != fmt.Sprint(value) { + t.Fatalf("Bad value for %s %v: %s", thetype, value, s) + } + v := int16(0) + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + } + trans.Close() +} + +func TestReadSimpleJSONProtocolI16(t *testing.T) { + thetype := "int16" + for _, value := range INT16_VALUES { + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + trans.WriteString(strconv.Itoa(int(value))) + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadI16() + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if v != value { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + trans.Close() + } +} + +func TestWriteSimpleJSONProtocolI32(t *testing.T) { + thetype := "int32" + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + for _, value := range INT32_VALUES { + if e := p.WriteI32(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) + } + s := trans.String() + if s != fmt.Sprint(value) { + t.Fatalf("Bad value for %s %v: %s", thetype, value, s) + } + v := int32(0) + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + } + trans.Close() +} + +func TestReadSimpleJSONProtocolI32(t *testing.T) { + thetype := "int32" + for _, value := range INT32_VALUES { + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + trans.WriteString(strconv.Itoa(int(value))) + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadI32() + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if v != value { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + trans.Close() + } +} + +func TestReadSimpleJSONProtocolI32Null(t *testing.T) { + thetype := "int32" + value := "null" + + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + trans.WriteString(value) + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadI32() + + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if v != 0 { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + trans.Reset() + trans.Close() +} + +func TestWriteSimpleJSONProtocolI64(t *testing.T) { + thetype := "int64" + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + for _, value := range INT64_VALUES { + if e := p.WriteI64(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) + } + s := trans.String() + if s != fmt.Sprint(value) { + t.Fatalf("Bad value for %s %v: %s", thetype, value, s) + } + v := int64(0) + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + } + trans.Close() +} + +func TestReadSimpleJSONProtocolI64(t *testing.T) { + thetype := "int64" + for _, value := range INT64_VALUES { + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + trans.WriteString(strconv.FormatInt(value, 10)) + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadI64() + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if v != value { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + trans.Reset() + trans.Close() + } +} + +func TestReadSimpleJSONProtocolI64Null(t *testing.T) { + thetype := "int32" + value := "null" + + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + trans.WriteString(value) + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadI64() + + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if v != 0 { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + trans.Reset() + trans.Close() +} + +func TestWriteSimpleJSONProtocolDouble(t *testing.T) { + thetype := "double" + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + for _, value := range DOUBLE_VALUES { + if e := p.WriteDouble(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) + } + s := trans.String() + if math.IsInf(value, 1) { + if s != jsonQuote(JSON_INFINITY) { + t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_INFINITY)) + } + } else if math.IsInf(value, -1) { + if s != jsonQuote(JSON_NEGATIVE_INFINITY) { + t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_NEGATIVE_INFINITY)) + } + } else if math.IsNaN(value) { + if s != jsonQuote(JSON_NAN) { + t.Fatalf("Bad value for %s %v, wrote: %v, expected: %v", thetype, value, s, jsonQuote(JSON_NAN)) + } + } else { + if s != fmt.Sprint(value) { + t.Fatalf("Bad value for %s %v: %s", thetype, value, s) + } + v := float64(0) + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + } + trans.Reset() + } + trans.Close() +} + +func TestReadSimpleJSONProtocolDouble(t *testing.T) { + thetype := "double" + for _, value := range DOUBLE_VALUES { + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + n := NewNumericFromDouble(value) + trans.WriteString(n.String()) + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadDouble() + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if math.IsInf(value, 1) { + if !math.IsInf(v, 1) { + t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) + } + } else if math.IsInf(value, -1) { + if !math.IsInf(v, -1) { + t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) + } + } else if math.IsNaN(value) { + if !math.IsNaN(v) { + t.Fatalf("Bad value for %s %v, wrote: %v, received: %v", thetype, value, s, v) + } + } else { + if v != value { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + } + trans.Reset() + trans.Close() + } +} + +func TestWriteSimpleJSONProtocolString(t *testing.T) { + thetype := "string" + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + for _, value := range STRING_VALUES { + if e := p.WriteString(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) + } + s := trans.String() + if s[0] != '"' || s[len(s)-1] != '"' { + t.Fatalf("Bad value for %s '%v', wrote '%v', expected: %v", thetype, value, s, fmt.Sprint("\"", value, "\"")) + } + v := new(string) + if err := json.Unmarshal([]byte(s), v); err != nil || *v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v) + } + trans.Reset() + } + trans.Close() +} + +func TestReadSimpleJSONProtocolString(t *testing.T) { + thetype := "string" + for _, value := range STRING_VALUES { + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + trans.WriteString(jsonQuote(value)) + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadString() + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if v != value { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + v1 := new(string) + if err := json.Unmarshal([]byte(s), v1); err != nil || *v1 != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v1) + } + trans.Reset() + trans.Close() + } +} +func TestReadSimpleJSONProtocolStringNull(t *testing.T) { + thetype := "string" + value := "null" + + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + trans.WriteString(value) + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadString() + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if v != "" { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + trans.Reset() + trans.Close() +} + +func TestWriteSimpleJSONProtocolBinary(t *testing.T) { + thetype := "binary" + value := protocol_bdata + b64value := make([]byte, base64.StdEncoding.EncodedLen(len(protocol_bdata))) + base64.StdEncoding.Encode(b64value, value) + b64String := string(b64value) + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + if e := p.WriteBinary(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s value %v due to error flushing: %s", thetype, value, e.Error()) + } + s := trans.String() + if s != fmt.Sprint("\"", b64String, "\"") { + t.Fatalf("Bad value for %s %v\n wrote: %v\nexpected: %v", thetype, value, s, "\""+b64String+"\"") + } + v1 := new(string) + if err := json.Unmarshal([]byte(s), v1); err != nil || *v1 != b64String { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v1) + } + trans.Close() +} + +func TestReadSimpleJSONProtocolBinary(t *testing.T) { + thetype := "binary" + value := protocol_bdata + b64value := make([]byte, base64.StdEncoding.EncodedLen(len(protocol_bdata))) + base64.StdEncoding.Encode(b64value, value) + b64String := string(b64value) + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + trans.WriteString(jsonQuote(b64String)) + trans.Flush(context.Background()) + s := trans.String() + v, e := p.ReadBinary() + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if len(v) != len(value) { + t.Fatalf("Bad value for %s value length %v, wrote: %v, received length: %v", thetype, len(value), s, len(v)) + } + for i := 0; i < len(v); i++ { + if v[i] != value[i] { + t.Fatalf("Bad value for %s at index %d value %v, wrote: %v, received: %v", thetype, i, value[i], s, v[i]) + } + } + v1 := new(string) + if err := json.Unmarshal([]byte(s), v1); err != nil || *v1 != b64String { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, *v1) + } + trans.Reset() + trans.Close() +} + +func TestReadSimpleJSONProtocolBinaryNull(t *testing.T) { + thetype := "binary" + value := "null" + + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + trans.WriteString(value) + trans.Flush(context.Background()) + s := trans.String() + b, e := p.ReadBinary() + v := string(b) + + if e != nil { + t.Fatalf("Unable to read %s value %v due to error: %s", thetype, value, e.Error()) + } + if v != "" { + t.Fatalf("Bad value for %s value %v, wrote: %v, received: %v", thetype, value, s, v) + } + trans.Reset() + trans.Close() +} + +func TestWriteSimpleJSONProtocolList(t *testing.T) { + thetype := "list" + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + p.WriteListBegin(TType(DOUBLE), len(DOUBLE_VALUES)) + for _, value := range DOUBLE_VALUES { + if e := p.WriteDouble(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + } + p.WriteListEnd() + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) + } + str := trans.String() + str1 := new([]interface{}) + err := json.Unmarshal([]byte(str), str1) + if err != nil { + t.Fatalf("Unable to decode %s, wrote: %s", thetype, str) + } + l := *str1 + if len(l) < 2 { + t.Fatalf("List must be at least of length two to include metadata") + } + if int(l[0].(float64)) != DOUBLE { + t.Fatal("Invalid type for list, expected: ", DOUBLE, ", but was: ", l[0]) + } + if int(l[1].(float64)) != len(DOUBLE_VALUES) { + t.Fatal("Invalid length for list, expected: ", len(DOUBLE_VALUES), ", but was: ", l[1]) + } + for k, value := range DOUBLE_VALUES { + s := l[k+2] + if math.IsInf(value, 1) { + if s.(string) != JSON_INFINITY { + t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_INFINITY), str) + } + } else if math.IsInf(value, 0) { + if s.(string) != JSON_NEGATIVE_INFINITY { + t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY), str) + } + } else if math.IsNaN(value) { + if s.(string) != JSON_NAN { + t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NAN), str) + } + } else { + if s.(float64) != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s'", thetype, value, s) + } + } + trans.Reset() + } + trans.Close() +} + +func TestWriteSimpleJSONProtocolSet(t *testing.T) { + thetype := "set" + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + p.WriteSetBegin(TType(DOUBLE), len(DOUBLE_VALUES)) + for _, value := range DOUBLE_VALUES { + if e := p.WriteDouble(value); e != nil { + t.Fatalf("Unable to write %s value %v due to error: %s", thetype, value, e.Error()) + } + } + p.WriteSetEnd() + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) + } + str := trans.String() + str1 := new([]interface{}) + err := json.Unmarshal([]byte(str), str1) + if err != nil { + t.Fatalf("Unable to decode %s, wrote: %s", thetype, str) + } + l := *str1 + if len(l) < 2 { + t.Fatalf("Set must be at least of length two to include metadata") + } + if int(l[0].(float64)) != DOUBLE { + t.Fatal("Invalid type for set, expected: ", DOUBLE, ", but was: ", l[0]) + } + if int(l[1].(float64)) != len(DOUBLE_VALUES) { + t.Fatal("Invalid length for set, expected: ", len(DOUBLE_VALUES), ", but was: ", l[1]) + } + for k, value := range DOUBLE_VALUES { + s := l[k+2] + if math.IsInf(value, 1) { + if s.(string) != JSON_INFINITY { + t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_INFINITY), str) + } + } else if math.IsInf(value, 0) { + if s.(string) != JSON_NEGATIVE_INFINITY { + t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY), str) + } + } else if math.IsNaN(value) { + if s.(string) != JSON_NAN { + t.Fatalf("Bad value for %s at index %v %v, wrote: %q, expected: %q, originally wrote: %q", thetype, k, value, s, jsonQuote(JSON_NAN), str) + } + } else { + if s.(float64) != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s'", thetype, value, s) + } + } + trans.Reset() + } + trans.Close() +} + +func TestWriteSimpleJSONProtocolMap(t *testing.T) { + thetype := "map" + trans := NewTMemoryBuffer() + p := NewTSimpleJSONProtocol(trans) + p.WriteMapBegin(TType(I32), TType(DOUBLE), len(DOUBLE_VALUES)) + for k, value := range DOUBLE_VALUES { + if e := p.WriteI32(int32(k)); e != nil { + t.Fatalf("Unable to write %s key int32 value %v due to error: %s", thetype, k, e.Error()) + } + if e := p.WriteDouble(value); e != nil { + t.Fatalf("Unable to write %s value float64 value %v due to error: %s", thetype, value, e.Error()) + } + } + p.WriteMapEnd() + if e := p.Flush(context.Background()); e != nil { + t.Fatalf("Unable to write %s due to error flushing: %s", thetype, e.Error()) + } + str := trans.String() + if str[0] != '[' || str[len(str)-1] != ']' { + t.Fatalf("Bad value for %s, wrote: %v, in go: %v", thetype, str, DOUBLE_VALUES) + } + l := strings.Split(str[1:len(str)-1], ",") + if len(l) < 3 { + t.Fatal("Expected list of at least length 3 for map for metadata, but was of length ", len(l)) + } + expectedKeyType, _ := strconv.Atoi(l[0]) + expectedValueType, _ := strconv.Atoi(l[1]) + expectedSize, _ := strconv.Atoi(l[2]) + if expectedKeyType != I32 { + t.Fatal("Expected map key type ", I32, ", but was ", l[0]) + } + if expectedValueType != DOUBLE { + t.Fatal("Expected map value type ", DOUBLE, ", but was ", l[1]) + } + if expectedSize != len(DOUBLE_VALUES) { + t.Fatal("Expected map size of ", len(DOUBLE_VALUES), ", but was ", l[2]) + } + for k, value := range DOUBLE_VALUES { + strk := l[k*2+3] + strv := l[k*2+4] + ik, err := strconv.Atoi(strk) + if err != nil { + t.Fatalf("Bad value for %s index %v, wrote: %v, expected: %v, error: %s", thetype, k, strk, string(k), err.Error()) + } + if ik != k { + t.Fatalf("Bad value for %s index %v, wrote: %v, expected: %v", thetype, k, strk, k) + } + s := strv + if math.IsInf(value, 1) { + if s != jsonQuote(JSON_INFINITY) { + t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_INFINITY)) + } + } else if math.IsInf(value, 0) { + if s != jsonQuote(JSON_NEGATIVE_INFINITY) { + t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_NEGATIVE_INFINITY)) + } + } else if math.IsNaN(value) { + if s != jsonQuote(JSON_NAN) { + t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected: %v", thetype, k, value, s, jsonQuote(JSON_NAN)) + } + } else { + expected := strconv.FormatFloat(value, 'g', 10, 64) + if s != expected { + t.Fatalf("Bad value for %s at index %v %v, wrote: %v, expected %v", thetype, k, value, s, expected) + } + v := float64(0) + if err := json.Unmarshal([]byte(s), &v); err != nil || v != value { + t.Fatalf("Bad json-decoded value for %s %v, wrote: '%s', expected: '%v'", thetype, value, s, v) + } + } + trans.Reset() + } + trans.Close() +} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/simple_server.go b/vendor/github.com/apache/thrift/lib/go/thrift/simple_server.go similarity index 77% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/simple_server.go rename to vendor/github.com/apache/thrift/lib/go/thrift/simple_server.go index bdf4428..6035802 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/simple_server.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/simple_server.go @@ -22,13 +22,19 @@ package thrift import ( "log" "runtime/debug" + "sync" "sync/atomic" ) -// Simple, non-concurrent server for testing. +/* + * This is not a typical TSimpleServer as it is not blocked after accept a socket. + * It is more like a TThreadedServer that can handle different connections in different goroutines. + * This will work if golang user implements a conn-pool like thing in client side. + */ type TSimpleServer struct { - quit chan struct{} - stopped int64 + closed int32 + wg sync.WaitGroup + mu sync.Mutex processorFactory TProcessorFactory serverTransport TServerTransport @@ -88,7 +94,6 @@ func NewTSimpleServerFactory6(processorFactory TProcessorFactory, serverTranspor outputTransportFactory: outputTransportFactory, inputProtocolFactory: inputProtocolFactory, outputProtocolFactory: outputProtocolFactory, - quit: make(chan struct{}, 1), } } @@ -120,23 +125,37 @@ func (p *TSimpleServer) Listen() error { return p.serverTransport.Listen() } +func (p *TSimpleServer) innerAccept() (int32, error) { + client, err := p.serverTransport.Accept() + p.mu.Lock() + defer p.mu.Unlock() + closed := atomic.LoadInt32(&p.closed) + if closed != 0 { + return closed, nil + } + if err != nil { + return 0, err + } + if client != nil { + p.wg.Add(1) + go func() { + defer p.wg.Done() + if err := p.processRequests(client); err != nil { + log.Println("error processing request:", err) + } + }() + } + return 0, nil +} + func (p *TSimpleServer) AcceptLoop() error { for { - client, err := p.serverTransport.Accept() + closed, err := p.innerAccept() if err != nil { - select { - case <-p.quit: - return nil - default: - } return err } - if client != nil { - go func() { - if err := p.processRequests(client); err != nil { - log.Println("error processing request:", err) - } - }() + if closed != 0 { + return nil } } } @@ -151,17 +170,27 @@ func (p *TSimpleServer) Serve() error { } func (p *TSimpleServer) Stop() error { - if atomic.CompareAndSwapInt64(&p.stopped, 0, 1) { - p.quit <- struct{}{} - p.serverTransport.Interrupt() + p.mu.Lock() + defer p.mu.Unlock() + if atomic.LoadInt32(&p.closed) != 0 { + return nil } + atomic.StoreInt32(&p.closed, 1) + p.serverTransport.Interrupt() + p.wg.Wait() return nil } func (p *TSimpleServer) processRequests(client TTransport) error { processor := p.processorFactory.GetProcessor(client) - inputTransport := p.inputTransportFactory.GetTransport(client) - outputTransport := p.outputTransportFactory.GetTransport(client) + inputTransport, err := p.inputTransportFactory.GetTransport(client) + if err != nil { + return err + } + outputTransport, err := p.outputTransportFactory.GetTransport(client) + if err != nil { + return err + } inputProtocol := p.inputProtocolFactory.GetProtocol(inputTransport) outputProtocol := p.outputProtocolFactory.GetProtocol(outputTransport) defer func() { @@ -169,6 +198,7 @@ func (p *TSimpleServer) processRequests(client TTransport) error { log.Printf("panic in processor: %s: %s", e, debug.Stack()) } }() + if inputTransport != nil { defer inputTransport.Close() } @@ -176,13 +206,19 @@ func (p *TSimpleServer) processRequests(client TTransport) error { defer outputTransport.Close() } for { - ok, err := processor.Process(inputProtocol, outputProtocol) + if atomic.LoadInt32(&p.closed) != 0 { + return nil + } + + ok, err := processor.Process(defaultCtx, inputProtocol, outputProtocol) if err, ok := err.(TTransportException); ok && err.TypeId() == END_OF_FILE { return nil } else if err != nil { - log.Printf("error processing request: %s", err) return err } + if err, ok := err.(TApplicationException); ok && err.TypeId() == UNKNOWN_METHOD { + continue + } if !ok { break } diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/simple_server_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/simple_server_test.go new file mode 100644 index 0000000..58149a8 --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/simple_server_test.go @@ -0,0 +1,156 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "testing" + "errors" + "runtime" +) + +type mockServerTransport struct { + ListenFunc func() error + AcceptFunc func() (TTransport, error) + CloseFunc func() error + InterruptFunc func() error +} + +func (m *mockServerTransport) Listen() error { + return m.ListenFunc() +} + +func (m *mockServerTransport) Accept() (TTransport, error) { + return m.AcceptFunc() +} + +func (m *mockServerTransport) Close() error { + return m.CloseFunc() +} + +func (m *mockServerTransport) Interrupt() error { + return m.InterruptFunc() +} + +type mockTTransport struct { + TTransport +} + +func (m *mockTTransport) Close() error { + return nil +} + +func TestMultipleStop(t *testing.T) { + proc := &mockProcessor{ + ProcessFunc: func(in, out TProtocol) (bool, TException) { + return false, nil + }, + } + + var interruptCalled bool + c := make(chan struct{}) + trans := &mockServerTransport{ + ListenFunc: func() error { + return nil + }, + AcceptFunc: func() (TTransport, error) { + <-c + return nil, nil + }, + CloseFunc: func() error { + c <- struct{}{} + return nil + }, + InterruptFunc: func() error { + interruptCalled = true + return nil + }, + } + + serv := NewTSimpleServer2(proc, trans) + go serv.Serve() + serv.Stop() + if !interruptCalled { + t.Error("first server transport should have been interrupted") + } + + serv = NewTSimpleServer2(proc, trans) + interruptCalled = false + go serv.Serve() + serv.Stop() + if !interruptCalled { + t.Error("second server transport should have been interrupted") + } +} + +func TestWaitRace(t *testing.T) { + proc := &mockProcessor{ + ProcessFunc: func(in, out TProtocol) (bool, TException) { + return false, nil + }, + } + + trans := &mockServerTransport{ + ListenFunc: func() error { + return nil + }, + AcceptFunc: func() (TTransport, error) { + return &mockTTransport{}, nil + }, + CloseFunc: func() error { + return nil + }, + InterruptFunc: func() error { + return nil + }, + } + + serv := NewTSimpleServer2(proc, trans) + go serv.Serve() + runtime.Gosched() + serv.Stop() +} + +func TestNoHangDuringStopFromDanglingLockAcquireDuringAcceptLoop(t *testing.T) { + proc := &mockProcessor{ + ProcessFunc: func(in, out TProtocol) (bool, TException) { + return false, nil + }, + } + + trans := &mockServerTransport{ + ListenFunc: func() error { + return nil + }, + AcceptFunc: func() (TTransport, error) { + return nil, errors.New("no sir") + }, + CloseFunc: func() error { + return nil + }, + InterruptFunc: func() error { + return nil + }, + } + + serv := NewTSimpleServer2(proc, trans) + go serv.Serve() + runtime.Gosched() + serv.Stop() +} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/socket.go b/vendor/github.com/apache/thrift/lib/go/thrift/socket.go similarity index 98% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/socket.go rename to vendor/github.com/apache/thrift/lib/go/thrift/socket.go index 383b1fe..8854279 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/socket.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/socket.go @@ -20,6 +20,7 @@ package thrift import ( + "context" "net" "time" ) @@ -148,7 +149,7 @@ func (p *TSocket) Write(buf []byte) (int, error) { return p.conn.Write(buf) } -func (p *TSocket) Flush() error { +func (p *TSocket) Flush(ctx context.Context) error { return nil } diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/ssl_server_socket.go b/vendor/github.com/apache/thrift/lib/go/thrift/ssl_server_socket.go similarity index 97% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/ssl_server_socket.go rename to vendor/github.com/apache/thrift/lib/go/thrift/ssl_server_socket.go index 0615528..907afca 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/ssl_server_socket.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/ssl_server_socket.go @@ -38,6 +38,9 @@ func NewTSSLServerSocket(listenAddr string, cfg *tls.Config) (*TSSLServerSocket, } func NewTSSLServerSocketTimeout(listenAddr string, cfg *tls.Config, clientTimeout time.Duration) (*TSSLServerSocket, error) { + if cfg.MinVersion == 0 { + cfg.MinVersion = tls.VersionTLS10 + } addr, err := net.ResolveTCPAddr("tcp", listenAddr) if err != nil { return nil, err diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/ssl_socket.go b/vendor/github.com/apache/thrift/lib/go/thrift/ssl_socket.go similarity index 92% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/ssl_socket.go rename to vendor/github.com/apache/thrift/lib/go/thrift/ssl_socket.go index 86a68a3..ba63377 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/ssl_socket.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/ssl_socket.go @@ -20,6 +20,7 @@ package thrift import ( + "context" "crypto/tls" "net" "time" @@ -48,6 +49,9 @@ func NewTSSLSocket(hostPort string, cfg *tls.Config) (*TSSLSocket, error) { // NewTSSLSocketTimeout creates a net.Conn-backed TTransport, given a host and port // it also accepts a tls Configuration and a timeout as a time.Duration func NewTSSLSocketTimeout(hostPort string, cfg *tls.Config, timeout time.Duration) (*TSSLSocket, error) { + if cfg.MinVersion == 0 { + cfg.MinVersion = tls.VersionTLS10 + } return &TSSLSocket{hostPort: hostPort, timeout: timeout, cfg: cfg}, nil } @@ -87,7 +91,8 @@ func (p *TSSLSocket) Open() error { // If we have a hostname, we need to pass the hostname to tls.Dial for // certificate hostname checks. if p.hostPort != "" { - if p.conn, err = tls.Dial("tcp", p.hostPort, p.cfg); err != nil { + if p.conn, err = tls.DialWithDialer(&net.Dialer{ + Timeout: p.timeout}, "tcp", p.hostPort, p.cfg); err != nil { return NewTTransportException(NOT_OPEN, err.Error()) } } else { @@ -103,7 +108,8 @@ func (p *TSSLSocket) Open() error { if len(p.addr.String()) == 0 { return NewTTransportException(NOT_OPEN, "Cannot open bad address.") } - if p.conn, err = tls.Dial(p.addr.Network(), p.addr.String(), p.cfg); err != nil { + if p.conn, err = tls.DialWithDialer(&net.Dialer{ + Timeout: p.timeout}, p.addr.Network(), p.addr.String(), p.cfg); err != nil { return NewTTransportException(NOT_OPEN, err.Error()) } } @@ -153,7 +159,7 @@ func (p *TSSLSocket) Write(buf []byte) (int, error) { return p.conn.Write(buf) } -func (p *TSSLSocket) Flush() error { +func (p *TSSLSocket) Flush(ctx context.Context) error { return nil } diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/transport.go similarity index 93% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/transport.go rename to vendor/github.com/apache/thrift/lib/go/thrift/transport.go index 70a85a8..ba2738a 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/transport.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/transport.go @@ -20,6 +20,7 @@ package thrift import ( + "context" "errors" "io" ) @@ -30,6 +31,10 @@ type Flusher interface { Flush() (err error) } +type ContextFlusher interface { + Flush(ctx context.Context) (err error) +} + type ReadSizeProvider interface { RemainingBytes() (num_bytes uint64) } @@ -37,7 +42,7 @@ type ReadSizeProvider interface { // Encapsulates the I/O layer type TTransport interface { io.ReadWriteCloser - Flusher + ContextFlusher ReadSizeProvider // Opens the transport for communication @@ -60,6 +65,6 @@ type TRichTransport interface { io.ByteReader io.ByteWriter stringWriter - Flusher + ContextFlusher ReadSizeProvider } diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/transport_exception.go b/vendor/github.com/apache/thrift/lib/go/thrift/transport_exception.go similarity index 100% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/transport_exception.go rename to vendor/github.com/apache/thrift/lib/go/thrift/transport_exception.go diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/transport_exception_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/transport_exception_test.go new file mode 100644 index 0000000..b44314f --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/transport_exception_test.go @@ -0,0 +1,60 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "fmt" + "io" + + "testing" +) + +type timeout struct{ timedout bool } + +func (t *timeout) Timeout() bool { + return t.timedout +} + +func (t *timeout) Error() string { + return fmt.Sprintf("Timeout: %v", t.timedout) +} + +func TestTExceptionTimeout(t *testing.T) { + timeout := &timeout{true} + exception := NewTTransportExceptionFromError(timeout) + if timeout.Error() != exception.Error() { + t.Fatalf("Error did not match: expected %q, got %q", timeout.Error(), exception.Error()) + } + + if exception.TypeId() != TIMED_OUT { + t.Fatalf("TypeId was not TIMED_OUT: expected %v, got %v", TIMED_OUT, exception.TypeId()) + } +} + +func TestTExceptionEOF(t *testing.T) { + exception := NewTTransportExceptionFromError(io.EOF) + if io.EOF.Error() != exception.Error() { + t.Fatalf("Error did not match: expected %q, got %q", io.EOF.Error(), exception.Error()) + } + + if exception.TypeId() != END_OF_FILE { + t.Fatalf("TypeId was not END_OF_FILE: expected %v, got %v", END_OF_FILE, exception.TypeId()) + } +} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/transport_factory.go b/vendor/github.com/apache/thrift/lib/go/thrift/transport_factory.go similarity index 89% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/transport_factory.go rename to vendor/github.com/apache/thrift/lib/go/thrift/transport_factory.go index 533d1b4..c805807 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/transport_factory.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/transport_factory.go @@ -24,14 +24,14 @@ package thrift // a ServerTransport and then may want to mutate them (i.e. create // a BufferedTransport from the underlying base transport) type TTransportFactory interface { - GetTransport(trans TTransport) TTransport + GetTransport(trans TTransport) (TTransport, error) } type tTransportFactory struct{} // Return a wrapped instance of the base Transport. -func (p *tTransportFactory) GetTransport(trans TTransport) TTransport { - return trans +func (p *tTransportFactory) GetTransport(trans TTransport) (TTransport, error) { + return trans, nil } func NewTTransportFactory() TTransportFactory { diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/transport_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/transport_test.go new file mode 100644 index 0000000..0127803 --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/transport_test.go @@ -0,0 +1,177 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "context" + "io" + "net" + "strconv" + "testing" +) + +const TRANSPORT_BINARY_DATA_SIZE = 4096 + +var ( + transport_bdata []byte // test data for writing; same as data + transport_header map[string]string +) + +func init() { + transport_bdata = make([]byte, TRANSPORT_BINARY_DATA_SIZE) + for i := 0; i < TRANSPORT_BINARY_DATA_SIZE; i++ { + transport_bdata[i] = byte((i + 'a') % 255) + } + transport_header = map[string]string{"key": "User-Agent", + "value": "Mozilla/5.0 (Windows NT 6.2; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/32.0.1667.0 Safari/537.36"} +} + +func TransportTest(t *testing.T, writeTrans TTransport, readTrans TTransport) { + buf := make([]byte, TRANSPORT_BINARY_DATA_SIZE) + if !writeTrans.IsOpen() { + t.Fatalf("Transport %T not open: %s", writeTrans, writeTrans) + } + if !readTrans.IsOpen() { + t.Fatalf("Transport %T not open: %s", readTrans, readTrans) + } + _, err := writeTrans.Write(transport_bdata) + if err != nil { + t.Fatalf("Transport %T cannot write binary data of length %d: %s", writeTrans, len(transport_bdata), err) + } + err = writeTrans.Flush(context.Background()) + if err != nil { + t.Fatalf("Transport %T cannot flush write of binary data: %s", writeTrans, err) + } + n, err := io.ReadFull(readTrans, buf) + if err != nil { + t.Errorf("Transport %T cannot read binary data of length %d: %s", readTrans, TRANSPORT_BINARY_DATA_SIZE, err) + } + if n != TRANSPORT_BINARY_DATA_SIZE { + t.Errorf("Transport %T read only %d instead of %d bytes of binary data", readTrans, n, TRANSPORT_BINARY_DATA_SIZE) + } + for k, v := range buf { + if v != transport_bdata[k] { + t.Fatalf("Transport %T read %d instead of %d for index %d of binary data 2", readTrans, v, transport_bdata[k], k) + } + } + _, err = writeTrans.Write(transport_bdata) + if err != nil { + t.Fatalf("Transport %T cannot write binary data 2 of length %d: %s", writeTrans, len(transport_bdata), err) + } + err = writeTrans.Flush(context.Background()) + if err != nil { + t.Fatalf("Transport %T cannot flush write binary data 2: %s", writeTrans, err) + } + buf = make([]byte, TRANSPORT_BINARY_DATA_SIZE) + read := 1 + for n = 0; n < TRANSPORT_BINARY_DATA_SIZE && read != 0; { + read, err = readTrans.Read(buf[n:]) + if err != nil { + t.Errorf("Transport %T cannot read binary data 2 of total length %d from offset %d: %s", readTrans, TRANSPORT_BINARY_DATA_SIZE, n, err) + } + n += read + } + if n != TRANSPORT_BINARY_DATA_SIZE { + t.Errorf("Transport %T read only %d instead of %d bytes of binary data 2", readTrans, n, TRANSPORT_BINARY_DATA_SIZE) + } + for k, v := range buf { + if v != transport_bdata[k] { + t.Fatalf("Transport %T read %d instead of %d for index %d of binary data 2", readTrans, v, transport_bdata[k], k) + } + } +} + +func TransportHeaderTest(t *testing.T, writeTrans TTransport, readTrans TTransport) { + buf := make([]byte, TRANSPORT_BINARY_DATA_SIZE) + if !writeTrans.IsOpen() { + t.Fatalf("Transport %T not open: %s", writeTrans, writeTrans) + } + if !readTrans.IsOpen() { + t.Fatalf("Transport %T not open: %s", readTrans, readTrans) + } + // Need to assert type of TTransport to THttpClient to expose the Setter + httpWPostTrans := writeTrans.(*THttpClient) + httpWPostTrans.SetHeader(transport_header["key"], transport_header["value"]) + + _, err := writeTrans.Write(transport_bdata) + if err != nil { + t.Fatalf("Transport %T cannot write binary data of length %d: %s", writeTrans, len(transport_bdata), err) + } + err = writeTrans.Flush(context.Background()) + if err != nil { + t.Fatalf("Transport %T cannot flush write of binary data: %s", writeTrans, err) + } + // Need to assert type of TTransport to THttpClient to expose the Getter + httpRPostTrans := readTrans.(*THttpClient) + readHeader := httpRPostTrans.GetHeader(transport_header["key"]) + if err != nil { + t.Errorf("Transport %T cannot read HTTP Header Value", httpRPostTrans) + } + + if transport_header["value"] != readHeader { + t.Errorf("Expected HTTP Header Value %s, got %s", transport_header["value"], readHeader) + } + n, err := io.ReadFull(readTrans, buf) + if err != nil { + t.Errorf("Transport %T cannot read binary data of length %d: %s", readTrans, TRANSPORT_BINARY_DATA_SIZE, err) + } + if n != TRANSPORT_BINARY_DATA_SIZE { + t.Errorf("Transport %T read only %d instead of %d bytes of binary data", readTrans, n, TRANSPORT_BINARY_DATA_SIZE) + } + for k, v := range buf { + if v != transport_bdata[k] { + t.Fatalf("Transport %T read %d instead of %d for index %d of binary data 2", readTrans, v, transport_bdata[k], k) + } + } +} + +func CloseTransports(t *testing.T, readTrans TTransport, writeTrans TTransport) { + err := readTrans.Close() + if err != nil { + t.Errorf("Transport %T cannot close read transport: %s", readTrans, err) + } + if writeTrans != readTrans { + err = writeTrans.Close() + if err != nil { + t.Errorf("Transport %T cannot close write transport: %s", writeTrans, err) + } + } +} + +func FindAvailableTCPServerPort(startPort int) (net.Addr, error) { + for i := startPort; i < 65535; i++ { + s := "127.0.0.1:" + strconv.Itoa(i) + l, err := net.Listen("tcp", s) + if err == nil { + l.Close() + return net.ResolveTCPAddr("tcp", s) + } + } + return nil, NewTTransportException(UNKNOWN_TRANSPORT_EXCEPTION, "Could not find available server port") +} + +func valueInSlice(value string, slice []string) bool { + for _, v := range slice { + if value == v { + return true + } + } + return false +} diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/type.go b/vendor/github.com/apache/thrift/lib/go/thrift/type.go similarity index 100% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/type.go rename to vendor/github.com/apache/thrift/lib/go/thrift/type.go diff --git a/vendor/git.apache.org/thrift.git/lib/go/thrift/zlib_transport.go b/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport.go similarity index 78% rename from vendor/git.apache.org/thrift.git/lib/go/thrift/zlib_transport.go rename to vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport.go index e47455f..f3d4267 100644 --- a/vendor/git.apache.org/thrift.git/lib/go/thrift/zlib_transport.go +++ b/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport.go @@ -21,13 +21,15 @@ package thrift import ( "compress/zlib" + "context" "io" "log" ) // TZlibTransportFactory is a factory for TZlibTransport instances type TZlibTransportFactory struct { - level int + level int + factory TTransportFactory } // TZlibTransport is a TTransport implementation that makes use of zlib compression. @@ -38,14 +40,27 @@ type TZlibTransport struct { } // GetTransport constructs a new instance of NewTZlibTransport -func (p *TZlibTransportFactory) GetTransport(trans TTransport) TTransport { - t, _ := NewTZlibTransport(trans, p.level) - return t +func (p *TZlibTransportFactory) GetTransport(trans TTransport) (TTransport, error) { + if p.factory != nil { + // wrap other factory + var err error + trans, err = p.factory.GetTransport(trans) + if err != nil { + return nil, err + } + } + return NewTZlibTransport(trans, p.level) } // NewTZlibTransportFactory constructs a new instance of NewTZlibTransportFactory func NewTZlibTransportFactory(level int) *TZlibTransportFactory { - return &TZlibTransportFactory{level: level} + return &TZlibTransportFactory{level: level, factory: nil} +} + +// NewTZlibTransportFactory constructs a new instance of TZlibTransportFactory +// as a wrapper over existing transport factory +func NewTZlibTransportFactoryWithFactory(level int, factory TTransportFactory) *TZlibTransportFactory { + return &TZlibTransportFactory{level: level, factory: factory} } // NewTZlibTransport constructs a new instance of TZlibTransport @@ -77,11 +92,11 @@ func (z *TZlibTransport) Close() error { } // Flush flushes the writer and its underlying transport. -func (z *TZlibTransport) Flush() error { +func (z *TZlibTransport) Flush(ctx context.Context) error { if err := z.writer.Flush(); err != nil { return err } - return z.transport.Flush() + return z.transport.Flush(ctx) } // IsOpen returns true if the transport is open diff --git a/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport_test.go b/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport_test.go new file mode 100644 index 0000000..3c6f11e --- /dev/null +++ b/vendor/github.com/apache/thrift/lib/go/thrift/zlib_transport_test.go @@ -0,0 +1,62 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package thrift + +import ( + "compress/zlib" + "testing" +) + +func TestZlibTransport(t *testing.T) { + trans, err := NewTZlibTransport(NewTMemoryBuffer(), zlib.BestCompression) + if err != nil { + t.Fatal(err) + } + TransportTest(t, trans, trans) +} + +type DummyTransportFactory struct{} + +func (p *DummyTransportFactory) GetTransport(trans TTransport) (TTransport, error) { + return NewTMemoryBuffer(), nil +} + +func TestZlibFactoryTransportWithFactory(t *testing.T) { + factory := NewTZlibTransportFactoryWithFactory( + zlib.BestCompression, + &DummyTransportFactory{}, + ) + buffer := NewTMemoryBuffer() + trans, err := factory.GetTransport(buffer) + if err != nil { + t.Fatal(err) + } + TransportTest(t, trans, trans) +} + +func TestZlibFactoryTransportWithoutFactory(t *testing.T) { + factory := NewTZlibTransportFactoryWithFactory(zlib.BestCompression, nil) + buffer := NewTMemoryBuffer() + trans, err := factory.GetTransport(buffer) + if err != nil { + t.Fatal(err) + } + TransportTest(t, trans, trans) +} diff --git a/vendor/github.com/davecgh/go-spew/.gitignore b/vendor/github.com/davecgh/go-spew/.gitignore new file mode 100644 index 0000000..0026861 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/.gitignore @@ -0,0 +1,22 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe diff --git a/vendor/github.com/davecgh/go-spew/.travis.yml b/vendor/github.com/davecgh/go-spew/.travis.yml new file mode 100644 index 0000000..984e073 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/.travis.yml @@ -0,0 +1,14 @@ +language: go +go: + - 1.5.4 + - 1.6.3 + - 1.7 +install: + - go get -v golang.org/x/tools/cmd/cover +script: + - go test -v -tags=safe ./spew + - go test -v -tags=testcgo ./spew -covermode=count -coverprofile=profile.cov +after_success: + - go get -v github.com/mattn/goveralls + - export PATH=$PATH:$HOME/gopath/bin + - goveralls -coverprofile=profile.cov -service=travis-ci diff --git a/vendor/github.com/davecgh/go-spew/LICENSE b/vendor/github.com/davecgh/go-spew/LICENSE new file mode 100644 index 0000000..c836416 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/LICENSE @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2012-2016 Dave Collins + +Permission to use, copy, modify, and distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/vendor/github.com/davecgh/go-spew/README.md b/vendor/github.com/davecgh/go-spew/README.md new file mode 100644 index 0000000..2624304 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/README.md @@ -0,0 +1,205 @@ +go-spew +======= + +[![Build Status](https://img.shields.io/travis/davecgh/go-spew.svg)] +(https://travis-ci.org/davecgh/go-spew) [![ISC License] +(http://img.shields.io/badge/license-ISC-blue.svg)](http://copyfree.org) [![Coverage Status] +(https://img.shields.io/coveralls/davecgh/go-spew.svg)] +(https://coveralls.io/r/davecgh/go-spew?branch=master) + + +Go-spew implements a deep pretty printer for Go data structures to aid in +debugging. A comprehensive suite of tests with 100% test coverage is provided +to ensure proper functionality. See `test_coverage.txt` for the gocov coverage +report. Go-spew is licensed under the liberal ISC license, so it may be used in +open source or commercial projects. + +If you're interested in reading about how this package came to life and some +of the challenges involved in providing a deep pretty printer, there is a blog +post about it +[here](https://web.archive.org/web/20160304013555/https://blog.cyphertite.com/go-spew-a-journey-into-dumping-go-data-structures/). + +## Documentation + +[![GoDoc](https://img.shields.io/badge/godoc-reference-blue.svg)] +(http://godoc.org/github.com/davecgh/go-spew/spew) + +Full `go doc` style documentation for the project can be viewed online without +installing this package by using the excellent GoDoc site here: +http://godoc.org/github.com/davecgh/go-spew/spew + +You can also view the documentation locally once the package is installed with +the `godoc` tool by running `godoc -http=":6060"` and pointing your browser to +http://localhost:6060/pkg/github.com/davecgh/go-spew/spew + +## Installation + +```bash +$ go get -u github.com/davecgh/go-spew/spew +``` + +## Quick Start + +Add this import line to the file you're working in: + +```Go +import "github.com/davecgh/go-spew/spew" +``` + +To dump a variable with full newlines, indentation, type, and pointer +information use Dump, Fdump, or Sdump: + +```Go +spew.Dump(myVar1, myVar2, ...) +spew.Fdump(someWriter, myVar1, myVar2, ...) +str := spew.Sdump(myVar1, myVar2, ...) +``` + +Alternatively, if you would prefer to use format strings with a compacted inline +printing style, use the convenience wrappers Printf, Fprintf, etc with %v (most +compact), %+v (adds pointer addresses), %#v (adds types), or %#+v (adds types +and pointer addresses): + +```Go +spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2) +spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) +spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2) +spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) +``` + +## Debugging a Web Application Example + +Here is an example of how you can use `spew.Sdump()` to help debug a web application. Please be sure to wrap your output using the `html.EscapeString()` function for safety reasons. You should also only use this debugging technique in a development environment, never in production. + +```Go +package main + +import ( + "fmt" + "html" + "net/http" + + "github.com/davecgh/go-spew/spew" +) + +func handler(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/html") + fmt.Fprintf(w, "Hi there, %s!", r.URL.Path[1:]) + fmt.Fprintf(w, "") +} + +func main() { + http.HandleFunc("/", handler) + http.ListenAndServe(":8080", nil) +} +``` + +## Sample Dump Output + +``` +(main.Foo) { + unexportedField: (*main.Bar)(0xf84002e210)({ + flag: (main.Flag) flagTwo, + data: (uintptr) + }), + ExportedField: (map[interface {}]interface {}) { + (string) "one": (bool) true + } +} +([]uint8) { + 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... | + 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0| + 00000020 31 32 |12| +} +``` + +## Sample Formatter Output + +Double pointer to a uint8: +``` + %v: <**>5 + %+v: <**>(0xf8400420d0->0xf8400420c8)5 + %#v: (**uint8)5 + %#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5 +``` + +Pointer to circular struct with a uint8 field and a pointer to itself: +``` + %v: <*>{1 <*>} + %+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)} + %#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)} + %#+v: (*main.circular)(0xf84003e260){ui8:(uint8)1 c:(*main.circular)(0xf84003e260)} +``` + +## Configuration Options + +Configuration of spew is handled by fields in the ConfigState type. For +convenience, all of the top-level functions use a global state available via the +spew.Config global. + +It is also possible to create a ConfigState instance that provides methods +equivalent to the top-level functions. This allows concurrent configuration +options. See the ConfigState documentation for more details. + +``` +* Indent + String to use for each indentation level for Dump functions. + It is a single space by default. A popular alternative is "\t". + +* MaxDepth + Maximum number of levels to descend into nested data structures. + There is no limit by default. + +* DisableMethods + Disables invocation of error and Stringer interface methods. + Method invocation is enabled by default. + +* DisablePointerMethods + Disables invocation of error and Stringer interface methods on types + which only accept pointer receivers from non-pointer variables. This option + relies on access to the unsafe package, so it will not have any effect when + running in environments without access to the unsafe package such as Google + App Engine or with the "safe" build tag specified. + Pointer method invocation is enabled by default. + +* DisablePointerAddresses + DisablePointerAddresses specifies whether to disable the printing of + pointer addresses. This is useful when diffing data structures in tests. + +* DisableCapacities + DisableCapacities specifies whether to disable the printing of capacities + for arrays, slices, maps and channels. This is useful when diffing data + structures in tests. + +* ContinueOnMethod + Enables recursion into types after invoking error and Stringer interface + methods. Recursion after method invocation is disabled by default. + +* SortKeys + Specifies map keys should be sorted before being printed. Use + this to have a more deterministic, diffable output. Note that + only native types (bool, int, uint, floats, uintptr and string) + and types which implement error or Stringer interfaces are supported, + with other types sorted according to the reflect.Value.String() output + which guarantees display stability. Natural map order is used by + default. + +* SpewKeys + SpewKeys specifies that, as a last resort attempt, map keys should be + spewed to strings and sorted by those strings. This is only considered + if SortKeys is true. + +``` + +## Unsafe Package Dependency + +This package relies on the unsafe package to perform some of the more advanced +features, however it also supports a "limited" mode which allows it to work in +environments where the unsafe package is not available. By default, it will +operate in this mode on Google App Engine and when compiled with GopherJS. The +"safe" build tag may also be specified to force the package to build without +using the unsafe package. + +## License + +Go-spew is licensed under the [copyfree](http://copyfree.org) ISC License. diff --git a/vendor/github.com/davecgh/go-spew/cov_report.sh b/vendor/github.com/davecgh/go-spew/cov_report.sh new file mode 100644 index 0000000..9579497 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/cov_report.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# This script uses gocov to generate a test coverage report. +# The gocov tool my be obtained with the following command: +# go get github.com/axw/gocov/gocov +# +# It will be installed to $GOPATH/bin, so ensure that location is in your $PATH. + +# Check for gocov. +if ! type gocov >/dev/null 2>&1; then + echo >&2 "This script requires the gocov tool." + echo >&2 "You may obtain it with the following command:" + echo >&2 "go get github.com/axw/gocov/gocov" + exit 1 +fi + +# Only run the cgo tests if gcc is installed. +if type gcc >/dev/null 2>&1; then + (cd spew && gocov test -tags testcgo | gocov report) +else + (cd spew && gocov test | gocov report) +fi diff --git a/vendor/github.com/davecgh/go-spew/spew/bypass.go b/vendor/github.com/davecgh/go-spew/spew/bypass.go new file mode 100644 index 0000000..8a4a658 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/bypass.go @@ -0,0 +1,152 @@ +// Copyright (c) 2015-2016 Dave Collins +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// NOTE: Due to the following build constraints, this file will only be compiled +// when the code is not running on Google App Engine, compiled by GopherJS, and +// "-tags safe" is not added to the go build command line. The "disableunsafe" +// tag is deprecated and thus should not be used. +// +build !js,!appengine,!safe,!disableunsafe + +package spew + +import ( + "reflect" + "unsafe" +) + +const ( + // UnsafeDisabled is a build-time constant which specifies whether or + // not access to the unsafe package is available. + UnsafeDisabled = false + + // ptrSize is the size of a pointer on the current arch. + ptrSize = unsafe.Sizeof((*byte)(nil)) +) + +var ( + // offsetPtr, offsetScalar, and offsetFlag are the offsets for the + // internal reflect.Value fields. These values are valid before golang + // commit ecccf07e7f9d which changed the format. The are also valid + // after commit 82f48826c6c7 which changed the format again to mirror + // the original format. Code in the init function updates these offsets + // as necessary. + offsetPtr = uintptr(ptrSize) + offsetScalar = uintptr(0) + offsetFlag = uintptr(ptrSize * 2) + + // flagKindWidth and flagKindShift indicate various bits that the + // reflect package uses internally to track kind information. + // + // flagRO indicates whether or not the value field of a reflect.Value is + // read-only. + // + // flagIndir indicates whether the value field of a reflect.Value is + // the actual data or a pointer to the data. + // + // These values are valid before golang commit 90a7c3c86944 which + // changed their positions. Code in the init function updates these + // flags as necessary. + flagKindWidth = uintptr(5) + flagKindShift = uintptr(flagKindWidth - 1) + flagRO = uintptr(1 << 0) + flagIndir = uintptr(1 << 1) +) + +func init() { + // Older versions of reflect.Value stored small integers directly in the + // ptr field (which is named val in the older versions). Versions + // between commits ecccf07e7f9d and 82f48826c6c7 added a new field named + // scalar for this purpose which unfortunately came before the flag + // field, so the offset of the flag field is different for those + // versions. + // + // This code constructs a new reflect.Value from a known small integer + // and checks if the size of the reflect.Value struct indicates it has + // the scalar field. When it does, the offsets are updated accordingly. + vv := reflect.ValueOf(0xf00) + if unsafe.Sizeof(vv) == (ptrSize * 4) { + offsetScalar = ptrSize * 2 + offsetFlag = ptrSize * 3 + } + + // Commit 90a7c3c86944 changed the flag positions such that the low + // order bits are the kind. This code extracts the kind from the flags + // field and ensures it's the correct type. When it's not, the flag + // order has been changed to the newer format, so the flags are updated + // accordingly. + upf := unsafe.Pointer(uintptr(unsafe.Pointer(&vv)) + offsetFlag) + upfv := *(*uintptr)(upf) + flagKindMask := uintptr((1<>flagKindShift != uintptr(reflect.Int) { + flagKindShift = 0 + flagRO = 1 << 5 + flagIndir = 1 << 6 + + // Commit adf9b30e5594 modified the flags to separate the + // flagRO flag into two bits which specifies whether or not the + // field is embedded. This causes flagIndir to move over a bit + // and means that flagRO is the combination of either of the + // original flagRO bit and the new bit. + // + // This code detects the change by extracting what used to be + // the indirect bit to ensure it's set. When it's not, the flag + // order has been changed to the newer format, so the flags are + // updated accordingly. + if upfv&flagIndir == 0 { + flagRO = 3 << 5 + flagIndir = 1 << 7 + } + } +} + +// unsafeReflectValue converts the passed reflect.Value into a one that bypasses +// the typical safety restrictions preventing access to unaddressable and +// unexported data. It works by digging the raw pointer to the underlying +// value out of the protected value and generating a new unprotected (unsafe) +// reflect.Value to it. +// +// This allows us to check for implementations of the Stringer and error +// interfaces to be used for pretty printing ordinarily unaddressable and +// inaccessible values such as unexported struct fields. +func unsafeReflectValue(v reflect.Value) (rv reflect.Value) { + indirects := 1 + vt := v.Type() + upv := unsafe.Pointer(uintptr(unsafe.Pointer(&v)) + offsetPtr) + rvf := *(*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(&v)) + offsetFlag)) + if rvf&flagIndir != 0 { + vt = reflect.PtrTo(v.Type()) + indirects++ + } else if offsetScalar != 0 { + // The value is in the scalar field when it's not one of the + // reference types. + switch vt.Kind() { + case reflect.Uintptr: + case reflect.Chan: + case reflect.Func: + case reflect.Map: + case reflect.Ptr: + case reflect.UnsafePointer: + default: + upv = unsafe.Pointer(uintptr(unsafe.Pointer(&v)) + + offsetScalar) + } + } + + pv := reflect.NewAt(vt, upv) + rv = pv + for i := 0; i < indirects; i++ { + rv = rv.Elem() + } + return rv +} diff --git a/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go b/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go new file mode 100644 index 0000000..1fe3cf3 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/bypasssafe.go @@ -0,0 +1,38 @@ +// Copyright (c) 2015-2016 Dave Collins +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// NOTE: Due to the following build constraints, this file will only be compiled +// when the code is running on Google App Engine, compiled by GopherJS, or +// "-tags safe" is added to the go build command line. The "disableunsafe" +// tag is deprecated and thus should not be used. +// +build js appengine safe disableunsafe + +package spew + +import "reflect" + +const ( + // UnsafeDisabled is a build-time constant which specifies whether or + // not access to the unsafe package is available. + UnsafeDisabled = true +) + +// unsafeReflectValue typically converts the passed reflect.Value into a one +// that bypasses the typical safety restrictions preventing access to +// unaddressable and unexported data. However, doing this relies on access to +// the unsafe package. This is a stub version which simply returns the passed +// reflect.Value when the unsafe package is not available. +func unsafeReflectValue(v reflect.Value) reflect.Value { + return v +} diff --git a/vendor/github.com/davecgh/go-spew/spew/common.go b/vendor/github.com/davecgh/go-spew/spew/common.go new file mode 100644 index 0000000..7c519ff --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/common.go @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew + +import ( + "bytes" + "fmt" + "io" + "reflect" + "sort" + "strconv" +) + +// Some constants in the form of bytes to avoid string overhead. This mirrors +// the technique used in the fmt package. +var ( + panicBytes = []byte("(PANIC=") + plusBytes = []byte("+") + iBytes = []byte("i") + trueBytes = []byte("true") + falseBytes = []byte("false") + interfaceBytes = []byte("(interface {})") + commaNewlineBytes = []byte(",\n") + newlineBytes = []byte("\n") + openBraceBytes = []byte("{") + openBraceNewlineBytes = []byte("{\n") + closeBraceBytes = []byte("}") + asteriskBytes = []byte("*") + colonBytes = []byte(":") + colonSpaceBytes = []byte(": ") + openParenBytes = []byte("(") + closeParenBytes = []byte(")") + spaceBytes = []byte(" ") + pointerChainBytes = []byte("->") + nilAngleBytes = []byte("") + maxNewlineBytes = []byte("\n") + maxShortBytes = []byte("") + circularBytes = []byte("") + circularShortBytes = []byte("") + invalidAngleBytes = []byte("") + openBracketBytes = []byte("[") + closeBracketBytes = []byte("]") + percentBytes = []byte("%") + precisionBytes = []byte(".") + openAngleBytes = []byte("<") + closeAngleBytes = []byte(">") + openMapBytes = []byte("map[") + closeMapBytes = []byte("]") + lenEqualsBytes = []byte("len=") + capEqualsBytes = []byte("cap=") +) + +// hexDigits is used to map a decimal value to a hex digit. +var hexDigits = "0123456789abcdef" + +// catchPanic handles any panics that might occur during the handleMethods +// calls. +func catchPanic(w io.Writer, v reflect.Value) { + if err := recover(); err != nil { + w.Write(panicBytes) + fmt.Fprintf(w, "%v", err) + w.Write(closeParenBytes) + } +} + +// handleMethods attempts to call the Error and String methods on the underlying +// type the passed reflect.Value represents and outputes the result to Writer w. +// +// It handles panics in any called methods by catching and displaying the error +// as the formatted value. +func handleMethods(cs *ConfigState, w io.Writer, v reflect.Value) (handled bool) { + // We need an interface to check if the type implements the error or + // Stringer interface. However, the reflect package won't give us an + // interface on certain things like unexported struct fields in order + // to enforce visibility rules. We use unsafe, when it's available, + // to bypass these restrictions since this package does not mutate the + // values. + if !v.CanInterface() { + if UnsafeDisabled { + return false + } + + v = unsafeReflectValue(v) + } + + // Choose whether or not to do error and Stringer interface lookups against + // the base type or a pointer to the base type depending on settings. + // Technically calling one of these methods with a pointer receiver can + // mutate the value, however, types which choose to satisify an error or + // Stringer interface with a pointer receiver should not be mutating their + // state inside these interface methods. + if !cs.DisablePointerMethods && !UnsafeDisabled && !v.CanAddr() { + v = unsafeReflectValue(v) + } + if v.CanAddr() { + v = v.Addr() + } + + // Is it an error or Stringer? + switch iface := v.Interface().(type) { + case error: + defer catchPanic(w, v) + if cs.ContinueOnMethod { + w.Write(openParenBytes) + w.Write([]byte(iface.Error())) + w.Write(closeParenBytes) + w.Write(spaceBytes) + return false + } + + w.Write([]byte(iface.Error())) + return true + + case fmt.Stringer: + defer catchPanic(w, v) + if cs.ContinueOnMethod { + w.Write(openParenBytes) + w.Write([]byte(iface.String())) + w.Write(closeParenBytes) + w.Write(spaceBytes) + return false + } + w.Write([]byte(iface.String())) + return true + } + return false +} + +// printBool outputs a boolean value as true or false to Writer w. +func printBool(w io.Writer, val bool) { + if val { + w.Write(trueBytes) + } else { + w.Write(falseBytes) + } +} + +// printInt outputs a signed integer value to Writer w. +func printInt(w io.Writer, val int64, base int) { + w.Write([]byte(strconv.FormatInt(val, base))) +} + +// printUint outputs an unsigned integer value to Writer w. +func printUint(w io.Writer, val uint64, base int) { + w.Write([]byte(strconv.FormatUint(val, base))) +} + +// printFloat outputs a floating point value using the specified precision, +// which is expected to be 32 or 64bit, to Writer w. +func printFloat(w io.Writer, val float64, precision int) { + w.Write([]byte(strconv.FormatFloat(val, 'g', -1, precision))) +} + +// printComplex outputs a complex value using the specified float precision +// for the real and imaginary parts to Writer w. +func printComplex(w io.Writer, c complex128, floatPrecision int) { + r := real(c) + w.Write(openParenBytes) + w.Write([]byte(strconv.FormatFloat(r, 'g', -1, floatPrecision))) + i := imag(c) + if i >= 0 { + w.Write(plusBytes) + } + w.Write([]byte(strconv.FormatFloat(i, 'g', -1, floatPrecision))) + w.Write(iBytes) + w.Write(closeParenBytes) +} + +// printHexPtr outputs a uintptr formatted as hexidecimal with a leading '0x' +// prefix to Writer w. +func printHexPtr(w io.Writer, p uintptr) { + // Null pointer. + num := uint64(p) + if num == 0 { + w.Write(nilAngleBytes) + return + } + + // Max uint64 is 16 bytes in hex + 2 bytes for '0x' prefix + buf := make([]byte, 18) + + // It's simpler to construct the hex string right to left. + base := uint64(16) + i := len(buf) - 1 + for num >= base { + buf[i] = hexDigits[num%base] + num /= base + i-- + } + buf[i] = hexDigits[num] + + // Add '0x' prefix. + i-- + buf[i] = 'x' + i-- + buf[i] = '0' + + // Strip unused leading bytes. + buf = buf[i:] + w.Write(buf) +} + +// valuesSorter implements sort.Interface to allow a slice of reflect.Value +// elements to be sorted. +type valuesSorter struct { + values []reflect.Value + strings []string // either nil or same len and values + cs *ConfigState +} + +// newValuesSorter initializes a valuesSorter instance, which holds a set of +// surrogate keys on which the data should be sorted. It uses flags in +// ConfigState to decide if and how to populate those surrogate keys. +func newValuesSorter(values []reflect.Value, cs *ConfigState) sort.Interface { + vs := &valuesSorter{values: values, cs: cs} + if canSortSimply(vs.values[0].Kind()) { + return vs + } + if !cs.DisableMethods { + vs.strings = make([]string, len(values)) + for i := range vs.values { + b := bytes.Buffer{} + if !handleMethods(cs, &b, vs.values[i]) { + vs.strings = nil + break + } + vs.strings[i] = b.String() + } + } + if vs.strings == nil && cs.SpewKeys { + vs.strings = make([]string, len(values)) + for i := range vs.values { + vs.strings[i] = Sprintf("%#v", vs.values[i].Interface()) + } + } + return vs +} + +// canSortSimply tests whether a reflect.Kind is a primitive that can be sorted +// directly, or whether it should be considered for sorting by surrogate keys +// (if the ConfigState allows it). +func canSortSimply(kind reflect.Kind) bool { + // This switch parallels valueSortLess, except for the default case. + switch kind { + case reflect.Bool: + return true + case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: + return true + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: + return true + case reflect.Float32, reflect.Float64: + return true + case reflect.String: + return true + case reflect.Uintptr: + return true + case reflect.Array: + return true + } + return false +} + +// Len returns the number of values in the slice. It is part of the +// sort.Interface implementation. +func (s *valuesSorter) Len() int { + return len(s.values) +} + +// Swap swaps the values at the passed indices. It is part of the +// sort.Interface implementation. +func (s *valuesSorter) Swap(i, j int) { + s.values[i], s.values[j] = s.values[j], s.values[i] + if s.strings != nil { + s.strings[i], s.strings[j] = s.strings[j], s.strings[i] + } +} + +// valueSortLess returns whether the first value should sort before the second +// value. It is used by valueSorter.Less as part of the sort.Interface +// implementation. +func valueSortLess(a, b reflect.Value) bool { + switch a.Kind() { + case reflect.Bool: + return !a.Bool() && b.Bool() + case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: + return a.Int() < b.Int() + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: + return a.Uint() < b.Uint() + case reflect.Float32, reflect.Float64: + return a.Float() < b.Float() + case reflect.String: + return a.String() < b.String() + case reflect.Uintptr: + return a.Uint() < b.Uint() + case reflect.Array: + // Compare the contents of both arrays. + l := a.Len() + for i := 0; i < l; i++ { + av := a.Index(i) + bv := b.Index(i) + if av.Interface() == bv.Interface() { + continue + } + return valueSortLess(av, bv) + } + } + return a.String() < b.String() +} + +// Less returns whether the value at index i should sort before the +// value at index j. It is part of the sort.Interface implementation. +func (s *valuesSorter) Less(i, j int) bool { + if s.strings == nil { + return valueSortLess(s.values[i], s.values[j]) + } + return s.strings[i] < s.strings[j] +} + +// sortValues is a sort function that handles both native types and any type that +// can be converted to error or Stringer. Other inputs are sorted according to +// their Value.String() value to ensure display stability. +func sortValues(values []reflect.Value, cs *ConfigState) { + if len(values) == 0 { + return + } + sort.Sort(newValuesSorter(values, cs)) +} diff --git a/vendor/github.com/davecgh/go-spew/spew/common_test.go b/vendor/github.com/davecgh/go-spew/spew/common_test.go new file mode 100644 index 0000000..0f5ce47 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/common_test.go @@ -0,0 +1,298 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew_test + +import ( + "fmt" + "reflect" + "testing" + + "github.com/davecgh/go-spew/spew" +) + +// custom type to test Stinger interface on non-pointer receiver. +type stringer string + +// String implements the Stringer interface for testing invocation of custom +// stringers on types with non-pointer receivers. +func (s stringer) String() string { + return "stringer " + string(s) +} + +// custom type to test Stinger interface on pointer receiver. +type pstringer string + +// String implements the Stringer interface for testing invocation of custom +// stringers on types with only pointer receivers. +func (s *pstringer) String() string { + return "stringer " + string(*s) +} + +// xref1 and xref2 are cross referencing structs for testing circular reference +// detection. +type xref1 struct { + ps2 *xref2 +} +type xref2 struct { + ps1 *xref1 +} + +// indirCir1, indirCir2, and indirCir3 are used to generate an indirect circular +// reference for testing detection. +type indirCir1 struct { + ps2 *indirCir2 +} +type indirCir2 struct { + ps3 *indirCir3 +} +type indirCir3 struct { + ps1 *indirCir1 +} + +// embed is used to test embedded structures. +type embed struct { + a string +} + +// embedwrap is used to test embedded structures. +type embedwrap struct { + *embed + e *embed +} + +// panicer is used to intentionally cause a panic for testing spew properly +// handles them +type panicer int + +func (p panicer) String() string { + panic("test panic") +} + +// customError is used to test custom error interface invocation. +type customError int + +func (e customError) Error() string { + return fmt.Sprintf("error: %d", int(e)) +} + +// stringizeWants converts a slice of wanted test output into a format suitable +// for a test error message. +func stringizeWants(wants []string) string { + s := "" + for i, want := range wants { + if i > 0 { + s += fmt.Sprintf("want%d: %s", i+1, want) + } else { + s += "want: " + want + } + } + return s +} + +// testFailed returns whether or not a test failed by checking if the result +// of the test is in the slice of wanted strings. +func testFailed(result string, wants []string) bool { + for _, want := range wants { + if result == want { + return false + } + } + return true +} + +type sortableStruct struct { + x int +} + +func (ss sortableStruct) String() string { + return fmt.Sprintf("ss.%d", ss.x) +} + +type unsortableStruct struct { + x int +} + +type sortTestCase struct { + input []reflect.Value + expected []reflect.Value +} + +func helpTestSortValues(tests []sortTestCase, cs *spew.ConfigState, t *testing.T) { + getInterfaces := func(values []reflect.Value) []interface{} { + interfaces := []interface{}{} + for _, v := range values { + interfaces = append(interfaces, v.Interface()) + } + return interfaces + } + + for _, test := range tests { + spew.SortValues(test.input, cs) + // reflect.DeepEqual cannot really make sense of reflect.Value, + // probably because of all the pointer tricks. For instance, + // v(2.0) != v(2.0) on a 32-bits system. Turn them into interface{} + // instead. + input := getInterfaces(test.input) + expected := getInterfaces(test.expected) + if !reflect.DeepEqual(input, expected) { + t.Errorf("Sort mismatch:\n %v != %v", input, expected) + } + } +} + +// TestSortValues ensures the sort functionality for relect.Value based sorting +// works as intended. +func TestSortValues(t *testing.T) { + v := reflect.ValueOf + + a := v("a") + b := v("b") + c := v("c") + embedA := v(embed{"a"}) + embedB := v(embed{"b"}) + embedC := v(embed{"c"}) + tests := []sortTestCase{ + // No values. + { + []reflect.Value{}, + []reflect.Value{}, + }, + // Bools. + { + []reflect.Value{v(false), v(true), v(false)}, + []reflect.Value{v(false), v(false), v(true)}, + }, + // Ints. + { + []reflect.Value{v(2), v(1), v(3)}, + []reflect.Value{v(1), v(2), v(3)}, + }, + // Uints. + { + []reflect.Value{v(uint8(2)), v(uint8(1)), v(uint8(3))}, + []reflect.Value{v(uint8(1)), v(uint8(2)), v(uint8(3))}, + }, + // Floats. + { + []reflect.Value{v(2.0), v(1.0), v(3.0)}, + []reflect.Value{v(1.0), v(2.0), v(3.0)}, + }, + // Strings. + { + []reflect.Value{b, a, c}, + []reflect.Value{a, b, c}, + }, + // Array + { + []reflect.Value{v([3]int{3, 2, 1}), v([3]int{1, 3, 2}), v([3]int{1, 2, 3})}, + []reflect.Value{v([3]int{1, 2, 3}), v([3]int{1, 3, 2}), v([3]int{3, 2, 1})}, + }, + // Uintptrs. + { + []reflect.Value{v(uintptr(2)), v(uintptr(1)), v(uintptr(3))}, + []reflect.Value{v(uintptr(1)), v(uintptr(2)), v(uintptr(3))}, + }, + // SortableStructs. + { + // Note: not sorted - DisableMethods is set. + []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})}, + []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})}, + }, + // UnsortableStructs. + { + // Note: not sorted - SpewKeys is false. + []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})}, + []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})}, + }, + // Invalid. + { + []reflect.Value{embedB, embedA, embedC}, + []reflect.Value{embedB, embedA, embedC}, + }, + } + cs := spew.ConfigState{DisableMethods: true, SpewKeys: false} + helpTestSortValues(tests, &cs, t) +} + +// TestSortValuesWithMethods ensures the sort functionality for relect.Value +// based sorting works as intended when using string methods. +func TestSortValuesWithMethods(t *testing.T) { + v := reflect.ValueOf + + a := v("a") + b := v("b") + c := v("c") + tests := []sortTestCase{ + // Ints. + { + []reflect.Value{v(2), v(1), v(3)}, + []reflect.Value{v(1), v(2), v(3)}, + }, + // Strings. + { + []reflect.Value{b, a, c}, + []reflect.Value{a, b, c}, + }, + // SortableStructs. + { + []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})}, + []reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})}, + }, + // UnsortableStructs. + { + // Note: not sorted - SpewKeys is false. + []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})}, + []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})}, + }, + } + cs := spew.ConfigState{DisableMethods: false, SpewKeys: false} + helpTestSortValues(tests, &cs, t) +} + +// TestSortValuesWithSpew ensures the sort functionality for relect.Value +// based sorting works as intended when using spew to stringify keys. +func TestSortValuesWithSpew(t *testing.T) { + v := reflect.ValueOf + + a := v("a") + b := v("b") + c := v("c") + tests := []sortTestCase{ + // Ints. + { + []reflect.Value{v(2), v(1), v(3)}, + []reflect.Value{v(1), v(2), v(3)}, + }, + // Strings. + { + []reflect.Value{b, a, c}, + []reflect.Value{a, b, c}, + }, + // SortableStructs. + { + []reflect.Value{v(sortableStruct{2}), v(sortableStruct{1}), v(sortableStruct{3})}, + []reflect.Value{v(sortableStruct{1}), v(sortableStruct{2}), v(sortableStruct{3})}, + }, + // UnsortableStructs. + { + []reflect.Value{v(unsortableStruct{2}), v(unsortableStruct{1}), v(unsortableStruct{3})}, + []reflect.Value{v(unsortableStruct{1}), v(unsortableStruct{2}), v(unsortableStruct{3})}, + }, + } + cs := spew.ConfigState{DisableMethods: true, SpewKeys: true} + helpTestSortValues(tests, &cs, t) +} diff --git a/vendor/github.com/davecgh/go-spew/spew/config.go b/vendor/github.com/davecgh/go-spew/spew/config.go new file mode 100644 index 0000000..2e3d22f --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/config.go @@ -0,0 +1,306 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew + +import ( + "bytes" + "fmt" + "io" + "os" +) + +// ConfigState houses the configuration options used by spew to format and +// display values. There is a global instance, Config, that is used to control +// all top-level Formatter and Dump functionality. Each ConfigState instance +// provides methods equivalent to the top-level functions. +// +// The zero value for ConfigState provides no indentation. You would typically +// want to set it to a space or a tab. +// +// Alternatively, you can use NewDefaultConfig to get a ConfigState instance +// with default settings. See the documentation of NewDefaultConfig for default +// values. +type ConfigState struct { + // Indent specifies the string to use for each indentation level. The + // global config instance that all top-level functions use set this to a + // single space by default. If you would like more indentation, you might + // set this to a tab with "\t" or perhaps two spaces with " ". + Indent string + + // MaxDepth controls the maximum number of levels to descend into nested + // data structures. The default, 0, means there is no limit. + // + // NOTE: Circular data structures are properly detected, so it is not + // necessary to set this value unless you specifically want to limit deeply + // nested data structures. + MaxDepth int + + // DisableMethods specifies whether or not error and Stringer interfaces are + // invoked for types that implement them. + DisableMethods bool + + // DisablePointerMethods specifies whether or not to check for and invoke + // error and Stringer interfaces on types which only accept a pointer + // receiver when the current type is not a pointer. + // + // NOTE: This might be an unsafe action since calling one of these methods + // with a pointer receiver could technically mutate the value, however, + // in practice, types which choose to satisify an error or Stringer + // interface with a pointer receiver should not be mutating their state + // inside these interface methods. As a result, this option relies on + // access to the unsafe package, so it will not have any effect when + // running in environments without access to the unsafe package such as + // Google App Engine or with the "safe" build tag specified. + DisablePointerMethods bool + + // DisablePointerAddresses specifies whether to disable the printing of + // pointer addresses. This is useful when diffing data structures in tests. + DisablePointerAddresses bool + + // DisableCapacities specifies whether to disable the printing of capacities + // for arrays, slices, maps and channels. This is useful when diffing + // data structures in tests. + DisableCapacities bool + + // ContinueOnMethod specifies whether or not recursion should continue once + // a custom error or Stringer interface is invoked. The default, false, + // means it will print the results of invoking the custom error or Stringer + // interface and return immediately instead of continuing to recurse into + // the internals of the data type. + // + // NOTE: This flag does not have any effect if method invocation is disabled + // via the DisableMethods or DisablePointerMethods options. + ContinueOnMethod bool + + // SortKeys specifies map keys should be sorted before being printed. Use + // this to have a more deterministic, diffable output. Note that only + // native types (bool, int, uint, floats, uintptr and string) and types + // that support the error or Stringer interfaces (if methods are + // enabled) are supported, with other types sorted according to the + // reflect.Value.String() output which guarantees display stability. + SortKeys bool + + // SpewKeys specifies that, as a last resort attempt, map keys should + // be spewed to strings and sorted by those strings. This is only + // considered if SortKeys is true. + SpewKeys bool +} + +// Config is the active configuration of the top-level functions. +// The configuration can be changed by modifying the contents of spew.Config. +var Config = ConfigState{Indent: " "} + +// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the formatted string as a value that satisfies error. See NewFormatter +// for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Errorf(format, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Errorf(format string, a ...interface{}) (err error) { + return fmt.Errorf(format, c.convertArgs(a)...) +} + +// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprint(w, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Fprint(w io.Writer, a ...interface{}) (n int, err error) { + return fmt.Fprint(w, c.convertArgs(a)...) +} + +// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprintf(w, format, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) { + return fmt.Fprintf(w, format, c.convertArgs(a)...) +} + +// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it +// passed with a Formatter interface returned by c.NewFormatter. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprintln(w, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Fprintln(w io.Writer, a ...interface{}) (n int, err error) { + return fmt.Fprintln(w, c.convertArgs(a)...) +} + +// Print is a wrapper for fmt.Print that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Print(c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Print(a ...interface{}) (n int, err error) { + return fmt.Print(c.convertArgs(a)...) +} + +// Printf is a wrapper for fmt.Printf that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Printf(format, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Printf(format string, a ...interface{}) (n int, err error) { + return fmt.Printf(format, c.convertArgs(a)...) +} + +// Println is a wrapper for fmt.Println that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Println(c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Println(a ...interface{}) (n int, err error) { + return fmt.Println(c.convertArgs(a)...) +} + +// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprint(c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Sprint(a ...interface{}) string { + return fmt.Sprint(c.convertArgs(a)...) +} + +// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were +// passed with a Formatter interface returned by c.NewFormatter. It returns +// the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprintf(format, c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Sprintf(format string, a ...interface{}) string { + return fmt.Sprintf(format, c.convertArgs(a)...) +} + +// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it +// were passed with a Formatter interface returned by c.NewFormatter. It +// returns the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprintln(c.NewFormatter(a), c.NewFormatter(b)) +func (c *ConfigState) Sprintln(a ...interface{}) string { + return fmt.Sprintln(c.convertArgs(a)...) +} + +/* +NewFormatter returns a custom formatter that satisfies the fmt.Formatter +interface. As a result, it integrates cleanly with standard fmt package +printing functions. The formatter is useful for inline printing of smaller data +types similar to the standard %v format specifier. + +The custom formatter only responds to the %v (most compact), %+v (adds pointer +addresses), %#v (adds types), and %#+v (adds types and pointer addresses) verb +combinations. Any other verbs such as %x and %q will be sent to the the +standard fmt package for formatting. In addition, the custom formatter ignores +the width and precision arguments (however they will still work on the format +specifiers not handled by the custom formatter). + +Typically this function shouldn't be called directly. It is much easier to make +use of the custom formatter by calling one of the convenience functions such as +c.Printf, c.Println, or c.Printf. +*/ +func (c *ConfigState) NewFormatter(v interface{}) fmt.Formatter { + return newFormatter(c, v) +} + +// Fdump formats and displays the passed arguments to io.Writer w. It formats +// exactly the same as Dump. +func (c *ConfigState) Fdump(w io.Writer, a ...interface{}) { + fdump(c, w, a...) +} + +/* +Dump displays the passed parameters to standard out with newlines, customizable +indentation, and additional debug information such as complete types and all +pointer addresses used to indirect to the final value. It provides the +following features over the built-in printing facilities provided by the fmt +package: + + * Pointers are dereferenced and followed + * Circular data structures are detected and handled properly + * Custom Stringer/error interfaces are optionally invoked, including + on unexported types + * Custom types which only implement the Stringer/error interfaces via + a pointer receiver are optionally invoked when passing non-pointer + variables + * Byte arrays and slices are dumped like the hexdump -C command which + includes offsets, byte values in hex, and ASCII output + +The configuration options are controlled by modifying the public members +of c. See ConfigState for options documentation. + +See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to +get the formatted result as a string. +*/ +func (c *ConfigState) Dump(a ...interface{}) { + fdump(c, os.Stdout, a...) +} + +// Sdump returns a string with the passed arguments formatted exactly the same +// as Dump. +func (c *ConfigState) Sdump(a ...interface{}) string { + var buf bytes.Buffer + fdump(c, &buf, a...) + return buf.String() +} + +// convertArgs accepts a slice of arguments and returns a slice of the same +// length with each argument converted to a spew Formatter interface using +// the ConfigState associated with s. +func (c *ConfigState) convertArgs(args []interface{}) (formatters []interface{}) { + formatters = make([]interface{}, len(args)) + for index, arg := range args { + formatters[index] = newFormatter(c, arg) + } + return formatters +} + +// NewDefaultConfig returns a ConfigState with the following default settings. +// +// Indent: " " +// MaxDepth: 0 +// DisableMethods: false +// DisablePointerMethods: false +// ContinueOnMethod: false +// SortKeys: false +func NewDefaultConfig() *ConfigState { + return &ConfigState{Indent: " "} +} diff --git a/vendor/github.com/davecgh/go-spew/spew/doc.go b/vendor/github.com/davecgh/go-spew/spew/doc.go new file mode 100644 index 0000000..aacaac6 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/doc.go @@ -0,0 +1,211 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* +Package spew implements a deep pretty printer for Go data structures to aid in +debugging. + +A quick overview of the additional features spew provides over the built-in +printing facilities for Go data types are as follows: + + * Pointers are dereferenced and followed + * Circular data structures are detected and handled properly + * Custom Stringer/error interfaces are optionally invoked, including + on unexported types + * Custom types which only implement the Stringer/error interfaces via + a pointer receiver are optionally invoked when passing non-pointer + variables + * Byte arrays and slices are dumped like the hexdump -C command which + includes offsets, byte values in hex, and ASCII output (only when using + Dump style) + +There are two different approaches spew allows for dumping Go data structures: + + * Dump style which prints with newlines, customizable indentation, + and additional debug information such as types and all pointer addresses + used to indirect to the final value + * A custom Formatter interface that integrates cleanly with the standard fmt + package and replaces %v, %+v, %#v, and %#+v to provide inline printing + similar to the default %v while providing the additional functionality + outlined above and passing unsupported format verbs such as %x and %q + along to fmt + +Quick Start + +This section demonstrates how to quickly get started with spew. See the +sections below for further details on formatting and configuration options. + +To dump a variable with full newlines, indentation, type, and pointer +information use Dump, Fdump, or Sdump: + spew.Dump(myVar1, myVar2, ...) + spew.Fdump(someWriter, myVar1, myVar2, ...) + str := spew.Sdump(myVar1, myVar2, ...) + +Alternatively, if you would prefer to use format strings with a compacted inline +printing style, use the convenience wrappers Printf, Fprintf, etc with +%v (most compact), %+v (adds pointer addresses), %#v (adds types), or +%#+v (adds types and pointer addresses): + spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2) + spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) + spew.Fprintf(someWriter, "myVar1: %v -- myVar2: %+v", myVar1, myVar2) + spew.Fprintf(someWriter, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) + +Configuration Options + +Configuration of spew is handled by fields in the ConfigState type. For +convenience, all of the top-level functions use a global state available +via the spew.Config global. + +It is also possible to create a ConfigState instance that provides methods +equivalent to the top-level functions. This allows concurrent configuration +options. See the ConfigState documentation for more details. + +The following configuration options are available: + * Indent + String to use for each indentation level for Dump functions. + It is a single space by default. A popular alternative is "\t". + + * MaxDepth + Maximum number of levels to descend into nested data structures. + There is no limit by default. + + * DisableMethods + Disables invocation of error and Stringer interface methods. + Method invocation is enabled by default. + + * DisablePointerMethods + Disables invocation of error and Stringer interface methods on types + which only accept pointer receivers from non-pointer variables. + Pointer method invocation is enabled by default. + + * DisablePointerAddresses + DisablePointerAddresses specifies whether to disable the printing of + pointer addresses. This is useful when diffing data structures in tests. + + * DisableCapacities + DisableCapacities specifies whether to disable the printing of + capacities for arrays, slices, maps and channels. This is useful when + diffing data structures in tests. + + * ContinueOnMethod + Enables recursion into types after invoking error and Stringer interface + methods. Recursion after method invocation is disabled by default. + + * SortKeys + Specifies map keys should be sorted before being printed. Use + this to have a more deterministic, diffable output. Note that + only native types (bool, int, uint, floats, uintptr and string) + and types which implement error or Stringer interfaces are + supported with other types sorted according to the + reflect.Value.String() output which guarantees display + stability. Natural map order is used by default. + + * SpewKeys + Specifies that, as a last resort attempt, map keys should be + spewed to strings and sorted by those strings. This is only + considered if SortKeys is true. + +Dump Usage + +Simply call spew.Dump with a list of variables you want to dump: + + spew.Dump(myVar1, myVar2, ...) + +You may also call spew.Fdump if you would prefer to output to an arbitrary +io.Writer. For example, to dump to standard error: + + spew.Fdump(os.Stderr, myVar1, myVar2, ...) + +A third option is to call spew.Sdump to get the formatted output as a string: + + str := spew.Sdump(myVar1, myVar2, ...) + +Sample Dump Output + +See the Dump example for details on the setup of the types and variables being +shown here. + + (main.Foo) { + unexportedField: (*main.Bar)(0xf84002e210)({ + flag: (main.Flag) flagTwo, + data: (uintptr) + }), + ExportedField: (map[interface {}]interface {}) (len=1) { + (string) (len=3) "one": (bool) true + } + } + +Byte (and uint8) arrays and slices are displayed uniquely like the hexdump -C +command as shown. + ([]uint8) (len=32 cap=32) { + 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... | + 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0| + 00000020 31 32 |12| + } + +Custom Formatter + +Spew provides a custom formatter that implements the fmt.Formatter interface +so that it integrates cleanly with standard fmt package printing functions. The +formatter is useful for inline printing of smaller data types similar to the +standard %v format specifier. + +The custom formatter only responds to the %v (most compact), %+v (adds pointer +addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb +combinations. Any other verbs such as %x and %q will be sent to the the +standard fmt package for formatting. In addition, the custom formatter ignores +the width and precision arguments (however they will still work on the format +specifiers not handled by the custom formatter). + +Custom Formatter Usage + +The simplest way to make use of the spew custom formatter is to call one of the +convenience functions such as spew.Printf, spew.Println, or spew.Printf. The +functions have syntax you are most likely already familiar with: + + spew.Printf("myVar1: %v -- myVar2: %+v", myVar1, myVar2) + spew.Printf("myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) + spew.Println(myVar, myVar2) + spew.Fprintf(os.Stderr, "myVar1: %v -- myVar2: %+v", myVar1, myVar2) + spew.Fprintf(os.Stderr, "myVar3: %#v -- myVar4: %#+v", myVar3, myVar4) + +See the Index for the full list convenience functions. + +Sample Formatter Output + +Double pointer to a uint8: + %v: <**>5 + %+v: <**>(0xf8400420d0->0xf8400420c8)5 + %#v: (**uint8)5 + %#+v: (**uint8)(0xf8400420d0->0xf8400420c8)5 + +Pointer to circular struct with a uint8 field and a pointer to itself: + %v: <*>{1 <*>} + %+v: <*>(0xf84003e260){ui8:1 c:<*>(0xf84003e260)} + %#v: (*main.circular){ui8:(uint8)1 c:(*main.circular)} + %#+v: (*main.circular)(0xf84003e260){ui8:(uint8)1 c:(*main.circular)(0xf84003e260)} + +See the Printf example for details on the setup of variables being shown +here. + +Errors + +Since it is possible for custom Stringer/error interfaces to panic, spew +detects them and handles them internally by printing the panic information +inline with the output. Since spew is intended to provide deep pretty printing +capabilities on structures, it intentionally does not return any errors. +*/ +package spew diff --git a/vendor/github.com/davecgh/go-spew/spew/dump.go b/vendor/github.com/davecgh/go-spew/spew/dump.go new file mode 100644 index 0000000..df1d582 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/dump.go @@ -0,0 +1,509 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew + +import ( + "bytes" + "encoding/hex" + "fmt" + "io" + "os" + "reflect" + "regexp" + "strconv" + "strings" +) + +var ( + // uint8Type is a reflect.Type representing a uint8. It is used to + // convert cgo types to uint8 slices for hexdumping. + uint8Type = reflect.TypeOf(uint8(0)) + + // cCharRE is a regular expression that matches a cgo char. + // It is used to detect character arrays to hexdump them. + cCharRE = regexp.MustCompile("^.*\\._Ctype_char$") + + // cUnsignedCharRE is a regular expression that matches a cgo unsigned + // char. It is used to detect unsigned character arrays to hexdump + // them. + cUnsignedCharRE = regexp.MustCompile("^.*\\._Ctype_unsignedchar$") + + // cUint8tCharRE is a regular expression that matches a cgo uint8_t. + // It is used to detect uint8_t arrays to hexdump them. + cUint8tCharRE = regexp.MustCompile("^.*\\._Ctype_uint8_t$") +) + +// dumpState contains information about the state of a dump operation. +type dumpState struct { + w io.Writer + depth int + pointers map[uintptr]int + ignoreNextType bool + ignoreNextIndent bool + cs *ConfigState +} + +// indent performs indentation according to the depth level and cs.Indent +// option. +func (d *dumpState) indent() { + if d.ignoreNextIndent { + d.ignoreNextIndent = false + return + } + d.w.Write(bytes.Repeat([]byte(d.cs.Indent), d.depth)) +} + +// unpackValue returns values inside of non-nil interfaces when possible. +// This is useful for data types like structs, arrays, slices, and maps which +// can contain varying types packed inside an interface. +func (d *dumpState) unpackValue(v reflect.Value) reflect.Value { + if v.Kind() == reflect.Interface && !v.IsNil() { + v = v.Elem() + } + return v +} + +// dumpPtr handles formatting of pointers by indirecting them as necessary. +func (d *dumpState) dumpPtr(v reflect.Value) { + // Remove pointers at or below the current depth from map used to detect + // circular refs. + for k, depth := range d.pointers { + if depth >= d.depth { + delete(d.pointers, k) + } + } + + // Keep list of all dereferenced pointers to show later. + pointerChain := make([]uintptr, 0) + + // Figure out how many levels of indirection there are by dereferencing + // pointers and unpacking interfaces down the chain while detecting circular + // references. + nilFound := false + cycleFound := false + indirects := 0 + ve := v + for ve.Kind() == reflect.Ptr { + if ve.IsNil() { + nilFound = true + break + } + indirects++ + addr := ve.Pointer() + pointerChain = append(pointerChain, addr) + if pd, ok := d.pointers[addr]; ok && pd < d.depth { + cycleFound = true + indirects-- + break + } + d.pointers[addr] = d.depth + + ve = ve.Elem() + if ve.Kind() == reflect.Interface { + if ve.IsNil() { + nilFound = true + break + } + ve = ve.Elem() + } + } + + // Display type information. + d.w.Write(openParenBytes) + d.w.Write(bytes.Repeat(asteriskBytes, indirects)) + d.w.Write([]byte(ve.Type().String())) + d.w.Write(closeParenBytes) + + // Display pointer information. + if !d.cs.DisablePointerAddresses && len(pointerChain) > 0 { + d.w.Write(openParenBytes) + for i, addr := range pointerChain { + if i > 0 { + d.w.Write(pointerChainBytes) + } + printHexPtr(d.w, addr) + } + d.w.Write(closeParenBytes) + } + + // Display dereferenced value. + d.w.Write(openParenBytes) + switch { + case nilFound == true: + d.w.Write(nilAngleBytes) + + case cycleFound == true: + d.w.Write(circularBytes) + + default: + d.ignoreNextType = true + d.dump(ve) + } + d.w.Write(closeParenBytes) +} + +// dumpSlice handles formatting of arrays and slices. Byte (uint8 under +// reflection) arrays and slices are dumped in hexdump -C fashion. +func (d *dumpState) dumpSlice(v reflect.Value) { + // Determine whether this type should be hex dumped or not. Also, + // for types which should be hexdumped, try to use the underlying data + // first, then fall back to trying to convert them to a uint8 slice. + var buf []uint8 + doConvert := false + doHexDump := false + numEntries := v.Len() + if numEntries > 0 { + vt := v.Index(0).Type() + vts := vt.String() + switch { + // C types that need to be converted. + case cCharRE.MatchString(vts): + fallthrough + case cUnsignedCharRE.MatchString(vts): + fallthrough + case cUint8tCharRE.MatchString(vts): + doConvert = true + + // Try to use existing uint8 slices and fall back to converting + // and copying if that fails. + case vt.Kind() == reflect.Uint8: + // We need an addressable interface to convert the type + // to a byte slice. However, the reflect package won't + // give us an interface on certain things like + // unexported struct fields in order to enforce + // visibility rules. We use unsafe, when available, to + // bypass these restrictions since this package does not + // mutate the values. + vs := v + if !vs.CanInterface() || !vs.CanAddr() { + vs = unsafeReflectValue(vs) + } + if !UnsafeDisabled { + vs = vs.Slice(0, numEntries) + + // Use the existing uint8 slice if it can be + // type asserted. + iface := vs.Interface() + if slice, ok := iface.([]uint8); ok { + buf = slice + doHexDump = true + break + } + } + + // The underlying data needs to be converted if it can't + // be type asserted to a uint8 slice. + doConvert = true + } + + // Copy and convert the underlying type if needed. + if doConvert && vt.ConvertibleTo(uint8Type) { + // Convert and copy each element into a uint8 byte + // slice. + buf = make([]uint8, numEntries) + for i := 0; i < numEntries; i++ { + vv := v.Index(i) + buf[i] = uint8(vv.Convert(uint8Type).Uint()) + } + doHexDump = true + } + } + + // Hexdump the entire slice as needed. + if doHexDump { + indent := strings.Repeat(d.cs.Indent, d.depth) + str := indent + hex.Dump(buf) + str = strings.Replace(str, "\n", "\n"+indent, -1) + str = strings.TrimRight(str, d.cs.Indent) + d.w.Write([]byte(str)) + return + } + + // Recursively call dump for each item. + for i := 0; i < numEntries; i++ { + d.dump(d.unpackValue(v.Index(i))) + if i < (numEntries - 1) { + d.w.Write(commaNewlineBytes) + } else { + d.w.Write(newlineBytes) + } + } +} + +// dump is the main workhorse for dumping a value. It uses the passed reflect +// value to figure out what kind of object we are dealing with and formats it +// appropriately. It is a recursive function, however circular data structures +// are detected and handled properly. +func (d *dumpState) dump(v reflect.Value) { + // Handle invalid reflect values immediately. + kind := v.Kind() + if kind == reflect.Invalid { + d.w.Write(invalidAngleBytes) + return + } + + // Handle pointers specially. + if kind == reflect.Ptr { + d.indent() + d.dumpPtr(v) + return + } + + // Print type information unless already handled elsewhere. + if !d.ignoreNextType { + d.indent() + d.w.Write(openParenBytes) + d.w.Write([]byte(v.Type().String())) + d.w.Write(closeParenBytes) + d.w.Write(spaceBytes) + } + d.ignoreNextType = false + + // Display length and capacity if the built-in len and cap functions + // work with the value's kind and the len/cap itself is non-zero. + valueLen, valueCap := 0, 0 + switch v.Kind() { + case reflect.Array, reflect.Slice, reflect.Chan: + valueLen, valueCap = v.Len(), v.Cap() + case reflect.Map, reflect.String: + valueLen = v.Len() + } + if valueLen != 0 || !d.cs.DisableCapacities && valueCap != 0 { + d.w.Write(openParenBytes) + if valueLen != 0 { + d.w.Write(lenEqualsBytes) + printInt(d.w, int64(valueLen), 10) + } + if !d.cs.DisableCapacities && valueCap != 0 { + if valueLen != 0 { + d.w.Write(spaceBytes) + } + d.w.Write(capEqualsBytes) + printInt(d.w, int64(valueCap), 10) + } + d.w.Write(closeParenBytes) + d.w.Write(spaceBytes) + } + + // Call Stringer/error interfaces if they exist and the handle methods flag + // is enabled + if !d.cs.DisableMethods { + if (kind != reflect.Invalid) && (kind != reflect.Interface) { + if handled := handleMethods(d.cs, d.w, v); handled { + return + } + } + } + + switch kind { + case reflect.Invalid: + // Do nothing. We should never get here since invalid has already + // been handled above. + + case reflect.Bool: + printBool(d.w, v.Bool()) + + case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: + printInt(d.w, v.Int(), 10) + + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: + printUint(d.w, v.Uint(), 10) + + case reflect.Float32: + printFloat(d.w, v.Float(), 32) + + case reflect.Float64: + printFloat(d.w, v.Float(), 64) + + case reflect.Complex64: + printComplex(d.w, v.Complex(), 32) + + case reflect.Complex128: + printComplex(d.w, v.Complex(), 64) + + case reflect.Slice: + if v.IsNil() { + d.w.Write(nilAngleBytes) + break + } + fallthrough + + case reflect.Array: + d.w.Write(openBraceNewlineBytes) + d.depth++ + if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { + d.indent() + d.w.Write(maxNewlineBytes) + } else { + d.dumpSlice(v) + } + d.depth-- + d.indent() + d.w.Write(closeBraceBytes) + + case reflect.String: + d.w.Write([]byte(strconv.Quote(v.String()))) + + case reflect.Interface: + // The only time we should get here is for nil interfaces due to + // unpackValue calls. + if v.IsNil() { + d.w.Write(nilAngleBytes) + } + + case reflect.Ptr: + // Do nothing. We should never get here since pointers have already + // been handled above. + + case reflect.Map: + // nil maps should be indicated as different than empty maps + if v.IsNil() { + d.w.Write(nilAngleBytes) + break + } + + d.w.Write(openBraceNewlineBytes) + d.depth++ + if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { + d.indent() + d.w.Write(maxNewlineBytes) + } else { + numEntries := v.Len() + keys := v.MapKeys() + if d.cs.SortKeys { + sortValues(keys, d.cs) + } + for i, key := range keys { + d.dump(d.unpackValue(key)) + d.w.Write(colonSpaceBytes) + d.ignoreNextIndent = true + d.dump(d.unpackValue(v.MapIndex(key))) + if i < (numEntries - 1) { + d.w.Write(commaNewlineBytes) + } else { + d.w.Write(newlineBytes) + } + } + } + d.depth-- + d.indent() + d.w.Write(closeBraceBytes) + + case reflect.Struct: + d.w.Write(openBraceNewlineBytes) + d.depth++ + if (d.cs.MaxDepth != 0) && (d.depth > d.cs.MaxDepth) { + d.indent() + d.w.Write(maxNewlineBytes) + } else { + vt := v.Type() + numFields := v.NumField() + for i := 0; i < numFields; i++ { + d.indent() + vtf := vt.Field(i) + d.w.Write([]byte(vtf.Name)) + d.w.Write(colonSpaceBytes) + d.ignoreNextIndent = true + d.dump(d.unpackValue(v.Field(i))) + if i < (numFields - 1) { + d.w.Write(commaNewlineBytes) + } else { + d.w.Write(newlineBytes) + } + } + } + d.depth-- + d.indent() + d.w.Write(closeBraceBytes) + + case reflect.Uintptr: + printHexPtr(d.w, uintptr(v.Uint())) + + case reflect.UnsafePointer, reflect.Chan, reflect.Func: + printHexPtr(d.w, v.Pointer()) + + // There were not any other types at the time this code was written, but + // fall back to letting the default fmt package handle it in case any new + // types are added. + default: + if v.CanInterface() { + fmt.Fprintf(d.w, "%v", v.Interface()) + } else { + fmt.Fprintf(d.w, "%v", v.String()) + } + } +} + +// fdump is a helper function to consolidate the logic from the various public +// methods which take varying writers and config states. +func fdump(cs *ConfigState, w io.Writer, a ...interface{}) { + for _, arg := range a { + if arg == nil { + w.Write(interfaceBytes) + w.Write(spaceBytes) + w.Write(nilAngleBytes) + w.Write(newlineBytes) + continue + } + + d := dumpState{w: w, cs: cs} + d.pointers = make(map[uintptr]int) + d.dump(reflect.ValueOf(arg)) + d.w.Write(newlineBytes) + } +} + +// Fdump formats and displays the passed arguments to io.Writer w. It formats +// exactly the same as Dump. +func Fdump(w io.Writer, a ...interface{}) { + fdump(&Config, w, a...) +} + +// Sdump returns a string with the passed arguments formatted exactly the same +// as Dump. +func Sdump(a ...interface{}) string { + var buf bytes.Buffer + fdump(&Config, &buf, a...) + return buf.String() +} + +/* +Dump displays the passed parameters to standard out with newlines, customizable +indentation, and additional debug information such as complete types and all +pointer addresses used to indirect to the final value. It provides the +following features over the built-in printing facilities provided by the fmt +package: + + * Pointers are dereferenced and followed + * Circular data structures are detected and handled properly + * Custom Stringer/error interfaces are optionally invoked, including + on unexported types + * Custom types which only implement the Stringer/error interfaces via + a pointer receiver are optionally invoked when passing non-pointer + variables + * Byte arrays and slices are dumped like the hexdump -C command which + includes offsets, byte values in hex, and ASCII output + +The configuration options are controlled by an exported package global, +spew.Config. See ConfigState for options documentation. + +See Fdump if you would prefer dumping to an arbitrary io.Writer or Sdump to +get the formatted result as a string. +*/ +func Dump(a ...interface{}) { + fdump(&Config, os.Stdout, a...) +} diff --git a/vendor/github.com/davecgh/go-spew/spew/dump_test.go b/vendor/github.com/davecgh/go-spew/spew/dump_test.go new file mode 100644 index 0000000..5aad9c7 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/dump_test.go @@ -0,0 +1,1042 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* +Test Summary: +NOTE: For each test, a nil pointer, a single pointer and double pointer to the +base test element are also tested to ensure proper indirection across all types. + +- Max int8, int16, int32, int64, int +- Max uint8, uint16, uint32, uint64, uint +- Boolean true and false +- Standard complex64 and complex128 +- Array containing standard ints +- Array containing type with custom formatter on pointer receiver only +- Array containing interfaces +- Array containing bytes +- Slice containing standard float32 values +- Slice containing type with custom formatter on pointer receiver only +- Slice containing interfaces +- Slice containing bytes +- Nil slice +- Standard string +- Nil interface +- Sub-interface +- Map with string keys and int vals +- Map with custom formatter type on pointer receiver only keys and vals +- Map with interface keys and values +- Map with nil interface value +- Struct with primitives +- Struct that contains another struct +- Struct that contains custom type with Stringer pointer interface via both + exported and unexported fields +- Struct that contains embedded struct and field to same struct +- Uintptr to 0 (null pointer) +- Uintptr address of real variable +- Unsafe.Pointer to 0 (null pointer) +- Unsafe.Pointer to address of real variable +- Nil channel +- Standard int channel +- Function with no params and no returns +- Function with param and no returns +- Function with multiple params and multiple returns +- Struct that is circular through self referencing +- Structs that are circular through cross referencing +- Structs that are indirectly circular +- Type that panics in its Stringer interface +*/ + +package spew_test + +import ( + "bytes" + "fmt" + "testing" + "unsafe" + + "github.com/davecgh/go-spew/spew" +) + +// dumpTest is used to describe a test to be performed against the Dump method. +type dumpTest struct { + in interface{} + wants []string +} + +// dumpTests houses all of the tests to be performed against the Dump method. +var dumpTests = make([]dumpTest, 0) + +// addDumpTest is a helper method to append the passed input and desired result +// to dumpTests +func addDumpTest(in interface{}, wants ...string) { + test := dumpTest{in, wants} + dumpTests = append(dumpTests, test) +} + +func addIntDumpTests() { + // Max int8. + v := int8(127) + nv := (*int8)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "int8" + vs := "127" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Max int16. + v2 := int16(32767) + nv2 := (*int16)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "int16" + v2s := "32767" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv2, "(*"+v2t+")()\n") + + // Max int32. + v3 := int32(2147483647) + nv3 := (*int32)(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "int32" + v3s := "2147483647" + addDumpTest(v3, "("+v3t+") "+v3s+"\n") + addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") + addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") + addDumpTest(nv3, "(*"+v3t+")()\n") + + // Max int64. + v4 := int64(9223372036854775807) + nv4 := (*int64)(nil) + pv4 := &v4 + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "int64" + v4s := "9223372036854775807" + addDumpTest(v4, "("+v4t+") "+v4s+"\n") + addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") + addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") + addDumpTest(nv4, "(*"+v4t+")()\n") + + // Max int. + v5 := int(2147483647) + nv5 := (*int)(nil) + pv5 := &v5 + v5Addr := fmt.Sprintf("%p", pv5) + pv5Addr := fmt.Sprintf("%p", &pv5) + v5t := "int" + v5s := "2147483647" + addDumpTest(v5, "("+v5t+") "+v5s+"\n") + addDumpTest(pv5, "(*"+v5t+")("+v5Addr+")("+v5s+")\n") + addDumpTest(&pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")("+v5s+")\n") + addDumpTest(nv5, "(*"+v5t+")()\n") +} + +func addUintDumpTests() { + // Max uint8. + v := uint8(255) + nv := (*uint8)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "uint8" + vs := "255" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Max uint16. + v2 := uint16(65535) + nv2 := (*uint16)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "uint16" + v2s := "65535" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv2, "(*"+v2t+")()\n") + + // Max uint32. + v3 := uint32(4294967295) + nv3 := (*uint32)(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "uint32" + v3s := "4294967295" + addDumpTest(v3, "("+v3t+") "+v3s+"\n") + addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") + addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") + addDumpTest(nv3, "(*"+v3t+")()\n") + + // Max uint64. + v4 := uint64(18446744073709551615) + nv4 := (*uint64)(nil) + pv4 := &v4 + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "uint64" + v4s := "18446744073709551615" + addDumpTest(v4, "("+v4t+") "+v4s+"\n") + addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") + addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") + addDumpTest(nv4, "(*"+v4t+")()\n") + + // Max uint. + v5 := uint(4294967295) + nv5 := (*uint)(nil) + pv5 := &v5 + v5Addr := fmt.Sprintf("%p", pv5) + pv5Addr := fmt.Sprintf("%p", &pv5) + v5t := "uint" + v5s := "4294967295" + addDumpTest(v5, "("+v5t+") "+v5s+"\n") + addDumpTest(pv5, "(*"+v5t+")("+v5Addr+")("+v5s+")\n") + addDumpTest(&pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")("+v5s+")\n") + addDumpTest(nv5, "(*"+v5t+")()\n") +} + +func addBoolDumpTests() { + // Boolean true. + v := bool(true) + nv := (*bool)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "bool" + vs := "true" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Boolean false. + v2 := bool(false) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "bool" + v2s := "false" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") +} + +func addFloatDumpTests() { + // Standard float32. + v := float32(3.1415) + nv := (*float32)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "float32" + vs := "3.1415" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Standard float64. + v2 := float64(3.1415926) + nv2 := (*float64)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "float64" + v2s := "3.1415926" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv2, "(*"+v2t+")()\n") +} + +func addComplexDumpTests() { + // Standard complex64. + v := complex(float32(6), -2) + nv := (*complex64)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "complex64" + vs := "(6-2i)" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Standard complex128. + v2 := complex(float64(-6), 2) + nv2 := (*complex128)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "complex128" + v2s := "(-6+2i)" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv2, "(*"+v2t+")()\n") +} + +func addArrayDumpTests() { + // Array containing standard ints. + v := [3]int{1, 2, 3} + vLen := fmt.Sprintf("%d", len(v)) + vCap := fmt.Sprintf("%d", cap(v)) + nv := (*[3]int)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "int" + vs := "(len=" + vLen + " cap=" + vCap + ") {\n (" + vt + ") 1,\n (" + + vt + ") 2,\n (" + vt + ") 3\n}" + addDumpTest(v, "([3]"+vt+") "+vs+"\n") + addDumpTest(pv, "(*[3]"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**[3]"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*[3]"+vt+")()\n") + + // Array containing type with custom formatter on pointer receiver only. + v2i0 := pstringer("1") + v2i1 := pstringer("2") + v2i2 := pstringer("3") + v2 := [3]pstringer{v2i0, v2i1, v2i2} + v2i0Len := fmt.Sprintf("%d", len(v2i0)) + v2i1Len := fmt.Sprintf("%d", len(v2i1)) + v2i2Len := fmt.Sprintf("%d", len(v2i2)) + v2Len := fmt.Sprintf("%d", len(v2)) + v2Cap := fmt.Sprintf("%d", cap(v2)) + nv2 := (*[3]pstringer)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "spew_test.pstringer" + v2sp := "(len=" + v2Len + " cap=" + v2Cap + ") {\n (" + v2t + + ") (len=" + v2i0Len + ") stringer 1,\n (" + v2t + + ") (len=" + v2i1Len + ") stringer 2,\n (" + v2t + + ") (len=" + v2i2Len + ") " + "stringer 3\n}" + v2s := v2sp + if spew.UnsafeDisabled { + v2s = "(len=" + v2Len + " cap=" + v2Cap + ") {\n (" + v2t + + ") (len=" + v2i0Len + ") \"1\",\n (" + v2t + ") (len=" + + v2i1Len + ") \"2\",\n (" + v2t + ") (len=" + v2i2Len + + ") " + "\"3\"\n}" + } + addDumpTest(v2, "([3]"+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*[3]"+v2t+")("+v2Addr+")("+v2sp+")\n") + addDumpTest(&pv2, "(**[3]"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2sp+")\n") + addDumpTest(nv2, "(*[3]"+v2t+")()\n") + + // Array containing interfaces. + v3i0 := "one" + v3 := [3]interface{}{v3i0, int(2), uint(3)} + v3i0Len := fmt.Sprintf("%d", len(v3i0)) + v3Len := fmt.Sprintf("%d", len(v3)) + v3Cap := fmt.Sprintf("%d", cap(v3)) + nv3 := (*[3]interface{})(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "[3]interface {}" + v3t2 := "string" + v3t3 := "int" + v3t4 := "uint" + v3s := "(len=" + v3Len + " cap=" + v3Cap + ") {\n (" + v3t2 + ") " + + "(len=" + v3i0Len + ") \"one\",\n (" + v3t3 + ") 2,\n (" + + v3t4 + ") 3\n}" + addDumpTest(v3, "("+v3t+") "+v3s+"\n") + addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") + addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") + addDumpTest(nv3, "(*"+v3t+")()\n") + + // Array containing bytes. + v4 := [34]byte{ + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, + 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, + 0x31, 0x32, + } + v4Len := fmt.Sprintf("%d", len(v4)) + v4Cap := fmt.Sprintf("%d", cap(v4)) + nv4 := (*[34]byte)(nil) + pv4 := &v4 + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "[34]uint8" + v4s := "(len=" + v4Len + " cap=" + v4Cap + ") " + + "{\n 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20" + + " |............... |\n" + + " 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30" + + " |!\"#$%&'()*+,-./0|\n" + + " 00000020 31 32 " + + " |12|\n}" + addDumpTest(v4, "("+v4t+") "+v4s+"\n") + addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") + addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") + addDumpTest(nv4, "(*"+v4t+")()\n") +} + +func addSliceDumpTests() { + // Slice containing standard float32 values. + v := []float32{3.14, 6.28, 12.56} + vLen := fmt.Sprintf("%d", len(v)) + vCap := fmt.Sprintf("%d", cap(v)) + nv := (*[]float32)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "float32" + vs := "(len=" + vLen + " cap=" + vCap + ") {\n (" + vt + ") 3.14,\n (" + + vt + ") 6.28,\n (" + vt + ") 12.56\n}" + addDumpTest(v, "([]"+vt+") "+vs+"\n") + addDumpTest(pv, "(*[]"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**[]"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*[]"+vt+")()\n") + + // Slice containing type with custom formatter on pointer receiver only. + v2i0 := pstringer("1") + v2i1 := pstringer("2") + v2i2 := pstringer("3") + v2 := []pstringer{v2i0, v2i1, v2i2} + v2i0Len := fmt.Sprintf("%d", len(v2i0)) + v2i1Len := fmt.Sprintf("%d", len(v2i1)) + v2i2Len := fmt.Sprintf("%d", len(v2i2)) + v2Len := fmt.Sprintf("%d", len(v2)) + v2Cap := fmt.Sprintf("%d", cap(v2)) + nv2 := (*[]pstringer)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "spew_test.pstringer" + v2s := "(len=" + v2Len + " cap=" + v2Cap + ") {\n (" + v2t + ") (len=" + + v2i0Len + ") stringer 1,\n (" + v2t + ") (len=" + v2i1Len + + ") stringer 2,\n (" + v2t + ") (len=" + v2i2Len + ") " + + "stringer 3\n}" + addDumpTest(v2, "([]"+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*[]"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**[]"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv2, "(*[]"+v2t+")()\n") + + // Slice containing interfaces. + v3i0 := "one" + v3 := []interface{}{v3i0, int(2), uint(3), nil} + v3i0Len := fmt.Sprintf("%d", len(v3i0)) + v3Len := fmt.Sprintf("%d", len(v3)) + v3Cap := fmt.Sprintf("%d", cap(v3)) + nv3 := (*[]interface{})(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "[]interface {}" + v3t2 := "string" + v3t3 := "int" + v3t4 := "uint" + v3t5 := "interface {}" + v3s := "(len=" + v3Len + " cap=" + v3Cap + ") {\n (" + v3t2 + ") " + + "(len=" + v3i0Len + ") \"one\",\n (" + v3t3 + ") 2,\n (" + + v3t4 + ") 3,\n (" + v3t5 + ") \n}" + addDumpTest(v3, "("+v3t+") "+v3s+"\n") + addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") + addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") + addDumpTest(nv3, "(*"+v3t+")()\n") + + // Slice containing bytes. + v4 := []byte{ + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, + 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, + 0x31, 0x32, + } + v4Len := fmt.Sprintf("%d", len(v4)) + v4Cap := fmt.Sprintf("%d", cap(v4)) + nv4 := (*[]byte)(nil) + pv4 := &v4 + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "[]uint8" + v4s := "(len=" + v4Len + " cap=" + v4Cap + ") " + + "{\n 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20" + + " |............... |\n" + + " 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30" + + " |!\"#$%&'()*+,-./0|\n" + + " 00000020 31 32 " + + " |12|\n}" + addDumpTest(v4, "("+v4t+") "+v4s+"\n") + addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") + addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") + addDumpTest(nv4, "(*"+v4t+")()\n") + + // Nil slice. + v5 := []int(nil) + nv5 := (*[]int)(nil) + pv5 := &v5 + v5Addr := fmt.Sprintf("%p", pv5) + pv5Addr := fmt.Sprintf("%p", &pv5) + v5t := "[]int" + v5s := "" + addDumpTest(v5, "("+v5t+") "+v5s+"\n") + addDumpTest(pv5, "(*"+v5t+")("+v5Addr+")("+v5s+")\n") + addDumpTest(&pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")("+v5s+")\n") + addDumpTest(nv5, "(*"+v5t+")()\n") +} + +func addStringDumpTests() { + // Standard string. + v := "test" + vLen := fmt.Sprintf("%d", len(v)) + nv := (*string)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "string" + vs := "(len=" + vLen + ") \"test\"" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") +} + +func addInterfaceDumpTests() { + // Nil interface. + var v interface{} + nv := (*interface{})(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "interface {}" + vs := "" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Sub-interface. + v2 := interface{}(uint16(65535)) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "uint16" + v2s := "65535" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") +} + +func addMapDumpTests() { + // Map with string keys and int vals. + k := "one" + kk := "two" + m := map[string]int{k: 1, kk: 2} + klen := fmt.Sprintf("%d", len(k)) // not kLen to shut golint up + kkLen := fmt.Sprintf("%d", len(kk)) + mLen := fmt.Sprintf("%d", len(m)) + nilMap := map[string]int(nil) + nm := (*map[string]int)(nil) + pm := &m + mAddr := fmt.Sprintf("%p", pm) + pmAddr := fmt.Sprintf("%p", &pm) + mt := "map[string]int" + mt1 := "string" + mt2 := "int" + ms := "(len=" + mLen + ") {\n (" + mt1 + ") (len=" + klen + ") " + + "\"one\": (" + mt2 + ") 1,\n (" + mt1 + ") (len=" + kkLen + + ") \"two\": (" + mt2 + ") 2\n}" + ms2 := "(len=" + mLen + ") {\n (" + mt1 + ") (len=" + kkLen + ") " + + "\"two\": (" + mt2 + ") 2,\n (" + mt1 + ") (len=" + klen + + ") \"one\": (" + mt2 + ") 1\n}" + addDumpTest(m, "("+mt+") "+ms+"\n", "("+mt+") "+ms2+"\n") + addDumpTest(pm, "(*"+mt+")("+mAddr+")("+ms+")\n", + "(*"+mt+")("+mAddr+")("+ms2+")\n") + addDumpTest(&pm, "(**"+mt+")("+pmAddr+"->"+mAddr+")("+ms+")\n", + "(**"+mt+")("+pmAddr+"->"+mAddr+")("+ms2+")\n") + addDumpTest(nm, "(*"+mt+")()\n") + addDumpTest(nilMap, "("+mt+") \n") + + // Map with custom formatter type on pointer receiver only keys and vals. + k2 := pstringer("one") + v2 := pstringer("1") + m2 := map[pstringer]pstringer{k2: v2} + k2Len := fmt.Sprintf("%d", len(k2)) + v2Len := fmt.Sprintf("%d", len(v2)) + m2Len := fmt.Sprintf("%d", len(m2)) + nilMap2 := map[pstringer]pstringer(nil) + nm2 := (*map[pstringer]pstringer)(nil) + pm2 := &m2 + m2Addr := fmt.Sprintf("%p", pm2) + pm2Addr := fmt.Sprintf("%p", &pm2) + m2t := "map[spew_test.pstringer]spew_test.pstringer" + m2t1 := "spew_test.pstringer" + m2t2 := "spew_test.pstringer" + m2s := "(len=" + m2Len + ") {\n (" + m2t1 + ") (len=" + k2Len + ") " + + "stringer one: (" + m2t2 + ") (len=" + v2Len + ") stringer 1\n}" + if spew.UnsafeDisabled { + m2s = "(len=" + m2Len + ") {\n (" + m2t1 + ") (len=" + k2Len + + ") " + "\"one\": (" + m2t2 + ") (len=" + v2Len + + ") \"1\"\n}" + } + addDumpTest(m2, "("+m2t+") "+m2s+"\n") + addDumpTest(pm2, "(*"+m2t+")("+m2Addr+")("+m2s+")\n") + addDumpTest(&pm2, "(**"+m2t+")("+pm2Addr+"->"+m2Addr+")("+m2s+")\n") + addDumpTest(nm2, "(*"+m2t+")()\n") + addDumpTest(nilMap2, "("+m2t+") \n") + + // Map with interface keys and values. + k3 := "one" + k3Len := fmt.Sprintf("%d", len(k3)) + m3 := map[interface{}]interface{}{k3: 1} + m3Len := fmt.Sprintf("%d", len(m3)) + nilMap3 := map[interface{}]interface{}(nil) + nm3 := (*map[interface{}]interface{})(nil) + pm3 := &m3 + m3Addr := fmt.Sprintf("%p", pm3) + pm3Addr := fmt.Sprintf("%p", &pm3) + m3t := "map[interface {}]interface {}" + m3t1 := "string" + m3t2 := "int" + m3s := "(len=" + m3Len + ") {\n (" + m3t1 + ") (len=" + k3Len + ") " + + "\"one\": (" + m3t2 + ") 1\n}" + addDumpTest(m3, "("+m3t+") "+m3s+"\n") + addDumpTest(pm3, "(*"+m3t+")("+m3Addr+")("+m3s+")\n") + addDumpTest(&pm3, "(**"+m3t+")("+pm3Addr+"->"+m3Addr+")("+m3s+")\n") + addDumpTest(nm3, "(*"+m3t+")()\n") + addDumpTest(nilMap3, "("+m3t+") \n") + + // Map with nil interface value. + k4 := "nil" + k4Len := fmt.Sprintf("%d", len(k4)) + m4 := map[string]interface{}{k4: nil} + m4Len := fmt.Sprintf("%d", len(m4)) + nilMap4 := map[string]interface{}(nil) + nm4 := (*map[string]interface{})(nil) + pm4 := &m4 + m4Addr := fmt.Sprintf("%p", pm4) + pm4Addr := fmt.Sprintf("%p", &pm4) + m4t := "map[string]interface {}" + m4t1 := "string" + m4t2 := "interface {}" + m4s := "(len=" + m4Len + ") {\n (" + m4t1 + ") (len=" + k4Len + ")" + + " \"nil\": (" + m4t2 + ") \n}" + addDumpTest(m4, "("+m4t+") "+m4s+"\n") + addDumpTest(pm4, "(*"+m4t+")("+m4Addr+")("+m4s+")\n") + addDumpTest(&pm4, "(**"+m4t+")("+pm4Addr+"->"+m4Addr+")("+m4s+")\n") + addDumpTest(nm4, "(*"+m4t+")()\n") + addDumpTest(nilMap4, "("+m4t+") \n") +} + +func addStructDumpTests() { + // Struct with primitives. + type s1 struct { + a int8 + b uint8 + } + v := s1{127, 255} + nv := (*s1)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "spew_test.s1" + vt2 := "int8" + vt3 := "uint8" + vs := "{\n a: (" + vt2 + ") 127,\n b: (" + vt3 + ") 255\n}" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Struct that contains another struct. + type s2 struct { + s1 s1 + b bool + } + v2 := s2{s1{127, 255}, true} + nv2 := (*s2)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "spew_test.s2" + v2t2 := "spew_test.s1" + v2t3 := "int8" + v2t4 := "uint8" + v2t5 := "bool" + v2s := "{\n s1: (" + v2t2 + ") {\n a: (" + v2t3 + ") 127,\n b: (" + + v2t4 + ") 255\n },\n b: (" + v2t5 + ") true\n}" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv2, "(*"+v2t+")()\n") + + // Struct that contains custom type with Stringer pointer interface via both + // exported and unexported fields. + type s3 struct { + s pstringer + S pstringer + } + v3 := s3{"test", "test2"} + nv3 := (*s3)(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "spew_test.s3" + v3t2 := "spew_test.pstringer" + v3s := "{\n s: (" + v3t2 + ") (len=4) stringer test,\n S: (" + v3t2 + + ") (len=5) stringer test2\n}" + v3sp := v3s + if spew.UnsafeDisabled { + v3s = "{\n s: (" + v3t2 + ") (len=4) \"test\",\n S: (" + + v3t2 + ") (len=5) \"test2\"\n}" + v3sp = "{\n s: (" + v3t2 + ") (len=4) \"test\",\n S: (" + + v3t2 + ") (len=5) stringer test2\n}" + } + addDumpTest(v3, "("+v3t+") "+v3s+"\n") + addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3sp+")\n") + addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3sp+")\n") + addDumpTest(nv3, "(*"+v3t+")()\n") + + // Struct that contains embedded struct and field to same struct. + e := embed{"embedstr"} + eLen := fmt.Sprintf("%d", len("embedstr")) + v4 := embedwrap{embed: &e, e: &e} + nv4 := (*embedwrap)(nil) + pv4 := &v4 + eAddr := fmt.Sprintf("%p", &e) + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "spew_test.embedwrap" + v4t2 := "spew_test.embed" + v4t3 := "string" + v4s := "{\n embed: (*" + v4t2 + ")(" + eAddr + ")({\n a: (" + v4t3 + + ") (len=" + eLen + ") \"embedstr\"\n }),\n e: (*" + v4t2 + + ")(" + eAddr + ")({\n a: (" + v4t3 + ") (len=" + eLen + ")" + + " \"embedstr\"\n })\n}" + addDumpTest(v4, "("+v4t+") "+v4s+"\n") + addDumpTest(pv4, "(*"+v4t+")("+v4Addr+")("+v4s+")\n") + addDumpTest(&pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")("+v4s+")\n") + addDumpTest(nv4, "(*"+v4t+")()\n") +} + +func addUintptrDumpTests() { + // Null pointer. + v := uintptr(0) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "uintptr" + vs := "" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + + // Address of real variable. + i := 1 + v2 := uintptr(unsafe.Pointer(&i)) + nv2 := (*uintptr)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "uintptr" + v2s := fmt.Sprintf("%p", &i) + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv2, "(*"+v2t+")()\n") +} + +func addUnsafePointerDumpTests() { + // Null pointer. + v := unsafe.Pointer(uintptr(0)) + nv := (*unsafe.Pointer)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "unsafe.Pointer" + vs := "" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Address of real variable. + i := 1 + v2 := unsafe.Pointer(&i) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "unsafe.Pointer" + v2s := fmt.Sprintf("%p", &i) + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv, "(*"+vt+")()\n") +} + +func addChanDumpTests() { + // Nil channel. + var v chan int + pv := &v + nv := (*chan int)(nil) + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "chan int" + vs := "" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Real channel. + v2 := make(chan int) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "chan int" + v2s := fmt.Sprintf("%p", v2) + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") +} + +func addFuncDumpTests() { + // Function with no params and no returns. + v := addIntDumpTests + nv := (*func())(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "func()" + vs := fmt.Sprintf("%p", v) + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") + + // Function with param and no returns. + v2 := TestDump + nv2 := (*func(*testing.T))(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "func(*testing.T)" + v2s := fmt.Sprintf("%p", v2) + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s+")\n") + addDumpTest(nv2, "(*"+v2t+")()\n") + + // Function with multiple params and multiple returns. + var v3 = func(i int, s string) (b bool, err error) { + return true, nil + } + nv3 := (*func(int, string) (bool, error))(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "func(int, string) (bool, error)" + v3s := fmt.Sprintf("%p", v3) + addDumpTest(v3, "("+v3t+") "+v3s+"\n") + addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s+")\n") + addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s+")\n") + addDumpTest(nv3, "(*"+v3t+")()\n") +} + +func addCircularDumpTests() { + // Struct that is circular through self referencing. + type circular struct { + c *circular + } + v := circular{nil} + v.c = &v + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "spew_test.circular" + vs := "{\n c: (*" + vt + ")(" + vAddr + ")({\n c: (*" + vt + ")(" + + vAddr + ")()\n })\n}" + vs2 := "{\n c: (*" + vt + ")(" + vAddr + ")()\n}" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs2+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs2+")\n") + + // Structs that are circular through cross referencing. + v2 := xref1{nil} + ts2 := xref2{&v2} + v2.ps2 = &ts2 + pv2 := &v2 + ts2Addr := fmt.Sprintf("%p", &ts2) + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "spew_test.xref1" + v2t2 := "spew_test.xref2" + v2s := "{\n ps2: (*" + v2t2 + ")(" + ts2Addr + ")({\n ps1: (*" + v2t + + ")(" + v2Addr + ")({\n ps2: (*" + v2t2 + ")(" + ts2Addr + + ")()\n })\n })\n}" + v2s2 := "{\n ps2: (*" + v2t2 + ")(" + ts2Addr + ")({\n ps1: (*" + v2t + + ")(" + v2Addr + ")()\n })\n}" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + addDumpTest(pv2, "(*"+v2t+")("+v2Addr+")("+v2s2+")\n") + addDumpTest(&pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")("+v2s2+")\n") + + // Structs that are indirectly circular. + v3 := indirCir1{nil} + tic2 := indirCir2{nil} + tic3 := indirCir3{&v3} + tic2.ps3 = &tic3 + v3.ps2 = &tic2 + pv3 := &v3 + tic2Addr := fmt.Sprintf("%p", &tic2) + tic3Addr := fmt.Sprintf("%p", &tic3) + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "spew_test.indirCir1" + v3t2 := "spew_test.indirCir2" + v3t3 := "spew_test.indirCir3" + v3s := "{\n ps2: (*" + v3t2 + ")(" + tic2Addr + ")({\n ps3: (*" + v3t3 + + ")(" + tic3Addr + ")({\n ps1: (*" + v3t + ")(" + v3Addr + + ")({\n ps2: (*" + v3t2 + ")(" + tic2Addr + + ")()\n })\n })\n })\n}" + v3s2 := "{\n ps2: (*" + v3t2 + ")(" + tic2Addr + ")({\n ps3: (*" + v3t3 + + ")(" + tic3Addr + ")({\n ps1: (*" + v3t + ")(" + v3Addr + + ")()\n })\n })\n}" + addDumpTest(v3, "("+v3t+") "+v3s+"\n") + addDumpTest(pv3, "(*"+v3t+")("+v3Addr+")("+v3s2+")\n") + addDumpTest(&pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")("+v3s2+")\n") +} + +func addPanicDumpTests() { + // Type that panics in its Stringer interface. + v := panicer(127) + nv := (*panicer)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "spew_test.panicer" + vs := "(PANIC=test panic)127" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") +} + +func addErrorDumpTests() { + // Type that has a custom Error interface. + v := customError(127) + nv := (*customError)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "spew_test.customError" + vs := "error: 127" + addDumpTest(v, "("+vt+") "+vs+"\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")("+vs+")\n") + addDumpTest(nv, "(*"+vt+")()\n") +} + +// TestDump executes all of the tests described by dumpTests. +func TestDump(t *testing.T) { + // Setup tests. + addIntDumpTests() + addUintDumpTests() + addBoolDumpTests() + addFloatDumpTests() + addComplexDumpTests() + addArrayDumpTests() + addSliceDumpTests() + addStringDumpTests() + addInterfaceDumpTests() + addMapDumpTests() + addStructDumpTests() + addUintptrDumpTests() + addUnsafePointerDumpTests() + addChanDumpTests() + addFuncDumpTests() + addCircularDumpTests() + addPanicDumpTests() + addErrorDumpTests() + addCgoDumpTests() + + t.Logf("Running %d tests", len(dumpTests)) + for i, test := range dumpTests { + buf := new(bytes.Buffer) + spew.Fdump(buf, test.in) + s := buf.String() + if testFailed(s, test.wants) { + t.Errorf("Dump #%d\n got: %s %s", i, s, stringizeWants(test.wants)) + continue + } + } +} + +func TestDumpSortedKeys(t *testing.T) { + cfg := spew.ConfigState{SortKeys: true} + s := cfg.Sdump(map[int]string{1: "1", 3: "3", 2: "2"}) + expected := "(map[int]string) (len=3) {\n(int) 1: (string) (len=1) " + + "\"1\",\n(int) 2: (string) (len=1) \"2\",\n(int) 3: (string) " + + "(len=1) \"3\"\n" + + "}\n" + if s != expected { + t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) + } + + s = cfg.Sdump(map[stringer]int{"1": 1, "3": 3, "2": 2}) + expected = "(map[spew_test.stringer]int) (len=3) {\n" + + "(spew_test.stringer) (len=1) stringer 1: (int) 1,\n" + + "(spew_test.stringer) (len=1) stringer 2: (int) 2,\n" + + "(spew_test.stringer) (len=1) stringer 3: (int) 3\n" + + "}\n" + if s != expected { + t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) + } + + s = cfg.Sdump(map[pstringer]int{pstringer("1"): 1, pstringer("3"): 3, pstringer("2"): 2}) + expected = "(map[spew_test.pstringer]int) (len=3) {\n" + + "(spew_test.pstringer) (len=1) stringer 1: (int) 1,\n" + + "(spew_test.pstringer) (len=1) stringer 2: (int) 2,\n" + + "(spew_test.pstringer) (len=1) stringer 3: (int) 3\n" + + "}\n" + if spew.UnsafeDisabled { + expected = "(map[spew_test.pstringer]int) (len=3) {\n" + + "(spew_test.pstringer) (len=1) \"1\": (int) 1,\n" + + "(spew_test.pstringer) (len=1) \"2\": (int) 2,\n" + + "(spew_test.pstringer) (len=1) \"3\": (int) 3\n" + + "}\n" + } + if s != expected { + t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) + } + + s = cfg.Sdump(map[customError]int{customError(1): 1, customError(3): 3, customError(2): 2}) + expected = "(map[spew_test.customError]int) (len=3) {\n" + + "(spew_test.customError) error: 1: (int) 1,\n" + + "(spew_test.customError) error: 2: (int) 2,\n" + + "(spew_test.customError) error: 3: (int) 3\n" + + "}\n" + if s != expected { + t.Errorf("Sorted keys mismatch:\n %v %v", s, expected) + } + +} diff --git a/vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go b/vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go new file mode 100644 index 0000000..6ab1808 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/dumpcgo_test.go @@ -0,0 +1,99 @@ +// Copyright (c) 2013-2016 Dave Collins +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// NOTE: Due to the following build constraints, this file will only be compiled +// when both cgo is supported and "-tags testcgo" is added to the go test +// command line. This means the cgo tests are only added (and hence run) when +// specifially requested. This configuration is used because spew itself +// does not require cgo to run even though it does handle certain cgo types +// specially. Rather than forcing all clients to require cgo and an external +// C compiler just to run the tests, this scheme makes them optional. +// +build cgo,testcgo + +package spew_test + +import ( + "fmt" + + "github.com/davecgh/go-spew/spew/testdata" +) + +func addCgoDumpTests() { + // C char pointer. + v := testdata.GetCgoCharPointer() + nv := testdata.GetCgoNullCharPointer() + pv := &v + vcAddr := fmt.Sprintf("%p", v) + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "*testdata._Ctype_char" + vs := "116" + addDumpTest(v, "("+vt+")("+vcAddr+")("+vs+")\n") + addDumpTest(pv, "(*"+vt+")("+vAddr+"->"+vcAddr+")("+vs+")\n") + addDumpTest(&pv, "(**"+vt+")("+pvAddr+"->"+vAddr+"->"+vcAddr+")("+vs+")\n") + addDumpTest(nv, "("+vt+")()\n") + + // C char array. + v2, v2l, v2c := testdata.GetCgoCharArray() + v2Len := fmt.Sprintf("%d", v2l) + v2Cap := fmt.Sprintf("%d", v2c) + v2t := "[6]testdata._Ctype_char" + v2s := "(len=" + v2Len + " cap=" + v2Cap + ") " + + "{\n 00000000 74 65 73 74 32 00 " + + " |test2.|\n}" + addDumpTest(v2, "("+v2t+") "+v2s+"\n") + + // C unsigned char array. + v3, v3l, v3c := testdata.GetCgoUnsignedCharArray() + v3Len := fmt.Sprintf("%d", v3l) + v3Cap := fmt.Sprintf("%d", v3c) + v3t := "[6]testdata._Ctype_unsignedchar" + v3t2 := "[6]testdata._Ctype_uchar" + v3s := "(len=" + v3Len + " cap=" + v3Cap + ") " + + "{\n 00000000 74 65 73 74 33 00 " + + " |test3.|\n}" + addDumpTest(v3, "("+v3t+") "+v3s+"\n", "("+v3t2+") "+v3s+"\n") + + // C signed char array. + v4, v4l, v4c := testdata.GetCgoSignedCharArray() + v4Len := fmt.Sprintf("%d", v4l) + v4Cap := fmt.Sprintf("%d", v4c) + v4t := "[6]testdata._Ctype_schar" + v4t2 := "testdata._Ctype_schar" + v4s := "(len=" + v4Len + " cap=" + v4Cap + ") " + + "{\n (" + v4t2 + ") 116,\n (" + v4t2 + ") 101,\n (" + v4t2 + + ") 115,\n (" + v4t2 + ") 116,\n (" + v4t2 + ") 52,\n (" + v4t2 + + ") 0\n}" + addDumpTest(v4, "("+v4t+") "+v4s+"\n") + + // C uint8_t array. + v5, v5l, v5c := testdata.GetCgoUint8tArray() + v5Len := fmt.Sprintf("%d", v5l) + v5Cap := fmt.Sprintf("%d", v5c) + v5t := "[6]testdata._Ctype_uint8_t" + v5s := "(len=" + v5Len + " cap=" + v5Cap + ") " + + "{\n 00000000 74 65 73 74 35 00 " + + " |test5.|\n}" + addDumpTest(v5, "("+v5t+") "+v5s+"\n") + + // C typedefed unsigned char array. + v6, v6l, v6c := testdata.GetCgoTypdefedUnsignedCharArray() + v6Len := fmt.Sprintf("%d", v6l) + v6Cap := fmt.Sprintf("%d", v6c) + v6t := "[6]testdata._Ctype_custom_uchar_t" + v6s := "(len=" + v6Len + " cap=" + v6Cap + ") " + + "{\n 00000000 74 65 73 74 36 00 " + + " |test6.|\n}" + addDumpTest(v6, "("+v6t+") "+v6s+"\n") +} diff --git a/vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go b/vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go new file mode 100644 index 0000000..52a0971 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/dumpnocgo_test.go @@ -0,0 +1,26 @@ +// Copyright (c) 2013 Dave Collins +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// NOTE: Due to the following build constraints, this file will only be compiled +// when either cgo is not supported or "-tags testcgo" is not added to the go +// test command line. This file intentionally does not setup any cgo tests in +// this scenario. +// +build !cgo !testcgo + +package spew_test + +func addCgoDumpTests() { + // Don't add any tests for cgo since this file is only compiled when + // there should not be any cgo tests. +} diff --git a/vendor/github.com/davecgh/go-spew/spew/example_test.go b/vendor/github.com/davecgh/go-spew/spew/example_test.go new file mode 100644 index 0000000..c6ec8c6 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/example_test.go @@ -0,0 +1,226 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew_test + +import ( + "fmt" + + "github.com/davecgh/go-spew/spew" +) + +type Flag int + +const ( + flagOne Flag = iota + flagTwo +) + +var flagStrings = map[Flag]string{ + flagOne: "flagOne", + flagTwo: "flagTwo", +} + +func (f Flag) String() string { + if s, ok := flagStrings[f]; ok { + return s + } + return fmt.Sprintf("Unknown flag (%d)", int(f)) +} + +type Bar struct { + data uintptr +} + +type Foo struct { + unexportedField Bar + ExportedField map[interface{}]interface{} +} + +// This example demonstrates how to use Dump to dump variables to stdout. +func ExampleDump() { + // The following package level declarations are assumed for this example: + /* + type Flag int + + const ( + flagOne Flag = iota + flagTwo + ) + + var flagStrings = map[Flag]string{ + flagOne: "flagOne", + flagTwo: "flagTwo", + } + + func (f Flag) String() string { + if s, ok := flagStrings[f]; ok { + return s + } + return fmt.Sprintf("Unknown flag (%d)", int(f)) + } + + type Bar struct { + data uintptr + } + + type Foo struct { + unexportedField Bar + ExportedField map[interface{}]interface{} + } + */ + + // Setup some sample data structures for the example. + bar := Bar{uintptr(0)} + s1 := Foo{bar, map[interface{}]interface{}{"one": true}} + f := Flag(5) + b := []byte{ + 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, + 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20, + 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, + 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30, + 0x31, 0x32, + } + + // Dump! + spew.Dump(s1, f, b) + + // Output: + // (spew_test.Foo) { + // unexportedField: (spew_test.Bar) { + // data: (uintptr) + // }, + // ExportedField: (map[interface {}]interface {}) (len=1) { + // (string) (len=3) "one": (bool) true + // } + // } + // (spew_test.Flag) Unknown flag (5) + // ([]uint8) (len=34 cap=34) { + // 00000000 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20 |............... | + // 00000010 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f 30 |!"#$%&'()*+,-./0| + // 00000020 31 32 |12| + // } + // +} + +// This example demonstrates how to use Printf to display a variable with a +// format string and inline formatting. +func ExamplePrintf() { + // Create a double pointer to a uint 8. + ui8 := uint8(5) + pui8 := &ui8 + ppui8 := &pui8 + + // Create a circular data type. + type circular struct { + ui8 uint8 + c *circular + } + c := circular{ui8: 1} + c.c = &c + + // Print! + spew.Printf("ppui8: %v\n", ppui8) + spew.Printf("circular: %v\n", c) + + // Output: + // ppui8: <**>5 + // circular: {1 <*>{1 <*>}} +} + +// This example demonstrates how to use a ConfigState. +func ExampleConfigState() { + // Modify the indent level of the ConfigState only. The global + // configuration is not modified. + scs := spew.ConfigState{Indent: "\t"} + + // Output using the ConfigState instance. + v := map[string]int{"one": 1} + scs.Printf("v: %v\n", v) + scs.Dump(v) + + // Output: + // v: map[one:1] + // (map[string]int) (len=1) { + // (string) (len=3) "one": (int) 1 + // } +} + +// This example demonstrates how to use ConfigState.Dump to dump variables to +// stdout +func ExampleConfigState_Dump() { + // See the top-level Dump example for details on the types used in this + // example. + + // Create two ConfigState instances with different indentation. + scs := spew.ConfigState{Indent: "\t"} + scs2 := spew.ConfigState{Indent: " "} + + // Setup some sample data structures for the example. + bar := Bar{uintptr(0)} + s1 := Foo{bar, map[interface{}]interface{}{"one": true}} + + // Dump using the ConfigState instances. + scs.Dump(s1) + scs2.Dump(s1) + + // Output: + // (spew_test.Foo) { + // unexportedField: (spew_test.Bar) { + // data: (uintptr) + // }, + // ExportedField: (map[interface {}]interface {}) (len=1) { + // (string) (len=3) "one": (bool) true + // } + // } + // (spew_test.Foo) { + // unexportedField: (spew_test.Bar) { + // data: (uintptr) + // }, + // ExportedField: (map[interface {}]interface {}) (len=1) { + // (string) (len=3) "one": (bool) true + // } + // } + // +} + +// This example demonstrates how to use ConfigState.Printf to display a variable +// with a format string and inline formatting. +func ExampleConfigState_Printf() { + // See the top-level Dump example for details on the types used in this + // example. + + // Create two ConfigState instances and modify the method handling of the + // first ConfigState only. + scs := spew.NewDefaultConfig() + scs2 := spew.NewDefaultConfig() + scs.DisableMethods = true + + // Alternatively + // scs := spew.ConfigState{Indent: " ", DisableMethods: true} + // scs2 := spew.ConfigState{Indent: " "} + + // This is of type Flag which implements a Stringer and has raw value 1. + f := flagTwo + + // Dump using the ConfigState instances. + scs.Printf("f: %v\n", f) + scs2.Printf("f: %v\n", f) + + // Output: + // f: 1 + // f: flagTwo +} diff --git a/vendor/github.com/davecgh/go-spew/spew/format.go b/vendor/github.com/davecgh/go-spew/spew/format.go new file mode 100644 index 0000000..c49875b --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/format.go @@ -0,0 +1,419 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew + +import ( + "bytes" + "fmt" + "reflect" + "strconv" + "strings" +) + +// supportedFlags is a list of all the character flags supported by fmt package. +const supportedFlags = "0-+# " + +// formatState implements the fmt.Formatter interface and contains information +// about the state of a formatting operation. The NewFormatter function can +// be used to get a new Formatter which can be used directly as arguments +// in standard fmt package printing calls. +type formatState struct { + value interface{} + fs fmt.State + depth int + pointers map[uintptr]int + ignoreNextType bool + cs *ConfigState +} + +// buildDefaultFormat recreates the original format string without precision +// and width information to pass in to fmt.Sprintf in the case of an +// unrecognized type. Unless new types are added to the language, this +// function won't ever be called. +func (f *formatState) buildDefaultFormat() (format string) { + buf := bytes.NewBuffer(percentBytes) + + for _, flag := range supportedFlags { + if f.fs.Flag(int(flag)) { + buf.WriteRune(flag) + } + } + + buf.WriteRune('v') + + format = buf.String() + return format +} + +// constructOrigFormat recreates the original format string including precision +// and width information to pass along to the standard fmt package. This allows +// automatic deferral of all format strings this package doesn't support. +func (f *formatState) constructOrigFormat(verb rune) (format string) { + buf := bytes.NewBuffer(percentBytes) + + for _, flag := range supportedFlags { + if f.fs.Flag(int(flag)) { + buf.WriteRune(flag) + } + } + + if width, ok := f.fs.Width(); ok { + buf.WriteString(strconv.Itoa(width)) + } + + if precision, ok := f.fs.Precision(); ok { + buf.Write(precisionBytes) + buf.WriteString(strconv.Itoa(precision)) + } + + buf.WriteRune(verb) + + format = buf.String() + return format +} + +// unpackValue returns values inside of non-nil interfaces when possible and +// ensures that types for values which have been unpacked from an interface +// are displayed when the show types flag is also set. +// This is useful for data types like structs, arrays, slices, and maps which +// can contain varying types packed inside an interface. +func (f *formatState) unpackValue(v reflect.Value) reflect.Value { + if v.Kind() == reflect.Interface { + f.ignoreNextType = false + if !v.IsNil() { + v = v.Elem() + } + } + return v +} + +// formatPtr handles formatting of pointers by indirecting them as necessary. +func (f *formatState) formatPtr(v reflect.Value) { + // Display nil if top level pointer is nil. + showTypes := f.fs.Flag('#') + if v.IsNil() && (!showTypes || f.ignoreNextType) { + f.fs.Write(nilAngleBytes) + return + } + + // Remove pointers at or below the current depth from map used to detect + // circular refs. + for k, depth := range f.pointers { + if depth >= f.depth { + delete(f.pointers, k) + } + } + + // Keep list of all dereferenced pointers to possibly show later. + pointerChain := make([]uintptr, 0) + + // Figure out how many levels of indirection there are by derferencing + // pointers and unpacking interfaces down the chain while detecting circular + // references. + nilFound := false + cycleFound := false + indirects := 0 + ve := v + for ve.Kind() == reflect.Ptr { + if ve.IsNil() { + nilFound = true + break + } + indirects++ + addr := ve.Pointer() + pointerChain = append(pointerChain, addr) + if pd, ok := f.pointers[addr]; ok && pd < f.depth { + cycleFound = true + indirects-- + break + } + f.pointers[addr] = f.depth + + ve = ve.Elem() + if ve.Kind() == reflect.Interface { + if ve.IsNil() { + nilFound = true + break + } + ve = ve.Elem() + } + } + + // Display type or indirection level depending on flags. + if showTypes && !f.ignoreNextType { + f.fs.Write(openParenBytes) + f.fs.Write(bytes.Repeat(asteriskBytes, indirects)) + f.fs.Write([]byte(ve.Type().String())) + f.fs.Write(closeParenBytes) + } else { + if nilFound || cycleFound { + indirects += strings.Count(ve.Type().String(), "*") + } + f.fs.Write(openAngleBytes) + f.fs.Write([]byte(strings.Repeat("*", indirects))) + f.fs.Write(closeAngleBytes) + } + + // Display pointer information depending on flags. + if f.fs.Flag('+') && (len(pointerChain) > 0) { + f.fs.Write(openParenBytes) + for i, addr := range pointerChain { + if i > 0 { + f.fs.Write(pointerChainBytes) + } + printHexPtr(f.fs, addr) + } + f.fs.Write(closeParenBytes) + } + + // Display dereferenced value. + switch { + case nilFound == true: + f.fs.Write(nilAngleBytes) + + case cycleFound == true: + f.fs.Write(circularShortBytes) + + default: + f.ignoreNextType = true + f.format(ve) + } +} + +// format is the main workhorse for providing the Formatter interface. It +// uses the passed reflect value to figure out what kind of object we are +// dealing with and formats it appropriately. It is a recursive function, +// however circular data structures are detected and handled properly. +func (f *formatState) format(v reflect.Value) { + // Handle invalid reflect values immediately. + kind := v.Kind() + if kind == reflect.Invalid { + f.fs.Write(invalidAngleBytes) + return + } + + // Handle pointers specially. + if kind == reflect.Ptr { + f.formatPtr(v) + return + } + + // Print type information unless already handled elsewhere. + if !f.ignoreNextType && f.fs.Flag('#') { + f.fs.Write(openParenBytes) + f.fs.Write([]byte(v.Type().String())) + f.fs.Write(closeParenBytes) + } + f.ignoreNextType = false + + // Call Stringer/error interfaces if they exist and the handle methods + // flag is enabled. + if !f.cs.DisableMethods { + if (kind != reflect.Invalid) && (kind != reflect.Interface) { + if handled := handleMethods(f.cs, f.fs, v); handled { + return + } + } + } + + switch kind { + case reflect.Invalid: + // Do nothing. We should never get here since invalid has already + // been handled above. + + case reflect.Bool: + printBool(f.fs, v.Bool()) + + case reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, reflect.Int: + printInt(f.fs, v.Int(), 10) + + case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, reflect.Uint: + printUint(f.fs, v.Uint(), 10) + + case reflect.Float32: + printFloat(f.fs, v.Float(), 32) + + case reflect.Float64: + printFloat(f.fs, v.Float(), 64) + + case reflect.Complex64: + printComplex(f.fs, v.Complex(), 32) + + case reflect.Complex128: + printComplex(f.fs, v.Complex(), 64) + + case reflect.Slice: + if v.IsNil() { + f.fs.Write(nilAngleBytes) + break + } + fallthrough + + case reflect.Array: + f.fs.Write(openBracketBytes) + f.depth++ + if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { + f.fs.Write(maxShortBytes) + } else { + numEntries := v.Len() + for i := 0; i < numEntries; i++ { + if i > 0 { + f.fs.Write(spaceBytes) + } + f.ignoreNextType = true + f.format(f.unpackValue(v.Index(i))) + } + } + f.depth-- + f.fs.Write(closeBracketBytes) + + case reflect.String: + f.fs.Write([]byte(v.String())) + + case reflect.Interface: + // The only time we should get here is for nil interfaces due to + // unpackValue calls. + if v.IsNil() { + f.fs.Write(nilAngleBytes) + } + + case reflect.Ptr: + // Do nothing. We should never get here since pointers have already + // been handled above. + + case reflect.Map: + // nil maps should be indicated as different than empty maps + if v.IsNil() { + f.fs.Write(nilAngleBytes) + break + } + + f.fs.Write(openMapBytes) + f.depth++ + if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { + f.fs.Write(maxShortBytes) + } else { + keys := v.MapKeys() + if f.cs.SortKeys { + sortValues(keys, f.cs) + } + for i, key := range keys { + if i > 0 { + f.fs.Write(spaceBytes) + } + f.ignoreNextType = true + f.format(f.unpackValue(key)) + f.fs.Write(colonBytes) + f.ignoreNextType = true + f.format(f.unpackValue(v.MapIndex(key))) + } + } + f.depth-- + f.fs.Write(closeMapBytes) + + case reflect.Struct: + numFields := v.NumField() + f.fs.Write(openBraceBytes) + f.depth++ + if (f.cs.MaxDepth != 0) && (f.depth > f.cs.MaxDepth) { + f.fs.Write(maxShortBytes) + } else { + vt := v.Type() + for i := 0; i < numFields; i++ { + if i > 0 { + f.fs.Write(spaceBytes) + } + vtf := vt.Field(i) + if f.fs.Flag('+') || f.fs.Flag('#') { + f.fs.Write([]byte(vtf.Name)) + f.fs.Write(colonBytes) + } + f.format(f.unpackValue(v.Field(i))) + } + } + f.depth-- + f.fs.Write(closeBraceBytes) + + case reflect.Uintptr: + printHexPtr(f.fs, uintptr(v.Uint())) + + case reflect.UnsafePointer, reflect.Chan, reflect.Func: + printHexPtr(f.fs, v.Pointer()) + + // There were not any other types at the time this code was written, but + // fall back to letting the default fmt package handle it if any get added. + default: + format := f.buildDefaultFormat() + if v.CanInterface() { + fmt.Fprintf(f.fs, format, v.Interface()) + } else { + fmt.Fprintf(f.fs, format, v.String()) + } + } +} + +// Format satisfies the fmt.Formatter interface. See NewFormatter for usage +// details. +func (f *formatState) Format(fs fmt.State, verb rune) { + f.fs = fs + + // Use standard formatting for verbs that are not v. + if verb != 'v' { + format := f.constructOrigFormat(verb) + fmt.Fprintf(fs, format, f.value) + return + } + + if f.value == nil { + if fs.Flag('#') { + fs.Write(interfaceBytes) + } + fs.Write(nilAngleBytes) + return + } + + f.format(reflect.ValueOf(f.value)) +} + +// newFormatter is a helper function to consolidate the logic from the various +// public methods which take varying config states. +func newFormatter(cs *ConfigState, v interface{}) fmt.Formatter { + fs := &formatState{value: v, cs: cs} + fs.pointers = make(map[uintptr]int) + return fs +} + +/* +NewFormatter returns a custom formatter that satisfies the fmt.Formatter +interface. As a result, it integrates cleanly with standard fmt package +printing functions. The formatter is useful for inline printing of smaller data +types similar to the standard %v format specifier. + +The custom formatter only responds to the %v (most compact), %+v (adds pointer +addresses), %#v (adds types), or %#+v (adds types and pointer addresses) verb +combinations. Any other verbs such as %x and %q will be sent to the the +standard fmt package for formatting. In addition, the custom formatter ignores +the width and precision arguments (however they will still work on the format +specifiers not handled by the custom formatter). + +Typically this function shouldn't be called directly. It is much easier to make +use of the custom formatter by calling one of the convenience functions such as +Printf, Println, or Fprintf. +*/ +func NewFormatter(v interface{}) fmt.Formatter { + return newFormatter(&Config, v) +} diff --git a/vendor/github.com/davecgh/go-spew/spew/format_test.go b/vendor/github.com/davecgh/go-spew/spew/format_test.go new file mode 100644 index 0000000..f9b93ab --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/format_test.go @@ -0,0 +1,1558 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* +Test Summary: +NOTE: For each test, a nil pointer, a single pointer and double pointer to the +base test element are also tested to ensure proper indirection across all types. + +- Max int8, int16, int32, int64, int +- Max uint8, uint16, uint32, uint64, uint +- Boolean true and false +- Standard complex64 and complex128 +- Array containing standard ints +- Array containing type with custom formatter on pointer receiver only +- Array containing interfaces +- Slice containing standard float32 values +- Slice containing type with custom formatter on pointer receiver only +- Slice containing interfaces +- Nil slice +- Standard string +- Nil interface +- Sub-interface +- Map with string keys and int vals +- Map with custom formatter type on pointer receiver only keys and vals +- Map with interface keys and values +- Map with nil interface value +- Struct with primitives +- Struct that contains another struct +- Struct that contains custom type with Stringer pointer interface via both + exported and unexported fields +- Struct that contains embedded struct and field to same struct +- Uintptr to 0 (null pointer) +- Uintptr address of real variable +- Unsafe.Pointer to 0 (null pointer) +- Unsafe.Pointer to address of real variable +- Nil channel +- Standard int channel +- Function with no params and no returns +- Function with param and no returns +- Function with multiple params and multiple returns +- Struct that is circular through self referencing +- Structs that are circular through cross referencing +- Structs that are indirectly circular +- Type that panics in its Stringer interface +- Type that has a custom Error interface +- %x passthrough with uint +- %#x passthrough with uint +- %f passthrough with precision +- %f passthrough with width and precision +- %d passthrough with width +- %q passthrough with string +*/ + +package spew_test + +import ( + "bytes" + "fmt" + "testing" + "unsafe" + + "github.com/davecgh/go-spew/spew" +) + +// formatterTest is used to describe a test to be performed against NewFormatter. +type formatterTest struct { + format string + in interface{} + wants []string +} + +// formatterTests houses all of the tests to be performed against NewFormatter. +var formatterTests = make([]formatterTest, 0) + +// addFormatterTest is a helper method to append the passed input and desired +// result to formatterTests. +func addFormatterTest(format string, in interface{}, wants ...string) { + test := formatterTest{format, in, wants} + formatterTests = append(formatterTests, test) +} + +func addIntFormatterTests() { + // Max int8. + v := int8(127) + nv := (*int8)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "int8" + vs := "127" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Max int16. + v2 := int16(32767) + nv2 := (*int16)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "int16" + v2s := "32767" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%v", nv2, "") + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") + + // Max int32. + v3 := int32(2147483647) + nv3 := (*int32)(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "int32" + v3s := "2147483647" + addFormatterTest("%v", v3, v3s) + addFormatterTest("%v", pv3, "<*>"+v3s) + addFormatterTest("%v", &pv3, "<**>"+v3s) + addFormatterTest("%v", nv3, "") + addFormatterTest("%+v", v3, v3s) + addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) + addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%#v", v3, "("+v3t+")"+v3s) + addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s) + addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + addFormatterTest("%#+v", v3, "("+v3t+")"+v3s) + addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s) + addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + + // Max int64. + v4 := int64(9223372036854775807) + nv4 := (*int64)(nil) + pv4 := &v4 + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "int64" + v4s := "9223372036854775807" + addFormatterTest("%v", v4, v4s) + addFormatterTest("%v", pv4, "<*>"+v4s) + addFormatterTest("%v", &pv4, "<**>"+v4s) + addFormatterTest("%v", nv4, "") + addFormatterTest("%+v", v4, v4s) + addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s) + addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s) + addFormatterTest("%+v", nv4, "") + addFormatterTest("%#v", v4, "("+v4t+")"+v4s) + addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s) + addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s) + addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") + addFormatterTest("%#+v", v4, "("+v4t+")"+v4s) + addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s) + addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s) + addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") + + // Max int. + v5 := int(2147483647) + nv5 := (*int)(nil) + pv5 := &v5 + v5Addr := fmt.Sprintf("%p", pv5) + pv5Addr := fmt.Sprintf("%p", &pv5) + v5t := "int" + v5s := "2147483647" + addFormatterTest("%v", v5, v5s) + addFormatterTest("%v", pv5, "<*>"+v5s) + addFormatterTest("%v", &pv5, "<**>"+v5s) + addFormatterTest("%v", nv5, "") + addFormatterTest("%+v", v5, v5s) + addFormatterTest("%+v", pv5, "<*>("+v5Addr+")"+v5s) + addFormatterTest("%+v", &pv5, "<**>("+pv5Addr+"->"+v5Addr+")"+v5s) + addFormatterTest("%+v", nv5, "") + addFormatterTest("%#v", v5, "("+v5t+")"+v5s) + addFormatterTest("%#v", pv5, "(*"+v5t+")"+v5s) + addFormatterTest("%#v", &pv5, "(**"+v5t+")"+v5s) + addFormatterTest("%#v", nv5, "(*"+v5t+")"+"") + addFormatterTest("%#+v", v5, "("+v5t+")"+v5s) + addFormatterTest("%#+v", pv5, "(*"+v5t+")("+v5Addr+")"+v5s) + addFormatterTest("%#+v", &pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")"+v5s) + addFormatterTest("%#+v", nv5, "(*"+v5t+")"+"") +} + +func addUintFormatterTests() { + // Max uint8. + v := uint8(255) + nv := (*uint8)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "uint8" + vs := "255" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Max uint16. + v2 := uint16(65535) + nv2 := (*uint16)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "uint16" + v2s := "65535" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%v", nv2, "") + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") + + // Max uint32. + v3 := uint32(4294967295) + nv3 := (*uint32)(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "uint32" + v3s := "4294967295" + addFormatterTest("%v", v3, v3s) + addFormatterTest("%v", pv3, "<*>"+v3s) + addFormatterTest("%v", &pv3, "<**>"+v3s) + addFormatterTest("%v", nv3, "") + addFormatterTest("%+v", v3, v3s) + addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) + addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%#v", v3, "("+v3t+")"+v3s) + addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s) + addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + addFormatterTest("%#+v", v3, "("+v3t+")"+v3s) + addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s) + addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + + // Max uint64. + v4 := uint64(18446744073709551615) + nv4 := (*uint64)(nil) + pv4 := &v4 + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "uint64" + v4s := "18446744073709551615" + addFormatterTest("%v", v4, v4s) + addFormatterTest("%v", pv4, "<*>"+v4s) + addFormatterTest("%v", &pv4, "<**>"+v4s) + addFormatterTest("%v", nv4, "") + addFormatterTest("%+v", v4, v4s) + addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s) + addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s) + addFormatterTest("%+v", nv4, "") + addFormatterTest("%#v", v4, "("+v4t+")"+v4s) + addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s) + addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s) + addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") + addFormatterTest("%#+v", v4, "("+v4t+")"+v4s) + addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s) + addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s) + addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") + + // Max uint. + v5 := uint(4294967295) + nv5 := (*uint)(nil) + pv5 := &v5 + v5Addr := fmt.Sprintf("%p", pv5) + pv5Addr := fmt.Sprintf("%p", &pv5) + v5t := "uint" + v5s := "4294967295" + addFormatterTest("%v", v5, v5s) + addFormatterTest("%v", pv5, "<*>"+v5s) + addFormatterTest("%v", &pv5, "<**>"+v5s) + addFormatterTest("%v", nv5, "") + addFormatterTest("%+v", v5, v5s) + addFormatterTest("%+v", pv5, "<*>("+v5Addr+")"+v5s) + addFormatterTest("%+v", &pv5, "<**>("+pv5Addr+"->"+v5Addr+")"+v5s) + addFormatterTest("%+v", nv5, "") + addFormatterTest("%#v", v5, "("+v5t+")"+v5s) + addFormatterTest("%#v", pv5, "(*"+v5t+")"+v5s) + addFormatterTest("%#v", &pv5, "(**"+v5t+")"+v5s) + addFormatterTest("%#v", nv5, "(*"+v5t+")"+"") + addFormatterTest("%#+v", v5, "("+v5t+")"+v5s) + addFormatterTest("%#+v", pv5, "(*"+v5t+")("+v5Addr+")"+v5s) + addFormatterTest("%#+v", &pv5, "(**"+v5t+")("+pv5Addr+"->"+v5Addr+")"+v5s) + addFormatterTest("%#v", nv5, "(*"+v5t+")"+"") +} + +func addBoolFormatterTests() { + // Boolean true. + v := bool(true) + nv := (*bool)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "bool" + vs := "true" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Boolean false. + v2 := bool(false) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "bool" + v2s := "false" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) +} + +func addFloatFormatterTests() { + // Standard float32. + v := float32(3.1415) + nv := (*float32)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "float32" + vs := "3.1415" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Standard float64. + v2 := float64(3.1415926) + nv2 := (*float64)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "float64" + v2s := "3.1415926" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") +} + +func addComplexFormatterTests() { + // Standard complex64. + v := complex(float32(6), -2) + nv := (*complex64)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "complex64" + vs := "(6-2i)" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Standard complex128. + v2 := complex(float64(-6), 2) + nv2 := (*complex128)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "complex128" + v2s := "(-6+2i)" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") +} + +func addArrayFormatterTests() { + // Array containing standard ints. + v := [3]int{1, 2, 3} + nv := (*[3]int)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "[3]int" + vs := "[1 2 3]" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Array containing type with custom formatter on pointer receiver only. + v2 := [3]pstringer{"1", "2", "3"} + nv2 := (*[3]pstringer)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "[3]spew_test.pstringer" + v2sp := "[stringer 1 stringer 2 stringer 3]" + v2s := v2sp + if spew.UnsafeDisabled { + v2s = "[1 2 3]" + } + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2sp) + addFormatterTest("%v", &pv2, "<**>"+v2sp) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2sp) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2sp) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2sp) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2sp) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2sp) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2sp) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") + + // Array containing interfaces. + v3 := [3]interface{}{"one", int(2), uint(3)} + nv3 := (*[3]interface{})(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "[3]interface {}" + v3t2 := "string" + v3t3 := "int" + v3t4 := "uint" + v3s := "[one 2 3]" + v3s2 := "[(" + v3t2 + ")one (" + v3t3 + ")2 (" + v3t4 + ")3]" + addFormatterTest("%v", v3, v3s) + addFormatterTest("%v", pv3, "<*>"+v3s) + addFormatterTest("%v", &pv3, "<**>"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%+v", v3, v3s) + addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) + addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%#v", v3, "("+v3t+")"+v3s2) + addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s2) + addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s2) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + addFormatterTest("%#+v", v3, "("+v3t+")"+v3s2) + addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s2) + addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s2) + addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") +} + +func addSliceFormatterTests() { + // Slice containing standard float32 values. + v := []float32{3.14, 6.28, 12.56} + nv := (*[]float32)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "[]float32" + vs := "[3.14 6.28 12.56]" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Slice containing type with custom formatter on pointer receiver only. + v2 := []pstringer{"1", "2", "3"} + nv2 := (*[]pstringer)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "[]spew_test.pstringer" + v2s := "[stringer 1 stringer 2 stringer 3]" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") + + // Slice containing interfaces. + v3 := []interface{}{"one", int(2), uint(3), nil} + nv3 := (*[]interface{})(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "[]interface {}" + v3t2 := "string" + v3t3 := "int" + v3t4 := "uint" + v3t5 := "interface {}" + v3s := "[one 2 3 ]" + v3s2 := "[(" + v3t2 + ")one (" + v3t3 + ")2 (" + v3t4 + ")3 (" + v3t5 + + ")]" + addFormatterTest("%v", v3, v3s) + addFormatterTest("%v", pv3, "<*>"+v3s) + addFormatterTest("%v", &pv3, "<**>"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%+v", v3, v3s) + addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) + addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%#v", v3, "("+v3t+")"+v3s2) + addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s2) + addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s2) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + addFormatterTest("%#+v", v3, "("+v3t+")"+v3s2) + addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s2) + addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s2) + addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") + + // Nil slice. + var v4 []int + nv4 := (*[]int)(nil) + pv4 := &v4 + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "[]int" + v4s := "" + addFormatterTest("%v", v4, v4s) + addFormatterTest("%v", pv4, "<*>"+v4s) + addFormatterTest("%v", &pv4, "<**>"+v4s) + addFormatterTest("%+v", nv4, "") + addFormatterTest("%+v", v4, v4s) + addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s) + addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s) + addFormatterTest("%+v", nv4, "") + addFormatterTest("%#v", v4, "("+v4t+")"+v4s) + addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s) + addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s) + addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") + addFormatterTest("%#+v", v4, "("+v4t+")"+v4s) + addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s) + addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s) + addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") +} + +func addStringFormatterTests() { + // Standard string. + v := "test" + nv := (*string)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "string" + vs := "test" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") +} + +func addInterfaceFormatterTests() { + // Nil interface. + var v interface{} + nv := (*interface{})(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "interface {}" + vs := "" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Sub-interface. + v2 := interface{}(uint16(65535)) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "uint16" + v2s := "65535" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) +} + +func addMapFormatterTests() { + // Map with string keys and int vals. + v := map[string]int{"one": 1, "two": 2} + nilMap := map[string]int(nil) + nv := (*map[string]int)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "map[string]int" + vs := "map[one:1 two:2]" + vs2 := "map[two:2 one:1]" + addFormatterTest("%v", v, vs, vs2) + addFormatterTest("%v", pv, "<*>"+vs, "<*>"+vs2) + addFormatterTest("%v", &pv, "<**>"+vs, "<**>"+vs2) + addFormatterTest("%+v", nilMap, "") + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs, vs2) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs, "<*>("+vAddr+")"+vs2) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs, + "<**>("+pvAddr+"->"+vAddr+")"+vs2) + addFormatterTest("%+v", nilMap, "") + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs, "("+vt+")"+vs2) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs, "(*"+vt+")"+vs2) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs, "(**"+vt+")"+vs2) + addFormatterTest("%#v", nilMap, "("+vt+")"+"") + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs, "("+vt+")"+vs2) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs, + "(*"+vt+")("+vAddr+")"+vs2) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs, + "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs2) + addFormatterTest("%#+v", nilMap, "("+vt+")"+"") + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Map with custom formatter type on pointer receiver only keys and vals. + v2 := map[pstringer]pstringer{"one": "1"} + nv2 := (*map[pstringer]pstringer)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "map[spew_test.pstringer]spew_test.pstringer" + v2s := "map[stringer one:stringer 1]" + if spew.UnsafeDisabled { + v2s = "map[one:1]" + } + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") + + // Map with interface keys and values. + v3 := map[interface{}]interface{}{"one": 1} + nv3 := (*map[interface{}]interface{})(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "map[interface {}]interface {}" + v3t1 := "string" + v3t2 := "int" + v3s := "map[one:1]" + v3s2 := "map[(" + v3t1 + ")one:(" + v3t2 + ")1]" + addFormatterTest("%v", v3, v3s) + addFormatterTest("%v", pv3, "<*>"+v3s) + addFormatterTest("%v", &pv3, "<**>"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%+v", v3, v3s) + addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) + addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%#v", v3, "("+v3t+")"+v3s2) + addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s2) + addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s2) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + addFormatterTest("%#+v", v3, "("+v3t+")"+v3s2) + addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s2) + addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s2) + addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") + + // Map with nil interface value + v4 := map[string]interface{}{"nil": nil} + nv4 := (*map[string]interface{})(nil) + pv4 := &v4 + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "map[string]interface {}" + v4t1 := "interface {}" + v4s := "map[nil:]" + v4s2 := "map[nil:(" + v4t1 + ")]" + addFormatterTest("%v", v4, v4s) + addFormatterTest("%v", pv4, "<*>"+v4s) + addFormatterTest("%v", &pv4, "<**>"+v4s) + addFormatterTest("%+v", nv4, "") + addFormatterTest("%+v", v4, v4s) + addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s) + addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s) + addFormatterTest("%+v", nv4, "") + addFormatterTest("%#v", v4, "("+v4t+")"+v4s2) + addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s2) + addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s2) + addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") + addFormatterTest("%#+v", v4, "("+v4t+")"+v4s2) + addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s2) + addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s2) + addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") +} + +func addStructFormatterTests() { + // Struct with primitives. + type s1 struct { + a int8 + b uint8 + } + v := s1{127, 255} + nv := (*s1)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "spew_test.s1" + vt2 := "int8" + vt3 := "uint8" + vs := "{127 255}" + vs2 := "{a:127 b:255}" + vs3 := "{a:(" + vt2 + ")127 b:(" + vt3 + ")255}" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs2) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs2) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs2) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs3) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs3) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs3) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs3) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs3) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs3) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Struct that contains another struct. + type s2 struct { + s1 s1 + b bool + } + v2 := s2{s1{127, 255}, true} + nv2 := (*s2)(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "spew_test.s2" + v2t2 := "spew_test.s1" + v2t3 := "int8" + v2t4 := "uint8" + v2t5 := "bool" + v2s := "{{127 255} true}" + v2s2 := "{s1:{a:127 b:255} b:true}" + v2s3 := "{s1:(" + v2t2 + "){a:(" + v2t3 + ")127 b:(" + v2t4 + ")255} b:(" + + v2t5 + ")true}" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%+v", v2, v2s2) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s2) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s2) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s3) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s3) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s3) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s3) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s3) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s3) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") + + // Struct that contains custom type with Stringer pointer interface via both + // exported and unexported fields. + type s3 struct { + s pstringer + S pstringer + } + v3 := s3{"test", "test2"} + nv3 := (*s3)(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "spew_test.s3" + v3t2 := "spew_test.pstringer" + v3s := "{stringer test stringer test2}" + v3sp := v3s + v3s2 := "{s:stringer test S:stringer test2}" + v3s2p := v3s2 + v3s3 := "{s:(" + v3t2 + ")stringer test S:(" + v3t2 + ")stringer test2}" + v3s3p := v3s3 + if spew.UnsafeDisabled { + v3s = "{test test2}" + v3sp = "{test stringer test2}" + v3s2 = "{s:test S:test2}" + v3s2p = "{s:test S:stringer test2}" + v3s3 = "{s:(" + v3t2 + ")test S:(" + v3t2 + ")test2}" + v3s3p = "{s:(" + v3t2 + ")test S:(" + v3t2 + ")stringer test2}" + } + addFormatterTest("%v", v3, v3s) + addFormatterTest("%v", pv3, "<*>"+v3sp) + addFormatterTest("%v", &pv3, "<**>"+v3sp) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%+v", v3, v3s2) + addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s2p) + addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s2p) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%#v", v3, "("+v3t+")"+v3s3) + addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s3p) + addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s3p) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + addFormatterTest("%#+v", v3, "("+v3t+")"+v3s3) + addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s3p) + addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s3p) + addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") + + // Struct that contains embedded struct and field to same struct. + e := embed{"embedstr"} + v4 := embedwrap{embed: &e, e: &e} + nv4 := (*embedwrap)(nil) + pv4 := &v4 + eAddr := fmt.Sprintf("%p", &e) + v4Addr := fmt.Sprintf("%p", pv4) + pv4Addr := fmt.Sprintf("%p", &pv4) + v4t := "spew_test.embedwrap" + v4t2 := "spew_test.embed" + v4t3 := "string" + v4s := "{<*>{embedstr} <*>{embedstr}}" + v4s2 := "{embed:<*>(" + eAddr + "){a:embedstr} e:<*>(" + eAddr + + "){a:embedstr}}" + v4s3 := "{embed:(*" + v4t2 + "){a:(" + v4t3 + ")embedstr} e:(*" + v4t2 + + "){a:(" + v4t3 + ")embedstr}}" + v4s4 := "{embed:(*" + v4t2 + ")(" + eAddr + "){a:(" + v4t3 + + ")embedstr} e:(*" + v4t2 + ")(" + eAddr + "){a:(" + v4t3 + ")embedstr}}" + addFormatterTest("%v", v4, v4s) + addFormatterTest("%v", pv4, "<*>"+v4s) + addFormatterTest("%v", &pv4, "<**>"+v4s) + addFormatterTest("%+v", nv4, "") + addFormatterTest("%+v", v4, v4s2) + addFormatterTest("%+v", pv4, "<*>("+v4Addr+")"+v4s2) + addFormatterTest("%+v", &pv4, "<**>("+pv4Addr+"->"+v4Addr+")"+v4s2) + addFormatterTest("%+v", nv4, "") + addFormatterTest("%#v", v4, "("+v4t+")"+v4s3) + addFormatterTest("%#v", pv4, "(*"+v4t+")"+v4s3) + addFormatterTest("%#v", &pv4, "(**"+v4t+")"+v4s3) + addFormatterTest("%#v", nv4, "(*"+v4t+")"+"") + addFormatterTest("%#+v", v4, "("+v4t+")"+v4s4) + addFormatterTest("%#+v", pv4, "(*"+v4t+")("+v4Addr+")"+v4s4) + addFormatterTest("%#+v", &pv4, "(**"+v4t+")("+pv4Addr+"->"+v4Addr+")"+v4s4) + addFormatterTest("%#+v", nv4, "(*"+v4t+")"+"") +} + +func addUintptrFormatterTests() { + // Null pointer. + v := uintptr(0) + nv := (*uintptr)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "uintptr" + vs := "" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Address of real variable. + i := 1 + v2 := uintptr(unsafe.Pointer(&i)) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "uintptr" + v2s := fmt.Sprintf("%p", &i) + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) +} + +func addUnsafePointerFormatterTests() { + // Null pointer. + v := unsafe.Pointer(uintptr(0)) + nv := (*unsafe.Pointer)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "unsafe.Pointer" + vs := "" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Address of real variable. + i := 1 + v2 := unsafe.Pointer(&i) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "unsafe.Pointer" + v2s := fmt.Sprintf("%p", &i) + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) +} + +func addChanFormatterTests() { + // Nil channel. + var v chan int + pv := &v + nv := (*chan int)(nil) + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "chan int" + vs := "" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Real channel. + v2 := make(chan int) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "chan int" + v2s := fmt.Sprintf("%p", v2) + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) +} + +func addFuncFormatterTests() { + // Function with no params and no returns. + v := addIntFormatterTests + nv := (*func())(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "func()" + vs := fmt.Sprintf("%p", v) + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") + + // Function with param and no returns. + v2 := TestFormatter + nv2 := (*func(*testing.T))(nil) + pv2 := &v2 + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "func(*testing.T)" + v2s := fmt.Sprintf("%p", v2) + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s) + addFormatterTest("%v", &pv2, "<**>"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%+v", v2, v2s) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%+v", nv2, "") + addFormatterTest("%#v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s) + addFormatterTest("%#v", nv2, "(*"+v2t+")"+"") + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s) + addFormatterTest("%#+v", nv2, "(*"+v2t+")"+"") + + // Function with multiple params and multiple returns. + var v3 = func(i int, s string) (b bool, err error) { + return true, nil + } + nv3 := (*func(int, string) (bool, error))(nil) + pv3 := &v3 + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "func(int, string) (bool, error)" + v3s := fmt.Sprintf("%p", v3) + addFormatterTest("%v", v3, v3s) + addFormatterTest("%v", pv3, "<*>"+v3s) + addFormatterTest("%v", &pv3, "<**>"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%+v", v3, v3s) + addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s) + addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%+v", nv3, "") + addFormatterTest("%#v", v3, "("+v3t+")"+v3s) + addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s) + addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s) + addFormatterTest("%#v", nv3, "(*"+v3t+")"+"") + addFormatterTest("%#+v", v3, "("+v3t+")"+v3s) + addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s) + addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s) + addFormatterTest("%#+v", nv3, "(*"+v3t+")"+"") +} + +func addCircularFormatterTests() { + // Struct that is circular through self referencing. + type circular struct { + c *circular + } + v := circular{nil} + v.c = &v + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "spew_test.circular" + vs := "{<*>{<*>}}" + vs2 := "{<*>}" + vs3 := "{c:<*>(" + vAddr + "){c:<*>(" + vAddr + ")}}" + vs4 := "{c:<*>(" + vAddr + ")}" + vs5 := "{c:(*" + vt + "){c:(*" + vt + ")}}" + vs6 := "{c:(*" + vt + ")}" + vs7 := "{c:(*" + vt + ")(" + vAddr + "){c:(*" + vt + ")(" + vAddr + + ")}}" + vs8 := "{c:(*" + vt + ")(" + vAddr + ")}" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs2) + addFormatterTest("%v", &pv, "<**>"+vs2) + addFormatterTest("%+v", v, vs3) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs4) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs4) + addFormatterTest("%#v", v, "("+vt+")"+vs5) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs6) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs6) + addFormatterTest("%#+v", v, "("+vt+")"+vs7) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs8) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs8) + + // Structs that are circular through cross referencing. + v2 := xref1{nil} + ts2 := xref2{&v2} + v2.ps2 = &ts2 + pv2 := &v2 + ts2Addr := fmt.Sprintf("%p", &ts2) + v2Addr := fmt.Sprintf("%p", pv2) + pv2Addr := fmt.Sprintf("%p", &pv2) + v2t := "spew_test.xref1" + v2t2 := "spew_test.xref2" + v2s := "{<*>{<*>{<*>}}}" + v2s2 := "{<*>{<*>}}" + v2s3 := "{ps2:<*>(" + ts2Addr + "){ps1:<*>(" + v2Addr + "){ps2:<*>(" + + ts2Addr + ")}}}" + v2s4 := "{ps2:<*>(" + ts2Addr + "){ps1:<*>(" + v2Addr + ")}}" + v2s5 := "{ps2:(*" + v2t2 + "){ps1:(*" + v2t + "){ps2:(*" + v2t2 + + ")}}}" + v2s6 := "{ps2:(*" + v2t2 + "){ps1:(*" + v2t + ")}}" + v2s7 := "{ps2:(*" + v2t2 + ")(" + ts2Addr + "){ps1:(*" + v2t + + ")(" + v2Addr + "){ps2:(*" + v2t2 + ")(" + ts2Addr + + ")}}}" + v2s8 := "{ps2:(*" + v2t2 + ")(" + ts2Addr + "){ps1:(*" + v2t + + ")(" + v2Addr + ")}}" + addFormatterTest("%v", v2, v2s) + addFormatterTest("%v", pv2, "<*>"+v2s2) + addFormatterTest("%v", &pv2, "<**>"+v2s2) + addFormatterTest("%+v", v2, v2s3) + addFormatterTest("%+v", pv2, "<*>("+v2Addr+")"+v2s4) + addFormatterTest("%+v", &pv2, "<**>("+pv2Addr+"->"+v2Addr+")"+v2s4) + addFormatterTest("%#v", v2, "("+v2t+")"+v2s5) + addFormatterTest("%#v", pv2, "(*"+v2t+")"+v2s6) + addFormatterTest("%#v", &pv2, "(**"+v2t+")"+v2s6) + addFormatterTest("%#+v", v2, "("+v2t+")"+v2s7) + addFormatterTest("%#+v", pv2, "(*"+v2t+")("+v2Addr+")"+v2s8) + addFormatterTest("%#+v", &pv2, "(**"+v2t+")("+pv2Addr+"->"+v2Addr+")"+v2s8) + + // Structs that are indirectly circular. + v3 := indirCir1{nil} + tic2 := indirCir2{nil} + tic3 := indirCir3{&v3} + tic2.ps3 = &tic3 + v3.ps2 = &tic2 + pv3 := &v3 + tic2Addr := fmt.Sprintf("%p", &tic2) + tic3Addr := fmt.Sprintf("%p", &tic3) + v3Addr := fmt.Sprintf("%p", pv3) + pv3Addr := fmt.Sprintf("%p", &pv3) + v3t := "spew_test.indirCir1" + v3t2 := "spew_test.indirCir2" + v3t3 := "spew_test.indirCir3" + v3s := "{<*>{<*>{<*>{<*>}}}}" + v3s2 := "{<*>{<*>{<*>}}}" + v3s3 := "{ps2:<*>(" + tic2Addr + "){ps3:<*>(" + tic3Addr + "){ps1:<*>(" + + v3Addr + "){ps2:<*>(" + tic2Addr + ")}}}}" + v3s4 := "{ps2:<*>(" + tic2Addr + "){ps3:<*>(" + tic3Addr + "){ps1:<*>(" + + v3Addr + ")}}}" + v3s5 := "{ps2:(*" + v3t2 + "){ps3:(*" + v3t3 + "){ps1:(*" + v3t + + "){ps2:(*" + v3t2 + ")}}}}" + v3s6 := "{ps2:(*" + v3t2 + "){ps3:(*" + v3t3 + "){ps1:(*" + v3t + + ")}}}" + v3s7 := "{ps2:(*" + v3t2 + ")(" + tic2Addr + "){ps3:(*" + v3t3 + ")(" + + tic3Addr + "){ps1:(*" + v3t + ")(" + v3Addr + "){ps2:(*" + v3t2 + + ")(" + tic2Addr + ")}}}}" + v3s8 := "{ps2:(*" + v3t2 + ")(" + tic2Addr + "){ps3:(*" + v3t3 + ")(" + + tic3Addr + "){ps1:(*" + v3t + ")(" + v3Addr + ")}}}" + addFormatterTest("%v", v3, v3s) + addFormatterTest("%v", pv3, "<*>"+v3s2) + addFormatterTest("%v", &pv3, "<**>"+v3s2) + addFormatterTest("%+v", v3, v3s3) + addFormatterTest("%+v", pv3, "<*>("+v3Addr+")"+v3s4) + addFormatterTest("%+v", &pv3, "<**>("+pv3Addr+"->"+v3Addr+")"+v3s4) + addFormatterTest("%#v", v3, "("+v3t+")"+v3s5) + addFormatterTest("%#v", pv3, "(*"+v3t+")"+v3s6) + addFormatterTest("%#v", &pv3, "(**"+v3t+")"+v3s6) + addFormatterTest("%#+v", v3, "("+v3t+")"+v3s7) + addFormatterTest("%#+v", pv3, "(*"+v3t+")("+v3Addr+")"+v3s8) + addFormatterTest("%#+v", &pv3, "(**"+v3t+")("+pv3Addr+"->"+v3Addr+")"+v3s8) +} + +func addPanicFormatterTests() { + // Type that panics in its Stringer interface. + v := panicer(127) + nv := (*panicer)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "spew_test.panicer" + vs := "(PANIC=test panic)127" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") +} + +func addErrorFormatterTests() { + // Type that has a custom Error interface. + v := customError(127) + nv := (*customError)(nil) + pv := &v + vAddr := fmt.Sprintf("%p", pv) + pvAddr := fmt.Sprintf("%p", &pv) + vt := "spew_test.customError" + vs := "error: 127" + addFormatterTest("%v", v, vs) + addFormatterTest("%v", pv, "<*>"+vs) + addFormatterTest("%v", &pv, "<**>"+vs) + addFormatterTest("%v", nv, "") + addFormatterTest("%+v", v, vs) + addFormatterTest("%+v", pv, "<*>("+vAddr+")"+vs) + addFormatterTest("%+v", &pv, "<**>("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%+v", nv, "") + addFormatterTest("%#v", v, "("+vt+")"+vs) + addFormatterTest("%#v", pv, "(*"+vt+")"+vs) + addFormatterTest("%#v", &pv, "(**"+vt+")"+vs) + addFormatterTest("%#v", nv, "(*"+vt+")"+"") + addFormatterTest("%#+v", v, "("+vt+")"+vs) + addFormatterTest("%#+v", pv, "(*"+vt+")("+vAddr+")"+vs) + addFormatterTest("%#+v", &pv, "(**"+vt+")("+pvAddr+"->"+vAddr+")"+vs) + addFormatterTest("%#+v", nv, "(*"+vt+")"+"") +} + +func addPassthroughFormatterTests() { + // %x passthrough with uint. + v := uint(4294967295) + pv := &v + vAddr := fmt.Sprintf("%x", pv) + pvAddr := fmt.Sprintf("%x", &pv) + vs := "ffffffff" + addFormatterTest("%x", v, vs) + addFormatterTest("%x", pv, vAddr) + addFormatterTest("%x", &pv, pvAddr) + + // %#x passthrough with uint. + v2 := int(2147483647) + pv2 := &v2 + v2Addr := fmt.Sprintf("%#x", pv2) + pv2Addr := fmt.Sprintf("%#x", &pv2) + v2s := "0x7fffffff" + addFormatterTest("%#x", v2, v2s) + addFormatterTest("%#x", pv2, v2Addr) + addFormatterTest("%#x", &pv2, pv2Addr) + + // %f passthrough with precision. + addFormatterTest("%.2f", 3.1415, "3.14") + addFormatterTest("%.3f", 3.1415, "3.142") + addFormatterTest("%.4f", 3.1415, "3.1415") + + // %f passthrough with width and precision. + addFormatterTest("%5.2f", 3.1415, " 3.14") + addFormatterTest("%6.3f", 3.1415, " 3.142") + addFormatterTest("%7.4f", 3.1415, " 3.1415") + + // %d passthrough with width. + addFormatterTest("%3d", 127, "127") + addFormatterTest("%4d", 127, " 127") + addFormatterTest("%5d", 127, " 127") + + // %q passthrough with string. + addFormatterTest("%q", "test", "\"test\"") +} + +// TestFormatter executes all of the tests described by formatterTests. +func TestFormatter(t *testing.T) { + // Setup tests. + addIntFormatterTests() + addUintFormatterTests() + addBoolFormatterTests() + addFloatFormatterTests() + addComplexFormatterTests() + addArrayFormatterTests() + addSliceFormatterTests() + addStringFormatterTests() + addInterfaceFormatterTests() + addMapFormatterTests() + addStructFormatterTests() + addUintptrFormatterTests() + addUnsafePointerFormatterTests() + addChanFormatterTests() + addFuncFormatterTests() + addCircularFormatterTests() + addPanicFormatterTests() + addErrorFormatterTests() + addPassthroughFormatterTests() + + t.Logf("Running %d tests", len(formatterTests)) + for i, test := range formatterTests { + buf := new(bytes.Buffer) + spew.Fprintf(buf, test.format, test.in) + s := buf.String() + if testFailed(s, test.wants) { + t.Errorf("Formatter #%d format: %s got: %s %s", i, test.format, s, + stringizeWants(test.wants)) + continue + } + } +} + +type testStruct struct { + x int +} + +func (ts testStruct) String() string { + return fmt.Sprintf("ts.%d", ts.x) +} + +type testStructP struct { + x int +} + +func (ts *testStructP) String() string { + return fmt.Sprintf("ts.%d", ts.x) +} + +func TestPrintSortedKeys(t *testing.T) { + cfg := spew.ConfigState{SortKeys: true} + s := cfg.Sprint(map[int]string{1: "1", 3: "3", 2: "2"}) + expected := "map[1:1 2:2 3:3]" + if s != expected { + t.Errorf("Sorted keys mismatch 1:\n %v %v", s, expected) + } + + s = cfg.Sprint(map[stringer]int{"1": 1, "3": 3, "2": 2}) + expected = "map[stringer 1:1 stringer 2:2 stringer 3:3]" + if s != expected { + t.Errorf("Sorted keys mismatch 2:\n %v %v", s, expected) + } + + s = cfg.Sprint(map[pstringer]int{pstringer("1"): 1, pstringer("3"): 3, pstringer("2"): 2}) + expected = "map[stringer 1:1 stringer 2:2 stringer 3:3]" + if spew.UnsafeDisabled { + expected = "map[1:1 2:2 3:3]" + } + if s != expected { + t.Errorf("Sorted keys mismatch 3:\n %v %v", s, expected) + } + + s = cfg.Sprint(map[testStruct]int{testStruct{1}: 1, testStruct{3}: 3, testStruct{2}: 2}) + expected = "map[ts.1:1 ts.2:2 ts.3:3]" + if s != expected { + t.Errorf("Sorted keys mismatch 4:\n %v %v", s, expected) + } + + if !spew.UnsafeDisabled { + s = cfg.Sprint(map[testStructP]int{testStructP{1}: 1, testStructP{3}: 3, testStructP{2}: 2}) + expected = "map[ts.1:1 ts.2:2 ts.3:3]" + if s != expected { + t.Errorf("Sorted keys mismatch 5:\n %v %v", s, expected) + } + } + + s = cfg.Sprint(map[customError]int{customError(1): 1, customError(3): 3, customError(2): 2}) + expected = "map[error: 1:1 error: 2:2 error: 3:3]" + if s != expected { + t.Errorf("Sorted keys mismatch 6:\n %v %v", s, expected) + } +} diff --git a/vendor/github.com/davecgh/go-spew/spew/internal_test.go b/vendor/github.com/davecgh/go-spew/spew/internal_test.go new file mode 100644 index 0000000..20a9cfe --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/internal_test.go @@ -0,0 +1,87 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* +This test file is part of the spew package rather than than the spew_test +package because it needs access to internals to properly test certain cases +which are not possible via the public interface since they should never happen. +*/ + +package spew + +import ( + "bytes" + "reflect" + "testing" +) + +// dummyFmtState implements a fake fmt.State to use for testing invalid +// reflect.Value handling. This is necessary because the fmt package catches +// invalid values before invoking the formatter on them. +type dummyFmtState struct { + bytes.Buffer +} + +func (dfs *dummyFmtState) Flag(f int) bool { + if f == int('+') { + return true + } + return false +} + +func (dfs *dummyFmtState) Precision() (int, bool) { + return 0, false +} + +func (dfs *dummyFmtState) Width() (int, bool) { + return 0, false +} + +// TestInvalidReflectValue ensures the dump and formatter code handles an +// invalid reflect value properly. This needs access to internal state since it +// should never happen in real code and therefore can't be tested via the public +// API. +func TestInvalidReflectValue(t *testing.T) { + i := 1 + + // Dump invalid reflect value. + v := new(reflect.Value) + buf := new(bytes.Buffer) + d := dumpState{w: buf, cs: &Config} + d.dump(*v) + s := buf.String() + want := "" + if s != want { + t.Errorf("InvalidReflectValue #%d\n got: %s want: %s", i, s, want) + } + i++ + + // Formatter invalid reflect value. + buf2 := new(dummyFmtState) + f := formatState{value: *v, cs: &Config, fs: buf2} + f.format(*v) + s = buf2.String() + want = "" + if s != want { + t.Errorf("InvalidReflectValue #%d got: %s want: %s", i, s, want) + } +} + +// SortValues makes the internal sortValues function available to the test +// package. +func SortValues(values []reflect.Value, cs *ConfigState) { + sortValues(values, cs) +} diff --git a/vendor/github.com/davecgh/go-spew/spew/internalunsafe_test.go b/vendor/github.com/davecgh/go-spew/spew/internalunsafe_test.go new file mode 100644 index 0000000..a0c612e --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/internalunsafe_test.go @@ -0,0 +1,102 @@ +// Copyright (c) 2013-2016 Dave Collins + +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. + +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// NOTE: Due to the following build constraints, this file will only be compiled +// when the code is not running on Google App Engine, compiled by GopherJS, and +// "-tags safe" is not added to the go build command line. The "disableunsafe" +// tag is deprecated and thus should not be used. +// +build !js,!appengine,!safe,!disableunsafe + +/* +This test file is part of the spew package rather than than the spew_test +package because it needs access to internals to properly test certain cases +which are not possible via the public interface since they should never happen. +*/ + +package spew + +import ( + "bytes" + "reflect" + "testing" + "unsafe" +) + +// changeKind uses unsafe to intentionally change the kind of a reflect.Value to +// the maximum kind value which does not exist. This is needed to test the +// fallback code which punts to the standard fmt library for new types that +// might get added to the language. +func changeKind(v *reflect.Value, readOnly bool) { + rvf := (*uintptr)(unsafe.Pointer(uintptr(unsafe.Pointer(v)) + offsetFlag)) + *rvf = *rvf | ((1< + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew + +import ( + "fmt" + "io" +) + +// Errorf is a wrapper for fmt.Errorf that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the formatted string as a value that satisfies error. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Errorf(format, spew.NewFormatter(a), spew.NewFormatter(b)) +func Errorf(format string, a ...interface{}) (err error) { + return fmt.Errorf(format, convertArgs(a)...) +} + +// Fprint is a wrapper for fmt.Fprint that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprint(w, spew.NewFormatter(a), spew.NewFormatter(b)) +func Fprint(w io.Writer, a ...interface{}) (n int, err error) { + return fmt.Fprint(w, convertArgs(a)...) +} + +// Fprintf is a wrapper for fmt.Fprintf that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprintf(w, format, spew.NewFormatter(a), spew.NewFormatter(b)) +func Fprintf(w io.Writer, format string, a ...interface{}) (n int, err error) { + return fmt.Fprintf(w, format, convertArgs(a)...) +} + +// Fprintln is a wrapper for fmt.Fprintln that treats each argument as if it +// passed with a default Formatter interface returned by NewFormatter. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Fprintln(w, spew.NewFormatter(a), spew.NewFormatter(b)) +func Fprintln(w io.Writer, a ...interface{}) (n int, err error) { + return fmt.Fprintln(w, convertArgs(a)...) +} + +// Print is a wrapper for fmt.Print that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Print(spew.NewFormatter(a), spew.NewFormatter(b)) +func Print(a ...interface{}) (n int, err error) { + return fmt.Print(convertArgs(a)...) +} + +// Printf is a wrapper for fmt.Printf that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Printf(format, spew.NewFormatter(a), spew.NewFormatter(b)) +func Printf(format string, a ...interface{}) (n int, err error) { + return fmt.Printf(format, convertArgs(a)...) +} + +// Println is a wrapper for fmt.Println that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the number of bytes written and any write error encountered. See +// NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Println(spew.NewFormatter(a), spew.NewFormatter(b)) +func Println(a ...interface{}) (n int, err error) { + return fmt.Println(convertArgs(a)...) +} + +// Sprint is a wrapper for fmt.Sprint that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprint(spew.NewFormatter(a), spew.NewFormatter(b)) +func Sprint(a ...interface{}) string { + return fmt.Sprint(convertArgs(a)...) +} + +// Sprintf is a wrapper for fmt.Sprintf that treats each argument as if it were +// passed with a default Formatter interface returned by NewFormatter. It +// returns the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprintf(format, spew.NewFormatter(a), spew.NewFormatter(b)) +func Sprintf(format string, a ...interface{}) string { + return fmt.Sprintf(format, convertArgs(a)...) +} + +// Sprintln is a wrapper for fmt.Sprintln that treats each argument as if it +// were passed with a default Formatter interface returned by NewFormatter. It +// returns the resulting string. See NewFormatter for formatting details. +// +// This function is shorthand for the following syntax: +// +// fmt.Sprintln(spew.NewFormatter(a), spew.NewFormatter(b)) +func Sprintln(a ...interface{}) string { + return fmt.Sprintln(convertArgs(a)...) +} + +// convertArgs accepts a slice of arguments and returns a slice of the same +// length with each argument converted to a default spew Formatter interface. +func convertArgs(args []interface{}) (formatters []interface{}) { + formatters = make([]interface{}, len(args)) + for index, arg := range args { + formatters[index] = NewFormatter(arg) + } + return formatters +} diff --git a/vendor/github.com/davecgh/go-spew/spew/spew_test.go b/vendor/github.com/davecgh/go-spew/spew/spew_test.go new file mode 100644 index 0000000..b70466c --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/spew_test.go @@ -0,0 +1,320 @@ +/* + * Copyright (c) 2013-2016 Dave Collins + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +package spew_test + +import ( + "bytes" + "fmt" + "io/ioutil" + "os" + "testing" + + "github.com/davecgh/go-spew/spew" +) + +// spewFunc is used to identify which public function of the spew package or +// ConfigState a test applies to. +type spewFunc int + +const ( + fCSFdump spewFunc = iota + fCSFprint + fCSFprintf + fCSFprintln + fCSPrint + fCSPrintln + fCSSdump + fCSSprint + fCSSprintf + fCSSprintln + fCSErrorf + fCSNewFormatter + fErrorf + fFprint + fFprintln + fPrint + fPrintln + fSdump + fSprint + fSprintf + fSprintln +) + +// Map of spewFunc values to names for pretty printing. +var spewFuncStrings = map[spewFunc]string{ + fCSFdump: "ConfigState.Fdump", + fCSFprint: "ConfigState.Fprint", + fCSFprintf: "ConfigState.Fprintf", + fCSFprintln: "ConfigState.Fprintln", + fCSSdump: "ConfigState.Sdump", + fCSPrint: "ConfigState.Print", + fCSPrintln: "ConfigState.Println", + fCSSprint: "ConfigState.Sprint", + fCSSprintf: "ConfigState.Sprintf", + fCSSprintln: "ConfigState.Sprintln", + fCSErrorf: "ConfigState.Errorf", + fCSNewFormatter: "ConfigState.NewFormatter", + fErrorf: "spew.Errorf", + fFprint: "spew.Fprint", + fFprintln: "spew.Fprintln", + fPrint: "spew.Print", + fPrintln: "spew.Println", + fSdump: "spew.Sdump", + fSprint: "spew.Sprint", + fSprintf: "spew.Sprintf", + fSprintln: "spew.Sprintln", +} + +func (f spewFunc) String() string { + if s, ok := spewFuncStrings[f]; ok { + return s + } + return fmt.Sprintf("Unknown spewFunc (%d)", int(f)) +} + +// spewTest is used to describe a test to be performed against the public +// functions of the spew package or ConfigState. +type spewTest struct { + cs *spew.ConfigState + f spewFunc + format string + in interface{} + want string +} + +// spewTests houses the tests to be performed against the public functions of +// the spew package and ConfigState. +// +// These tests are only intended to ensure the public functions are exercised +// and are intentionally not exhaustive of types. The exhaustive type +// tests are handled in the dump and format tests. +var spewTests []spewTest + +// redirStdout is a helper function to return the standard output from f as a +// byte slice. +func redirStdout(f func()) ([]byte, error) { + tempFile, err := ioutil.TempFile("", "ss-test") + if err != nil { + return nil, err + } + fileName := tempFile.Name() + defer os.Remove(fileName) // Ignore error + + origStdout := os.Stdout + os.Stdout = tempFile + f() + os.Stdout = origStdout + tempFile.Close() + + return ioutil.ReadFile(fileName) +} + +func initSpewTests() { + // Config states with various settings. + scsDefault := spew.NewDefaultConfig() + scsNoMethods := &spew.ConfigState{Indent: " ", DisableMethods: true} + scsNoPmethods := &spew.ConfigState{Indent: " ", DisablePointerMethods: true} + scsMaxDepth := &spew.ConfigState{Indent: " ", MaxDepth: 1} + scsContinue := &spew.ConfigState{Indent: " ", ContinueOnMethod: true} + scsNoPtrAddr := &spew.ConfigState{DisablePointerAddresses: true} + scsNoCap := &spew.ConfigState{DisableCapacities: true} + + // Variables for tests on types which implement Stringer interface with and + // without a pointer receiver. + ts := stringer("test") + tps := pstringer("test") + + type ptrTester struct { + s *struct{} + } + tptr := &ptrTester{s: &struct{}{}} + + // depthTester is used to test max depth handling for structs, array, slices + // and maps. + type depthTester struct { + ic indirCir1 + arr [1]string + slice []string + m map[string]int + } + dt := depthTester{indirCir1{nil}, [1]string{"arr"}, []string{"slice"}, + map[string]int{"one": 1}} + + // Variable for tests on types which implement error interface. + te := customError(10) + + spewTests = []spewTest{ + {scsDefault, fCSFdump, "", int8(127), "(int8) 127\n"}, + {scsDefault, fCSFprint, "", int16(32767), "32767"}, + {scsDefault, fCSFprintf, "%v", int32(2147483647), "2147483647"}, + {scsDefault, fCSFprintln, "", int(2147483647), "2147483647\n"}, + {scsDefault, fCSPrint, "", int64(9223372036854775807), "9223372036854775807"}, + {scsDefault, fCSPrintln, "", uint8(255), "255\n"}, + {scsDefault, fCSSdump, "", uint8(64), "(uint8) 64\n"}, + {scsDefault, fCSSprint, "", complex(1, 2), "(1+2i)"}, + {scsDefault, fCSSprintf, "%v", complex(float32(3), 4), "(3+4i)"}, + {scsDefault, fCSSprintln, "", complex(float64(5), 6), "(5+6i)\n"}, + {scsDefault, fCSErrorf, "%#v", uint16(65535), "(uint16)65535"}, + {scsDefault, fCSNewFormatter, "%v", uint32(4294967295), "4294967295"}, + {scsDefault, fErrorf, "%v", uint64(18446744073709551615), "18446744073709551615"}, + {scsDefault, fFprint, "", float32(3.14), "3.14"}, + {scsDefault, fFprintln, "", float64(6.28), "6.28\n"}, + {scsDefault, fPrint, "", true, "true"}, + {scsDefault, fPrintln, "", false, "false\n"}, + {scsDefault, fSdump, "", complex(-10, -20), "(complex128) (-10-20i)\n"}, + {scsDefault, fSprint, "", complex(-1, -2), "(-1-2i)"}, + {scsDefault, fSprintf, "%v", complex(float32(-3), -4), "(-3-4i)"}, + {scsDefault, fSprintln, "", complex(float64(-5), -6), "(-5-6i)\n"}, + {scsNoMethods, fCSFprint, "", ts, "test"}, + {scsNoMethods, fCSFprint, "", &ts, "<*>test"}, + {scsNoMethods, fCSFprint, "", tps, "test"}, + {scsNoMethods, fCSFprint, "", &tps, "<*>test"}, + {scsNoPmethods, fCSFprint, "", ts, "stringer test"}, + {scsNoPmethods, fCSFprint, "", &ts, "<*>stringer test"}, + {scsNoPmethods, fCSFprint, "", tps, "test"}, + {scsNoPmethods, fCSFprint, "", &tps, "<*>stringer test"}, + {scsMaxDepth, fCSFprint, "", dt, "{{} [] [] map[]}"}, + {scsMaxDepth, fCSFdump, "", dt, "(spew_test.depthTester) {\n" + + " ic: (spew_test.indirCir1) {\n \n },\n" + + " arr: ([1]string) (len=1 cap=1) {\n \n },\n" + + " slice: ([]string) (len=1 cap=1) {\n \n },\n" + + " m: (map[string]int) (len=1) {\n \n }\n}\n"}, + {scsContinue, fCSFprint, "", ts, "(stringer test) test"}, + {scsContinue, fCSFdump, "", ts, "(spew_test.stringer) " + + "(len=4) (stringer test) \"test\"\n"}, + {scsContinue, fCSFprint, "", te, "(error: 10) 10"}, + {scsContinue, fCSFdump, "", te, "(spew_test.customError) " + + "(error: 10) 10\n"}, + {scsNoPtrAddr, fCSFprint, "", tptr, "<*>{<*>{}}"}, + {scsNoPtrAddr, fCSSdump, "", tptr, "(*spew_test.ptrTester)({\ns: (*struct {})({\n})\n})\n"}, + {scsNoCap, fCSSdump, "", make([]string, 0, 10), "([]string) {\n}\n"}, + {scsNoCap, fCSSdump, "", make([]string, 1, 10), "([]string) (len=1) {\n(string) \"\"\n}\n"}, + } +} + +// TestSpew executes all of the tests described by spewTests. +func TestSpew(t *testing.T) { + initSpewTests() + + t.Logf("Running %d tests", len(spewTests)) + for i, test := range spewTests { + buf := new(bytes.Buffer) + switch test.f { + case fCSFdump: + test.cs.Fdump(buf, test.in) + + case fCSFprint: + test.cs.Fprint(buf, test.in) + + case fCSFprintf: + test.cs.Fprintf(buf, test.format, test.in) + + case fCSFprintln: + test.cs.Fprintln(buf, test.in) + + case fCSPrint: + b, err := redirStdout(func() { test.cs.Print(test.in) }) + if err != nil { + t.Errorf("%v #%d %v", test.f, i, err) + continue + } + buf.Write(b) + + case fCSPrintln: + b, err := redirStdout(func() { test.cs.Println(test.in) }) + if err != nil { + t.Errorf("%v #%d %v", test.f, i, err) + continue + } + buf.Write(b) + + case fCSSdump: + str := test.cs.Sdump(test.in) + buf.WriteString(str) + + case fCSSprint: + str := test.cs.Sprint(test.in) + buf.WriteString(str) + + case fCSSprintf: + str := test.cs.Sprintf(test.format, test.in) + buf.WriteString(str) + + case fCSSprintln: + str := test.cs.Sprintln(test.in) + buf.WriteString(str) + + case fCSErrorf: + err := test.cs.Errorf(test.format, test.in) + buf.WriteString(err.Error()) + + case fCSNewFormatter: + fmt.Fprintf(buf, test.format, test.cs.NewFormatter(test.in)) + + case fErrorf: + err := spew.Errorf(test.format, test.in) + buf.WriteString(err.Error()) + + case fFprint: + spew.Fprint(buf, test.in) + + case fFprintln: + spew.Fprintln(buf, test.in) + + case fPrint: + b, err := redirStdout(func() { spew.Print(test.in) }) + if err != nil { + t.Errorf("%v #%d %v", test.f, i, err) + continue + } + buf.Write(b) + + case fPrintln: + b, err := redirStdout(func() { spew.Println(test.in) }) + if err != nil { + t.Errorf("%v #%d %v", test.f, i, err) + continue + } + buf.Write(b) + + case fSdump: + str := spew.Sdump(test.in) + buf.WriteString(str) + + case fSprint: + str := spew.Sprint(test.in) + buf.WriteString(str) + + case fSprintf: + str := spew.Sprintf(test.format, test.in) + buf.WriteString(str) + + case fSprintln: + str := spew.Sprintln(test.in) + buf.WriteString(str) + + default: + t.Errorf("%v #%d unrecognized function", test.f, i) + continue + } + s := buf.String() + if test.want != s { + t.Errorf("ConfigState #%d\n got: %s want: %s", i, s, test.want) + continue + } + } +} diff --git a/vendor/github.com/davecgh/go-spew/spew/testdata/dumpcgo.go b/vendor/github.com/davecgh/go-spew/spew/testdata/dumpcgo.go new file mode 100644 index 0000000..5c87dd4 --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/spew/testdata/dumpcgo.go @@ -0,0 +1,82 @@ +// Copyright (c) 2013 Dave Collins +// +// Permission to use, copy, modify, and distribute this software for any +// purpose with or without fee is hereby granted, provided that the above +// copyright notice and this permission notice appear in all copies. +// +// THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +// WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +// MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +// ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +// ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +// OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + +// NOTE: Due to the following build constraints, this file will only be compiled +// when both cgo is supported and "-tags testcgo" is added to the go test +// command line. This code should really only be in the dumpcgo_test.go file, +// but unfortunately Go will not allow cgo in test files, so this is a +// workaround to allow cgo types to be tested. This configuration is used +// because spew itself does not require cgo to run even though it does handle +// certain cgo types specially. Rather than forcing all clients to require cgo +// and an external C compiler just to run the tests, this scheme makes them +// optional. +// +build cgo,testcgo + +package testdata + +/* +#include +typedef unsigned char custom_uchar_t; + +char *ncp = 0; +char *cp = "test"; +char ca[6] = {'t', 'e', 's', 't', '2', '\0'}; +unsigned char uca[6] = {'t', 'e', 's', 't', '3', '\0'}; +signed char sca[6] = {'t', 'e', 's', 't', '4', '\0'}; +uint8_t ui8ta[6] = {'t', 'e', 's', 't', '5', '\0'}; +custom_uchar_t tuca[6] = {'t', 'e', 's', 't', '6', '\0'}; +*/ +import "C" + +// GetCgoNullCharPointer returns a null char pointer via cgo. This is only +// used for tests. +func GetCgoNullCharPointer() interface{} { + return C.ncp +} + +// GetCgoCharPointer returns a char pointer via cgo. This is only used for +// tests. +func GetCgoCharPointer() interface{} { + return C.cp +} + +// GetCgoCharArray returns a char array via cgo and the array's len and cap. +// This is only used for tests. +func GetCgoCharArray() (interface{}, int, int) { + return C.ca, len(C.ca), cap(C.ca) +} + +// GetCgoUnsignedCharArray returns an unsigned char array via cgo and the +// array's len and cap. This is only used for tests. +func GetCgoUnsignedCharArray() (interface{}, int, int) { + return C.uca, len(C.uca), cap(C.uca) +} + +// GetCgoSignedCharArray returns a signed char array via cgo and the array's len +// and cap. This is only used for tests. +func GetCgoSignedCharArray() (interface{}, int, int) { + return C.sca, len(C.sca), cap(C.sca) +} + +// GetCgoUint8tArray returns a uint8_t array via cgo and the array's len and +// cap. This is only used for tests. +func GetCgoUint8tArray() (interface{}, int, int) { + return C.ui8ta, len(C.ui8ta), cap(C.ui8ta) +} + +// GetCgoTypdefedUnsignedCharArray returns a typedefed unsigned char array via +// cgo and the array's len and cap. This is only used for tests. +func GetCgoTypdefedUnsignedCharArray() (interface{}, int, int) { + return C.tuca, len(C.tuca), cap(C.tuca) +} diff --git a/vendor/github.com/davecgh/go-spew/test_coverage.txt b/vendor/github.com/davecgh/go-spew/test_coverage.txt new file mode 100644 index 0000000..2cd087a --- /dev/null +++ b/vendor/github.com/davecgh/go-spew/test_coverage.txt @@ -0,0 +1,61 @@ + +github.com/davecgh/go-spew/spew/dump.go dumpState.dump 100.00% (88/88) +github.com/davecgh/go-spew/spew/format.go formatState.format 100.00% (82/82) +github.com/davecgh/go-spew/spew/format.go formatState.formatPtr 100.00% (52/52) +github.com/davecgh/go-spew/spew/dump.go dumpState.dumpPtr 100.00% (44/44) +github.com/davecgh/go-spew/spew/dump.go dumpState.dumpSlice 100.00% (39/39) +github.com/davecgh/go-spew/spew/common.go handleMethods 100.00% (30/30) +github.com/davecgh/go-spew/spew/common.go printHexPtr 100.00% (18/18) +github.com/davecgh/go-spew/spew/common.go unsafeReflectValue 100.00% (13/13) +github.com/davecgh/go-spew/spew/format.go formatState.constructOrigFormat 100.00% (12/12) +github.com/davecgh/go-spew/spew/dump.go fdump 100.00% (11/11) +github.com/davecgh/go-spew/spew/format.go formatState.Format 100.00% (11/11) +github.com/davecgh/go-spew/spew/common.go init 100.00% (10/10) +github.com/davecgh/go-spew/spew/common.go printComplex 100.00% (9/9) +github.com/davecgh/go-spew/spew/common.go valuesSorter.Less 100.00% (8/8) +github.com/davecgh/go-spew/spew/format.go formatState.buildDefaultFormat 100.00% (7/7) +github.com/davecgh/go-spew/spew/format.go formatState.unpackValue 100.00% (5/5) +github.com/davecgh/go-spew/spew/dump.go dumpState.indent 100.00% (4/4) +github.com/davecgh/go-spew/spew/common.go catchPanic 100.00% (4/4) +github.com/davecgh/go-spew/spew/config.go ConfigState.convertArgs 100.00% (4/4) +github.com/davecgh/go-spew/spew/spew.go convertArgs 100.00% (4/4) +github.com/davecgh/go-spew/spew/format.go newFormatter 100.00% (3/3) +github.com/davecgh/go-spew/spew/dump.go Sdump 100.00% (3/3) +github.com/davecgh/go-spew/spew/common.go printBool 100.00% (3/3) +github.com/davecgh/go-spew/spew/common.go sortValues 100.00% (3/3) +github.com/davecgh/go-spew/spew/config.go ConfigState.Sdump 100.00% (3/3) +github.com/davecgh/go-spew/spew/dump.go dumpState.unpackValue 100.00% (3/3) +github.com/davecgh/go-spew/spew/spew.go Printf 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Println 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Sprint 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Sprintf 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Sprintln 100.00% (1/1) +github.com/davecgh/go-spew/spew/common.go printFloat 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go NewDefaultConfig 100.00% (1/1) +github.com/davecgh/go-spew/spew/common.go printInt 100.00% (1/1) +github.com/davecgh/go-spew/spew/common.go printUint 100.00% (1/1) +github.com/davecgh/go-spew/spew/common.go valuesSorter.Len 100.00% (1/1) +github.com/davecgh/go-spew/spew/common.go valuesSorter.Swap 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Errorf 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Fprint 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Fprintf 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Fprintln 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Print 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Printf 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Println 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Sprint 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Sprintf 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Sprintln 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.NewFormatter 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Fdump 100.00% (1/1) +github.com/davecgh/go-spew/spew/config.go ConfigState.Dump 100.00% (1/1) +github.com/davecgh/go-spew/spew/dump.go Fdump 100.00% (1/1) +github.com/davecgh/go-spew/spew/dump.go Dump 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Fprintln 100.00% (1/1) +github.com/davecgh/go-spew/spew/format.go NewFormatter 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Errorf 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Fprint 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Fprintf 100.00% (1/1) +github.com/davecgh/go-spew/spew/spew.go Print 100.00% (1/1) +github.com/davecgh/go-spew/spew ------------------------------- 100.00% (505/505) + diff --git a/vendor/github.com/pkg/errors/.gitignore b/vendor/github.com/pkg/errors/.gitignore new file mode 100644 index 0000000..daf913b --- /dev/null +++ b/vendor/github.com/pkg/errors/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe +*.test +*.prof diff --git a/vendor/github.com/pkg/errors/.travis.yml b/vendor/github.com/pkg/errors/.travis.yml new file mode 100644 index 0000000..7ca408d --- /dev/null +++ b/vendor/github.com/pkg/errors/.travis.yml @@ -0,0 +1,13 @@ +language: go +go_import_path: github.com/pkg/errors +go: + - 1.4.x + - 1.5.x + - 1.6.x + - 1.7.x + - 1.8.x + - 1.9.x + - tip + +script: + - go test -v ./... diff --git a/vendor/github.com/pkg/errors/README.md b/vendor/github.com/pkg/errors/README.md index 6ea6422..6483ba2 100644 --- a/vendor/github.com/pkg/errors/README.md +++ b/vendor/github.com/pkg/errors/README.md @@ -1,7 +1,9 @@ -# errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) +# errors [![Travis-CI](https://travis-ci.org/pkg/errors.svg)](https://travis-ci.org/pkg/errors) [![AppVeyor](https://ci.appveyor.com/api/projects/status/b98mptawhudj53ep/branch/master?svg=true)](https://ci.appveyor.com/project/davecheney/errors/branch/master) [![GoDoc](https://godoc.org/github.com/pkg/errors?status.svg)](http://godoc.org/github.com/pkg/errors) [![Report card](https://goreportcard.com/badge/github.com/pkg/errors)](https://goreportcard.com/report/github.com/pkg/errors) [![Sourcegraph](https://sourcegraph.com/github.com/pkg/errors/-/badge.svg)](https://sourcegraph.com/github.com/pkg/errors?badge) Package errors provides simple error handling primitives. +`go get github.com/pkg/errors` + The traditional error handling idiom in Go is roughly akin to ```go if err != nil { @@ -45,6 +47,6 @@ We welcome pull requests, bug fixes and issue reports. With that said, the bar f Before proposing a change, please discuss your change by raising an issue. -## Licence +## License BSD-2-Clause diff --git a/vendor/github.com/pkg/errors/bench_test.go b/vendor/github.com/pkg/errors/bench_test.go new file mode 100644 index 0000000..903b5f2 --- /dev/null +++ b/vendor/github.com/pkg/errors/bench_test.go @@ -0,0 +1,63 @@ +// +build go1.7 + +package errors + +import ( + "fmt" + "testing" + + stderrors "errors" +) + +func noErrors(at, depth int) error { + if at >= depth { + return stderrors.New("no error") + } + return noErrors(at+1, depth) +} + +func yesErrors(at, depth int) error { + if at >= depth { + return New("ye error") + } + return yesErrors(at+1, depth) +} + +// GlobalE is an exported global to store the result of benchmark results, +// preventing the compiler from optimising the benchmark functions away. +var GlobalE error + +func BenchmarkErrors(b *testing.B) { + type run struct { + stack int + std bool + } + runs := []run{ + {10, false}, + {10, true}, + {100, false}, + {100, true}, + {1000, false}, + {1000, true}, + } + for _, r := range runs { + part := "pkg/errors" + if r.std { + part = "errors" + } + name := fmt.Sprintf("%s-stack-%d", part, r.stack) + b.Run(name, func(b *testing.B) { + var err error + f := yesErrors + if r.std { + f = noErrors + } + b.ReportAllocs() + for i := 0; i < b.N; i++ { + err = f(0, r.stack) + } + b.StopTimer() + GlobalE = err + }) + } +} diff --git a/vendor/github.com/pkg/errors/errors.go b/vendor/github.com/pkg/errors/errors.go index 6c45c8d..842ee80 100644 --- a/vendor/github.com/pkg/errors/errors.go +++ b/vendor/github.com/pkg/errors/errors.go @@ -14,13 +14,18 @@ // Adding context to an error // // The errors.Wrap function returns a new error that adds context to the -// original error. For example +// original error by recording a stack trace at the point Wrap is called, +// and the supplied message. For example // // _, err := ioutil.ReadAll(r) // if err != nil { // return errors.Wrap(err, "read failed") // } // +// If additional control is required the errors.WithStack and errors.WithMessage +// functions destructure errors.Wrap into its component operations of annotating +// an error with a stack trace and an a message, respectively. +// // Retrieving the cause of an error // // Using errors.Wrap constructs a stack of errors, adding context to the @@ -28,7 +33,7 @@ // to reverse the operation of errors.Wrap to retrieve the original error // for inspection. Any error value which implements this interface // -// type Causer interface { +// type causer interface { // Cause() error // } // @@ -43,6 +48,9 @@ // // unknown error // } // +// causer interface is not exported by this package, but is considered a part +// of stable public API. +// // Formatted printing of errors // // All error values returned from this package implement fmt.Formatter and can @@ -77,6 +85,9 @@ // } // } // +// stackTracer interface is not exported by this package, but is considered a part +// of stable public API. +// // See the documentation for Frame.Format for more details. package errors @@ -85,68 +96,74 @@ import ( "io" ) -// _error is an error implementation returned by New and Errorf -// that implements its own fmt.Formatter. -type _error struct { - msg string - *stack -} - -func (e _error) Error() string { return e.msg } - -func (e _error) Format(s fmt.State, verb rune) { - switch verb { - case 'v': - if s.Flag('+') { - io.WriteString(s, e.msg) - fmt.Fprintf(s, "%+v", e.StackTrace()) - return - } - fallthrough - case 's': - io.WriteString(s, e.msg) - } -} - // New returns an error with the supplied message. +// New also records the stack trace at the point it was called. func New(message string) error { - return _error{ - message, - callers(), + return &fundamental{ + msg: message, + stack: callers(), } } // Errorf formats according to a format specifier and returns the string // as a value that satisfies error. +// Errorf also records the stack trace at the point it was called. func Errorf(format string, args ...interface{}) error { - return _error{ - fmt.Sprintf(format, args...), + return &fundamental{ + msg: fmt.Sprintf(format, args...), + stack: callers(), + } +} + +// fundamental is an error that has a message and a stack, but no caller. +type fundamental struct { + msg string + *stack +} + +func (f *fundamental) Error() string { return f.msg } + +func (f *fundamental) Format(s fmt.State, verb rune) { + switch verb { + case 'v': + if s.Flag('+') { + io.WriteString(s, f.msg) + f.stack.Format(s, verb) + return + } + fallthrough + case 's': + io.WriteString(s, f.msg) + case 'q': + fmt.Fprintf(s, "%q", f.msg) + } +} + +// WithStack annotates err with a stack trace at the point WithStack was called. +// If err is nil, WithStack returns nil. +func WithStack(err error) error { + if err == nil { + return nil + } + return &withStack{ + err, callers(), } } -type cause struct { - cause error - msg string -} - -func (c cause) Error() string { return fmt.Sprintf("%s: %v", c.msg, c.Cause()) } -func (c cause) Cause() error { return c.cause } - -// wrapper is an error implementation returned by Wrap and Wrapf -// that implements its own fmt.Formatter. -type wrapper struct { - cause +type withStack struct { + error *stack } -func (w wrapper) Format(s fmt.State, verb rune) { +func (w *withStack) Cause() error { return w.error } + +func (w *withStack) Format(s fmt.State, verb rune) { switch verb { case 'v': if s.Flag('+') { - fmt.Fprintf(s, "%+v\n", w.Cause()) - io.WriteString(s, w.msg) - fmt.Fprintf(s, "%+v", w.StackTrace()) + fmt.Fprintf(s, "%+v", w.Cause()) + w.stack.Format(s, verb) return } fallthrough @@ -157,33 +174,71 @@ func (w wrapper) Format(s fmt.State, verb rune) { } } -// Wrap returns an error annotating err with message. +// Wrap returns an error annotating err with a stack trace +// at the point Wrap is called, and the supplied message. // If err is nil, Wrap returns nil. func Wrap(err error, message string) error { if err == nil { return nil } - return wrapper{ - cause: cause{ - cause: err, - msg: message, - }, - stack: callers(), + err = &withMessage{ + cause: err, + msg: message, + } + return &withStack{ + err, + callers(), } } -// Wrapf returns an error annotating err with the format specifier. +// Wrapf returns an error annotating err with a stack trace +// at the point Wrapf is call, and the format specifier. // If err is nil, Wrapf returns nil. func Wrapf(err error, format string, args ...interface{}) error { if err == nil { return nil } - return wrapper{ - cause: cause{ - cause: err, - msg: fmt.Sprintf(format, args...), - }, - stack: callers(), + err = &withMessage{ + cause: err, + msg: fmt.Sprintf(format, args...), + } + return &withStack{ + err, + callers(), + } +} + +// WithMessage annotates err with a new message. +// If err is nil, WithMessage returns nil. +func WithMessage(err error, message string) error { + if err == nil { + return nil + } + return &withMessage{ + cause: err, + msg: message, + } +} + +type withMessage struct { + cause error + msg string +} + +func (w *withMessage) Error() string { return w.msg + ": " + w.cause.Error() } +func (w *withMessage) Cause() error { return w.cause } + +func (w *withMessage) Format(s fmt.State, verb rune) { + switch verb { + case 'v': + if s.Flag('+') { + fmt.Fprintf(s, "%+v\n", w.Cause()) + io.WriteString(s, w.msg) + return + } + fallthrough + case 's', 'q': + io.WriteString(s, w.Error()) } } @@ -191,7 +246,7 @@ func Wrapf(err error, format string, args ...interface{}) error { // An error value has a cause if it implements the following // interface: // -// type Causer interface { +// type causer interface { // Cause() error // } // diff --git a/vendor/github.com/pkg/errors/errors_test.go b/vendor/github.com/pkg/errors/errors_test.go new file mode 100644 index 0000000..c4e6eef --- /dev/null +++ b/vendor/github.com/pkg/errors/errors_test.go @@ -0,0 +1,225 @@ +package errors + +import ( + "errors" + "fmt" + "io" + "reflect" + "testing" +) + +func TestNew(t *testing.T) { + tests := []struct { + err string + want error + }{ + {"", fmt.Errorf("")}, + {"foo", fmt.Errorf("foo")}, + {"foo", New("foo")}, + {"string with format specifiers: %v", errors.New("string with format specifiers: %v")}, + } + + for _, tt := range tests { + got := New(tt.err) + if got.Error() != tt.want.Error() { + t.Errorf("New.Error(): got: %q, want %q", got, tt.want) + } + } +} + +func TestWrapNil(t *testing.T) { + got := Wrap(nil, "no error") + if got != nil { + t.Errorf("Wrap(nil, \"no error\"): got %#v, expected nil", got) + } +} + +func TestWrap(t *testing.T) { + tests := []struct { + err error + message string + want string + }{ + {io.EOF, "read error", "read error: EOF"}, + {Wrap(io.EOF, "read error"), "client error", "client error: read error: EOF"}, + } + + for _, tt := range tests { + got := Wrap(tt.err, tt.message).Error() + if got != tt.want { + t.Errorf("Wrap(%v, %q): got: %v, want %v", tt.err, tt.message, got, tt.want) + } + } +} + +type nilError struct{} + +func (nilError) Error() string { return "nil error" } + +func TestCause(t *testing.T) { + x := New("error") + tests := []struct { + err error + want error + }{{ + // nil error is nil + err: nil, + want: nil, + }, { + // explicit nil error is nil + err: (error)(nil), + want: nil, + }, { + // typed nil is nil + err: (*nilError)(nil), + want: (*nilError)(nil), + }, { + // uncaused error is unaffected + err: io.EOF, + want: io.EOF, + }, { + // caused error returns cause + err: Wrap(io.EOF, "ignored"), + want: io.EOF, + }, { + err: x, // return from errors.New + want: x, + }, { + WithMessage(nil, "whoops"), + nil, + }, { + WithMessage(io.EOF, "whoops"), + io.EOF, + }, { + WithStack(nil), + nil, + }, { + WithStack(io.EOF), + io.EOF, + }} + + for i, tt := range tests { + got := Cause(tt.err) + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("test %d: got %#v, want %#v", i+1, got, tt.want) + } + } +} + +func TestWrapfNil(t *testing.T) { + got := Wrapf(nil, "no error") + if got != nil { + t.Errorf("Wrapf(nil, \"no error\"): got %#v, expected nil", got) + } +} + +func TestWrapf(t *testing.T) { + tests := []struct { + err error + message string + want string + }{ + {io.EOF, "read error", "read error: EOF"}, + {Wrapf(io.EOF, "read error without format specifiers"), "client error", "client error: read error without format specifiers: EOF"}, + {Wrapf(io.EOF, "read error with %d format specifier", 1), "client error", "client error: read error with 1 format specifier: EOF"}, + } + + for _, tt := range tests { + got := Wrapf(tt.err, tt.message).Error() + if got != tt.want { + t.Errorf("Wrapf(%v, %q): got: %v, want %v", tt.err, tt.message, got, tt.want) + } + } +} + +func TestErrorf(t *testing.T) { + tests := []struct { + err error + want string + }{ + {Errorf("read error without format specifiers"), "read error without format specifiers"}, + {Errorf("read error with %d format specifier", 1), "read error with 1 format specifier"}, + } + + for _, tt := range tests { + got := tt.err.Error() + if got != tt.want { + t.Errorf("Errorf(%v): got: %q, want %q", tt.err, got, tt.want) + } + } +} + +func TestWithStackNil(t *testing.T) { + got := WithStack(nil) + if got != nil { + t.Errorf("WithStack(nil): got %#v, expected nil", got) + } +} + +func TestWithStack(t *testing.T) { + tests := []struct { + err error + want string + }{ + {io.EOF, "EOF"}, + {WithStack(io.EOF), "EOF"}, + } + + for _, tt := range tests { + got := WithStack(tt.err).Error() + if got != tt.want { + t.Errorf("WithStack(%v): got: %v, want %v", tt.err, got, tt.want) + } + } +} + +func TestWithMessageNil(t *testing.T) { + got := WithMessage(nil, "no error") + if got != nil { + t.Errorf("WithMessage(nil, \"no error\"): got %#v, expected nil", got) + } +} + +func TestWithMessage(t *testing.T) { + tests := []struct { + err error + message string + want string + }{ + {io.EOF, "read error", "read error: EOF"}, + {WithMessage(io.EOF, "read error"), "client error", "client error: read error: EOF"}, + } + + for _, tt := range tests { + got := WithMessage(tt.err, tt.message).Error() + if got != tt.want { + t.Errorf("WithMessage(%v, %q): got: %q, want %q", tt.err, tt.message, got, tt.want) + } + } +} + +// errors.New, etc values are not expected to be compared by value +// but the change in errors#27 made them incomparable. Assert that +// various kinds of errors have a functional equality operator, even +// if the result of that equality is always false. +func TestErrorEquality(t *testing.T) { + vals := []error{ + nil, + io.EOF, + errors.New("EOF"), + New("EOF"), + Errorf("EOF"), + Wrap(io.EOF, "EOF"), + Wrapf(io.EOF, "EOF%d", 2), + WithMessage(nil, "whoops"), + WithMessage(io.EOF, "whoops"), + WithStack(io.EOF), + WithStack(nil), + } + + for i := range vals { + for j := range vals { + _ = vals[i] == vals[j] // mustn't panic + } + } +} diff --git a/vendor/github.com/pkg/errors/example_test.go b/vendor/github.com/pkg/errors/example_test.go new file mode 100644 index 0000000..c1fc13e --- /dev/null +++ b/vendor/github.com/pkg/errors/example_test.go @@ -0,0 +1,205 @@ +package errors_test + +import ( + "fmt" + + "github.com/pkg/errors" +) + +func ExampleNew() { + err := errors.New("whoops") + fmt.Println(err) + + // Output: whoops +} + +func ExampleNew_printf() { + err := errors.New("whoops") + fmt.Printf("%+v", err) + + // Example output: + // whoops + // github.com/pkg/errors_test.ExampleNew_printf + // /home/dfc/src/github.com/pkg/errors/example_test.go:17 + // testing.runExample + // /home/dfc/go/src/testing/example.go:114 + // testing.RunExamples + // /home/dfc/go/src/testing/example.go:38 + // testing.(*M).Run + // /home/dfc/go/src/testing/testing.go:744 + // main.main + // /github.com/pkg/errors/_test/_testmain.go:106 + // runtime.main + // /home/dfc/go/src/runtime/proc.go:183 + // runtime.goexit + // /home/dfc/go/src/runtime/asm_amd64.s:2059 +} + +func ExampleWithMessage() { + cause := errors.New("whoops") + err := errors.WithMessage(cause, "oh noes") + fmt.Println(err) + + // Output: oh noes: whoops +} + +func ExampleWithStack() { + cause := errors.New("whoops") + err := errors.WithStack(cause) + fmt.Println(err) + + // Output: whoops +} + +func ExampleWithStack_printf() { + cause := errors.New("whoops") + err := errors.WithStack(cause) + fmt.Printf("%+v", err) + + // Example Output: + // whoops + // github.com/pkg/errors_test.ExampleWithStack_printf + // /home/fabstu/go/src/github.com/pkg/errors/example_test.go:55 + // testing.runExample + // /usr/lib/go/src/testing/example.go:114 + // testing.RunExamples + // /usr/lib/go/src/testing/example.go:38 + // testing.(*M).Run + // /usr/lib/go/src/testing/testing.go:744 + // main.main + // github.com/pkg/errors/_test/_testmain.go:106 + // runtime.main + // /usr/lib/go/src/runtime/proc.go:183 + // runtime.goexit + // /usr/lib/go/src/runtime/asm_amd64.s:2086 + // github.com/pkg/errors_test.ExampleWithStack_printf + // /home/fabstu/go/src/github.com/pkg/errors/example_test.go:56 + // testing.runExample + // /usr/lib/go/src/testing/example.go:114 + // testing.RunExamples + // /usr/lib/go/src/testing/example.go:38 + // testing.(*M).Run + // /usr/lib/go/src/testing/testing.go:744 + // main.main + // github.com/pkg/errors/_test/_testmain.go:106 + // runtime.main + // /usr/lib/go/src/runtime/proc.go:183 + // runtime.goexit + // /usr/lib/go/src/runtime/asm_amd64.s:2086 +} + +func ExampleWrap() { + cause := errors.New("whoops") + err := errors.Wrap(cause, "oh noes") + fmt.Println(err) + + // Output: oh noes: whoops +} + +func fn() error { + e1 := errors.New("error") + e2 := errors.Wrap(e1, "inner") + e3 := errors.Wrap(e2, "middle") + return errors.Wrap(e3, "outer") +} + +func ExampleCause() { + err := fn() + fmt.Println(err) + fmt.Println(errors.Cause(err)) + + // Output: outer: middle: inner: error + // error +} + +func ExampleWrap_extended() { + err := fn() + fmt.Printf("%+v\n", err) + + // Example output: + // error + // github.com/pkg/errors_test.fn + // /home/dfc/src/github.com/pkg/errors/example_test.go:47 + // github.com/pkg/errors_test.ExampleCause_printf + // /home/dfc/src/github.com/pkg/errors/example_test.go:63 + // testing.runExample + // /home/dfc/go/src/testing/example.go:114 + // testing.RunExamples + // /home/dfc/go/src/testing/example.go:38 + // testing.(*M).Run + // /home/dfc/go/src/testing/testing.go:744 + // main.main + // /github.com/pkg/errors/_test/_testmain.go:104 + // runtime.main + // /home/dfc/go/src/runtime/proc.go:183 + // runtime.goexit + // /home/dfc/go/src/runtime/asm_amd64.s:2059 + // github.com/pkg/errors_test.fn + // /home/dfc/src/github.com/pkg/errors/example_test.go:48: inner + // github.com/pkg/errors_test.fn + // /home/dfc/src/github.com/pkg/errors/example_test.go:49: middle + // github.com/pkg/errors_test.fn + // /home/dfc/src/github.com/pkg/errors/example_test.go:50: outer +} + +func ExampleWrapf() { + cause := errors.New("whoops") + err := errors.Wrapf(cause, "oh noes #%d", 2) + fmt.Println(err) + + // Output: oh noes #2: whoops +} + +func ExampleErrorf_extended() { + err := errors.Errorf("whoops: %s", "foo") + fmt.Printf("%+v", err) + + // Example output: + // whoops: foo + // github.com/pkg/errors_test.ExampleErrorf + // /home/dfc/src/github.com/pkg/errors/example_test.go:101 + // testing.runExample + // /home/dfc/go/src/testing/example.go:114 + // testing.RunExamples + // /home/dfc/go/src/testing/example.go:38 + // testing.(*M).Run + // /home/dfc/go/src/testing/testing.go:744 + // main.main + // /github.com/pkg/errors/_test/_testmain.go:102 + // runtime.main + // /home/dfc/go/src/runtime/proc.go:183 + // runtime.goexit + // /home/dfc/go/src/runtime/asm_amd64.s:2059 +} + +func Example_stackTrace() { + type stackTracer interface { + StackTrace() errors.StackTrace + } + + err, ok := errors.Cause(fn()).(stackTracer) + if !ok { + panic("oops, err does not implement stackTracer") + } + + st := err.StackTrace() + fmt.Printf("%+v", st[0:2]) // top two frames + + // Example output: + // github.com/pkg/errors_test.fn + // /home/dfc/src/github.com/pkg/errors/example_test.go:47 + // github.com/pkg/errors_test.Example_stackTrace + // /home/dfc/src/github.com/pkg/errors/example_test.go:127 +} + +func ExampleCause_printf() { + err := errors.Wrap(func() error { + return func() error { + return errors.Errorf("hello %s", fmt.Sprintf("world")) + }() + }(), "failed") + + fmt.Printf("%v", err) + + // Output: failed: hello world +} diff --git a/vendor/github.com/pkg/errors/format_test.go b/vendor/github.com/pkg/errors/format_test.go new file mode 100644 index 0000000..c2eef5f --- /dev/null +++ b/vendor/github.com/pkg/errors/format_test.go @@ -0,0 +1,535 @@ +package errors + +import ( + "errors" + "fmt" + "io" + "regexp" + "strings" + "testing" +) + +func TestFormatNew(t *testing.T) { + tests := []struct { + error + format string + want string + }{{ + New("error"), + "%s", + "error", + }, { + New("error"), + "%v", + "error", + }, { + New("error"), + "%+v", + "error\n" + + "github.com/pkg/errors.TestFormatNew\n" + + "\t.+/github.com/pkg/errors/format_test.go:26", + }, { + New("error"), + "%q", + `"error"`, + }} + + for i, tt := range tests { + testFormatRegexp(t, i, tt.error, tt.format, tt.want) + } +} + +func TestFormatErrorf(t *testing.T) { + tests := []struct { + error + format string + want string + }{{ + Errorf("%s", "error"), + "%s", + "error", + }, { + Errorf("%s", "error"), + "%v", + "error", + }, { + Errorf("%s", "error"), + "%+v", + "error\n" + + "github.com/pkg/errors.TestFormatErrorf\n" + + "\t.+/github.com/pkg/errors/format_test.go:56", + }} + + for i, tt := range tests { + testFormatRegexp(t, i, tt.error, tt.format, tt.want) + } +} + +func TestFormatWrap(t *testing.T) { + tests := []struct { + error + format string + want string + }{{ + Wrap(New("error"), "error2"), + "%s", + "error2: error", + }, { + Wrap(New("error"), "error2"), + "%v", + "error2: error", + }, { + Wrap(New("error"), "error2"), + "%+v", + "error\n" + + "github.com/pkg/errors.TestFormatWrap\n" + + "\t.+/github.com/pkg/errors/format_test.go:82", + }, { + Wrap(io.EOF, "error"), + "%s", + "error: EOF", + }, { + Wrap(io.EOF, "error"), + "%v", + "error: EOF", + }, { + Wrap(io.EOF, "error"), + "%+v", + "EOF\n" + + "error\n" + + "github.com/pkg/errors.TestFormatWrap\n" + + "\t.+/github.com/pkg/errors/format_test.go:96", + }, { + Wrap(Wrap(io.EOF, "error1"), "error2"), + "%+v", + "EOF\n" + + "error1\n" + + "github.com/pkg/errors.TestFormatWrap\n" + + "\t.+/github.com/pkg/errors/format_test.go:103\n", + }, { + Wrap(New("error with space"), "context"), + "%q", + `"context: error with space"`, + }} + + for i, tt := range tests { + testFormatRegexp(t, i, tt.error, tt.format, tt.want) + } +} + +func TestFormatWrapf(t *testing.T) { + tests := []struct { + error + format string + want string + }{{ + Wrapf(io.EOF, "error%d", 2), + "%s", + "error2: EOF", + }, { + Wrapf(io.EOF, "error%d", 2), + "%v", + "error2: EOF", + }, { + Wrapf(io.EOF, "error%d", 2), + "%+v", + "EOF\n" + + "error2\n" + + "github.com/pkg/errors.TestFormatWrapf\n" + + "\t.+/github.com/pkg/errors/format_test.go:134", + }, { + Wrapf(New("error"), "error%d", 2), + "%s", + "error2: error", + }, { + Wrapf(New("error"), "error%d", 2), + "%v", + "error2: error", + }, { + Wrapf(New("error"), "error%d", 2), + "%+v", + "error\n" + + "github.com/pkg/errors.TestFormatWrapf\n" + + "\t.+/github.com/pkg/errors/format_test.go:149", + }} + + for i, tt := range tests { + testFormatRegexp(t, i, tt.error, tt.format, tt.want) + } +} + +func TestFormatWithStack(t *testing.T) { + tests := []struct { + error + format string + want []string + }{{ + WithStack(io.EOF), + "%s", + []string{"EOF"}, + }, { + WithStack(io.EOF), + "%v", + []string{"EOF"}, + }, { + WithStack(io.EOF), + "%+v", + []string{"EOF", + "github.com/pkg/errors.TestFormatWithStack\n" + + "\t.+/github.com/pkg/errors/format_test.go:175"}, + }, { + WithStack(New("error")), + "%s", + []string{"error"}, + }, { + WithStack(New("error")), + "%v", + []string{"error"}, + }, { + WithStack(New("error")), + "%+v", + []string{"error", + "github.com/pkg/errors.TestFormatWithStack\n" + + "\t.+/github.com/pkg/errors/format_test.go:189", + "github.com/pkg/errors.TestFormatWithStack\n" + + "\t.+/github.com/pkg/errors/format_test.go:189"}, + }, { + WithStack(WithStack(io.EOF)), + "%+v", + []string{"EOF", + "github.com/pkg/errors.TestFormatWithStack\n" + + "\t.+/github.com/pkg/errors/format_test.go:197", + "github.com/pkg/errors.TestFormatWithStack\n" + + "\t.+/github.com/pkg/errors/format_test.go:197"}, + }, { + WithStack(WithStack(Wrapf(io.EOF, "message"))), + "%+v", + []string{"EOF", + "message", + "github.com/pkg/errors.TestFormatWithStack\n" + + "\t.+/github.com/pkg/errors/format_test.go:205", + "github.com/pkg/errors.TestFormatWithStack\n" + + "\t.+/github.com/pkg/errors/format_test.go:205", + "github.com/pkg/errors.TestFormatWithStack\n" + + "\t.+/github.com/pkg/errors/format_test.go:205"}, + }, { + WithStack(Errorf("error%d", 1)), + "%+v", + []string{"error1", + "github.com/pkg/errors.TestFormatWithStack\n" + + "\t.+/github.com/pkg/errors/format_test.go:216", + "github.com/pkg/errors.TestFormatWithStack\n" + + "\t.+/github.com/pkg/errors/format_test.go:216"}, + }} + + for i, tt := range tests { + testFormatCompleteCompare(t, i, tt.error, tt.format, tt.want, true) + } +} + +func TestFormatWithMessage(t *testing.T) { + tests := []struct { + error + format string + want []string + }{{ + WithMessage(New("error"), "error2"), + "%s", + []string{"error2: error"}, + }, { + WithMessage(New("error"), "error2"), + "%v", + []string{"error2: error"}, + }, { + WithMessage(New("error"), "error2"), + "%+v", + []string{ + "error", + "github.com/pkg/errors.TestFormatWithMessage\n" + + "\t.+/github.com/pkg/errors/format_test.go:244", + "error2"}, + }, { + WithMessage(io.EOF, "addition1"), + "%s", + []string{"addition1: EOF"}, + }, { + WithMessage(io.EOF, "addition1"), + "%v", + []string{"addition1: EOF"}, + }, { + WithMessage(io.EOF, "addition1"), + "%+v", + []string{"EOF", "addition1"}, + }, { + WithMessage(WithMessage(io.EOF, "addition1"), "addition2"), + "%v", + []string{"addition2: addition1: EOF"}, + }, { + WithMessage(WithMessage(io.EOF, "addition1"), "addition2"), + "%+v", + []string{"EOF", "addition1", "addition2"}, + }, { + Wrap(WithMessage(io.EOF, "error1"), "error2"), + "%+v", + []string{"EOF", "error1", "error2", + "github.com/pkg/errors.TestFormatWithMessage\n" + + "\t.+/github.com/pkg/errors/format_test.go:272"}, + }, { + WithMessage(Errorf("error%d", 1), "error2"), + "%+v", + []string{"error1", + "github.com/pkg/errors.TestFormatWithMessage\n" + + "\t.+/github.com/pkg/errors/format_test.go:278", + "error2"}, + }, { + WithMessage(WithStack(io.EOF), "error"), + "%+v", + []string{ + "EOF", + "github.com/pkg/errors.TestFormatWithMessage\n" + + "\t.+/github.com/pkg/errors/format_test.go:285", + "error"}, + }, { + WithMessage(Wrap(WithStack(io.EOF), "inside-error"), "outside-error"), + "%+v", + []string{ + "EOF", + "github.com/pkg/errors.TestFormatWithMessage\n" + + "\t.+/github.com/pkg/errors/format_test.go:293", + "inside-error", + "github.com/pkg/errors.TestFormatWithMessage\n" + + "\t.+/github.com/pkg/errors/format_test.go:293", + "outside-error"}, + }} + + for i, tt := range tests { + testFormatCompleteCompare(t, i, tt.error, tt.format, tt.want, true) + } +} + +func TestFormatGeneric(t *testing.T) { + starts := []struct { + err error + want []string + }{ + {New("new-error"), []string{ + "new-error", + "github.com/pkg/errors.TestFormatGeneric\n" + + "\t.+/github.com/pkg/errors/format_test.go:315"}, + }, {Errorf("errorf-error"), []string{ + "errorf-error", + "github.com/pkg/errors.TestFormatGeneric\n" + + "\t.+/github.com/pkg/errors/format_test.go:319"}, + }, {errors.New("errors-new-error"), []string{ + "errors-new-error"}, + }, + } + + wrappers := []wrapper{ + { + func(err error) error { return WithMessage(err, "with-message") }, + []string{"with-message"}, + }, { + func(err error) error { return WithStack(err) }, + []string{ + "github.com/pkg/errors.(func·002|TestFormatGeneric.func2)\n\t" + + ".+/github.com/pkg/errors/format_test.go:333", + }, + }, { + func(err error) error { return Wrap(err, "wrap-error") }, + []string{ + "wrap-error", + "github.com/pkg/errors.(func·003|TestFormatGeneric.func3)\n\t" + + ".+/github.com/pkg/errors/format_test.go:339", + }, + }, { + func(err error) error { return Wrapf(err, "wrapf-error%d", 1) }, + []string{ + "wrapf-error1", + "github.com/pkg/errors.(func·004|TestFormatGeneric.func4)\n\t" + + ".+/github.com/pkg/errors/format_test.go:346", + }, + }, + } + + for s := range starts { + err := starts[s].err + want := starts[s].want + testFormatCompleteCompare(t, s, err, "%+v", want, false) + testGenericRecursive(t, err, want, wrappers, 3) + } +} + +func testFormatRegexp(t *testing.T, n int, arg interface{}, format, want string) { + got := fmt.Sprintf(format, arg) + gotLines := strings.SplitN(got, "\n", -1) + wantLines := strings.SplitN(want, "\n", -1) + + if len(wantLines) > len(gotLines) { + t.Errorf("test %d: wantLines(%d) > gotLines(%d):\n got: %q\nwant: %q", n+1, len(wantLines), len(gotLines), got, want) + return + } + + for i, w := range wantLines { + match, err := regexp.MatchString(w, gotLines[i]) + if err != nil { + t.Fatal(err) + } + if !match { + t.Errorf("test %d: line %d: fmt.Sprintf(%q, err):\n got: %q\nwant: %q", n+1, i+1, format, got, want) + } + } +} + +var stackLineR = regexp.MustCompile(`\.`) + +// parseBlocks parses input into a slice, where: +// - incase entry contains a newline, its a stacktrace +// - incase entry contains no newline, its a solo line. +// +// Detecting stack boundaries only works incase the WithStack-calls are +// to be found on the same line, thats why it is optionally here. +// +// Example use: +// +// for _, e := range blocks { +// if strings.ContainsAny(e, "\n") { +// // Match as stack +// } else { +// // Match as line +// } +// } +// +func parseBlocks(input string, detectStackboundaries bool) ([]string, error) { + var blocks []string + + stack := "" + wasStack := false + lines := map[string]bool{} // already found lines + + for _, l := range strings.Split(input, "\n") { + isStackLine := stackLineR.MatchString(l) + + switch { + case !isStackLine && wasStack: + blocks = append(blocks, stack, l) + stack = "" + lines = map[string]bool{} + case isStackLine: + if wasStack { + // Detecting two stacks after another, possible cause lines match in + // our tests due to WithStack(WithStack(io.EOF)) on same line. + if detectStackboundaries { + if lines[l] { + if len(stack) == 0 { + return nil, errors.New("len of block must not be zero here") + } + + blocks = append(blocks, stack) + stack = l + lines = map[string]bool{l: true} + continue + } + } + + stack = stack + "\n" + l + } else { + stack = l + } + lines[l] = true + case !isStackLine && !wasStack: + blocks = append(blocks, l) + default: + return nil, errors.New("must not happen") + } + + wasStack = isStackLine + } + + // Use up stack + if stack != "" { + blocks = append(blocks, stack) + } + return blocks, nil +} + +func testFormatCompleteCompare(t *testing.T, n int, arg interface{}, format string, want []string, detectStackBoundaries bool) { + gotStr := fmt.Sprintf(format, arg) + + got, err := parseBlocks(gotStr, detectStackBoundaries) + if err != nil { + t.Fatal(err) + } + + if len(got) != len(want) { + t.Fatalf("test %d: fmt.Sprintf(%s, err) -> wrong number of blocks: got(%d) want(%d)\n got: %s\nwant: %s\ngotStr: %q", + n+1, format, len(got), len(want), prettyBlocks(got), prettyBlocks(want), gotStr) + } + + for i := range got { + if strings.ContainsAny(want[i], "\n") { + // Match as stack + match, err := regexp.MatchString(want[i], got[i]) + if err != nil { + t.Fatal(err) + } + if !match { + t.Fatalf("test %d: block %d: fmt.Sprintf(%q, err):\ngot:\n%q\nwant:\n%q\nall-got:\n%s\nall-want:\n%s\n", + n+1, i+1, format, got[i], want[i], prettyBlocks(got), prettyBlocks(want)) + } + } else { + // Match as message + if got[i] != want[i] { + t.Fatalf("test %d: fmt.Sprintf(%s, err) at block %d got != want:\n got: %q\nwant: %q", n+1, format, i+1, got[i], want[i]) + } + } + } +} + +type wrapper struct { + wrap func(err error) error + want []string +} + +func prettyBlocks(blocks []string) string { + var out []string + + for _, b := range blocks { + out = append(out, fmt.Sprintf("%v", b)) + } + + return " " + strings.Join(out, "\n ") +} + +func testGenericRecursive(t *testing.T, beforeErr error, beforeWant []string, list []wrapper, maxDepth int) { + if len(beforeWant) == 0 { + panic("beforeWant must not be empty") + } + for _, w := range list { + if len(w.want) == 0 { + panic("want must not be empty") + } + + err := w.wrap(beforeErr) + + // Copy required cause append(beforeWant, ..) modified beforeWant subtly. + beforeCopy := make([]string, len(beforeWant)) + copy(beforeCopy, beforeWant) + + beforeWant := beforeCopy + last := len(beforeWant) - 1 + var want []string + + // Merge two stacks behind each other. + if strings.ContainsAny(beforeWant[last], "\n") && strings.ContainsAny(w.want[0], "\n") { + want = append(beforeWant[:last], append([]string{beforeWant[last] + "((?s).*)" + w.want[0]}, w.want[1:]...)...) + } else { + want = append(beforeWant, w.want...) + } + + testFormatCompleteCompare(t, maxDepth, err, "%+v", want, false) + if maxDepth > 0 { + testGenericRecursive(t, err, want, list, maxDepth-1) + } + } +} diff --git a/vendor/github.com/pkg/errors/stack.go b/vendor/github.com/pkg/errors/stack.go index 243a64a..b485761 100644 --- a/vendor/github.com/pkg/errors/stack.go +++ b/vendor/github.com/pkg/errors/stack.go @@ -46,7 +46,8 @@ func (f Frame) line() int { // // Format accepts flags that alter the printing of some verbs, as follows: // -// %+s path of source file relative to the compile time GOPATH +// %+s function name and path of source file relative to the compile time +// GOPATH separated by \n\t (\n\t) // %+v equivalent to %+s:%d func (f Frame) Format(s fmt.State, verb rune) { switch verb { @@ -79,6 +80,14 @@ func (f Frame) Format(s fmt.State, verb rune) { // StackTrace is stack of Frames from innermost (newest) to outermost (oldest). type StackTrace []Frame +// Format formats the stack of Frames according to the fmt.Formatter interface. +// +// %s lists source files for each Frame in the stack +// %v lists the source file and line number for each Frame in the stack +// +// Format accepts flags that alter the printing of some verbs, as follows: +// +// %+v Prints filename, function, and line number for each Frame in the stack. func (st StackTrace) Format(s fmt.State, verb rune) { switch verb { case 'v': @@ -100,6 +109,19 @@ func (st StackTrace) Format(s fmt.State, verb rune) { // stack represents a stack of program counters. type stack []uintptr +func (s *stack) Format(st fmt.State, verb rune) { + switch verb { + case 'v': + switch { + case st.Flag('+'): + for _, pc := range *s { + f := Frame(pc) + fmt.Fprintf(st, "\n%+v", f) + } + } + } +} + func (s *stack) StackTrace() StackTrace { f := make([]Frame, len(*s)) for i := 0; i < len(f); i++ { diff --git a/vendor/github.com/pkg/errors/stack_test.go b/vendor/github.com/pkg/errors/stack_test.go new file mode 100644 index 0000000..510c27a --- /dev/null +++ b/vendor/github.com/pkg/errors/stack_test.go @@ -0,0 +1,292 @@ +package errors + +import ( + "fmt" + "runtime" + "testing" +) + +var initpc, _, _, _ = runtime.Caller(0) + +func TestFrameLine(t *testing.T) { + var tests = []struct { + Frame + want int + }{{ + Frame(initpc), + 9, + }, { + func() Frame { + var pc, _, _, _ = runtime.Caller(0) + return Frame(pc) + }(), + 20, + }, { + func() Frame { + var pc, _, _, _ = runtime.Caller(1) + return Frame(pc) + }(), + 28, + }, { + Frame(0), // invalid PC + 0, + }} + + for _, tt := range tests { + got := tt.Frame.line() + want := tt.want + if want != got { + t.Errorf("Frame(%v): want: %v, got: %v", uintptr(tt.Frame), want, got) + } + } +} + +type X struct{} + +func (x X) val() Frame { + var pc, _, _, _ = runtime.Caller(0) + return Frame(pc) +} + +func (x *X) ptr() Frame { + var pc, _, _, _ = runtime.Caller(0) + return Frame(pc) +} + +func TestFrameFormat(t *testing.T) { + var tests = []struct { + Frame + format string + want string + }{{ + Frame(initpc), + "%s", + "stack_test.go", + }, { + Frame(initpc), + "%+s", + "github.com/pkg/errors.init\n" + + "\t.+/github.com/pkg/errors/stack_test.go", + }, { + Frame(0), + "%s", + "unknown", + }, { + Frame(0), + "%+s", + "unknown", + }, { + Frame(initpc), + "%d", + "9", + }, { + Frame(0), + "%d", + "0", + }, { + Frame(initpc), + "%n", + "init", + }, { + func() Frame { + var x X + return x.ptr() + }(), + "%n", + `\(\*X\).ptr`, + }, { + func() Frame { + var x X + return x.val() + }(), + "%n", + "X.val", + }, { + Frame(0), + "%n", + "", + }, { + Frame(initpc), + "%v", + "stack_test.go:9", + }, { + Frame(initpc), + "%+v", + "github.com/pkg/errors.init\n" + + "\t.+/github.com/pkg/errors/stack_test.go:9", + }, { + Frame(0), + "%v", + "unknown:0", + }} + + for i, tt := range tests { + testFormatRegexp(t, i, tt.Frame, tt.format, tt.want) + } +} + +func TestFuncname(t *testing.T) { + tests := []struct { + name, want string + }{ + {"", ""}, + {"runtime.main", "main"}, + {"github.com/pkg/errors.funcname", "funcname"}, + {"funcname", "funcname"}, + {"io.copyBuffer", "copyBuffer"}, + {"main.(*R).Write", "(*R).Write"}, + } + + for _, tt := range tests { + got := funcname(tt.name) + want := tt.want + if got != want { + t.Errorf("funcname(%q): want: %q, got %q", tt.name, want, got) + } + } +} + +func TestTrimGOPATH(t *testing.T) { + var tests = []struct { + Frame + want string + }{{ + Frame(initpc), + "github.com/pkg/errors/stack_test.go", + }} + + for i, tt := range tests { + pc := tt.Frame.pc() + fn := runtime.FuncForPC(pc) + file, _ := fn.FileLine(pc) + got := trimGOPATH(fn.Name(), file) + testFormatRegexp(t, i, got, "%s", tt.want) + } +} + +func TestStackTrace(t *testing.T) { + tests := []struct { + err error + want []string + }{{ + New("ooh"), []string{ + "github.com/pkg/errors.TestStackTrace\n" + + "\t.+/github.com/pkg/errors/stack_test.go:172", + }, + }, { + Wrap(New("ooh"), "ahh"), []string{ + "github.com/pkg/errors.TestStackTrace\n" + + "\t.+/github.com/pkg/errors/stack_test.go:177", // this is the stack of Wrap, not New + }, + }, { + Cause(Wrap(New("ooh"), "ahh")), []string{ + "github.com/pkg/errors.TestStackTrace\n" + + "\t.+/github.com/pkg/errors/stack_test.go:182", // this is the stack of New + }, + }, { + func() error { return New("ooh") }(), []string{ + `github.com/pkg/errors.(func·009|TestStackTrace.func1)` + + "\n\t.+/github.com/pkg/errors/stack_test.go:187", // this is the stack of New + "github.com/pkg/errors.TestStackTrace\n" + + "\t.+/github.com/pkg/errors/stack_test.go:187", // this is the stack of New's caller + }, + }, { + Cause(func() error { + return func() error { + return Errorf("hello %s", fmt.Sprintf("world")) + }() + }()), []string{ + `github.com/pkg/errors.(func·010|TestStackTrace.func2.1)` + + "\n\t.+/github.com/pkg/errors/stack_test.go:196", // this is the stack of Errorf + `github.com/pkg/errors.(func·011|TestStackTrace.func2)` + + "\n\t.+/github.com/pkg/errors/stack_test.go:197", // this is the stack of Errorf's caller + "github.com/pkg/errors.TestStackTrace\n" + + "\t.+/github.com/pkg/errors/stack_test.go:198", // this is the stack of Errorf's caller's caller + }, + }} + for i, tt := range tests { + x, ok := tt.err.(interface { + StackTrace() StackTrace + }) + if !ok { + t.Errorf("expected %#v to implement StackTrace() StackTrace", tt.err) + continue + } + st := x.StackTrace() + for j, want := range tt.want { + testFormatRegexp(t, i, st[j], "%+v", want) + } + } +} + +func stackTrace() StackTrace { + const depth = 8 + var pcs [depth]uintptr + n := runtime.Callers(1, pcs[:]) + var st stack = pcs[0:n] + return st.StackTrace() +} + +func TestStackTraceFormat(t *testing.T) { + tests := []struct { + StackTrace + format string + want string + }{{ + nil, + "%s", + `\[\]`, + }, { + nil, + "%v", + `\[\]`, + }, { + nil, + "%+v", + "", + }, { + nil, + "%#v", + `\[\]errors.Frame\(nil\)`, + }, { + make(StackTrace, 0), + "%s", + `\[\]`, + }, { + make(StackTrace, 0), + "%v", + `\[\]`, + }, { + make(StackTrace, 0), + "%+v", + "", + }, { + make(StackTrace, 0), + "%#v", + `\[\]errors.Frame{}`, + }, { + stackTrace()[:2], + "%s", + `\[stack_test.go stack_test.go\]`, + }, { + stackTrace()[:2], + "%v", + `\[stack_test.go:225 stack_test.go:272\]`, + }, { + stackTrace()[:2], + "%+v", + "\n" + + "github.com/pkg/errors.stackTrace\n" + + "\t.+/github.com/pkg/errors/stack_test.go:225\n" + + "github.com/pkg/errors.TestStackTraceFormat\n" + + "\t.+/github.com/pkg/errors/stack_test.go:276", + }, { + stackTrace()[:2], + "%#v", + `\[\]errors.Frame{stack_test.go:225, stack_test.go:284}`, + }} + + for i, tt := range tests { + testFormatRegexp(t, i, tt.StackTrace, tt.format, tt.want) + } +} diff --git a/vendor/github.com/pmezard/go-difflib/.travis.yml b/vendor/github.com/pmezard/go-difflib/.travis.yml new file mode 100644 index 0000000..90c9c6f --- /dev/null +++ b/vendor/github.com/pmezard/go-difflib/.travis.yml @@ -0,0 +1,5 @@ +language: go +go: + - 1.5 + - tip + diff --git a/vendor/github.com/pmezard/go-difflib/LICENSE b/vendor/github.com/pmezard/go-difflib/LICENSE new file mode 100644 index 0000000..c67dad6 --- /dev/null +++ b/vendor/github.com/pmezard/go-difflib/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) 2013, Patrick Mezard +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + Redistributions of source code must retain the above copyright +notice, this list of conditions and the following disclaimer. + Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + The names of its contributors may not be used to endorse or promote +products derived from this software without specific prior written +permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS +IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR +PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/vendor/github.com/pmezard/go-difflib/README.md b/vendor/github.com/pmezard/go-difflib/README.md new file mode 100644 index 0000000..e87f307 --- /dev/null +++ b/vendor/github.com/pmezard/go-difflib/README.md @@ -0,0 +1,50 @@ +go-difflib +========== + +[![Build Status](https://travis-ci.org/pmezard/go-difflib.png?branch=master)](https://travis-ci.org/pmezard/go-difflib) +[![GoDoc](https://godoc.org/github.com/pmezard/go-difflib/difflib?status.svg)](https://godoc.org/github.com/pmezard/go-difflib/difflib) + +Go-difflib is a partial port of python 3 difflib package. Its main goal +was to make unified and context diff available in pure Go, mostly for +testing purposes. + +The following class and functions (and related tests) have be ported: + +* `SequenceMatcher` +* `unified_diff()` +* `context_diff()` + +## Installation + +```bash +$ go get github.com/pmezard/go-difflib/difflib +``` + +### Quick Start + +Diffs are configured with Unified (or ContextDiff) structures, and can +be output to an io.Writer or returned as a string. + +```Go +diff := UnifiedDiff{ + A: difflib.SplitLines("foo\nbar\n"), + B: difflib.SplitLines("foo\nbaz\n"), + FromFile: "Original", + ToFile: "Current", + Context: 3, +} +text, _ := GetUnifiedDiffString(diff) +fmt.Printf(text) +``` + +would output: + +``` +--- Original ++++ Current +@@ -1,3 +1,3 @@ + foo +-bar ++baz +``` + diff --git a/vendor/github.com/pmezard/go-difflib/difflib/difflib.go b/vendor/github.com/pmezard/go-difflib/difflib/difflib.go new file mode 100644 index 0000000..003e99f --- /dev/null +++ b/vendor/github.com/pmezard/go-difflib/difflib/difflib.go @@ -0,0 +1,772 @@ +// Package difflib is a partial port of Python difflib module. +// +// It provides tools to compare sequences of strings and generate textual diffs. +// +// The following class and functions have been ported: +// +// - SequenceMatcher +// +// - unified_diff +// +// - context_diff +// +// Getting unified diffs was the main goal of the port. Keep in mind this code +// is mostly suitable to output text differences in a human friendly way, there +// are no guarantees generated diffs are consumable by patch(1). +package difflib + +import ( + "bufio" + "bytes" + "fmt" + "io" + "strings" +) + +func min(a, b int) int { + if a < b { + return a + } + return b +} + +func max(a, b int) int { + if a > b { + return a + } + return b +} + +func calculateRatio(matches, length int) float64 { + if length > 0 { + return 2.0 * float64(matches) / float64(length) + } + return 1.0 +} + +type Match struct { + A int + B int + Size int +} + +type OpCode struct { + Tag byte + I1 int + I2 int + J1 int + J2 int +} + +// SequenceMatcher compares sequence of strings. The basic +// algorithm predates, and is a little fancier than, an algorithm +// published in the late 1980's by Ratcliff and Obershelp under the +// hyperbolic name "gestalt pattern matching". The basic idea is to find +// the longest contiguous matching subsequence that contains no "junk" +// elements (R-O doesn't address junk). The same idea is then applied +// recursively to the pieces of the sequences to the left and to the right +// of the matching subsequence. This does not yield minimal edit +// sequences, but does tend to yield matches that "look right" to people. +// +// SequenceMatcher tries to compute a "human-friendly diff" between two +// sequences. Unlike e.g. UNIX(tm) diff, the fundamental notion is the +// longest *contiguous* & junk-free matching subsequence. That's what +// catches peoples' eyes. The Windows(tm) windiff has another interesting +// notion, pairing up elements that appear uniquely in each sequence. +// That, and the method here, appear to yield more intuitive difference +// reports than does diff. This method appears to be the least vulnerable +// to synching up on blocks of "junk lines", though (like blank lines in +// ordinary text files, or maybe "

" lines in HTML files). That may be +// because this is the only method of the 3 that has a *concept* of +// "junk" . +// +// Timing: Basic R-O is cubic time worst case and quadratic time expected +// case. SequenceMatcher is quadratic time for the worst case and has +// expected-case behavior dependent in a complicated way on how many +// elements the sequences have in common; best case time is linear. +type SequenceMatcher struct { + a []string + b []string + b2j map[string][]int + IsJunk func(string) bool + autoJunk bool + bJunk map[string]struct{} + matchingBlocks []Match + fullBCount map[string]int + bPopular map[string]struct{} + opCodes []OpCode +} + +func NewMatcher(a, b []string) *SequenceMatcher { + m := SequenceMatcher{autoJunk: true} + m.SetSeqs(a, b) + return &m +} + +func NewMatcherWithJunk(a, b []string, autoJunk bool, + isJunk func(string) bool) *SequenceMatcher { + + m := SequenceMatcher{IsJunk: isJunk, autoJunk: autoJunk} + m.SetSeqs(a, b) + return &m +} + +// Set two sequences to be compared. +func (m *SequenceMatcher) SetSeqs(a, b []string) { + m.SetSeq1(a) + m.SetSeq2(b) +} + +// Set the first sequence to be compared. The second sequence to be compared is +// not changed. +// +// SequenceMatcher computes and caches detailed information about the second +// sequence, so if you want to compare one sequence S against many sequences, +// use .SetSeq2(s) once and call .SetSeq1(x) repeatedly for each of the other +// sequences. +// +// See also SetSeqs() and SetSeq2(). +func (m *SequenceMatcher) SetSeq1(a []string) { + if &a == &m.a { + return + } + m.a = a + m.matchingBlocks = nil + m.opCodes = nil +} + +// Set the second sequence to be compared. The first sequence to be compared is +// not changed. +func (m *SequenceMatcher) SetSeq2(b []string) { + if &b == &m.b { + return + } + m.b = b + m.matchingBlocks = nil + m.opCodes = nil + m.fullBCount = nil + m.chainB() +} + +func (m *SequenceMatcher) chainB() { + // Populate line -> index mapping + b2j := map[string][]int{} + for i, s := range m.b { + indices := b2j[s] + indices = append(indices, i) + b2j[s] = indices + } + + // Purge junk elements + m.bJunk = map[string]struct{}{} + if m.IsJunk != nil { + junk := m.bJunk + for s, _ := range b2j { + if m.IsJunk(s) { + junk[s] = struct{}{} + } + } + for s, _ := range junk { + delete(b2j, s) + } + } + + // Purge remaining popular elements + popular := map[string]struct{}{} + n := len(m.b) + if m.autoJunk && n >= 200 { + ntest := n/100 + 1 + for s, indices := range b2j { + if len(indices) > ntest { + popular[s] = struct{}{} + } + } + for s, _ := range popular { + delete(b2j, s) + } + } + m.bPopular = popular + m.b2j = b2j +} + +func (m *SequenceMatcher) isBJunk(s string) bool { + _, ok := m.bJunk[s] + return ok +} + +// Find longest matching block in a[alo:ahi] and b[blo:bhi]. +// +// If IsJunk is not defined: +// +// Return (i,j,k) such that a[i:i+k] is equal to b[j:j+k], where +// alo <= i <= i+k <= ahi +// blo <= j <= j+k <= bhi +// and for all (i',j',k') meeting those conditions, +// k >= k' +// i <= i' +// and if i == i', j <= j' +// +// In other words, of all maximal matching blocks, return one that +// starts earliest in a, and of all those maximal matching blocks that +// start earliest in a, return the one that starts earliest in b. +// +// If IsJunk is defined, first the longest matching block is +// determined as above, but with the additional restriction that no +// junk element appears in the block. Then that block is extended as +// far as possible by matching (only) junk elements on both sides. So +// the resulting block never matches on junk except as identical junk +// happens to be adjacent to an "interesting" match. +// +// If no blocks match, return (alo, blo, 0). +func (m *SequenceMatcher) findLongestMatch(alo, ahi, blo, bhi int) Match { + // CAUTION: stripping common prefix or suffix would be incorrect. + // E.g., + // ab + // acab + // Longest matching block is "ab", but if common prefix is + // stripped, it's "a" (tied with "b"). UNIX(tm) diff does so + // strip, so ends up claiming that ab is changed to acab by + // inserting "ca" in the middle. That's minimal but unintuitive: + // "it's obvious" that someone inserted "ac" at the front. + // Windiff ends up at the same place as diff, but by pairing up + // the unique 'b's and then matching the first two 'a's. + besti, bestj, bestsize := alo, blo, 0 + + // find longest junk-free match + // during an iteration of the loop, j2len[j] = length of longest + // junk-free match ending with a[i-1] and b[j] + j2len := map[int]int{} + for i := alo; i != ahi; i++ { + // look at all instances of a[i] in b; note that because + // b2j has no junk keys, the loop is skipped if a[i] is junk + newj2len := map[int]int{} + for _, j := range m.b2j[m.a[i]] { + // a[i] matches b[j] + if j < blo { + continue + } + if j >= bhi { + break + } + k := j2len[j-1] + 1 + newj2len[j] = k + if k > bestsize { + besti, bestj, bestsize = i-k+1, j-k+1, k + } + } + j2len = newj2len + } + + // Extend the best by non-junk elements on each end. In particular, + // "popular" non-junk elements aren't in b2j, which greatly speeds + // the inner loop above, but also means "the best" match so far + // doesn't contain any junk *or* popular non-junk elements. + for besti > alo && bestj > blo && !m.isBJunk(m.b[bestj-1]) && + m.a[besti-1] == m.b[bestj-1] { + besti, bestj, bestsize = besti-1, bestj-1, bestsize+1 + } + for besti+bestsize < ahi && bestj+bestsize < bhi && + !m.isBJunk(m.b[bestj+bestsize]) && + m.a[besti+bestsize] == m.b[bestj+bestsize] { + bestsize += 1 + } + + // Now that we have a wholly interesting match (albeit possibly + // empty!), we may as well suck up the matching junk on each + // side of it too. Can't think of a good reason not to, and it + // saves post-processing the (possibly considerable) expense of + // figuring out what to do with it. In the case of an empty + // interesting match, this is clearly the right thing to do, + // because no other kind of match is possible in the regions. + for besti > alo && bestj > blo && m.isBJunk(m.b[bestj-1]) && + m.a[besti-1] == m.b[bestj-1] { + besti, bestj, bestsize = besti-1, bestj-1, bestsize+1 + } + for besti+bestsize < ahi && bestj+bestsize < bhi && + m.isBJunk(m.b[bestj+bestsize]) && + m.a[besti+bestsize] == m.b[bestj+bestsize] { + bestsize += 1 + } + + return Match{A: besti, B: bestj, Size: bestsize} +} + +// Return list of triples describing matching subsequences. +// +// Each triple is of the form (i, j, n), and means that +// a[i:i+n] == b[j:j+n]. The triples are monotonically increasing in +// i and in j. It's also guaranteed that if (i, j, n) and (i', j', n') are +// adjacent triples in the list, and the second is not the last triple in the +// list, then i+n != i' or j+n != j'. IOW, adjacent triples never describe +// adjacent equal blocks. +// +// The last triple is a dummy, (len(a), len(b), 0), and is the only +// triple with n==0. +func (m *SequenceMatcher) GetMatchingBlocks() []Match { + if m.matchingBlocks != nil { + return m.matchingBlocks + } + + var matchBlocks func(alo, ahi, blo, bhi int, matched []Match) []Match + matchBlocks = func(alo, ahi, blo, bhi int, matched []Match) []Match { + match := m.findLongestMatch(alo, ahi, blo, bhi) + i, j, k := match.A, match.B, match.Size + if match.Size > 0 { + if alo < i && blo < j { + matched = matchBlocks(alo, i, blo, j, matched) + } + matched = append(matched, match) + if i+k < ahi && j+k < bhi { + matched = matchBlocks(i+k, ahi, j+k, bhi, matched) + } + } + return matched + } + matched := matchBlocks(0, len(m.a), 0, len(m.b), nil) + + // It's possible that we have adjacent equal blocks in the + // matching_blocks list now. + nonAdjacent := []Match{} + i1, j1, k1 := 0, 0, 0 + for _, b := range matched { + // Is this block adjacent to i1, j1, k1? + i2, j2, k2 := b.A, b.B, b.Size + if i1+k1 == i2 && j1+k1 == j2 { + // Yes, so collapse them -- this just increases the length of + // the first block by the length of the second, and the first + // block so lengthened remains the block to compare against. + k1 += k2 + } else { + // Not adjacent. Remember the first block (k1==0 means it's + // the dummy we started with), and make the second block the + // new block to compare against. + if k1 > 0 { + nonAdjacent = append(nonAdjacent, Match{i1, j1, k1}) + } + i1, j1, k1 = i2, j2, k2 + } + } + if k1 > 0 { + nonAdjacent = append(nonAdjacent, Match{i1, j1, k1}) + } + + nonAdjacent = append(nonAdjacent, Match{len(m.a), len(m.b), 0}) + m.matchingBlocks = nonAdjacent + return m.matchingBlocks +} + +// Return list of 5-tuples describing how to turn a into b. +// +// Each tuple is of the form (tag, i1, i2, j1, j2). The first tuple +// has i1 == j1 == 0, and remaining tuples have i1 == the i2 from the +// tuple preceding it, and likewise for j1 == the previous j2. +// +// The tags are characters, with these meanings: +// +// 'r' (replace): a[i1:i2] should be replaced by b[j1:j2] +// +// 'd' (delete): a[i1:i2] should be deleted, j1==j2 in this case. +// +// 'i' (insert): b[j1:j2] should be inserted at a[i1:i1], i1==i2 in this case. +// +// 'e' (equal): a[i1:i2] == b[j1:j2] +func (m *SequenceMatcher) GetOpCodes() []OpCode { + if m.opCodes != nil { + return m.opCodes + } + i, j := 0, 0 + matching := m.GetMatchingBlocks() + opCodes := make([]OpCode, 0, len(matching)) + for _, m := range matching { + // invariant: we've pumped out correct diffs to change + // a[:i] into b[:j], and the next matching block is + // a[ai:ai+size] == b[bj:bj+size]. So we need to pump + // out a diff to change a[i:ai] into b[j:bj], pump out + // the matching block, and move (i,j) beyond the match + ai, bj, size := m.A, m.B, m.Size + tag := byte(0) + if i < ai && j < bj { + tag = 'r' + } else if i < ai { + tag = 'd' + } else if j < bj { + tag = 'i' + } + if tag > 0 { + opCodes = append(opCodes, OpCode{tag, i, ai, j, bj}) + } + i, j = ai+size, bj+size + // the list of matching blocks is terminated by a + // sentinel with size 0 + if size > 0 { + opCodes = append(opCodes, OpCode{'e', ai, i, bj, j}) + } + } + m.opCodes = opCodes + return m.opCodes +} + +// Isolate change clusters by eliminating ranges with no changes. +// +// Return a generator of groups with up to n lines of context. +// Each group is in the same format as returned by GetOpCodes(). +func (m *SequenceMatcher) GetGroupedOpCodes(n int) [][]OpCode { + if n < 0 { + n = 3 + } + codes := m.GetOpCodes() + if len(codes) == 0 { + codes = []OpCode{OpCode{'e', 0, 1, 0, 1}} + } + // Fixup leading and trailing groups if they show no changes. + if codes[0].Tag == 'e' { + c := codes[0] + i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2 + codes[0] = OpCode{c.Tag, max(i1, i2-n), i2, max(j1, j2-n), j2} + } + if codes[len(codes)-1].Tag == 'e' { + c := codes[len(codes)-1] + i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2 + codes[len(codes)-1] = OpCode{c.Tag, i1, min(i2, i1+n), j1, min(j2, j1+n)} + } + nn := n + n + groups := [][]OpCode{} + group := []OpCode{} + for _, c := range codes { + i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2 + // End the current group and start a new one whenever + // there is a large range with no changes. + if c.Tag == 'e' && i2-i1 > nn { + group = append(group, OpCode{c.Tag, i1, min(i2, i1+n), + j1, min(j2, j1+n)}) + groups = append(groups, group) + group = []OpCode{} + i1, j1 = max(i1, i2-n), max(j1, j2-n) + } + group = append(group, OpCode{c.Tag, i1, i2, j1, j2}) + } + if len(group) > 0 && !(len(group) == 1 && group[0].Tag == 'e') { + groups = append(groups, group) + } + return groups +} + +// Return a measure of the sequences' similarity (float in [0,1]). +// +// Where T is the total number of elements in both sequences, and +// M is the number of matches, this is 2.0*M / T. +// Note that this is 1 if the sequences are identical, and 0 if +// they have nothing in common. +// +// .Ratio() is expensive to compute if you haven't already computed +// .GetMatchingBlocks() or .GetOpCodes(), in which case you may +// want to try .QuickRatio() or .RealQuickRation() first to get an +// upper bound. +func (m *SequenceMatcher) Ratio() float64 { + matches := 0 + for _, m := range m.GetMatchingBlocks() { + matches += m.Size + } + return calculateRatio(matches, len(m.a)+len(m.b)) +} + +// Return an upper bound on ratio() relatively quickly. +// +// This isn't defined beyond that it is an upper bound on .Ratio(), and +// is faster to compute. +func (m *SequenceMatcher) QuickRatio() float64 { + // viewing a and b as multisets, set matches to the cardinality + // of their intersection; this counts the number of matches + // without regard to order, so is clearly an upper bound + if m.fullBCount == nil { + m.fullBCount = map[string]int{} + for _, s := range m.b { + m.fullBCount[s] = m.fullBCount[s] + 1 + } + } + + // avail[x] is the number of times x appears in 'b' less the + // number of times we've seen it in 'a' so far ... kinda + avail := map[string]int{} + matches := 0 + for _, s := range m.a { + n, ok := avail[s] + if !ok { + n = m.fullBCount[s] + } + avail[s] = n - 1 + if n > 0 { + matches += 1 + } + } + return calculateRatio(matches, len(m.a)+len(m.b)) +} + +// Return an upper bound on ratio() very quickly. +// +// This isn't defined beyond that it is an upper bound on .Ratio(), and +// is faster to compute than either .Ratio() or .QuickRatio(). +func (m *SequenceMatcher) RealQuickRatio() float64 { + la, lb := len(m.a), len(m.b) + return calculateRatio(min(la, lb), la+lb) +} + +// Convert range to the "ed" format +func formatRangeUnified(start, stop int) string { + // Per the diff spec at http://www.unix.org/single_unix_specification/ + beginning := start + 1 // lines start numbering with one + length := stop - start + if length == 1 { + return fmt.Sprintf("%d", beginning) + } + if length == 0 { + beginning -= 1 // empty ranges begin at line just before the range + } + return fmt.Sprintf("%d,%d", beginning, length) +} + +// Unified diff parameters +type UnifiedDiff struct { + A []string // First sequence lines + FromFile string // First file name + FromDate string // First file time + B []string // Second sequence lines + ToFile string // Second file name + ToDate string // Second file time + Eol string // Headers end of line, defaults to LF + Context int // Number of context lines +} + +// Compare two sequences of lines; generate the delta as a unified diff. +// +// Unified diffs are a compact way of showing line changes and a few +// lines of context. The number of context lines is set by 'n' which +// defaults to three. +// +// By default, the diff control lines (those with ---, +++, or @@) are +// created with a trailing newline. This is helpful so that inputs +// created from file.readlines() result in diffs that are suitable for +// file.writelines() since both the inputs and outputs have trailing +// newlines. +// +// For inputs that do not have trailing newlines, set the lineterm +// argument to "" so that the output will be uniformly newline free. +// +// The unidiff format normally has a header for filenames and modification +// times. Any or all of these may be specified using strings for +// 'fromfile', 'tofile', 'fromfiledate', and 'tofiledate'. +// The modification times are normally expressed in the ISO 8601 format. +func WriteUnifiedDiff(writer io.Writer, diff UnifiedDiff) error { + buf := bufio.NewWriter(writer) + defer buf.Flush() + wf := func(format string, args ...interface{}) error { + _, err := buf.WriteString(fmt.Sprintf(format, args...)) + return err + } + ws := func(s string) error { + _, err := buf.WriteString(s) + return err + } + + if len(diff.Eol) == 0 { + diff.Eol = "\n" + } + + started := false + m := NewMatcher(diff.A, diff.B) + for _, g := range m.GetGroupedOpCodes(diff.Context) { + if !started { + started = true + fromDate := "" + if len(diff.FromDate) > 0 { + fromDate = "\t" + diff.FromDate + } + toDate := "" + if len(diff.ToDate) > 0 { + toDate = "\t" + diff.ToDate + } + if diff.FromFile != "" || diff.ToFile != "" { + err := wf("--- %s%s%s", diff.FromFile, fromDate, diff.Eol) + if err != nil { + return err + } + err = wf("+++ %s%s%s", diff.ToFile, toDate, diff.Eol) + if err != nil { + return err + } + } + } + first, last := g[0], g[len(g)-1] + range1 := formatRangeUnified(first.I1, last.I2) + range2 := formatRangeUnified(first.J1, last.J2) + if err := wf("@@ -%s +%s @@%s", range1, range2, diff.Eol); err != nil { + return err + } + for _, c := range g { + i1, i2, j1, j2 := c.I1, c.I2, c.J1, c.J2 + if c.Tag == 'e' { + for _, line := range diff.A[i1:i2] { + if err := ws(" " + line); err != nil { + return err + } + } + continue + } + if c.Tag == 'r' || c.Tag == 'd' { + for _, line := range diff.A[i1:i2] { + if err := ws("-" + line); err != nil { + return err + } + } + } + if c.Tag == 'r' || c.Tag == 'i' { + for _, line := range diff.B[j1:j2] { + if err := ws("+" + line); err != nil { + return err + } + } + } + } + } + return nil +} + +// Like WriteUnifiedDiff but returns the diff a string. +func GetUnifiedDiffString(diff UnifiedDiff) (string, error) { + w := &bytes.Buffer{} + err := WriteUnifiedDiff(w, diff) + return string(w.Bytes()), err +} + +// Convert range to the "ed" format. +func formatRangeContext(start, stop int) string { + // Per the diff spec at http://www.unix.org/single_unix_specification/ + beginning := start + 1 // lines start numbering with one + length := stop - start + if length == 0 { + beginning -= 1 // empty ranges begin at line just before the range + } + if length <= 1 { + return fmt.Sprintf("%d", beginning) + } + return fmt.Sprintf("%d,%d", beginning, beginning+length-1) +} + +type ContextDiff UnifiedDiff + +// Compare two sequences of lines; generate the delta as a context diff. +// +// Context diffs are a compact way of showing line changes and a few +// lines of context. The number of context lines is set by diff.Context +// which defaults to three. +// +// By default, the diff control lines (those with *** or ---) are +// created with a trailing newline. +// +// For inputs that do not have trailing newlines, set the diff.Eol +// argument to "" so that the output will be uniformly newline free. +// +// The context diff format normally has a header for filenames and +// modification times. Any or all of these may be specified using +// strings for diff.FromFile, diff.ToFile, diff.FromDate, diff.ToDate. +// The modification times are normally expressed in the ISO 8601 format. +// If not specified, the strings default to blanks. +func WriteContextDiff(writer io.Writer, diff ContextDiff) error { + buf := bufio.NewWriter(writer) + defer buf.Flush() + var diffErr error + wf := func(format string, args ...interface{}) { + _, err := buf.WriteString(fmt.Sprintf(format, args...)) + if diffErr == nil && err != nil { + diffErr = err + } + } + ws := func(s string) { + _, err := buf.WriteString(s) + if diffErr == nil && err != nil { + diffErr = err + } + } + + if len(diff.Eol) == 0 { + diff.Eol = "\n" + } + + prefix := map[byte]string{ + 'i': "+ ", + 'd': "- ", + 'r': "! ", + 'e': " ", + } + + started := false + m := NewMatcher(diff.A, diff.B) + for _, g := range m.GetGroupedOpCodes(diff.Context) { + if !started { + started = true + fromDate := "" + if len(diff.FromDate) > 0 { + fromDate = "\t" + diff.FromDate + } + toDate := "" + if len(diff.ToDate) > 0 { + toDate = "\t" + diff.ToDate + } + if diff.FromFile != "" || diff.ToFile != "" { + wf("*** %s%s%s", diff.FromFile, fromDate, diff.Eol) + wf("--- %s%s%s", diff.ToFile, toDate, diff.Eol) + } + } + + first, last := g[0], g[len(g)-1] + ws("***************" + diff.Eol) + + range1 := formatRangeContext(first.I1, last.I2) + wf("*** %s ****%s", range1, diff.Eol) + for _, c := range g { + if c.Tag == 'r' || c.Tag == 'd' { + for _, cc := range g { + if cc.Tag == 'i' { + continue + } + for _, line := range diff.A[cc.I1:cc.I2] { + ws(prefix[cc.Tag] + line) + } + } + break + } + } + + range2 := formatRangeContext(first.J1, last.J2) + wf("--- %s ----%s", range2, diff.Eol) + for _, c := range g { + if c.Tag == 'r' || c.Tag == 'i' { + for _, cc := range g { + if cc.Tag == 'd' { + continue + } + for _, line := range diff.B[cc.J1:cc.J2] { + ws(prefix[cc.Tag] + line) + } + } + break + } + } + } + return diffErr +} + +// Like WriteContextDiff but returns the diff a string. +func GetContextDiffString(diff ContextDiff) (string, error) { + w := &bytes.Buffer{} + err := WriteContextDiff(w, diff) + return string(w.Bytes()), err +} + +// Split a string on "\n" while preserving them. The output can be used +// as input for UnifiedDiff and ContextDiff structures. +func SplitLines(s string) []string { + lines := strings.SplitAfter(s, "\n") + lines[len(lines)-1] += "\n" + return lines +} diff --git a/vendor/github.com/pmezard/go-difflib/difflib/difflib_test.go b/vendor/github.com/pmezard/go-difflib/difflib/difflib_test.go new file mode 100644 index 0000000..d725119 --- /dev/null +++ b/vendor/github.com/pmezard/go-difflib/difflib/difflib_test.go @@ -0,0 +1,426 @@ +package difflib + +import ( + "bytes" + "fmt" + "math" + "reflect" + "strings" + "testing" +) + +func assertAlmostEqual(t *testing.T, a, b float64, places int) { + if math.Abs(a-b) > math.Pow10(-places) { + t.Errorf("%.7f != %.7f", a, b) + } +} + +func assertEqual(t *testing.T, a, b interface{}) { + if !reflect.DeepEqual(a, b) { + t.Errorf("%v != %v", a, b) + } +} + +func splitChars(s string) []string { + chars := make([]string, 0, len(s)) + // Assume ASCII inputs + for i := 0; i != len(s); i++ { + chars = append(chars, string(s[i])) + } + return chars +} + +func TestSequenceMatcherRatio(t *testing.T) { + s := NewMatcher(splitChars("abcd"), splitChars("bcde")) + assertEqual(t, s.Ratio(), 0.75) + assertEqual(t, s.QuickRatio(), 0.75) + assertEqual(t, s.RealQuickRatio(), 1.0) +} + +func TestGetOptCodes(t *testing.T) { + a := "qabxcd" + b := "abycdf" + s := NewMatcher(splitChars(a), splitChars(b)) + w := &bytes.Buffer{} + for _, op := range s.GetOpCodes() { + fmt.Fprintf(w, "%s a[%d:%d], (%s) b[%d:%d] (%s)\n", string(op.Tag), + op.I1, op.I2, a[op.I1:op.I2], op.J1, op.J2, b[op.J1:op.J2]) + } + result := string(w.Bytes()) + expected := `d a[0:1], (q) b[0:0] () +e a[1:3], (ab) b[0:2] (ab) +r a[3:4], (x) b[2:3] (y) +e a[4:6], (cd) b[3:5] (cd) +i a[6:6], () b[5:6] (f) +` + if expected != result { + t.Errorf("unexpected op codes: \n%s", result) + } +} + +func TestGroupedOpCodes(t *testing.T) { + a := []string{} + for i := 0; i != 39; i++ { + a = append(a, fmt.Sprintf("%02d", i)) + } + b := []string{} + b = append(b, a[:8]...) + b = append(b, " i") + b = append(b, a[8:19]...) + b = append(b, " x") + b = append(b, a[20:22]...) + b = append(b, a[27:34]...) + b = append(b, " y") + b = append(b, a[35:]...) + s := NewMatcher(a, b) + w := &bytes.Buffer{} + for _, g := range s.GetGroupedOpCodes(-1) { + fmt.Fprintf(w, "group\n") + for _, op := range g { + fmt.Fprintf(w, " %s, %d, %d, %d, %d\n", string(op.Tag), + op.I1, op.I2, op.J1, op.J2) + } + } + result := string(w.Bytes()) + expected := `group + e, 5, 8, 5, 8 + i, 8, 8, 8, 9 + e, 8, 11, 9, 12 +group + e, 16, 19, 17, 20 + r, 19, 20, 20, 21 + e, 20, 22, 21, 23 + d, 22, 27, 23, 23 + e, 27, 30, 23, 26 +group + e, 31, 34, 27, 30 + r, 34, 35, 30, 31 + e, 35, 38, 31, 34 +` + if expected != result { + t.Errorf("unexpected op codes: \n%s", result) + } +} + +func ExampleGetUnifiedDiffCode() { + a := `one +two +three +four +fmt.Printf("%s,%T",a,b)` + b := `zero +one +three +four` + diff := UnifiedDiff{ + A: SplitLines(a), + B: SplitLines(b), + FromFile: "Original", + FromDate: "2005-01-26 23:30:50", + ToFile: "Current", + ToDate: "2010-04-02 10:20:52", + Context: 3, + } + result, _ := GetUnifiedDiffString(diff) + fmt.Println(strings.Replace(result, "\t", " ", -1)) + // Output: + // --- Original 2005-01-26 23:30:50 + // +++ Current 2010-04-02 10:20:52 + // @@ -1,5 +1,4 @@ + // +zero + // one + // -two + // three + // four + // -fmt.Printf("%s,%T",a,b) +} + +func ExampleGetContextDiffCode() { + a := `one +two +three +four +fmt.Printf("%s,%T",a,b)` + b := `zero +one +tree +four` + diff := ContextDiff{ + A: SplitLines(a), + B: SplitLines(b), + FromFile: "Original", + ToFile: "Current", + Context: 3, + Eol: "\n", + } + result, _ := GetContextDiffString(diff) + fmt.Print(strings.Replace(result, "\t", " ", -1)) + // Output: + // *** Original + // --- Current + // *************** + // *** 1,5 **** + // one + // ! two + // ! three + // four + // - fmt.Printf("%s,%T",a,b) + // --- 1,4 ---- + // + zero + // one + // ! tree + // four +} + +func ExampleGetContextDiffString() { + a := `one +two +three +four` + b := `zero +one +tree +four` + diff := ContextDiff{ + A: SplitLines(a), + B: SplitLines(b), + FromFile: "Original", + ToFile: "Current", + Context: 3, + Eol: "\n", + } + result, _ := GetContextDiffString(diff) + fmt.Printf(strings.Replace(result, "\t", " ", -1)) + // Output: + // *** Original + // --- Current + // *************** + // *** 1,4 **** + // one + // ! two + // ! three + // four + // --- 1,4 ---- + // + zero + // one + // ! tree + // four +} + +func rep(s string, count int) string { + return strings.Repeat(s, count) +} + +func TestWithAsciiOneInsert(t *testing.T) { + sm := NewMatcher(splitChars(rep("b", 100)), + splitChars("a"+rep("b", 100))) + assertAlmostEqual(t, sm.Ratio(), 0.995, 3) + assertEqual(t, sm.GetOpCodes(), + []OpCode{{'i', 0, 0, 0, 1}, {'e', 0, 100, 1, 101}}) + assertEqual(t, len(sm.bPopular), 0) + + sm = NewMatcher(splitChars(rep("b", 100)), + splitChars(rep("b", 50)+"a"+rep("b", 50))) + assertAlmostEqual(t, sm.Ratio(), 0.995, 3) + assertEqual(t, sm.GetOpCodes(), + []OpCode{{'e', 0, 50, 0, 50}, {'i', 50, 50, 50, 51}, {'e', 50, 100, 51, 101}}) + assertEqual(t, len(sm.bPopular), 0) +} + +func TestWithAsciiOnDelete(t *testing.T) { + sm := NewMatcher(splitChars(rep("a", 40)+"c"+rep("b", 40)), + splitChars(rep("a", 40)+rep("b", 40))) + assertAlmostEqual(t, sm.Ratio(), 0.994, 3) + assertEqual(t, sm.GetOpCodes(), + []OpCode{{'e', 0, 40, 0, 40}, {'d', 40, 41, 40, 40}, {'e', 41, 81, 40, 80}}) +} + +func TestWithAsciiBJunk(t *testing.T) { + isJunk := func(s string) bool { + return s == " " + } + sm := NewMatcherWithJunk(splitChars(rep("a", 40)+rep("b", 40)), + splitChars(rep("a", 44)+rep("b", 40)), true, isJunk) + assertEqual(t, sm.bJunk, map[string]struct{}{}) + + sm = NewMatcherWithJunk(splitChars(rep("a", 40)+rep("b", 40)), + splitChars(rep("a", 44)+rep("b", 40)+rep(" ", 20)), false, isJunk) + assertEqual(t, sm.bJunk, map[string]struct{}{" ": struct{}{}}) + + isJunk = func(s string) bool { + return s == " " || s == "b" + } + sm = NewMatcherWithJunk(splitChars(rep("a", 40)+rep("b", 40)), + splitChars(rep("a", 44)+rep("b", 40)+rep(" ", 20)), false, isJunk) + assertEqual(t, sm.bJunk, map[string]struct{}{" ": struct{}{}, "b": struct{}{}}) +} + +func TestSFBugsRatioForNullSeqn(t *testing.T) { + sm := NewMatcher(nil, nil) + assertEqual(t, sm.Ratio(), 1.0) + assertEqual(t, sm.QuickRatio(), 1.0) + assertEqual(t, sm.RealQuickRatio(), 1.0) +} + +func TestSFBugsComparingEmptyLists(t *testing.T) { + groups := NewMatcher(nil, nil).GetGroupedOpCodes(-1) + assertEqual(t, len(groups), 0) + diff := UnifiedDiff{ + FromFile: "Original", + ToFile: "Current", + Context: 3, + } + result, err := GetUnifiedDiffString(diff) + assertEqual(t, err, nil) + assertEqual(t, result, "") +} + +func TestOutputFormatRangeFormatUnified(t *testing.T) { + // Per the diff spec at http://www.unix.org/single_unix_specification/ + // + // Each field shall be of the form: + // %1d", if the range contains exactly one line, + // and: + // "%1d,%1d", , otherwise. + // If a range is empty, its beginning line number shall be the number of + // the line just before the range, or 0 if the empty range starts the file. + fm := formatRangeUnified + assertEqual(t, fm(3, 3), "3,0") + assertEqual(t, fm(3, 4), "4") + assertEqual(t, fm(3, 5), "4,2") + assertEqual(t, fm(3, 6), "4,3") + assertEqual(t, fm(0, 0), "0,0") +} + +func TestOutputFormatRangeFormatContext(t *testing.T) { + // Per the diff spec at http://www.unix.org/single_unix_specification/ + // + // The range of lines in file1 shall be written in the following format + // if the range contains two or more lines: + // "*** %d,%d ****\n", , + // and the following format otherwise: + // "*** %d ****\n", + // The ending line number of an empty range shall be the number of the preceding line, + // or 0 if the range is at the start of the file. + // + // Next, the range of lines in file2 shall be written in the following format + // if the range contains two or more lines: + // "--- %d,%d ----\n", , + // and the following format otherwise: + // "--- %d ----\n", + fm := formatRangeContext + assertEqual(t, fm(3, 3), "3") + assertEqual(t, fm(3, 4), "4") + assertEqual(t, fm(3, 5), "4,5") + assertEqual(t, fm(3, 6), "4,6") + assertEqual(t, fm(0, 0), "0") +} + +func TestOutputFormatTabDelimiter(t *testing.T) { + diff := UnifiedDiff{ + A: splitChars("one"), + B: splitChars("two"), + FromFile: "Original", + FromDate: "2005-01-26 23:30:50", + ToFile: "Current", + ToDate: "2010-04-12 10:20:52", + Eol: "\n", + } + ud, err := GetUnifiedDiffString(diff) + assertEqual(t, err, nil) + assertEqual(t, SplitLines(ud)[:2], []string{ + "--- Original\t2005-01-26 23:30:50\n", + "+++ Current\t2010-04-12 10:20:52\n", + }) + cd, err := GetContextDiffString(ContextDiff(diff)) + assertEqual(t, err, nil) + assertEqual(t, SplitLines(cd)[:2], []string{ + "*** Original\t2005-01-26 23:30:50\n", + "--- Current\t2010-04-12 10:20:52\n", + }) +} + +func TestOutputFormatNoTrailingTabOnEmptyFiledate(t *testing.T) { + diff := UnifiedDiff{ + A: splitChars("one"), + B: splitChars("two"), + FromFile: "Original", + ToFile: "Current", + Eol: "\n", + } + ud, err := GetUnifiedDiffString(diff) + assertEqual(t, err, nil) + assertEqual(t, SplitLines(ud)[:2], []string{"--- Original\n", "+++ Current\n"}) + + cd, err := GetContextDiffString(ContextDiff(diff)) + assertEqual(t, err, nil) + assertEqual(t, SplitLines(cd)[:2], []string{"*** Original\n", "--- Current\n"}) +} + +func TestOmitFilenames(t *testing.T) { + diff := UnifiedDiff{ + A: SplitLines("o\nn\ne\n"), + B: SplitLines("t\nw\no\n"), + Eol: "\n", + } + ud, err := GetUnifiedDiffString(diff) + assertEqual(t, err, nil) + assertEqual(t, SplitLines(ud), []string{ + "@@ -0,0 +1,2 @@\n", + "+t\n", + "+w\n", + "@@ -2,2 +3,0 @@\n", + "-n\n", + "-e\n", + "\n", + }) + + cd, err := GetContextDiffString(ContextDiff(diff)) + assertEqual(t, err, nil) + assertEqual(t, SplitLines(cd), []string{ + "***************\n", + "*** 0 ****\n", + "--- 1,2 ----\n", + "+ t\n", + "+ w\n", + "***************\n", + "*** 2,3 ****\n", + "- n\n", + "- e\n", + "--- 3 ----\n", + "\n", + }) +} + +func TestSplitLines(t *testing.T) { + allTests := []struct { + input string + want []string + }{ + {"foo", []string{"foo\n"}}, + {"foo\nbar", []string{"foo\n", "bar\n"}}, + {"foo\nbar\n", []string{"foo\n", "bar\n", "\n"}}, + } + for _, test := range allTests { + assertEqual(t, SplitLines(test.input), test.want) + } +} + +func benchmarkSplitLines(b *testing.B, count int) { + str := strings.Repeat("foo\n", count) + + b.ResetTimer() + + n := 0 + for i := 0; i < b.N; i++ { + n += len(SplitLines(str)) + } +} + +func BenchmarkSplitLines100(b *testing.B) { + benchmarkSplitLines(b, 100) +} + +func BenchmarkSplitLines10000(b *testing.B) { + benchmarkSplitLines(b, 10000) +} diff --git a/vendor/github.com/samuel/go-zookeeper/.gitignore b/vendor/github.com/samuel/go-zookeeper/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/vendor/github.com/samuel/go-zookeeper/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/vendor/github.com/samuel/go-zookeeper/.travis.yml b/vendor/github.com/samuel/go-zookeeper/.travis.yml new file mode 100644 index 0000000..c6f1547 --- /dev/null +++ b/vendor/github.com/samuel/go-zookeeper/.travis.yml @@ -0,0 +1,31 @@ +language: go +go: + - 1.9 + +jdk: + - oraclejdk9 + +sudo: false + +branches: + only: + - master + +before_install: + - wget http://apache.cs.utah.edu/zookeeper/zookeeper-3.4.10/zookeeper-3.4.10.tar.gz + - tar -zxvf zookeeper*tar.gz + - go get github.com/mattn/goveralls + - go get golang.org/x/tools/cmd/cover + +script: + - jdk_switcher use oraclejdk9 + - go build ./... + - go fmt ./... + - go vet ./... + - go test -i -race ./... + - go test -race -covermode atomic -coverprofile=profile.cov ./zk + - goveralls -coverprofile=profile.cov -service=travis-ci + +env: + global: + secure: Coha3DDcXmsekrHCZlKvRAc+pMBaQU1QS/3++3YCCUXVDBWgVsC1ZIc9df4RLdZ/ncGd86eoRq/S+zyn1XbnqK5+ePqwJoUnJ59BE8ZyHLWI9ajVn3fND1MTduu/ksGsS79+IYbdVI5wgjSgjD3Ktp6Y5uPl+BPosjYBGdNcHS4= diff --git a/vendor/github.com/samuel/go-zookeeper/README.md b/vendor/github.com/samuel/go-zookeeper/README.md new file mode 100644 index 0000000..afc1d08 --- /dev/null +++ b/vendor/github.com/samuel/go-zookeeper/README.md @@ -0,0 +1,11 @@ +Native Go Zookeeper Client Library +=================================== + +[![GoDoc](https://godoc.org/github.com/samuel/go-zookeeper?status.svg)](https://godoc.org/github.com/samuel/go-zookeeper) +[![Build Status](https://travis-ci.org/samuel/go-zookeeper.png)](https://travis-ci.org/samuel/go-zookeeper) +[![Coverage Status](https://coveralls.io/repos/github/samuel/go-zookeeper/badge.svg?branch=master)](https://coveralls.io/github/samuel/go-zookeeper?branch=master) + +License +------- + +3-clause BSD. See LICENSE file. diff --git a/vendor/github.com/samuel/go-zookeeper/examples/basic.go b/vendor/github.com/samuel/go-zookeeper/examples/basic.go new file mode 100644 index 0000000..28dfa63 --- /dev/null +++ b/vendor/github.com/samuel/go-zookeeper/examples/basic.go @@ -0,0 +1,22 @@ +package main + +import ( + "fmt" + "time" + + "github.com/samuel/go-zookeeper/zk" +) + +func main() { + c, _, err := zk.Connect([]string{"127.0.0.1"}, time.Second) //*10) + if err != nil { + panic(err) + } + children, stat, ch, err := c.ChildrenW("/") + if err != nil { + panic(err) + } + fmt.Printf("%+v %+v\n", children, stat) + e := <-ch + fmt.Printf("%+v\n", e) +} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/cluster_test.go b/vendor/github.com/samuel/go-zookeeper/zk/cluster_test.go new file mode 100644 index 0000000..dcceaa4 --- /dev/null +++ b/vendor/github.com/samuel/go-zookeeper/zk/cluster_test.go @@ -0,0 +1,314 @@ +package zk + +import ( + "sync" + "testing" + "time" +) + +type logWriter struct { + t *testing.T + p string +} + +func (lw logWriter) Write(b []byte) (int, error) { + lw.t.Logf("%s%s", lw.p, string(b)) + return len(b), nil +} + +func TestBasicCluster(t *testing.T) { + ts, err := StartTestCluster(3, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + zk1, err := ts.Connect(0) + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk1.Close() + zk2, err := ts.Connect(1) + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk2.Close() + + time.Sleep(time.Second * 5) + + if _, err := zk1.Create("/gozk-test", []byte("foo-cluster"), 0, WorldACL(PermAll)); err != nil { + t.Fatalf("Create failed on node 1: %+v", err) + } + if by, _, err := zk2.Get("/gozk-test"); err != nil { + t.Fatalf("Get failed on node 2: %+v", err) + } else if string(by) != "foo-cluster" { + t.Fatal("Wrong data for node 2") + } +} + +// If the current leader dies, then the session is reestablished with the new one. +func TestClientClusterFailover(t *testing.T) { + tc, err := StartTestCluster(3, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer tc.Stop() + zk, evCh, err := tc.ConnectAll() + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + + sl := NewStateLogger(evCh) + + hasSessionEvent1 := sl.NewWatcher(sessionStateMatcher(StateHasSession)).Wait(8 * time.Second) + if hasSessionEvent1 == nil { + t.Fatalf("Failed to connect and get session") + } + + if _, err := zk.Create("/gozk-test", []byte("foo-cluster"), 0, WorldACL(PermAll)); err != nil { + t.Fatalf("Create failed on node 1: %+v", err) + } + + hasSessionWatcher2 := sl.NewWatcher(sessionStateMatcher(StateHasSession)) + + // Kill the current leader + tc.StopServer(hasSessionEvent1.Server) + + // Wait for the session to be reconnected with the new leader. + if hasSessionWatcher2.Wait(8*time.Second) == nil { + t.Fatalf("Failover failed") + } + + if by, _, err := zk.Get("/gozk-test"); err != nil { + t.Fatalf("Get failed on node 2: %+v", err) + } else if string(by) != "foo-cluster" { + t.Fatal("Wrong data for node 2") + } +} + +// If a ZooKeeper cluster looses quorum then a session is reconnected as soon +// as the quorum is restored. +func TestNoQuorum(t *testing.T) { + tc, err := StartTestCluster(3, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer tc.Stop() + zk, evCh, err := tc.ConnectAllTimeout(4 * time.Second) + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + sl := NewStateLogger(evCh) + + // Wait for initial session to be established + hasSessionEvent1 := sl.NewWatcher(sessionStateMatcher(StateHasSession)).Wait(8 * time.Second) + if hasSessionEvent1 == nil { + t.Fatalf("Failed to connect and get session") + } + initialSessionID := zk.sessionID + DefaultLogger.Printf(" Session established: id=%d, timeout=%d", zk.sessionID, zk.sessionTimeoutMs) + + // Kill the ZooKeeper leader and wait for the session to reconnect. + DefaultLogger.Printf(" Kill the leader") + disconnectWatcher1 := sl.NewWatcher(sessionStateMatcher(StateDisconnected)) + hasSessionWatcher2 := sl.NewWatcher(sessionStateMatcher(StateHasSession)) + tc.StopServer(hasSessionEvent1.Server) + + disconnectedEvent1 := disconnectWatcher1.Wait(8 * time.Second) + if disconnectedEvent1 == nil { + t.Fatalf("Failover failed, missed StateDisconnected event") + } + if disconnectedEvent1.Server != hasSessionEvent1.Server { + t.Fatalf("Unexpected StateDisconnected event, expected=%s, actual=%s", + hasSessionEvent1.Server, disconnectedEvent1.Server) + } + + hasSessionEvent2 := hasSessionWatcher2.Wait(8 * time.Second) + if hasSessionEvent2 == nil { + t.Fatalf("Failover failed, missed StateHasSession event") + } + + // Kill the ZooKeeper leader leaving the cluster without quorum. + DefaultLogger.Printf(" Kill the leader") + disconnectWatcher2 := sl.NewWatcher(sessionStateMatcher(StateDisconnected)) + tc.StopServer(hasSessionEvent2.Server) + + disconnectedEvent2 := disconnectWatcher2.Wait(8 * time.Second) + if disconnectedEvent2 == nil { + t.Fatalf("Failover failed, missed StateDisconnected event") + } + if disconnectedEvent2.Server != hasSessionEvent2.Server { + t.Fatalf("Unexpected StateDisconnected event, expected=%s, actual=%s", + hasSessionEvent2.Server, disconnectedEvent2.Server) + } + + // Make sure that we keep retrying connecting to the only remaining + // ZooKeeper server, but the attempts are being dropped because there is + // no quorum. + DefaultLogger.Printf(" Retrying no luck...") + var firstDisconnect *Event + begin := time.Now() + for time.Now().Sub(begin) < 6*time.Second { + disconnectedEvent := sl.NewWatcher(sessionStateMatcher(StateDisconnected)).Wait(4 * time.Second) + if disconnectedEvent == nil { + t.Fatalf("Disconnected event expected") + } + if firstDisconnect == nil { + firstDisconnect = disconnectedEvent + continue + } + if disconnectedEvent.Server != firstDisconnect.Server { + t.Fatalf("Disconnect from wrong server: expected=%s, actual=%s", + firstDisconnect.Server, disconnectedEvent.Server) + } + } + + // Start a ZooKeeper node to restore quorum. + hasSessionWatcher3 := sl.NewWatcher(sessionStateMatcher(StateHasSession)) + tc.StartServer(hasSessionEvent1.Server) + + // Make sure that session is reconnected with the same ID. + hasSessionEvent3 := hasSessionWatcher3.Wait(8 * time.Second) + if hasSessionEvent3 == nil { + t.Fatalf("Session has not been reconnected") + } + if zk.sessionID != initialSessionID { + t.Fatalf("Wrong session ID: expected=%d, actual=%d", initialSessionID, zk.sessionID) + } + + // Make sure that the session is not dropped soon after reconnect + e := sl.NewWatcher(sessionStateMatcher(StateDisconnected)).Wait(6 * time.Second) + if e != nil { + t.Fatalf("Unexpected disconnect") + } +} + +func TestWaitForClose(t *testing.T) { + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + zk, err := ts.Connect(0) + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + timeout := time.After(30 * time.Second) +CONNECTED: + for { + select { + case ev := <-zk.eventChan: + if ev.State == StateConnected { + break CONNECTED + } + case <-timeout: + zk.Close() + t.Fatal("Timeout") + } + } + zk.Close() + for { + select { + case _, ok := <-zk.eventChan: + if !ok { + return + } + case <-timeout: + t.Fatal("Timeout") + } + } +} + +func TestBadSession(t *testing.T) { + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + zk, _, err := ts.ConnectAll() + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + + if err := zk.Delete("/gozk-test", -1); err != nil && err != ErrNoNode { + t.Fatalf("Delete returned error: %+v", err) + } + + zk.conn.Close() + time.Sleep(time.Millisecond * 100) + + if err := zk.Delete("/gozk-test", -1); err != nil && err != ErrNoNode { + t.Fatalf("Delete returned error: %+v", err) + } +} + +type EventLogger struct { + events []Event + watchers []*EventWatcher + lock sync.Mutex + wg sync.WaitGroup +} + +func NewStateLogger(eventCh <-chan Event) *EventLogger { + el := &EventLogger{} + el.wg.Add(1) + go func() { + defer el.wg.Done() + for event := range eventCh { + el.lock.Lock() + for _, sw := range el.watchers { + if !sw.triggered && sw.matcher(event) { + sw.triggered = true + sw.matchCh <- event + } + } + DefaultLogger.Printf(" event received: %v\n", event) + el.events = append(el.events, event) + el.lock.Unlock() + } + }() + return el +} + +func (el *EventLogger) NewWatcher(matcher func(Event) bool) *EventWatcher { + ew := &EventWatcher{matcher: matcher, matchCh: make(chan Event, 1)} + el.lock.Lock() + el.watchers = append(el.watchers, ew) + el.lock.Unlock() + return ew +} + +func (el *EventLogger) Events() []Event { + el.lock.Lock() + transitions := make([]Event, len(el.events)) + copy(transitions, el.events) + el.lock.Unlock() + return transitions +} + +func (el *EventLogger) Wait4Stop() { + el.wg.Wait() +} + +type EventWatcher struct { + matcher func(Event) bool + matchCh chan Event + triggered bool +} + +func (ew *EventWatcher) Wait(timeout time.Duration) *Event { + select { + case event := <-ew.matchCh: + return &event + case <-time.After(timeout): + return nil + } +} + +func sessionStateMatcher(s State) func(Event) bool { + return func(e Event) bool { + return e.Type == EventSession && e.State == s + } +} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/conn.go b/vendor/github.com/samuel/go-zookeeper/zk/conn.go index b6b8dbc..13fb0f0 100644 --- a/vendor/github.com/samuel/go-zookeeper/zk/conn.go +++ b/vendor/github.com/samuel/go-zookeeper/zk/conn.go @@ -85,6 +85,7 @@ type Conn struct { pingInterval time.Duration recvTimeout time.Duration connectTimeout time.Duration + maxBufferSize int creds []authCreds credsMu sync.Mutex // protects server @@ -97,9 +98,12 @@ type Conn struct { closeChan chan struct{} // channel to tell send loop stop // Debug (used by unit tests) - reconnectDelay time.Duration + reconnectLatch chan struct{} + setWatchLimit int + setWatchCallback func([]*setWatchesRequest) - logger Logger + logger Logger + logInfo bool // true if information messages are logged; false if only errors are logged buf []byte } @@ -197,10 +201,8 @@ func Connect(servers []string, sessionTimeout time.Duration, options ...connOpti watchers: make(map[watchPathType][]chan Event), passwd: emptyPassword, logger: DefaultLogger, + logInfo: true, // default is true for backwards compatability buf: make([]byte, bufferSize), - - // Debug - reconnectDelay: 0, } // Set provided options. @@ -237,6 +239,21 @@ func WithHostProvider(hostProvider HostProvider) connOption { } } +// WithLogger returns a connection option specifying a non-default Logger +func WithLogger(logger Logger) connOption { + return func(c *Conn) { + c.logger = logger + } +} + +// WithLogInfo returns a connection option specifying whether or not information messages +// shoud be logged. +func WithLogInfo(logInfo bool) connOption { + return func(c *Conn) { + c.logInfo = logInfo + } +} + // EventCallback is a function that is called when an Event occurs. type EventCallback func(Event) @@ -249,6 +266,46 @@ func WithEventCallback(cb EventCallback) connOption { } } +// WithMaxBufferSize sets the maximum buffer size used to read and decode +// packets received from the Zookeeper server. The standard Zookeeper client for +// Java defaults to a limit of 1mb. For backwards compatibility, this Go client +// defaults to unbounded unless overridden via this option. A value that is zero +// or negative indicates that no limit is enforced. +// +// This is meant to prevent resource exhaustion in the face of potentially +// malicious data in ZK. It should generally match the server setting (which +// also defaults ot 1mb) so that clients and servers agree on the limits for +// things like the size of data in an individual znode and the total size of a +// transaction. +// +// For production systems, this should be set to a reasonable value (ideally +// that matches the server configuration). For ops tooling, it is handy to use a +// much larger limit, in order to do things like clean-up problematic state in +// the ZK tree. For example, if a single znode has a huge number of children, it +// is possible for the response to a "list children" operation to exceed this +// buffer size and cause errors in clients. The only way to subsequently clean +// up the tree (by removing superfluous children) is to use a client configured +// with a larger buffer size that can successfully query for all of the child +// names and then remove them. (Note there are other tools that can list all of +// the child names without an increased buffer size in the client, but they work +// by inspecting the servers' transaction logs to enumerate children instead of +// sending an online request to a server. +func WithMaxBufferSize(maxBufferSize int) connOption { + return func(c *Conn) { + c.maxBufferSize = maxBufferSize + } +} + +// WithMaxConnBufferSize sets maximum buffer size used to send and encode +// packets to Zookeeper server. The standard Zookeepeer client for java defaults +// to a limit of 1mb. This option should be used for non-standard server setup +// where znode is bigger than default 1mb. +func WithMaxConnBufferSize(maxBufferSize int) connOption { + return func(c *Conn) { + c.buf = make([]byte, maxBufferSize) + } +} + func (c *Conn) Close() { close(c.shouldQuit) @@ -321,7 +378,9 @@ func (c *Conn) connect() error { if err == nil { c.conn = zkConn c.setState(StateConnected) - c.logger.Printf("Connected to %s", c.Server()) + if c.logInfo { + c.logger.Printf("Connected to %s", c.Server()) + } return nil } @@ -335,8 +394,10 @@ func (c *Conn) resendZkAuth(reauthReadyChan chan struct{}) { defer close(reauthReadyChan) - c.logger.Printf("Re-submitting `%d` credentials after reconnect", - len(c.creds)) + if c.logInfo { + c.logger.Printf("Re-submitting `%d` credentials after reconnect", + len(c.creds)) + } for _, cred := range c.creds { resChan, err := c.sendRequest( @@ -404,7 +465,9 @@ func (c *Conn) loop() { c.logger.Printf("Authentication failed: %s", err) c.conn.Close() case err == nil: - c.logger.Printf("Authenticated: id=%d, timeout=%d", c.SessionID(), c.sessionTimeoutMs) + if c.logInfo { + c.logger.Printf("Authenticated: id=%d, timeout=%d", c.SessionID(), c.sessionTimeoutMs) + } c.hostProvider.Connected() // mark success c.closeChan = make(chan struct{}) // channel to tell send loop stop reauthChan := make(chan struct{}) // channel to tell send loop that authdata has been resubmitted @@ -414,7 +477,9 @@ func (c *Conn) loop() { go func() { <-reauthChan err := c.sendLoop() - c.logger.Printf("Send loop terminated: err=%v", err) + if err != nil || c.logInfo { + c.logger.Printf("Send loop terminated: err=%v", err) + } c.conn.Close() // causes recv loop to EOF/exit wg.Done() }() @@ -422,7 +487,9 @@ func (c *Conn) loop() { wg.Add(1) go func() { err := c.recvLoop(c.conn) - c.logger.Printf("Recv loop terminated: err=%v", err) + if err != io.EOF || c.logInfo { + c.logger.Printf("Recv loop terminated: err=%v", err) + } if err == nil { panic("zk: recvLoop should never return nil error") } @@ -450,11 +517,11 @@ func (c *Conn) loop() { } c.flushRequests(err) - if c.reconnectDelay > 0 { + if c.reconnectLatch != nil { select { case <-c.shouldQuit: return - case <-time.After(c.reconnectDelay): + case <-c.reconnectLatch: } } } @@ -506,17 +573,41 @@ func (c *Conn) sendSetWatches() { return } - req := &setWatchesRequest{ - RelativeZxid: c.lastZxid, - DataWatches: make([]string, 0), - ExistWatches: make([]string, 0), - ChildWatches: make([]string, 0), + // NB: A ZK server, by default, rejects packets >1mb. So, if we have too + // many watches to reset, we need to break this up into multiple packets + // to avoid hitting that limit. Mirroring the Java client behavior: we are + // conservative in that we limit requests to 128kb (since server limit is + // is actually configurable and could conceivably be configured smaller + // than default of 1mb). + limit := 128 * 1024 + if c.setWatchLimit > 0 { + limit = c.setWatchLimit } + + var reqs []*setWatchesRequest + var req *setWatchesRequest + var sizeSoFar int + n := 0 for pathType, watchers := range c.watchers { if len(watchers) == 0 { continue } + addlLen := 4 + len(pathType.path) + if req == nil || sizeSoFar+addlLen > limit { + if req != nil { + // add to set of requests that we'll send + reqs = append(reqs, req) + } + sizeSoFar = 28 // fixed overhead of a set-watches packet + req = &setWatchesRequest{ + RelativeZxid: c.lastZxid, + DataWatches: make([]string, 0), + ExistWatches: make([]string, 0), + ChildWatches: make([]string, 0), + } + } + sizeSoFar += addlLen switch pathType.wType { case watchTypeData: req.DataWatches = append(req.DataWatches, pathType.path) @@ -530,12 +621,26 @@ func (c *Conn) sendSetWatches() { if n == 0 { return } + if req != nil { // don't forget any trailing packet we were building + reqs = append(reqs, req) + } + + if c.setWatchCallback != nil { + c.setWatchCallback(reqs) + } go func() { res := &setWatchesResponse{} - _, err := c.request(opSetWatches, req, res, nil) - if err != nil { - c.logger.Printf("Failed to set previous watches: %s", err.Error()) + // TODO: Pipeline these so queue all of them up before waiting on any + // response. That will require some investigation to make sure there + // aren't failure modes where a blocking write to the channel of requests + // could hang indefinitely and cause this goroutine to leak... + for _, req := range reqs { + _, err := c.request(opSetWatches, req, res, nil) + if err != nil { + c.logger.Printf("Failed to set previous watches: %s", err.Error()) + break + } } }() } @@ -676,7 +781,11 @@ func (c *Conn) sendLoop() error { } func (c *Conn) recvLoop(conn net.Conn) error { - buf := make([]byte, bufferSize) + sz := bufferSize + if c.maxBufferSize > 0 && sz > c.maxBufferSize { + sz = c.maxBufferSize + } + buf := make([]byte, sz) for { // package length conn.SetReadDeadline(time.Now().Add(c.recvTimeout)) @@ -687,6 +796,9 @@ func (c *Conn) recvLoop(conn net.Conn) error { blen := int(binary.BigEndian.Uint32(buf[:4])) if cap(buf) < blen { + if c.maxBufferSize > 0 && blen > c.maxBufferSize { + return fmt.Errorf("received packet from server with length %d, which exceeds max buffer size %d", blen, c.maxBufferSize) + } buf = make([]byte, blen) } @@ -831,12 +943,20 @@ func (c *Conn) AddAuth(scheme string, auth []byte) error { } func (c *Conn) Children(path string) ([]string, *Stat, error) { + if err := validatePath(path, false); err != nil { + return nil, nil, err + } + res := &getChildren2Response{} _, err := c.request(opGetChildren2, &getChildren2Request{Path: path, Watch: false}, res, nil) return res.Children, &res.Stat, err } func (c *Conn) ChildrenW(path string) ([]string, *Stat, <-chan Event, error) { + if err := validatePath(path, false); err != nil { + return nil, nil, nil, err + } + var ech <-chan Event res := &getChildren2Response{} _, err := c.request(opGetChildren2, &getChildren2Request{Path: path, Watch: true}, res, func(req *request, res *responseHeader, err error) { @@ -851,6 +971,10 @@ func (c *Conn) ChildrenW(path string) ([]string, *Stat, <-chan Event, error) { } func (c *Conn) Get(path string) ([]byte, *Stat, error) { + if err := validatePath(path, false); err != nil { + return nil, nil, err + } + res := &getDataResponse{} _, err := c.request(opGetData, &getDataRequest{Path: path, Watch: false}, res, nil) return res.Data, &res.Stat, err @@ -858,6 +982,10 @@ func (c *Conn) Get(path string) ([]byte, *Stat, error) { // GetW returns the contents of a znode and sets a watch func (c *Conn) GetW(path string) ([]byte, *Stat, <-chan Event, error) { + if err := validatePath(path, false); err != nil { + return nil, nil, nil, err + } + var ech <-chan Event res := &getDataResponse{} _, err := c.request(opGetData, &getDataRequest{Path: path, Watch: true}, res, func(req *request, res *responseHeader, err error) { @@ -872,15 +1000,20 @@ func (c *Conn) GetW(path string) ([]byte, *Stat, <-chan Event, error) { } func (c *Conn) Set(path string, data []byte, version int32) (*Stat, error) { - if path == "" { - return nil, ErrInvalidPath + if err := validatePath(path, false); err != nil { + return nil, err } + res := &setDataResponse{} _, err := c.request(opSetData, &SetDataRequest{path, data, version}, res, nil) return &res.Stat, err } func (c *Conn) Create(path string, data []byte, flags int32, acl []ACL) (string, error) { + if err := validatePath(path, flags&FlagSequence == FlagSequence); err != nil { + return "", err + } + res := &createResponse{} _, err := c.request(opCreate, &CreateRequest{path, data, acl, flags}, res, nil) return res.Path, err @@ -891,6 +1024,10 @@ func (c *Conn) Create(path string, data []byte, flags int32, acl []ACL) (string, // ephemeral node still exists. Therefore, on reconnect we need to check if a node // with a GUID generated on create exists. func (c *Conn) CreateProtectedEphemeralSequential(path string, data []byte, acl []ACL) (string, error) { + if err := validatePath(path, true); err != nil { + return "", err + } + var guid [16]byte _, err := io.ReadFull(rand.Reader, guid[:16]) if err != nil { @@ -932,11 +1069,19 @@ func (c *Conn) CreateProtectedEphemeralSequential(path string, data []byte, acl } func (c *Conn) Delete(path string, version int32) error { + if err := validatePath(path, false); err != nil { + return err + } + _, err := c.request(opDelete, &DeleteRequest{path, version}, &deleteResponse{}, nil) return err } func (c *Conn) Exists(path string) (bool, *Stat, error) { + if err := validatePath(path, false); err != nil { + return false, nil, err + } + res := &existsResponse{} _, err := c.request(opExists, &existsRequest{Path: path, Watch: false}, res, nil) exists := true @@ -948,6 +1093,10 @@ func (c *Conn) Exists(path string) (bool, *Stat, error) { } func (c *Conn) ExistsW(path string) (bool, *Stat, <-chan Event, error) { + if err := validatePath(path, false); err != nil { + return false, nil, nil, err + } + var ech <-chan Event res := &existsResponse{} _, err := c.request(opExists, &existsRequest{Path: path, Watch: true}, res, func(req *request, res *responseHeader, err error) { @@ -969,17 +1118,29 @@ func (c *Conn) ExistsW(path string) (bool, *Stat, <-chan Event, error) { } func (c *Conn) GetACL(path string) ([]ACL, *Stat, error) { + if err := validatePath(path, false); err != nil { + return nil, nil, err + } + res := &getAclResponse{} _, err := c.request(opGetAcl, &getAclRequest{Path: path}, res, nil) return res.Acl, &res.Stat, err } func (c *Conn) SetACL(path string, acl []ACL, version int32) (*Stat, error) { + if err := validatePath(path, false); err != nil { + return nil, err + } + res := &setAclResponse{} _, err := c.request(opSetAcl, &setAclRequest{Path: path, Acl: acl, Version: version}, res, nil) return &res.Stat, err } func (c *Conn) Sync(path string) (string, error) { + if err := validatePath(path, false); err != nil { + return "", err + } + res := &syncResponse{} _, err := c.request(opSync, &syncRequest{Path: path}, res, nil) return res.Path, err diff --git a/vendor/github.com/samuel/go-zookeeper/zk/constants_test.go b/vendor/github.com/samuel/go-zookeeper/zk/constants_test.go new file mode 100644 index 0000000..9fe6b04 --- /dev/null +++ b/vendor/github.com/samuel/go-zookeeper/zk/constants_test.go @@ -0,0 +1,24 @@ +package zk + +import ( + "fmt" + "testing" +) + +func TestModeString(t *testing.T) { + if fmt.Sprintf("%v", ModeUnknown) != "unknown" { + t.Errorf("unknown value should be 'unknown'") + } + + if fmt.Sprintf("%v", ModeLeader) != "leader" { + t.Errorf("leader value should be 'leader'") + } + + if fmt.Sprintf("%v", ModeFollower) != "follower" { + t.Errorf("follower value should be 'follower'") + } + + if fmt.Sprintf("%v", ModeStandalone) != "standalone" { + t.Errorf("standlone value should be 'standalone'") + } +} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/dnshostprovider_test.go b/vendor/github.com/samuel/go-zookeeper/zk/dnshostprovider_test.go new file mode 100644 index 0000000..77a6065 --- /dev/null +++ b/vendor/github.com/samuel/go-zookeeper/zk/dnshostprovider_test.go @@ -0,0 +1,224 @@ +package zk + +import ( + "fmt" + "log" + "testing" + "time" +) + +// localhostLookupHost is a test replacement for net.LookupHost that +// always returns 127.0.0.1 +func localhostLookupHost(host string) ([]string, error) { + return []string{"127.0.0.1"}, nil +} + +// TestDNSHostProviderCreate is just like TestCreate, but with an +// overridden HostProvider that ignores the provided hostname. +func TestDNSHostProviderCreate(t *testing.T) { + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + + port := ts.Servers[0].Port + server := fmt.Sprintf("foo.example.com:%d", port) + hostProvider := &DNSHostProvider{lookupHost: localhostLookupHost} + zk, _, err := Connect([]string{server}, time.Second*15, WithHostProvider(hostProvider)) + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + + path := "/gozk-test" + + if err := zk.Delete(path, -1); err != nil && err != ErrNoNode { + t.Fatalf("Delete returned error: %+v", err) + } + if p, err := zk.Create(path, []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { + t.Fatalf("Create returned error: %+v", err) + } else if p != path { + t.Fatalf("Create returned different path '%s' != '%s'", p, path) + } + if data, stat, err := zk.Get(path); err != nil { + t.Fatalf("Get returned error: %+v", err) + } else if stat == nil { + t.Fatal("Get returned nil stat") + } else if len(data) < 4 { + t.Fatal("Get returned wrong size data") + } +} + +// localHostPortsFacade wraps a HostProvider, remapping the +// address/port combinations it returns to "localhost:$PORT" where +// $PORT is chosen from the provided ports. +type localHostPortsFacade struct { + inner HostProvider // The wrapped HostProvider + ports []int // The provided list of ports + nextPort int // The next port to use + mapped map[string]string // Already-mapped address/port combinations +} + +func newLocalHostPortsFacade(inner HostProvider, ports []int) *localHostPortsFacade { + return &localHostPortsFacade{ + inner: inner, + ports: ports, + mapped: make(map[string]string), + } +} + +func (lhpf *localHostPortsFacade) Len() int { return lhpf.inner.Len() } +func (lhpf *localHostPortsFacade) Connected() { lhpf.inner.Connected() } +func (lhpf *localHostPortsFacade) Init(servers []string) error { return lhpf.inner.Init(servers) } +func (lhpf *localHostPortsFacade) Next() (string, bool) { + server, retryStart := lhpf.inner.Next() + + // If we've already set up a mapping for that server, just return it. + if localMapping := lhpf.mapped[server]; localMapping != "" { + return localMapping, retryStart + } + + if lhpf.nextPort == len(lhpf.ports) { + log.Fatalf("localHostPortsFacade out of ports to assign to %q; current config: %q", server, lhpf.mapped) + } + + localMapping := fmt.Sprintf("localhost:%d", lhpf.ports[lhpf.nextPort]) + lhpf.mapped[server] = localMapping + lhpf.nextPort++ + return localMapping, retryStart +} + +var _ HostProvider = &localHostPortsFacade{} + +// TestDNSHostProviderReconnect tests that the zk.Conn correctly +// reconnects when the Zookeeper instance it's connected to +// restarts. It wraps the DNSHostProvider in a lightweight facade that +// remaps addresses to localhost:$PORT combinations corresponding to +// the test ZooKeeper instances. +func TestDNSHostProviderReconnect(t *testing.T) { + ts, err := StartTestCluster(3, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + + innerHp := &DNSHostProvider{lookupHost: func(host string) ([]string, error) { + return []string{"192.0.2.1", "192.0.2.2", "192.0.2.3"}, nil + }} + ports := make([]int, 0, len(ts.Servers)) + for _, server := range ts.Servers { + ports = append(ports, server.Port) + } + hp := newLocalHostPortsFacade(innerHp, ports) + + zk, _, err := Connect([]string{"foo.example.com:12345"}, time.Second, WithHostProvider(hp)) + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + + path := "/gozk-test" + + // Initial operation to force connection. + if err := zk.Delete(path, -1); err != nil && err != ErrNoNode { + t.Fatalf("Delete returned error: %+v", err) + } + + // Figure out which server we're connected to. + currentServer := zk.Server() + t.Logf("Connected to %q. Finding test server index…", currentServer) + serverIndex := -1 + for i, server := range ts.Servers { + server := fmt.Sprintf("localhost:%d", server.Port) + t.Logf("…trying %q", server) + if currentServer == server { + serverIndex = i + t.Logf("…found at index %d", i) + break + } + } + if serverIndex == -1 { + t.Fatalf("Cannot determine test server index.") + } + + // Restart the connected server. + ts.Servers[serverIndex].Srv.Stop() + ts.Servers[serverIndex].Srv.Start() + + // Continue with the basic TestCreate tests. + if p, err := zk.Create(path, []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { + t.Fatalf("Create returned error: %+v", err) + } else if p != path { + t.Fatalf("Create returned different path '%s' != '%s'", p, path) + } + if data, stat, err := zk.Get(path); err != nil { + t.Fatalf("Get returned error: %+v", err) + } else if stat == nil { + t.Fatal("Get returned nil stat") + } else if len(data) < 4 { + t.Fatal("Get returned wrong size data") + } + + if zk.Server() == currentServer { + t.Errorf("Still connected to %q after restart.", currentServer) + } +} + +// TestDNSHostProviderRetryStart tests the `retryStart` functionality +// of DNSHostProvider. +// It's also probably the clearest visual explanation of exactly how +// it works. +func TestDNSHostProviderRetryStart(t *testing.T) { + t.Parallel() + + hp := &DNSHostProvider{lookupHost: func(host string) ([]string, error) { + return []string{"192.0.2.1", "192.0.2.2", "192.0.2.3"}, nil + }} + + if err := hp.Init([]string{"foo.example.com:12345"}); err != nil { + t.Fatal(err) + } + + testdata := []struct { + retryStartWant bool + callConnected bool + }{ + // Repeated failures. + {false, false}, + {false, false}, + {false, false}, + {true, false}, + {false, false}, + {false, false}, + {true, true}, + + // One success offsets things. + {false, false}, + {false, true}, + {false, true}, + + // Repeated successes. + {false, true}, + {false, true}, + {false, true}, + {false, true}, + {false, true}, + + // And some more failures. + {false, false}, + {false, false}, + {true, false}, // Looped back to last known good server: all alternates failed. + {false, false}, + } + + for i, td := range testdata { + _, retryStartGot := hp.Next() + if retryStartGot != td.retryStartWant { + t.Errorf("%d: retryStart=%v; want %v", i, retryStartGot, td.retryStartWant) + } + if td.callConnected { + hp.Connected() + } + } +} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/flw_test.go b/vendor/github.com/samuel/go-zookeeper/zk/flw_test.go new file mode 100644 index 0000000..5bbabb9 --- /dev/null +++ b/vendor/github.com/samuel/go-zookeeper/zk/flw_test.go @@ -0,0 +1,330 @@ +package zk + +import ( + "net" + "testing" + "time" +) + +var ( + zkSrvrOut = `Zookeeper version: 3.4.6-1569965, built on 02/20/2014 09:09 GMT +Latency min/avg/max: 0/1/10 +Received: 4207 +Sent: 4220 +Connections: 81 +Outstanding: 1 +Zxid: 0x110a7a8f37 +Mode: leader +Node count: 306 +` + zkConsOut = ` /10.42.45.231:45361[1](queued=0,recved=9435,sent=9457,sid=0x94c2989e04716b5,lop=PING,est=1427238717217,to=20001,lcxid=0x55120915,lzxid=0xffffffffffffffff,lresp=1427259255908,llat=0,minlat=0,avglat=1,maxlat=17) + /10.55.33.98:34342[1](queued=0,recved=9338,sent=9350,sid=0x94c2989e0471731,lop=PING,est=1427238849319,to=20001,lcxid=0x55120944,lzxid=0xffffffffffffffff,lresp=1427259252294,llat=0,minlat=0,avglat=1,maxlat=18) + /10.44.145.114:46556[1](queued=0,recved=109253,sent=109617,sid=0x94c2989e0471709,lop=DELE,est=1427238791305,to=20001,lcxid=0x55139618,lzxid=0x110a7b187d,lresp=1427259257423,llat=2,minlat=0,avglat=1,maxlat=23) + +` +) + +func TestFLWRuok(t *testing.T) { + t.Parallel() + l, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + t.Fatal(err) + } + defer l.Close() + + go tcpServer(l, "") + + oks := FLWRuok([]string{l.Addr().String()}, time.Second*10) + if len(oks) == 0 { + t.Errorf("no values returned") + } + if !oks[0] { + t.Errorf("instance should be marked as OK") + } + + // + // Confirm that it also returns false for dead instances + // + l, err = net.Listen("tcp", "127.0.0.1:0") + if err != nil { + t.Fatal(err) + } + defer l.Close() + + go tcpServer(l, "dead") + + oks = FLWRuok([]string{l.Addr().String()}, time.Second*10) + if len(oks) == 0 { + t.Errorf("no values returned") + } + if oks[0] { + t.Errorf("instance should be marked as not OK") + } +} + +func TestFLWSrvr(t *testing.T) { + t.Parallel() + l, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + t.Fatal(err) + } + defer l.Close() + + go tcpServer(l, "") + + statsSlice, ok := FLWSrvr([]string{l.Addr().String()}, time.Second*10) + if !ok { + t.Errorf("failure indicated on 'srvr' parsing") + } + if len(statsSlice) == 0 { + t.Errorf("no *ServerStats instances returned") + } + + stats := statsSlice[0] + + if stats.Error != nil { + t.Fatalf("error seen in stats: %v", err.Error()) + } + + if stats.Sent != 4220 { + t.Errorf("Sent != 4220") + } + + if stats.Received != 4207 { + t.Errorf("Received != 4207") + } + + if stats.NodeCount != 306 { + t.Errorf("NodeCount != 306") + } + + if stats.MinLatency != 0 { + t.Errorf("MinLatency != 0") + } + + if stats.AvgLatency != 1 { + t.Errorf("AvgLatency != 1") + } + + if stats.MaxLatency != 10 { + t.Errorf("MaxLatency != 10") + } + + if stats.Connections != 81 { + t.Errorf("Connection != 81") + } + + if stats.Outstanding != 1 { + t.Errorf("Outstanding != 1") + } + + if stats.Epoch != 17 { + t.Errorf("Epoch != 17") + } + + if stats.Counter != 175804215 { + t.Errorf("Counter != 175804215") + } + + if stats.Mode != ModeLeader { + t.Errorf("Mode != ModeLeader") + } + + if stats.Version != "3.4.6-1569965" { + t.Errorf("Version expected: 3.4.6-1569965") + } +} + +func TestFLWCons(t *testing.T) { + t.Parallel() + l, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + t.Fatal(err) + } + defer l.Close() + + go tcpServer(l, "") + + clients, ok := FLWCons([]string{l.Addr().String()}, time.Second*10) + if !ok { + t.Errorf("failure indicated on 'cons' parsing") + } + if len(clients) == 0 { + t.Errorf("no *ServerClients instances returned") + } + + results := []*ServerClient{ + { + Queued: 0, + Received: 9435, + Sent: 9457, + SessionID: 669956116721374901, + LastOperation: "PING", + Established: time.Unix(1427238717217, 0), + Timeout: 20001, + Lcxid: 1427245333, + Lzxid: -1, + LastResponse: time.Unix(1427259255908, 0), + LastLatency: 0, + MinLatency: 0, + AvgLatency: 1, + MaxLatency: 17, + Addr: "10.42.45.231:45361", + }, + { + Queued: 0, + Received: 9338, + Sent: 9350, + SessionID: 669956116721375025, + LastOperation: "PING", + Established: time.Unix(1427238849319, 0), + Timeout: 20001, + Lcxid: 1427245380, + Lzxid: -1, + LastResponse: time.Unix(1427259252294, 0), + LastLatency: 0, + MinLatency: 0, + AvgLatency: 1, + MaxLatency: 18, + Addr: "10.55.33.98:34342", + }, + { + Queued: 0, + Received: 109253, + Sent: 109617, + SessionID: 669956116721374985, + LastOperation: "DELE", + Established: time.Unix(1427238791305, 0), + Timeout: 20001, + Lcxid: 1427346968, + Lzxid: 73190283389, + LastResponse: time.Unix(1427259257423, 0), + LastLatency: 2, + MinLatency: 0, + AvgLatency: 1, + MaxLatency: 23, + Addr: "10.44.145.114:46556", + }, + } + + for _, z := range clients { + if z.Error != nil { + t.Errorf("error seen: %v", err.Error()) + } + + for i, v := range z.Clients { + c := results[i] + + if v.Error != nil { + t.Errorf("client error seen: %v", err.Error()) + } + + if v.Queued != c.Queued { + t.Errorf("Queued value mismatch (%d/%d)", v.Queued, c.Queued) + } + + if v.Received != c.Received { + t.Errorf("Received value mismatch (%d/%d)", v.Received, c.Received) + } + + if v.Sent != c.Sent { + t.Errorf("Sent value mismatch (%d/%d)", v.Sent, c.Sent) + } + + if v.SessionID != c.SessionID { + t.Errorf("SessionID value mismatch (%d/%d)", v.SessionID, c.SessionID) + } + + if v.LastOperation != c.LastOperation { + t.Errorf("LastOperation value mismatch ('%v'/'%v')", v.LastOperation, c.LastOperation) + } + + if v.Timeout != c.Timeout { + t.Errorf("Timeout value mismatch (%d/%d)", v.Timeout, c.Timeout) + } + + if v.Lcxid != c.Lcxid { + t.Errorf("Lcxid value mismatch (%d/%d)", v.Lcxid, c.Lcxid) + } + + if v.Lzxid != c.Lzxid { + t.Errorf("Lzxid value mismatch (%d/%d)", v.Lzxid, c.Lzxid) + } + + if v.LastLatency != c.LastLatency { + t.Errorf("LastLatency value mismatch (%d/%d)", v.LastLatency, c.LastLatency) + } + + if v.MinLatency != c.MinLatency { + t.Errorf("MinLatency value mismatch (%d/%d)", v.MinLatency, c.MinLatency) + } + + if v.AvgLatency != c.AvgLatency { + t.Errorf("AvgLatency value mismatch (%d/%d)", v.AvgLatency, c.AvgLatency) + } + + if v.MaxLatency != c.MaxLatency { + t.Errorf("MaxLatency value mismatch (%d/%d)", v.MaxLatency, c.MaxLatency) + } + + if v.Addr != c.Addr { + t.Errorf("Addr value mismatch ('%v'/'%v')", v.Addr, c.Addr) + } + + if !c.Established.Equal(v.Established) { + t.Errorf("Established value mismatch (%v/%v)", c.Established, v.Established) + } + + if !c.LastResponse.Equal(v.LastResponse) { + t.Errorf("Established value mismatch (%v/%v)", c.LastResponse, v.LastResponse) + } + } + } +} + +func tcpServer(listener net.Listener, thing string) { + for { + conn, err := listener.Accept() + if err != nil { + return + } + go connHandler(conn, thing) + } +} + +func connHandler(conn net.Conn, thing string) { + defer conn.Close() + + data := make([]byte, 4) + + _, err := conn.Read(data) + if err != nil { + return + } + + switch string(data) { + case "ruok": + switch thing { + case "dead": + return + default: + conn.Write([]byte("imok")) + } + case "srvr": + switch thing { + case "dead": + return + default: + conn.Write([]byte(zkSrvrOut)) + } + case "cons": + switch thing { + case "dead": + return + default: + conn.Write([]byte(zkConsOut)) + } + default: + conn.Write([]byte("This ZooKeeper instance is not currently serving requests.")) + } +} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/lock_test.go b/vendor/github.com/samuel/go-zookeeper/zk/lock_test.go new file mode 100644 index 0000000..8a3478a --- /dev/null +++ b/vendor/github.com/samuel/go-zookeeper/zk/lock_test.go @@ -0,0 +1,94 @@ +package zk + +import ( + "testing" + "time" +) + +func TestLock(t *testing.T) { + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + zk, _, err := ts.ConnectAll() + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + + acls := WorldACL(PermAll) + + l := NewLock(zk, "/test", acls) + if err := l.Lock(); err != nil { + t.Fatal(err) + } + if err := l.Unlock(); err != nil { + t.Fatal(err) + } + + val := make(chan int, 3) + + if err := l.Lock(); err != nil { + t.Fatal(err) + } + + l2 := NewLock(zk, "/test", acls) + go func() { + if err := l2.Lock(); err != nil { + t.Fatal(err) + } + val <- 2 + if err := l2.Unlock(); err != nil { + t.Fatal(err) + } + val <- 3 + }() + time.Sleep(time.Millisecond * 100) + + val <- 1 + if err := l.Unlock(); err != nil { + t.Fatal(err) + } + if x := <-val; x != 1 { + t.Fatalf("Expected 1 instead of %d", x) + } + if x := <-val; x != 2 { + t.Fatalf("Expected 2 instead of %d", x) + } + if x := <-val; x != 3 { + t.Fatalf("Expected 3 instead of %d", x) + } +} + +// This tests creating a lock with a path that's more than 1 node deep (e.g. "/test-multi-level/lock"), +// when a part of that path already exists (i.e. "/test-multi-level" node already exists). +func TestMultiLevelLock(t *testing.T) { + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + zk, _, err := ts.ConnectAll() + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + + acls := WorldACL(PermAll) + path := "/test-multi-level" + if p, err := zk.Create(path, []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { + t.Fatalf("Create returned error: %+v", err) + } else if p != path { + t.Fatalf("Create returned different path '%s' != '%s'", p, path) + } + l := NewLock(zk, "/test-multi-level/lock", acls) + defer zk.Delete("/test-multi-level", -1) // Clean up what we've created for this test + defer zk.Delete("/test-multi-level/lock", -1) + if err := l.Lock(); err != nil { + t.Fatal(err) + } + if err := l.Unlock(); err != nil { + t.Fatal(err) + } +} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/structs_test.go b/vendor/github.com/samuel/go-zookeeper/zk/structs_test.go new file mode 100644 index 0000000..a3f2797 --- /dev/null +++ b/vendor/github.com/samuel/go-zookeeper/zk/structs_test.go @@ -0,0 +1,83 @@ +package zk + +import ( + "reflect" + "testing" +) + +func TestEncodeDecodePacket(t *testing.T) { + t.Parallel() + encodeDecodeTest(t, &requestHeader{-2, 5}) + encodeDecodeTest(t, &connectResponse{1, 2, 3, nil}) + encodeDecodeTest(t, &connectResponse{1, 2, 3, []byte{4, 5, 6}}) + encodeDecodeTest(t, &getAclResponse{[]ACL{{12, "s", "anyone"}}, Stat{}}) + encodeDecodeTest(t, &getChildrenResponse{[]string{"foo", "bar"}}) + encodeDecodeTest(t, &pathWatchRequest{"path", true}) + encodeDecodeTest(t, &pathWatchRequest{"path", false}) + encodeDecodeTest(t, &CheckVersionRequest{"/", -1}) + encodeDecodeTest(t, &multiRequest{Ops: []multiRequestOp{{multiHeader{opCheck, false, -1}, &CheckVersionRequest{"/", -1}}}}) +} + +func TestRequestStructForOp(t *testing.T) { + for op, name := range opNames { + if op != opNotify && op != opWatcherEvent { + if s := requestStructForOp(op); s == nil { + t.Errorf("No struct for op %s", name) + } + } + } +} + +func encodeDecodeTest(t *testing.T, r interface{}) { + buf := make([]byte, 1024) + n, err := encodePacket(buf, r) + if err != nil { + t.Errorf("encodePacket returned non-nil error %+v\n", err) + return + } + t.Logf("%+v %x", r, buf[:n]) + r2 := reflect.New(reflect.ValueOf(r).Elem().Type()).Interface() + n2, err := decodePacket(buf[:n], r2) + if err != nil { + t.Errorf("decodePacket returned non-nil error %+v\n", err) + return + } + if n != n2 { + t.Errorf("sizes don't match: %d != %d", n, n2) + return + } + if !reflect.DeepEqual(r, r2) { + t.Errorf("results don't match: %+v != %+v", r, r2) + return + } +} + +func TestEncodeShortBuffer(t *testing.T) { + t.Parallel() + _, err := encodePacket([]byte{}, &requestHeader{1, 2}) + if err != ErrShortBuffer { + t.Errorf("encodePacket should return ErrShortBuffer on a short buffer instead of '%+v'", err) + return + } +} + +func TestDecodeShortBuffer(t *testing.T) { + t.Parallel() + _, err := decodePacket([]byte{}, &responseHeader{}) + if err != ErrShortBuffer { + t.Errorf("decodePacket should return ErrShortBuffer on a short buffer instead of '%+v'", err) + return + } +} + +func BenchmarkEncode(b *testing.B) { + buf := make([]byte, 4096) + st := &connectRequest{Passwd: []byte("1234567890")} + b.ReportAllocs() + b.ResetTimer() + for i := 0; i < b.N; i++ { + if _, err := encodePacket(buf, st); err != nil { + b.Fatal(err) + } + } +} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/throttle_test.go b/vendor/github.com/samuel/go-zookeeper/zk/throttle_test.go new file mode 100644 index 0000000..633ce05 --- /dev/null +++ b/vendor/github.com/samuel/go-zookeeper/zk/throttle_test.go @@ -0,0 +1,136 @@ +/* +Copyright 2012 Google Inc. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +// Vendored from go4.org/net/throttle + +package zk + +import ( + "fmt" + "net" + "sync" + "time" +) + +const unitSize = 1400 // read/write chunk size. ~MTU size. + +type Rate struct { + KBps int // or 0, to not rate-limit bandwidth + Latency time.Duration +} + +// byteTime returns the time required for n bytes. +func (r Rate) byteTime(n int) time.Duration { + if r.KBps == 0 { + return 0 + } + return time.Duration(float64(n)/1024/float64(r.KBps)) * time.Second +} + +type Listener struct { + net.Listener + Down Rate // server Writes to Client + Up Rate // server Reads from client +} + +func (ln *Listener) Accept() (net.Conn, error) { + c, err := ln.Listener.Accept() + time.Sleep(ln.Up.Latency) + if err != nil { + return nil, err + } + tc := &conn{Conn: c, Down: ln.Down, Up: ln.Up} + tc.start() + return tc, nil +} + +type nErr struct { + n int + err error +} + +type writeReq struct { + writeAt time.Time + p []byte + resc chan nErr +} + +type conn struct { + net.Conn + Down Rate // for reads + Up Rate // for writes + + wchan chan writeReq + closeOnce sync.Once + closeErr error +} + +func (c *conn) start() { + c.wchan = make(chan writeReq, 1024) + go c.writeLoop() +} + +func (c *conn) writeLoop() { + for req := range c.wchan { + time.Sleep(req.writeAt.Sub(time.Now())) + var res nErr + for len(req.p) > 0 && res.err == nil { + writep := req.p + if len(writep) > unitSize { + writep = writep[:unitSize] + } + n, err := c.Conn.Write(writep) + time.Sleep(c.Up.byteTime(len(writep))) + res.n += n + res.err = err + req.p = req.p[n:] + } + req.resc <- res + } +} + +func (c *conn) Close() error { + c.closeOnce.Do(func() { + err := c.Conn.Close() + close(c.wchan) + c.closeErr = err + }) + return c.closeErr +} + +func (c *conn) Write(p []byte) (n int, err error) { + defer func() { + if e := recover(); e != nil { + n = 0 + err = fmt.Errorf("%v", err) + return + } + }() + resc := make(chan nErr, 1) + c.wchan <- writeReq{time.Now().Add(c.Up.Latency), p, resc} + res := <-resc + return res.n, res.err +} + +func (c *conn) Read(p []byte) (n int, err error) { + const max = 1024 + if len(p) > max { + p = p[:max] + } + n, err = c.Conn.Read(p) + time.Sleep(c.Down.byteTime(n)) + return +} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/util.go b/vendor/github.com/samuel/go-zookeeper/zk/util.go index 769bbe8..f40a5b1 100644 --- a/vendor/github.com/samuel/go-zookeeper/zk/util.go +++ b/vendor/github.com/samuel/go-zookeeper/zk/util.go @@ -7,6 +7,7 @@ import ( "math/rand" "strconv" "strings" + "unicode/utf8" ) // AuthACL produces an ACL list containing a single ACL which uses the @@ -52,3 +53,64 @@ func stringShuffle(s []string) { s[i], s[j] = s[j], s[i] } } + +// validatePath will make sure a path is valid before sending the request +func validatePath(path string, isSequential bool) error { + if path == "" { + return ErrInvalidPath + } + + if path[0] != '/' { + return ErrInvalidPath + } + + n := len(path) + if n == 1 { + // path is just the root + return nil + } + + if !isSequential && path[n-1] == '/' { + return ErrInvalidPath + } + + // Start at rune 1 since we already know that the first character is + // a '/'. + for i, w := 1, 0; i < n; i += w { + r, width := utf8.DecodeRuneInString(path[i:]) + switch { + case r == '\u0000': + return ErrInvalidPath + case r == '/': + last, _ := utf8.DecodeLastRuneInString(path[:i]) + if last == '/' { + return ErrInvalidPath + } + case r == '.': + last, lastWidth := utf8.DecodeLastRuneInString(path[:i]) + + // Check for double dot + if last == '.' { + last, _ = utf8.DecodeLastRuneInString(path[:i-lastWidth]) + } + + if last == '/' { + if i+1 == n { + return ErrInvalidPath + } + + next, _ := utf8.DecodeRuneInString(path[i+w:]) + if next == '/' { + return ErrInvalidPath + } + } + case r >= '\u0000' && r <= '\u001f', + r >= '\u007f' && r <= '\u009f', + r >= '\uf000' && r <= '\uf8ff', + r >= '\ufff0' && r < '\uffff': + return ErrInvalidPath + } + w = width + } + return nil +} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/util_test.go b/vendor/github.com/samuel/go-zookeeper/zk/util_test.go new file mode 100644 index 0000000..53a5950 --- /dev/null +++ b/vendor/github.com/samuel/go-zookeeper/zk/util_test.go @@ -0,0 +1,53 @@ +package zk + +import "testing" + +func TestFormatServers(t *testing.T) { + t.Parallel() + servers := []string{"127.0.0.1:2181", "127.0.0.42", "127.0.42.1:8811"} + r := []string{"127.0.0.1:2181", "127.0.0.42:2181", "127.0.42.1:8811"} + for i, s := range FormatServers(servers) { + if s != r[i] { + t.Errorf("%v should equal %v", s, r[i]) + } + } +} + +func TestValidatePath(t *testing.T) { + tt := []struct { + path string + seq bool + valid bool + }{ + {"/this is / a valid/path", false, true}, + {"/", false, true}, + {"", false, false}, + {"not/valid", false, false}, + {"/ends/with/slash/", false, false}, + {"/sequential/", true, true}, + {"/test\u0000", false, false}, + {"/double//slash", false, false}, + {"/single/./period", false, false}, + {"/double/../period", false, false}, + {"/double/..ok/period", false, true}, + {"/double/alsook../period", false, true}, + {"/double/period/at/end/..", false, false}, + {"/name/with.period", false, true}, + {"/test\u0001", false, false}, + {"/test\u001f", false, false}, + {"/test\u0020", false, true}, // first allowable + {"/test\u007e", false, true}, // last valid ascii + {"/test\u007f", false, false}, + {"/test\u009f", false, false}, + {"/test\uf8ff", false, false}, + {"/test\uffef", false, true}, + {"/test\ufff0", false, false}, + } + + for _, tc := range tt { + err := validatePath(tc.path, tc.seq) + if (err != nil) == tc.valid { + t.Errorf("failed to validate path %q", tc.path) + } + } +} diff --git a/vendor/github.com/samuel/go-zookeeper/zk/zk_test.go b/vendor/github.com/samuel/go-zookeeper/zk/zk_test.go new file mode 100644 index 0000000..c81ef9f --- /dev/null +++ b/vendor/github.com/samuel/go-zookeeper/zk/zk_test.go @@ -0,0 +1,939 @@ +package zk + +import ( + "crypto/rand" + "encoding/hex" + "fmt" + "io" + "net" + "reflect" + "regexp" + "sort" + "strings" + "sync" + "sync/atomic" + "testing" + "time" +) + +func TestStateChanges(t *testing.T) { + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + + callbackChan := make(chan Event) + f := func(event Event) { + callbackChan <- event + } + + zk, eventChan, err := ts.ConnectWithOptions(15*time.Second, WithEventCallback(f)) + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + + verifyEventOrder := func(c <-chan Event, expectedStates []State, source string) { + for _, state := range expectedStates { + for { + event, ok := <-c + if !ok { + t.Fatalf("unexpected channel close for %s", source) + } + + if event.Type != EventSession { + continue + } + + if event.State != state { + t.Fatalf("mismatched state order from %s, expected %v, received %v", source, state, event.State) + } + break + } + } + } + + states := []State{StateConnecting, StateConnected, StateHasSession} + verifyEventOrder(callbackChan, states, "callback") + verifyEventOrder(eventChan, states, "event channel") + + zk.Close() + verifyEventOrder(callbackChan, []State{StateDisconnected}, "callback") + verifyEventOrder(eventChan, []State{StateDisconnected}, "event channel") +} + +func TestCreate(t *testing.T) { + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + zk, _, err := ts.ConnectAll() + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + + path := "/gozk-test" + + if err := zk.Delete(path, -1); err != nil && err != ErrNoNode { + t.Fatalf("Delete returned error: %+v", err) + } + if p, err := zk.Create(path, []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { + t.Fatalf("Create returned error: %+v", err) + } else if p != path { + t.Fatalf("Create returned different path '%s' != '%s'", p, path) + } + if data, stat, err := zk.Get(path); err != nil { + t.Fatalf("Get returned error: %+v", err) + } else if stat == nil { + t.Fatal("Get returned nil stat") + } else if len(data) < 4 { + t.Fatal("Get returned wrong size data") + } +} + +func TestMulti(t *testing.T) { + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + zk, _, err := ts.ConnectAll() + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + + path := "/gozk-test" + + if err := zk.Delete(path, -1); err != nil && err != ErrNoNode { + t.Fatalf("Delete returned error: %+v", err) + } + ops := []interface{}{ + &CreateRequest{Path: path, Data: []byte{1, 2, 3, 4}, Acl: WorldACL(PermAll)}, + &SetDataRequest{Path: path, Data: []byte{1, 2, 3, 4}, Version: -1}, + } + if res, err := zk.Multi(ops...); err != nil { + t.Fatalf("Multi returned error: %+v", err) + } else if len(res) != 2 { + t.Fatalf("Expected 2 responses got %d", len(res)) + } else { + t.Logf("%+v", res) + } + if data, stat, err := zk.Get(path); err != nil { + t.Fatalf("Get returned error: %+v", err) + } else if stat == nil { + t.Fatal("Get returned nil stat") + } else if len(data) < 4 { + t.Fatal("Get returned wrong size data") + } +} + +func TestIfAuthdataSurvivesReconnect(t *testing.T) { + // This test case ensures authentication data is being resubmited after + // reconnect. + testNode := "/auth-testnode" + + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + + zk, _, err := ts.ConnectAll() + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + + acl := DigestACL(PermAll, "userfoo", "passbar") + + _, err = zk.Create(testNode, []byte("Some very secret content"), 0, acl) + if err != nil && err != ErrNodeExists { + t.Fatalf("Failed to create test node : %+v", err) + } + + _, _, err = zk.Get(testNode) + if err == nil || err != ErrNoAuth { + var msg string + + if err == nil { + msg = "Fetching data without auth should have resulted in an error" + } else { + msg = fmt.Sprintf("Expecting ErrNoAuth, got `%+v` instead", err) + } + t.Fatalf(msg) + } + + zk.AddAuth("digest", []byte("userfoo:passbar")) + + _, _, err = zk.Get(testNode) + if err != nil { + t.Fatalf("Fetching data with auth failed: %+v", err) + } + + ts.StopAllServers() + ts.StartAllServers() + + _, _, err = zk.Get(testNode) + if err != nil { + t.Fatalf("Fetching data after reconnect failed: %+v", err) + } +} + +func TestMultiFailures(t *testing.T) { + // This test case ensures that we return the errors associated with each + // opeThis in the event a call to Multi() fails. + const firstPath = "/gozk-test-first" + const secondPath = "/gozk-test-second" + + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + zk, _, err := ts.ConnectAll() + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + + // Ensure firstPath doesn't exist and secondPath does. This will cause the + // 2nd operation in the Multi() to fail. + if err := zk.Delete(firstPath, -1); err != nil && err != ErrNoNode { + t.Fatalf("Delete returned error: %+v", err) + } + if _, err := zk.Create(secondPath, nil /* data */, 0, WorldACL(PermAll)); err != nil { + t.Fatalf("Create returned error: %+v", err) + } + + ops := []interface{}{ + &CreateRequest{Path: firstPath, Data: []byte{1, 2}, Acl: WorldACL(PermAll)}, + &CreateRequest{Path: secondPath, Data: []byte{3, 4}, Acl: WorldACL(PermAll)}, + } + res, err := zk.Multi(ops...) + if err != ErrNodeExists { + t.Fatalf("Multi() didn't return correct error: %+v", err) + } + if len(res) != 2 { + t.Fatalf("Expected 2 responses received %d", len(res)) + } + if res[0].Error != nil { + t.Fatalf("First operation returned an unexpected error %+v", res[0].Error) + } + if res[1].Error != ErrNodeExists { + t.Fatalf("Second operation returned incorrect error %+v", res[1].Error) + } + if _, _, err := zk.Get(firstPath); err != ErrNoNode { + t.Fatalf("Node %s was incorrectly created: %+v", firstPath, err) + } +} + +func TestGetSetACL(t *testing.T) { + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + zk, _, err := ts.ConnectAll() + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + + if err := zk.AddAuth("digest", []byte("blah")); err != nil { + t.Fatalf("AddAuth returned error %+v", err) + } + + path := "/gozk-test" + + if err := zk.Delete(path, -1); err != nil && err != ErrNoNode { + t.Fatalf("Delete returned error: %+v", err) + } + if path, err := zk.Create(path, []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { + t.Fatalf("Create returned error: %+v", err) + } else if path != "/gozk-test" { + t.Fatalf("Create returned different path '%s' != '/gozk-test'", path) + } + + expected := WorldACL(PermAll) + + if acl, stat, err := zk.GetACL(path); err != nil { + t.Fatalf("GetACL returned error %+v", err) + } else if stat == nil { + t.Fatalf("GetACL returned nil Stat") + } else if len(acl) != 1 || expected[0] != acl[0] { + t.Fatalf("GetACL mismatch expected %+v instead of %+v", expected, acl) + } + + expected = []ACL{{PermAll, "ip", "127.0.0.1"}} + + if stat, err := zk.SetACL(path, expected, -1); err != nil { + t.Fatalf("SetACL returned error %+v", err) + } else if stat == nil { + t.Fatalf("SetACL returned nil Stat") + } + + if acl, stat, err := zk.GetACL(path); err != nil { + t.Fatalf("GetACL returned error %+v", err) + } else if stat == nil { + t.Fatalf("GetACL returned nil Stat") + } else if len(acl) != 1 || expected[0] != acl[0] { + t.Fatalf("GetACL mismatch expected %+v instead of %+v", expected, acl) + } +} + +func TestAuth(t *testing.T) { + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + zk, _, err := ts.ConnectAll() + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + + path := "/gozk-digest-test" + if err := zk.Delete(path, -1); err != nil && err != ErrNoNode { + t.Fatalf("Delete returned error: %+v", err) + } + + acl := DigestACL(PermAll, "user", "password") + + if p, err := zk.Create(path, []byte{1, 2, 3, 4}, 0, acl); err != nil { + t.Fatalf("Create returned error: %+v", err) + } else if p != path { + t.Fatalf("Create returned different path '%s' != '%s'", p, path) + } + + if a, stat, err := zk.GetACL(path); err != nil { + t.Fatalf("GetACL returned error %+v", err) + } else if stat == nil { + t.Fatalf("GetACL returned nil Stat") + } else if len(a) != 1 || acl[0] != a[0] { + t.Fatalf("GetACL mismatch expected %+v instead of %+v", acl, a) + } + + if _, _, err := zk.Get(path); err != ErrNoAuth { + t.Fatalf("Get returned error %+v instead of ErrNoAuth", err) + } + + if err := zk.AddAuth("digest", []byte("user:password")); err != nil { + t.Fatalf("AddAuth returned error %+v", err) + } + + if data, stat, err := zk.Get(path); err != nil { + t.Fatalf("Get returned error %+v", err) + } else if stat == nil { + t.Fatalf("Get returned nil Stat") + } else if len(data) != 4 { + t.Fatalf("Get returned wrong data length") + } +} + +func TestChildren(t *testing.T) { + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + zk, _, err := ts.ConnectAll() + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + + deleteNode := func(node string) { + if err := zk.Delete(node, -1); err != nil && err != ErrNoNode { + t.Fatalf("Delete returned error: %+v", err) + } + } + + deleteNode("/gozk-test-big") + + if path, err := zk.Create("/gozk-test-big", []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { + t.Fatalf("Create returned error: %+v", err) + } else if path != "/gozk-test-big" { + t.Fatalf("Create returned different path '%s' != '/gozk-test-big'", path) + } + + rb := make([]byte, 1000) + hb := make([]byte, 2000) + prefix := []byte("/gozk-test-big/") + for i := 0; i < 10000; i++ { + _, err := rand.Read(rb) + if err != nil { + t.Fatal("Cannot create random znode name") + } + hex.Encode(hb, rb) + + expect := string(append(prefix, hb...)) + if path, err := zk.Create(expect, []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { + t.Fatalf("Create returned error: %+v", err) + } else if path != expect { + t.Fatalf("Create returned different path '%s' != '%s'", path, expect) + } + defer deleteNode(string(expect)) + } + + children, _, err := zk.Children("/gozk-test-big") + if err != nil { + t.Fatalf("Children returned error: %+v", err) + } else if len(children) != 10000 { + t.Fatal("Children returned wrong number of nodes") + } +} + +func TestChildWatch(t *testing.T) { + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + zk, _, err := ts.ConnectAll() + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + + if err := zk.Delete("/gozk-test", -1); err != nil && err != ErrNoNode { + t.Fatalf("Delete returned error: %+v", err) + } + + children, stat, childCh, err := zk.ChildrenW("/") + if err != nil { + t.Fatalf("Children returned error: %+v", err) + } else if stat == nil { + t.Fatal("Children returned nil stat") + } else if len(children) < 1 { + t.Fatal("Children should return at least 1 child") + } + + if path, err := zk.Create("/gozk-test", []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { + t.Fatalf("Create returned error: %+v", err) + } else if path != "/gozk-test" { + t.Fatalf("Create returned different path '%s' != '/gozk-test'", path) + } + + select { + case ev := <-childCh: + if ev.Err != nil { + t.Fatalf("Child watcher error %+v", ev.Err) + } + if ev.Path != "/" { + t.Fatalf("Child watcher wrong path %s instead of %s", ev.Path, "/") + } + case _ = <-time.After(time.Second * 2): + t.Fatal("Child watcher timed out") + } + + // Delete of the watched node should trigger the watch + + children, stat, childCh, err = zk.ChildrenW("/gozk-test") + if err != nil { + t.Fatalf("Children returned error: %+v", err) + } else if stat == nil { + t.Fatal("Children returned nil stat") + } else if len(children) != 0 { + t.Fatal("Children should return 0 children") + } + + if err := zk.Delete("/gozk-test", -1); err != nil && err != ErrNoNode { + t.Fatalf("Delete returned error: %+v", err) + } + + select { + case ev := <-childCh: + if ev.Err != nil { + t.Fatalf("Child watcher error %+v", ev.Err) + } + if ev.Path != "/gozk-test" { + t.Fatalf("Child watcher wrong path %s instead of %s", ev.Path, "/") + } + case _ = <-time.After(time.Second * 2): + t.Fatal("Child watcher timed out") + } +} + +func TestSetWatchers(t *testing.T) { + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + zk, _, err := ts.ConnectAll() + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + + zk.reconnectLatch = make(chan struct{}) + zk.setWatchLimit = 1024 // break up set-watch step into 1k requests + var setWatchReqs atomic.Value + zk.setWatchCallback = func(reqs []*setWatchesRequest) { + setWatchReqs.Store(reqs) + } + + zk2, _, err := ts.ConnectAll() + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk2.Close() + + if err := zk.Delete("/gozk-test", -1); err != nil && err != ErrNoNode { + t.Fatalf("Delete returned error: %+v", err) + } + + testPaths := map[string]<-chan Event{} + defer func() { + // clean up all of the test paths we create + for p := range testPaths { + zk2.Delete(p, -1) + } + }() + + // we create lots of paths to watch, to make sure a "set watches" request + // on re-create will be too big and be required to span multiple packets + for i := 0; i < 1000; i++ { + testPath, err := zk.Create(fmt.Sprintf("/gozk-test-%d", i), []byte{}, 0, WorldACL(PermAll)) + if err != nil { + t.Fatalf("Create returned: %+v", err) + } + testPaths[testPath] = nil + _, _, testEvCh, err := zk.GetW(testPath) + if err != nil { + t.Fatalf("GetW returned: %+v", err) + } + testPaths[testPath] = testEvCh + } + + children, stat, childCh, err := zk.ChildrenW("/") + if err != nil { + t.Fatalf("Children returned error: %+v", err) + } else if stat == nil { + t.Fatal("Children returned nil stat") + } else if len(children) < 1 { + t.Fatal("Children should return at least 1 child") + } + + // Simulate network error by brutally closing the network connection. + zk.conn.Close() + for p := range testPaths { + if err := zk2.Delete(p, -1); err != nil && err != ErrNoNode { + t.Fatalf("Delete returned error: %+v", err) + } + } + if path, err := zk2.Create("/gozk-test", []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { + t.Fatalf("Create returned error: %+v", err) + } else if path != "/gozk-test" { + t.Fatalf("Create returned different path '%s' != '/gozk-test'", path) + } + + time.Sleep(100 * time.Millisecond) + + // zk should still be waiting to reconnect, so none of the watches should have been triggered + for p, ch := range testPaths { + select { + case <-ch: + t.Fatalf("GetW watcher for %q should not have triggered yet", p) + default: + } + } + select { + case <-childCh: + t.Fatalf("ChildrenW watcher should not have triggered yet") + default: + } + + // now we let the reconnect occur and make sure it resets watches + close(zk.reconnectLatch) + + for p, ch := range testPaths { + select { + case ev := <-ch: + if ev.Err != nil { + t.Fatalf("GetW watcher error %+v", ev.Err) + } + if ev.Path != p { + t.Fatalf("GetW watcher wrong path %s instead of %s", ev.Path, p) + } + case <-time.After(2 * time.Second): + t.Fatal("GetW watcher timed out") + } + } + + select { + case ev := <-childCh: + if ev.Err != nil { + t.Fatalf("Child watcher error %+v", ev.Err) + } + if ev.Path != "/" { + t.Fatalf("Child watcher wrong path %s instead of %s", ev.Path, "/") + } + case <-time.After(2 * time.Second): + t.Fatal("Child watcher timed out") + } + + // Yay! All watches fired correctly. Now we also inspect the actual set-watch request objects + // to ensure they didn't exceed the expected packet set. + buf := make([]byte, bufferSize) + totalWatches := 0 + actualReqs := setWatchReqs.Load().([]*setWatchesRequest) + if len(actualReqs) < 12 { + // sanity check: we should have generated *at least* 12 requests to reset watches + t.Fatalf("too few setWatchesRequest messages: %d", len(actualReqs)) + } + for _, r := range actualReqs { + totalWatches += len(r.ChildWatches) + len(r.DataWatches) + len(r.ExistWatches) + n, err := encodePacket(buf, r) + if err != nil { + t.Fatalf("encodePacket failed: %v! request:\n%+v", err, r) + } else if n > 1024 { + t.Fatalf("setWatchesRequest exceeded allowed size (%d > 1024)! request:\n%+v", n, r) + } + } + + if totalWatches != len(testPaths)+1 { + t.Fatalf("setWatchesRequests did not include all expected watches; expecting %d, got %d", len(testPaths)+1, totalWatches) + } +} + +func TestExpiringWatch(t *testing.T) { + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + zk, _, err := ts.ConnectAll() + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + + if err := zk.Delete("/gozk-test", -1); err != nil && err != ErrNoNode { + t.Fatalf("Delete returned error: %+v", err) + } + + children, stat, childCh, err := zk.ChildrenW("/") + if err != nil { + t.Fatalf("Children returned error: %+v", err) + } else if stat == nil { + t.Fatal("Children returned nil stat") + } else if len(children) < 1 { + t.Fatal("Children should return at least 1 child") + } + + zk.sessionID = 99999 + zk.conn.Close() + + select { + case ev := <-childCh: + if ev.Err != ErrSessionExpired { + t.Fatalf("Child watcher error %+v instead of expected ErrSessionExpired", ev.Err) + } + if ev.Path != "/" { + t.Fatalf("Child watcher wrong path %s instead of %s", ev.Path, "/") + } + case <-time.After(2 * time.Second): + t.Fatal("Child watcher timed out") + } +} + +func TestRequestFail(t *testing.T) { + // If connecting fails to all servers in the list then pending requests + // should be errored out so they don't hang forever. + + zk, _, err := Connect([]string{"127.0.0.1:32444"}, time.Second*15) + if err != nil { + t.Fatal(err) + } + defer zk.Close() + + ch := make(chan error) + go func() { + _, _, err := zk.Get("/blah") + ch <- err + }() + select { + case err := <-ch: + if err == nil { + t.Fatal("Expected non-nil error on failed request due to connection failure") + } + case <-time.After(time.Second * 2): + t.Fatal("Get hung when connection could not be made") + } +} + +func TestSlowServer(t *testing.T) { + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + + realAddr := fmt.Sprintf("127.0.0.1:%d", ts.Servers[0].Port) + proxyAddr, stopCh, err := startSlowProxy(t, + Rate{}, Rate{}, + realAddr, func(ln *Listener) { + if ln.Up.Latency == 0 { + ln.Up.Latency = time.Millisecond * 2000 + ln.Down.Latency = time.Millisecond * 2000 + } else { + ln.Up.Latency = 0 + ln.Down.Latency = 0 + } + }) + if err != nil { + t.Fatal(err) + } + defer close(stopCh) + + zk, _, err := Connect([]string{proxyAddr}, time.Millisecond*500) + if err != nil { + t.Fatal(err) + } + defer zk.Close() + + _, _, wch, err := zk.ChildrenW("/") + if err != nil { + t.Fatal(err) + } + + // Force a reconnect to get a throttled connection + zk.conn.Close() + + time.Sleep(time.Millisecond * 100) + + if err := zk.Delete("/gozk-test", -1); err == nil { + t.Fatal("Delete should have failed") + } + + // The previous request should have timed out causing the server to be disconnected and reconnected + + if _, err := zk.Create("/gozk-test", []byte{1, 2, 3, 4}, 0, WorldACL(PermAll)); err != nil { + t.Fatal(err) + } + + // Make sure event is still returned because the session should not have been affected + select { + case ev := <-wch: + t.Logf("Received event: %+v", ev) + case <-time.After(time.Second): + t.Fatal("Expected to receive a watch event") + } +} + +func startSlowProxy(t *testing.T, up, down Rate, upstream string, adj func(ln *Listener)) (string, chan bool, error) { + ln, err := net.Listen("tcp", "127.0.0.1:0") + if err != nil { + return "", nil, err + } + tln := &Listener{ + Listener: ln, + Up: up, + Down: down, + } + stopCh := make(chan bool) + go func() { + <-stopCh + tln.Close() + }() + go func() { + for { + cn, err := tln.Accept() + if err != nil { + if !strings.Contains(err.Error(), "use of closed network connection") { + t.Fatalf("Accept failed: %s", err.Error()) + } + return + } + if adj != nil { + adj(tln) + } + go func(cn net.Conn) { + defer cn.Close() + upcn, err := net.Dial("tcp", upstream) + if err != nil { + t.Log(err) + return + } + // This will leave hanging goroutines util stopCh is closed + // but it doesn't matter in the context of running tests. + go func() { + <-stopCh + upcn.Close() + }() + go func() { + if _, err := io.Copy(upcn, cn); err != nil { + if !strings.Contains(err.Error(), "use of closed network connection") { + // log.Printf("Upstream write failed: %s", err.Error()) + } + } + }() + if _, err := io.Copy(cn, upcn); err != nil { + if !strings.Contains(err.Error(), "use of closed network connection") { + // log.Printf("Upstream read failed: %s", err.Error()) + } + } + }(cn) + } + }() + return ln.Addr().String(), stopCh, nil +} + +func TestMaxBufferSize(t *testing.T) { + ts, err := StartTestCluster(1, nil, logWriter{t: t, p: "[ZKERR] "}) + if err != nil { + t.Fatal(err) + } + defer ts.Stop() + // no buffer size + zk, _, err := ts.ConnectWithOptions(15 * time.Second) + var l testLogger + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zk.Close() + // 1k buffer size, logs to custom test logger + zkLimited, _, err := ts.ConnectWithOptions(15*time.Second, WithMaxBufferSize(1024), func(conn *Conn) { + conn.SetLogger(&l) + }) + if err != nil { + t.Fatalf("Connect returned error: %+v", err) + } + defer zkLimited.Close() + + // With small node with small number of children + data := []byte{101, 102, 103, 103} + _, err = zk.Create("/foo", data, 0, WorldACL(PermAll)) + if err != nil { + t.Fatalf("Create returned error: %+v", err) + } + var children []string + for i := 0; i < 4; i++ { + childName, err := zk.Create("/foo/child", nil, FlagEphemeral|FlagSequence, WorldACL(PermAll)) + if err != nil { + t.Fatalf("Create returned error: %+v", err) + } + children = append(children, childName[len("/foo/"):]) // strip parent prefix from name + } + sort.Strings(children) + + // Limited client works fine + resultData, _, err := zkLimited.Get("/foo") + if err != nil { + t.Fatalf("Get returned error: %+v", err) + } + if !reflect.DeepEqual(resultData, data) { + t.Fatalf("Get returned unexpected data; expecting %+v, got %+v", data, resultData) + } + resultChildren, _, err := zkLimited.Children("/foo") + if err != nil { + t.Fatalf("Children returned error: %+v", err) + } + sort.Strings(resultChildren) + if !reflect.DeepEqual(resultChildren, children) { + t.Fatalf("Children returned unexpected names; expecting %+v, got %+v", children, resultChildren) + } + + // With large node though... + data = make([]byte, 1024) + for i := 0; i < 1024; i++ { + data[i] = byte(i) + } + _, err = zk.Create("/bar", data, 0, WorldACL(PermAll)) + if err != nil { + t.Fatalf("Create returned error: %+v", err) + } + _, _, err = zkLimited.Get("/bar") + // NB: Sadly, without actually de-serializing the too-large response packet, we can't send the + // right error to the corresponding outstanding request. So the request just sees ErrConnectionClosed + // while the log will see the actual reason the connection was closed. + expectErr(t, err, ErrConnectionClosed) + expectLogMessage(t, &l, "received packet from server with length .*, which exceeds max buffer size 1024") + + // Or with large number of children... + totalLen := 0 + children = nil + for totalLen < 1024 { + childName, err := zk.Create("/bar/child", nil, FlagEphemeral|FlagSequence, WorldACL(PermAll)) + if err != nil { + t.Fatalf("Create returned error: %+v", err) + } + n := childName[len("/bar/"):] // strip parent prefix from name + children = append(children, n) + totalLen += len(n) + } + sort.Strings(children) + _, _, err = zkLimited.Children("/bar") + expectErr(t, err, ErrConnectionClosed) + expectLogMessage(t, &l, "received packet from server with length .*, which exceeds max buffer size 1024") + + // Other client (without buffer size limit) can successfully query the node and its children, of course + resultData, _, err = zk.Get("/bar") + if err != nil { + t.Fatalf("Get returned error: %+v", err) + } + if !reflect.DeepEqual(resultData, data) { + t.Fatalf("Get returned unexpected data; expecting %+v, got %+v", data, resultData) + } + resultChildren, _, err = zk.Children("/bar") + if err != nil { + t.Fatalf("Children returned error: %+v", err) + } + sort.Strings(resultChildren) + if !reflect.DeepEqual(resultChildren, children) { + t.Fatalf("Children returned unexpected names; expecting %+v, got %+v", children, resultChildren) + } +} + +func expectErr(t *testing.T, err error, expected error) { + if err == nil { + t.Fatalf("Get for node that is too large should have returned error!") + } + if err != expected { + t.Fatalf("Get returned wrong error; expecting ErrClosing, got %+v", err) + } +} + +func expectLogMessage(t *testing.T, logger *testLogger, pattern string) { + re := regexp.MustCompile(pattern) + events := logger.Reset() + if len(events) == 0 { + t.Fatalf("Failed to log error; expecting message that matches pattern: %s", pattern) + } + var found []string + for _, e := range events { + if re.Match([]byte(e)) { + found = append(found, e) + } + } + if len(found) == 0 { + t.Fatalf("Failed to log error; expecting message that matches pattern: %s", pattern) + } else if len(found) > 1 { + t.Fatalf("Logged error redundantly %d times:\n%+v", len(found), found) + } +} + +type testLogger struct { + mu sync.Mutex + events []string +} + +func (l *testLogger) Printf(msgFormat string, args ...interface{}) { + msg := fmt.Sprintf(msgFormat, args...) + fmt.Println(msg) + l.mu.Lock() + defer l.mu.Unlock() + l.events = append(l.events, msg) +} + +func (l *testLogger) Reset() []string { + l.mu.Lock() + defer l.mu.Unlock() + ret := l.events + l.events = nil + return ret +} diff --git a/vendor/github.com/stretchr/testify/.gitignore b/vendor/github.com/stretchr/testify/.gitignore new file mode 100644 index 0000000..5aacdb7 --- /dev/null +++ b/vendor/github.com/stretchr/testify/.gitignore @@ -0,0 +1,24 @@ +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# Folders +_obj +_test + +# Architecture specific extensions/prefixes +*.[568vq] +[568vq].out + +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* + +_testmain.go + +*.exe + +.DS_Store diff --git a/vendor/github.com/stretchr/testify/.travis.gofmt.sh b/vendor/github.com/stretchr/testify/.travis.gofmt.sh new file mode 100755 index 0000000..bfffdca --- /dev/null +++ b/vendor/github.com/stretchr/testify/.travis.gofmt.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +if [ -n "$(gofmt -l .)" ]; then + echo "Go code is not formatted:" + gofmt -d . + exit 1 +fi diff --git a/vendor/github.com/stretchr/testify/.travis.gogenerate.sh b/vendor/github.com/stretchr/testify/.travis.gogenerate.sh new file mode 100755 index 0000000..161b449 --- /dev/null +++ b/vendor/github.com/stretchr/testify/.travis.gogenerate.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +if [[ "$TRAVIS_GO_VERSION" =~ ^1\.[45](\..*)?$ ]]; then + exit 0 +fi + +go get github.com/ernesto-jimenez/gogen/imports +go generate ./... +if [ -n "$(git diff)" ]; then + echo "Go generate had not been run" + git diff + exit 1 +fi diff --git a/vendor/github.com/stretchr/testify/.travis.govet.sh b/vendor/github.com/stretchr/testify/.travis.govet.sh new file mode 100755 index 0000000..f8fbba7 --- /dev/null +++ b/vendor/github.com/stretchr/testify/.travis.govet.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +cd "$(dirname $0)" +DIRS=". assert require mock _codegen" +set -e +for subdir in $DIRS; do + pushd $subdir + go vet + popd +done diff --git a/vendor/github.com/stretchr/testify/.travis.yml b/vendor/github.com/stretchr/testify/.travis.yml new file mode 100644 index 0000000..da6ba0d --- /dev/null +++ b/vendor/github.com/stretchr/testify/.travis.yml @@ -0,0 +1,19 @@ +language: go + +sudo: false + +matrix: + include: + - go: "1.8.x" + - go: "1.9.x" + - go: "1.10.x" + - go: "1.11.x" + env: GO111MODULE=off + - go: "1.11.x" + env: GO111MODULE=on + - go: tip + script: + - ./.travis.gogenerate.sh + - ./.travis.gofmt.sh + - ./.travis.govet.sh + - go test -v -race $(go list ./... | grep -v vendor) diff --git a/vendor/github.com/stretchr/testify/Gopkg.lock b/vendor/github.com/stretchr/testify/Gopkg.lock new file mode 100644 index 0000000..294cda0 --- /dev/null +++ b/vendor/github.com/stretchr/testify/Gopkg.lock @@ -0,0 +1,27 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + name = "github.com/davecgh/go-spew" + packages = ["spew"] + revision = "346938d642f2ec3594ed81d874461961cd0faa76" + version = "v1.1.0" + +[[projects]] + name = "github.com/pmezard/go-difflib" + packages = ["difflib"] + revision = "792786c7400a136282c1664665ae0a8db921c6c2" + version = "v1.0.0" + +[[projects]] + name = "github.com/stretchr/objx" + packages = ["."] + revision = "facf9a85c22f48d2f52f2380e4efce1768749a89" + version = "v0.1" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + inputs-digest = "448ddae4702c6aded2555faafd390c537789bb1c483f70b0431e6634f73f2090" + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/vendor/github.com/stretchr/testify/Gopkg.toml b/vendor/github.com/stretchr/testify/Gopkg.toml new file mode 100644 index 0000000..a16374c --- /dev/null +++ b/vendor/github.com/stretchr/testify/Gopkg.toml @@ -0,0 +1,16 @@ +[prune] + unused-packages = true + non-go = true + go-tests = true + +[[constraint]] + name = "github.com/davecgh/go-spew" + version = "~1.1.0" + +[[constraint]] + name = "github.com/pmezard/go-difflib" + version = "~1.0.0" + +[[constraint]] + name = "github.com/stretchr/objx" + version = "~0.1.0" diff --git a/vendor/github.com/stretchr/testify/LICENSE b/vendor/github.com/stretchr/testify/LICENSE index 473b670..f38ec59 100644 --- a/vendor/github.com/stretchr/testify/LICENSE +++ b/vendor/github.com/stretchr/testify/LICENSE @@ -1,22 +1,21 @@ -Copyright (c) 2012 - 2013 Mat Ryer and Tyler Bunnell +MIT License -Please consider promoting this project if you find it useful. +Copyright (c) 2012-2018 Mat Ryer and Tyler Bunnell -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: +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 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. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/github.com/stretchr/testify/README.md b/vendor/github.com/stretchr/testify/README.md new file mode 100644 index 0000000..11951d4 --- /dev/null +++ b/vendor/github.com/stretchr/testify/README.md @@ -0,0 +1,340 @@ +Testify - Thou Shalt Write Tests +================================ + +[![Build Status](https://travis-ci.org/stretchr/testify.svg)](https://travis-ci.org/stretchr/testify) [![Go Report Card](https://goreportcard.com/badge/github.com/stretchr/testify)](https://goreportcard.com/report/github.com/stretchr/testify) [![GoDoc](https://godoc.org/github.com/stretchr/testify?status.svg)](https://godoc.org/github.com/stretchr/testify) + +Go code (golang) set of packages that provide many tools for testifying that your code will behave as you intend. + +Features include: + + * [Easy assertions](#assert-package) + * [Mocking](#mock-package) + * [Testing suite interfaces and functions](#suite-package) + +Get started: + + * Install testify with [one line of code](#installation), or [update it with another](#staying-up-to-date) + * For an introduction to writing test code in Go, see http://golang.org/doc/code.html#Testing + * Check out the API Documentation http://godoc.org/github.com/stretchr/testify + * To make your testing life easier, check out our other project, [gorc](http://github.com/stretchr/gorc) + * A little about [Test-Driven Development (TDD)](http://en.wikipedia.org/wiki/Test-driven_development) + + + +[`assert`](http://godoc.org/github.com/stretchr/testify/assert "API documentation") package +------------------------------------------------------------------------------------------- + +The `assert` package provides some helpful methods that allow you to write better test code in Go. + + * Prints friendly, easy to read failure descriptions + * Allows for very readable code + * Optionally annotate each assertion with a message + +See it in action: + +```go +package yours + +import ( + "testing" + "github.com/stretchr/testify/assert" +) + +func TestSomething(t *testing.T) { + + // assert equality + assert.Equal(t, 123, 123, "they should be equal") + + // assert inequality + assert.NotEqual(t, 123, 456, "they should not be equal") + + // assert for nil (good for errors) + assert.Nil(t, object) + + // assert for not nil (good when you expect something) + if assert.NotNil(t, object) { + + // now we know that object isn't nil, we are safe to make + // further assertions without causing any errors + assert.Equal(t, "Something", object.Value) + + } + +} +``` + + * Every assert func takes the `testing.T` object as the first argument. This is how it writes the errors out through the normal `go test` capabilities. + * Every assert func returns a bool indicating whether the assertion was successful or not, this is useful for if you want to go on making further assertions under certain conditions. + +if you assert many times, use the below: + +```go +package yours + +import ( + "testing" + "github.com/stretchr/testify/assert" +) + +func TestSomething(t *testing.T) { + assert := assert.New(t) + + // assert equality + assert.Equal(123, 123, "they should be equal") + + // assert inequality + assert.NotEqual(123, 456, "they should not be equal") + + // assert for nil (good for errors) + assert.Nil(object) + + // assert for not nil (good when you expect something) + if assert.NotNil(object) { + + // now we know that object isn't nil, we are safe to make + // further assertions without causing any errors + assert.Equal("Something", object.Value) + } +} +``` + +[`require`](http://godoc.org/github.com/stretchr/testify/require "API documentation") package +--------------------------------------------------------------------------------------------- + +The `require` package provides same global functions as the `assert` package, but instead of returning a boolean result they terminate current test. + +See [t.FailNow](http://golang.org/pkg/testing/#T.FailNow) for details. + +[`mock`](http://godoc.org/github.com/stretchr/testify/mock "API documentation") package +---------------------------------------------------------------------------------------- + +The `mock` package provides a mechanism for easily writing mock objects that can be used in place of real objects when writing test code. + +An example test function that tests a piece of code that relies on an external object `testObj`, can setup expectations (testify) and assert that they indeed happened: + +```go +package yours + +import ( + "testing" + "github.com/stretchr/testify/mock" +) + +/* + Test objects +*/ + +// MyMockedObject is a mocked object that implements an interface +// that describes an object that the code I am testing relies on. +type MyMockedObject struct{ + mock.Mock +} + +// DoSomething is a method on MyMockedObject that implements some interface +// and just records the activity, and returns what the Mock object tells it to. +// +// In the real object, this method would do something useful, but since this +// is a mocked object - we're just going to stub it out. +// +// NOTE: This method is not being tested here, code that uses this object is. +func (m *MyMockedObject) DoSomething(number int) (bool, error) { + + args := m.Called(number) + return args.Bool(0), args.Error(1) + +} + +/* + Actual test functions +*/ + +// TestSomething is an example of how to use our test object to +// make assertions about some target code we are testing. +func TestSomething(t *testing.T) { + + // create an instance of our test object + testObj := new(MyMockedObject) + + // setup expectations + testObj.On("DoSomething", 123).Return(true, nil) + + // call the code we are testing + targetFuncThatDoesSomethingWithObj(testObj) + + // assert that the expectations were met + testObj.AssertExpectations(t) + + +} + +// TestSomethingElse is a second example of how to use our test object to +// make assertions about some target code we are testing. +// This time using a placeholder. Placeholders might be used when the +// data being passed in is normally dynamically generated and cannot be +// predicted beforehand (eg. containing hashes that are time sensitive) +func TestSomethingElse(t *testing.T) { + + // create an instance of our test object + testObj := new(MyMockedObject) + + // setup expectations with a placeholder in the argument list + testObj.On("DoSomething", mock.Anything).Return(true, nil) + + // call the code we are testing + targetFuncThatDoesSomethingWithObj(testObj) + + // assert that the expectations were met + testObj.AssertExpectations(t) + + +} +``` + +For more information on how to write mock code, check out the [API documentation for the `mock` package](http://godoc.org/github.com/stretchr/testify/mock). + +You can use the [mockery tool](http://github.com/vektra/mockery) to autogenerate the mock code against an interface as well, making using mocks much quicker. + +[`suite`](http://godoc.org/github.com/stretchr/testify/suite "API documentation") package +----------------------------------------------------------------------------------------- + +The `suite` package provides functionality that you might be used to from more common object oriented languages. With it, you can build a testing suite as a struct, build setup/teardown methods and testing methods on your struct, and run them with 'go test' as per normal. + +An example suite is shown below: + +```go +// Basic imports +import ( + "testing" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/suite" +) + +// Define the suite, and absorb the built-in basic suite +// functionality from testify - including a T() method which +// returns the current testing context +type ExampleTestSuite struct { + suite.Suite + VariableThatShouldStartAtFive int +} + +// Make sure that VariableThatShouldStartAtFive is set to five +// before each test +func (suite *ExampleTestSuite) SetupTest() { + suite.VariableThatShouldStartAtFive = 5 +} + +// All methods that begin with "Test" are run as tests within a +// suite. +func (suite *ExampleTestSuite) TestExample() { + assert.Equal(suite.T(), 5, suite.VariableThatShouldStartAtFive) +} + +// In order for 'go test' to run this suite, we need to create +// a normal test function and pass our suite to suite.Run +func TestExampleTestSuite(t *testing.T) { + suite.Run(t, new(ExampleTestSuite)) +} +``` + +For a more complete example, using all of the functionality provided by the suite package, look at our [example testing suite](https://github.com/stretchr/testify/blob/master/suite/suite_test.go) + +For more information on writing suites, check out the [API documentation for the `suite` package](http://godoc.org/github.com/stretchr/testify/suite). + +`Suite` object has assertion methods: + +```go +// Basic imports +import ( + "testing" + "github.com/stretchr/testify/suite" +) + +// Define the suite, and absorb the built-in basic suite +// functionality from testify - including assertion methods. +type ExampleTestSuite struct { + suite.Suite + VariableThatShouldStartAtFive int +} + +// Make sure that VariableThatShouldStartAtFive is set to five +// before each test +func (suite *ExampleTestSuite) SetupTest() { + suite.VariableThatShouldStartAtFive = 5 +} + +// All methods that begin with "Test" are run as tests within a +// suite. +func (suite *ExampleTestSuite) TestExample() { + suite.Equal(suite.VariableThatShouldStartAtFive, 5) +} + +// In order for 'go test' to run this suite, we need to create +// a normal test function and pass our suite to suite.Run +func TestExampleTestSuite(t *testing.T) { + suite.Run(t, new(ExampleTestSuite)) +} +``` + +------ + +Installation +============ + +To install Testify, use `go get`: + + go get github.com/stretchr/testify + +This will then make the following packages available to you: + + github.com/stretchr/testify/assert + github.com/stretchr/testify/require + github.com/stretchr/testify/mock + github.com/stretchr/testify/suite + github.com/stretchr/testify/http (deprecated) + +Import the `testify/assert` package into your code using this template: + +```go +package yours + +import ( + "testing" + "github.com/stretchr/testify/assert" +) + +func TestSomething(t *testing.T) { + + assert.True(t, true, "True is true!") + +} +``` + +------ + +Staying up to date +================== + +To update Testify to the latest version, use `go get -u github.com/stretchr/testify`. + +------ + +Supported go versions +================== + +We support the three major Go versions, which are 1.9, 1.10, and 1.11 at the moment. + +------ + +Contributing +============ + +Please feel free to submit issues, fork the repository and send pull requests! + +When submitting an issue, we ask that you please include a complete test function that demonstrates the issue. Extra credit for those using Testify to write the test code that demonstrates it. + +------ + +License +======= + +This project is licensed under the terms of the MIT license. diff --git a/vendor/github.com/stretchr/testify/_codegen/main.go b/vendor/github.com/stretchr/testify/_codegen/main.go new file mode 100644 index 0000000..2e5e812 --- /dev/null +++ b/vendor/github.com/stretchr/testify/_codegen/main.go @@ -0,0 +1,316 @@ +// This program reads all assertion functions from the assert package and +// automatically generates the corresponding requires and forwarded assertions + +package main + +import ( + "bytes" + "flag" + "fmt" + "go/ast" + "go/build" + "go/doc" + "go/format" + "go/importer" + "go/parser" + "go/token" + "go/types" + "io" + "io/ioutil" + "log" + "os" + "path" + "regexp" + "strings" + "text/template" + + "github.com/ernesto-jimenez/gogen/imports" +) + +var ( + pkg = flag.String("assert-path", "github.com/stretchr/testify/assert", "Path to the assert package") + includeF = flag.Bool("include-format-funcs", false, "include format functions such as Errorf and Equalf") + outputPkg = flag.String("output-package", "", "package for the resulting code") + tmplFile = flag.String("template", "", "What file to load the function template from") + out = flag.String("out", "", "What file to write the source code to") +) + +func main() { + flag.Parse() + + scope, docs, err := parsePackageSource(*pkg) + if err != nil { + log.Fatal(err) + } + + importer, funcs, err := analyzeCode(scope, docs) + if err != nil { + log.Fatal(err) + } + + if err := generateCode(importer, funcs); err != nil { + log.Fatal(err) + } +} + +func generateCode(importer imports.Importer, funcs []testFunc) error { + buff := bytes.NewBuffer(nil) + + tmplHead, tmplFunc, err := parseTemplates() + if err != nil { + return err + } + + // Generate header + if err := tmplHead.Execute(buff, struct { + Name string + Imports map[string]string + }{ + *outputPkg, + importer.Imports(), + }); err != nil { + return err + } + + // Generate funcs + for _, fn := range funcs { + buff.Write([]byte("\n\n")) + if err := tmplFunc.Execute(buff, &fn); err != nil { + return err + } + } + + code, err := format.Source(buff.Bytes()) + if err != nil { + return err + } + + // Write file + output, err := outputFile() + if err != nil { + return err + } + defer output.Close() + _, err = io.Copy(output, bytes.NewReader(code)) + return err +} + +func parseTemplates() (*template.Template, *template.Template, error) { + tmplHead, err := template.New("header").Parse(headerTemplate) + if err != nil { + return nil, nil, err + } + if *tmplFile != "" { + f, err := ioutil.ReadFile(*tmplFile) + if err != nil { + return nil, nil, err + } + funcTemplate = string(f) + } + tmpl, err := template.New("function").Parse(funcTemplate) + if err != nil { + return nil, nil, err + } + return tmplHead, tmpl, nil +} + +func outputFile() (*os.File, error) { + filename := *out + if filename == "-" || (filename == "" && *tmplFile == "") { + return os.Stdout, nil + } + if filename == "" { + filename = strings.TrimSuffix(strings.TrimSuffix(*tmplFile, ".tmpl"), ".go") + ".go" + } + return os.Create(filename) +} + +// analyzeCode takes the types scope and the docs and returns the import +// information and information about all the assertion functions. +func analyzeCode(scope *types.Scope, docs *doc.Package) (imports.Importer, []testFunc, error) { + testingT := scope.Lookup("TestingT").Type().Underlying().(*types.Interface) + + importer := imports.New(*outputPkg) + var funcs []testFunc + // Go through all the top level functions + for _, fdocs := range docs.Funcs { + // Find the function + obj := scope.Lookup(fdocs.Name) + + fn, ok := obj.(*types.Func) + if !ok { + continue + } + // Check function signature has at least two arguments + sig := fn.Type().(*types.Signature) + if sig.Params().Len() < 2 { + continue + } + // Check first argument is of type testingT + first, ok := sig.Params().At(0).Type().(*types.Named) + if !ok { + continue + } + firstType, ok := first.Underlying().(*types.Interface) + if !ok { + continue + } + if !types.Implements(firstType, testingT) { + continue + } + + // Skip functions ending with f + if strings.HasSuffix(fdocs.Name, "f") && !*includeF { + continue + } + + funcs = append(funcs, testFunc{*outputPkg, fdocs, fn}) + importer.AddImportsFrom(sig.Params()) + } + return importer, funcs, nil +} + +// parsePackageSource returns the types scope and the package documentation from the package +func parsePackageSource(pkg string) (*types.Scope, *doc.Package, error) { + pd, err := build.Import(pkg, ".", 0) + if err != nil { + return nil, nil, err + } + + fset := token.NewFileSet() + files := make(map[string]*ast.File) + fileList := make([]*ast.File, len(pd.GoFiles)) + for i, fname := range pd.GoFiles { + src, err := ioutil.ReadFile(path.Join(pd.SrcRoot, pd.ImportPath, fname)) + if err != nil { + return nil, nil, err + } + f, err := parser.ParseFile(fset, fname, src, parser.ParseComments|parser.AllErrors) + if err != nil { + return nil, nil, err + } + files[fname] = f + fileList[i] = f + } + + cfg := types.Config{ + Importer: importer.Default(), + } + info := types.Info{ + Defs: make(map[*ast.Ident]types.Object), + } + tp, err := cfg.Check(pkg, fset, fileList, &info) + if err != nil { + return nil, nil, err + } + + scope := tp.Scope() + + ap, _ := ast.NewPackage(fset, files, nil, nil) + docs := doc.New(ap, pkg, 0) + + return scope, docs, nil +} + +type testFunc struct { + CurrentPkg string + DocInfo *doc.Func + TypeInfo *types.Func +} + +func (f *testFunc) Qualifier(p *types.Package) string { + if p == nil || p.Name() == f.CurrentPkg { + return "" + } + return p.Name() +} + +func (f *testFunc) Params() string { + sig := f.TypeInfo.Type().(*types.Signature) + params := sig.Params() + p := "" + comma := "" + to := params.Len() + var i int + + if sig.Variadic() { + to-- + } + for i = 1; i < to; i++ { + param := params.At(i) + p += fmt.Sprintf("%s%s %s", comma, param.Name(), types.TypeString(param.Type(), f.Qualifier)) + comma = ", " + } + if sig.Variadic() { + param := params.At(params.Len() - 1) + p += fmt.Sprintf("%s%s ...%s", comma, param.Name(), types.TypeString(param.Type().(*types.Slice).Elem(), f.Qualifier)) + } + return p +} + +func (f *testFunc) ForwardedParams() string { + sig := f.TypeInfo.Type().(*types.Signature) + params := sig.Params() + p := "" + comma := "" + to := params.Len() + var i int + + if sig.Variadic() { + to-- + } + for i = 1; i < to; i++ { + param := params.At(i) + p += fmt.Sprintf("%s%s", comma, param.Name()) + comma = ", " + } + if sig.Variadic() { + param := params.At(params.Len() - 1) + p += fmt.Sprintf("%s%s...", comma, param.Name()) + } + return p +} + +func (f *testFunc) ParamsFormat() string { + return strings.Replace(f.Params(), "msgAndArgs", "msg string, args", 1) +} + +func (f *testFunc) ForwardedParamsFormat() string { + return strings.Replace(f.ForwardedParams(), "msgAndArgs", "append([]interface{}{msg}, args...)", 1) +} + +func (f *testFunc) Comment() string { + return "// " + strings.Replace(strings.TrimSpace(f.DocInfo.Doc), "\n", "\n// ", -1) +} + +func (f *testFunc) CommentFormat() string { + search := fmt.Sprintf("%s", f.DocInfo.Name) + replace := fmt.Sprintf("%sf", f.DocInfo.Name) + comment := strings.Replace(f.Comment(), search, replace, -1) + exp := regexp.MustCompile(replace + `\(((\(\)|[^)])+)\)`) + return exp.ReplaceAllString(comment, replace+`($1, "error message %s", "formatted")`) +} + +func (f *testFunc) CommentWithoutT(receiver string) string { + search := fmt.Sprintf("assert.%s(t, ", f.DocInfo.Name) + replace := fmt.Sprintf("%s.%s(", receiver, f.DocInfo.Name) + return strings.Replace(f.Comment(), search, replace, -1) +} + +var headerTemplate = `/* +* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen +* THIS FILE MUST NOT BE EDITED BY HAND +*/ + +package {{.Name}} + +import ( +{{range $path, $name := .Imports}} + {{$name}} "{{$path}}"{{end}} +) +` + +var funcTemplate = `{{.Comment}} +func (fwd *AssertionsForwarder) {{.DocInfo.Name}}({{.Params}}) bool { + return assert.{{.DocInfo.Name}}({{.ForwardedParams}}) +}` diff --git a/vendor/github.com/stretchr/testify/assert/assertion_format.go b/vendor/github.com/stretchr/testify/assert/assertion_format.go new file mode 100644 index 0000000..aa1c2b9 --- /dev/null +++ b/vendor/github.com/stretchr/testify/assert/assertion_format.go @@ -0,0 +1,484 @@ +/* +* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen +* THIS FILE MUST NOT BE EDITED BY HAND + */ + +package assert + +import ( + http "net/http" + url "net/url" + time "time" +) + +// Conditionf uses a Comparison to assert a complex condition. +func Conditionf(t TestingT, comp Comparison, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return Condition(t, comp, append([]interface{}{msg}, args...)...) +} + +// Containsf asserts that the specified string, list(array, slice...) or map contains the +// specified substring or element. +// +// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted") +// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted") +// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted") +func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return Contains(t, s, contains, append([]interface{}{msg}, args...)...) +} + +// DirExistsf checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. +func DirExistsf(t TestingT, path string, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return DirExists(t, path, append([]interface{}{msg}, args...)...) +} + +// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified +// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, +// the number of appearances of each of them in both lists should match. +// +// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted") +func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return ElementsMatch(t, listA, listB, append([]interface{}{msg}, args...)...) +} + +// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either +// a slice or a channel with len == 0. +// +// assert.Emptyf(t, obj, "error message %s", "formatted") +func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return Empty(t, object, append([]interface{}{msg}, args...)...) +} + +// Equalf asserts that two objects are equal. +// +// assert.Equalf(t, 123, 123, "error message %s", "formatted") +// +// Pointer variable equality is determined based on the equality of the +// referenced values (as opposed to the memory addresses). Function equality +// cannot be determined and will always fail. +func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return Equal(t, expected, actual, append([]interface{}{msg}, args...)...) +} + +// EqualErrorf asserts that a function returned an error (i.e. not `nil`) +// and that it is equal to the provided error. +// +// actualObj, err := SomeFunction() +// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted") +func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return EqualError(t, theError, errString, append([]interface{}{msg}, args...)...) +} + +// EqualValuesf asserts that two objects are equal or convertable to the same types +// and equal. +// +// assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123)) +func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return EqualValues(t, expected, actual, append([]interface{}{msg}, args...)...) +} + +// Errorf asserts that a function returned an error (i.e. not `nil`). +// +// actualObj, err := SomeFunction() +// if assert.Errorf(t, err, "error message %s", "formatted") { +// assert.Equal(t, expectedErrorf, err) +// } +func Errorf(t TestingT, err error, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return Error(t, err, append([]interface{}{msg}, args...)...) +} + +// Exactlyf asserts that two objects are equal in value and type. +// +// assert.Exactlyf(t, int32(123, "error message %s", "formatted"), int64(123)) +func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return Exactly(t, expected, actual, append([]interface{}{msg}, args...)...) +} + +// Failf reports a failure through +func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return Fail(t, failureMessage, append([]interface{}{msg}, args...)...) +} + +// FailNowf fails test +func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return FailNow(t, failureMessage, append([]interface{}{msg}, args...)...) +} + +// Falsef asserts that the specified value is false. +// +// assert.Falsef(t, myBool, "error message %s", "formatted") +func Falsef(t TestingT, value bool, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return False(t, value, append([]interface{}{msg}, args...)...) +} + +// FileExistsf checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. +func FileExistsf(t TestingT, path string, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return FileExists(t, path, append([]interface{}{msg}, args...)...) +} + +// HTTPBodyContainsf asserts that a specified handler returns a +// body that contains a string. +// +// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") +// +// Returns whether the assertion was successful (true) or not (false). +func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return HTTPBodyContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...) +} + +// HTTPBodyNotContainsf asserts that a specified handler returns a +// body that does not contain a string. +// +// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") +// +// Returns whether the assertion was successful (true) or not (false). +func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return HTTPBodyNotContains(t, handler, method, url, values, str, append([]interface{}{msg}, args...)...) +} + +// HTTPErrorf asserts that a specified handler returns an error status code. +// +// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// +// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). +func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return HTTPError(t, handler, method, url, values, append([]interface{}{msg}, args...)...) +} + +// HTTPRedirectf asserts that a specified handler returns a redirect status code. +// +// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// +// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). +func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return HTTPRedirect(t, handler, method, url, values, append([]interface{}{msg}, args...)...) +} + +// HTTPSuccessf asserts that a specified handler returns a success status code. +// +// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") +// +// Returns whether the assertion was successful (true) or not (false). +func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return HTTPSuccess(t, handler, method, url, values, append([]interface{}{msg}, args...)...) +} + +// Implementsf asserts that an object is implemented by the specified interface. +// +// assert.Implementsf(t, (*MyInterface, "error message %s", "formatted")(nil), new(MyObject)) +func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return Implements(t, interfaceObject, object, append([]interface{}{msg}, args...)...) +} + +// InDeltaf asserts that the two numerals are within delta of each other. +// +// assert.InDeltaf(t, math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01) +func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return InDelta(t, expected, actual, delta, append([]interface{}{msg}, args...)...) +} + +// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. +func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return InDeltaMapValues(t, expected, actual, delta, append([]interface{}{msg}, args...)...) +} + +// InDeltaSlicef is the same as InDelta, except it compares two slices. +func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return InDeltaSlice(t, expected, actual, delta, append([]interface{}{msg}, args...)...) +} + +// InEpsilonf asserts that expected and actual have a relative error less than epsilon +func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return InEpsilon(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...) +} + +// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices. +func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return InEpsilonSlice(t, expected, actual, epsilon, append([]interface{}{msg}, args...)...) +} + +// IsTypef asserts that the specified objects are of the same type. +func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return IsType(t, expectedType, object, append([]interface{}{msg}, args...)...) +} + +// JSONEqf asserts that two JSON strings are equivalent. +// +// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") +func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return JSONEq(t, expected, actual, append([]interface{}{msg}, args...)...) +} + +// Lenf asserts that the specified object has specific length. +// Lenf also fails if the object has a type that len() not accept. +// +// assert.Lenf(t, mySlice, 3, "error message %s", "formatted") +func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return Len(t, object, length, append([]interface{}{msg}, args...)...) +} + +// Nilf asserts that the specified object is nil. +// +// assert.Nilf(t, err, "error message %s", "formatted") +func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return Nil(t, object, append([]interface{}{msg}, args...)...) +} + +// NoErrorf asserts that a function returned no error (i.e. `nil`). +// +// actualObj, err := SomeFunction() +// if assert.NoErrorf(t, err, "error message %s", "formatted") { +// assert.Equal(t, expectedObj, actualObj) +// } +func NoErrorf(t TestingT, err error, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return NoError(t, err, append([]interface{}{msg}, args...)...) +} + +// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the +// specified substring or element. +// +// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted") +// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted") +// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted") +func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return NotContains(t, s, contains, append([]interface{}{msg}, args...)...) +} + +// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either +// a slice or a channel with len == 0. +// +// if assert.NotEmptyf(t, obj, "error message %s", "formatted") { +// assert.Equal(t, "two", obj[1]) +// } +func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return NotEmpty(t, object, append([]interface{}{msg}, args...)...) +} + +// NotEqualf asserts that the specified values are NOT equal. +// +// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted") +// +// Pointer variable equality is determined based on the equality of the +// referenced values (as opposed to the memory addresses). +func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return NotEqual(t, expected, actual, append([]interface{}{msg}, args...)...) +} + +// NotNilf asserts that the specified object is not nil. +// +// assert.NotNilf(t, err, "error message %s", "formatted") +func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return NotNil(t, object, append([]interface{}{msg}, args...)...) +} + +// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic. +// +// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted") +func NotPanicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return NotPanics(t, f, append([]interface{}{msg}, args...)...) +} + +// NotRegexpf asserts that a specified regexp does not match a string. +// +// assert.NotRegexpf(t, regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting") +// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted") +func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return NotRegexp(t, rx, str, append([]interface{}{msg}, args...)...) +} + +// NotSubsetf asserts that the specified list(array, slice...) contains not all +// elements given in the specified subset(array, slice...). +// +// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") +func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return NotSubset(t, list, subset, append([]interface{}{msg}, args...)...) +} + +// NotZerof asserts that i is not the zero value for its type. +func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return NotZero(t, i, append([]interface{}{msg}, args...)...) +} + +// Panicsf asserts that the code inside the specified PanicTestFunc panics. +// +// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted") +func Panicsf(t TestingT, f PanicTestFunc, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return Panics(t, f, append([]interface{}{msg}, args...)...) +} + +// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that +// the recovered panic value equals the expected panic value. +// +// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") +func PanicsWithValuef(t TestingT, expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return PanicsWithValue(t, expected, f, append([]interface{}{msg}, args...)...) +} + +// Regexpf asserts that a specified regexp matches a string. +// +// assert.Regexpf(t, regexp.MustCompile("start", "error message %s", "formatted"), "it's starting") +// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted") +func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return Regexp(t, rx, str, append([]interface{}{msg}, args...)...) +} + +// Subsetf asserts that the specified list(array, slice...) contains all +// elements given in the specified subset(array, slice...). +// +// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") +func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return Subset(t, list, subset, append([]interface{}{msg}, args...)...) +} + +// Truef asserts that the specified value is true. +// +// assert.Truef(t, myBool, "error message %s", "formatted") +func Truef(t TestingT, value bool, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return True(t, value, append([]interface{}{msg}, args...)...) +} + +// WithinDurationf asserts that the two times are within duration delta of each other. +// +// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") +func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return WithinDuration(t, expected, actual, delta, append([]interface{}{msg}, args...)...) +} + +// Zerof asserts that i is the zero value for its type. +func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + return Zero(t, i, append([]interface{}{msg}, args...)...) +} diff --git a/vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl b/vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl new file mode 100644 index 0000000..d2bb0b8 --- /dev/null +++ b/vendor/github.com/stretchr/testify/assert/assertion_format.go.tmpl @@ -0,0 +1,5 @@ +{{.CommentFormat}} +func {{.DocInfo.Name}}f(t TestingT, {{.ParamsFormat}}) bool { + if h, ok := t.(tHelper); ok { h.Helper() } + return {{.DocInfo.Name}}(t, {{.ForwardedParamsFormat}}) +} diff --git a/vendor/github.com/stretchr/testify/assert/assertion_forward.go b/vendor/github.com/stretchr/testify/assert/assertion_forward.go index 368992b..de39f79 100644 --- a/vendor/github.com/stretchr/testify/assert/assertion_forward.go +++ b/vendor/github.com/stretchr/testify/assert/assertion_forward.go @@ -13,37 +13,119 @@ import ( // Condition uses a Comparison to assert a complex condition. func (a *Assertions) Condition(comp Comparison, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return Condition(a.t, comp, msgAndArgs...) } +// Conditionf uses a Comparison to assert a complex condition. +func (a *Assertions) Conditionf(comp Comparison, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Conditionf(a.t, comp, msg, args...) +} + // Contains asserts that the specified string, list(array, slice...) or map contains the // specified substring or element. // -// a.Contains("Hello World", "World", "But 'Hello World' does contain 'World'") -// a.Contains(["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'") -// a.Contains({"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'") -// -// Returns whether the assertion was successful (true) or not (false). +// a.Contains("Hello World", "World") +// a.Contains(["Hello", "World"], "World") +// a.Contains({"Hello": "World"}, "Hello") func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return Contains(a.t, s, contains, msgAndArgs...) } +// Containsf asserts that the specified string, list(array, slice...) or map contains the +// specified substring or element. +// +// a.Containsf("Hello World", "World", "error message %s", "formatted") +// a.Containsf(["Hello", "World"], "World", "error message %s", "formatted") +// a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted") +func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Containsf(a.t, s, contains, msg, args...) +} + +// DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. +func (a *Assertions) DirExists(path string, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return DirExists(a.t, path, msgAndArgs...) +} + +// DirExistsf checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. +func (a *Assertions) DirExistsf(path string, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return DirExistsf(a.t, path, msg, args...) +} + +// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified +// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, +// the number of appearances of each of them in both lists should match. +// +// a.ElementsMatch([1, 3, 2, 3], [1, 3, 3, 2]) +func (a *Assertions) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return ElementsMatch(a.t, listA, listB, msgAndArgs...) +} + +// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified +// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, +// the number of appearances of each of them in both lists should match. +// +// a.ElementsMatchf([1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted") +func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return ElementsMatchf(a.t, listA, listB, msg, args...) +} + // Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either // a slice or a channel with len == 0. // // a.Empty(obj) -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return Empty(a.t, object, msgAndArgs...) } +// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either +// a slice or a channel with len == 0. +// +// a.Emptyf(obj, "error message %s", "formatted") +func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Emptyf(a.t, object, msg, args...) +} + // Equal asserts that two objects are equal. // -// a.Equal(123, 123, "123 and 123 should be equal") +// a.Equal(123, 123) // -// Returns whether the assertion was successful (true) or not (false). +// Pointer variable equality is determined based on the equality of the +// referenced values (as opposed to the memory addresses). Function equality +// cannot be determined and will always fail. func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return Equal(a.t, expected, actual, msgAndArgs...) } @@ -51,83 +133,226 @@ func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs // and that it is equal to the provided error. // // actualObj, err := SomeFunction() -// if assert.Error(t, err, "An error was expected") { -// assert.Equal(t, err, expectedError) -// } -// -// Returns whether the assertion was successful (true) or not (false). +// a.EqualError(err, expectedErrorString) func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return EqualError(a.t, theError, errString, msgAndArgs...) } +// EqualErrorf asserts that a function returned an error (i.e. not `nil`) +// and that it is equal to the provided error. +// +// actualObj, err := SomeFunction() +// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted") +func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return EqualErrorf(a.t, theError, errString, msg, args...) +} + // EqualValues asserts that two objects are equal or convertable to the same types // and equal. // -// a.EqualValues(uint32(123), int32(123), "123 and 123 should be equal") -// -// Returns whether the assertion was successful (true) or not (false). +// a.EqualValues(uint32(123), int32(123)) func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return EqualValues(a.t, expected, actual, msgAndArgs...) } +// EqualValuesf asserts that two objects are equal or convertable to the same types +// and equal. +// +// a.EqualValuesf(uint32(123, "error message %s", "formatted"), int32(123)) +func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return EqualValuesf(a.t, expected, actual, msg, args...) +} + +// Equalf asserts that two objects are equal. +// +// a.Equalf(123, 123, "error message %s", "formatted") +// +// Pointer variable equality is determined based on the equality of the +// referenced values (as opposed to the memory addresses). Function equality +// cannot be determined and will always fail. +func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Equalf(a.t, expected, actual, msg, args...) +} + // Error asserts that a function returned an error (i.e. not `nil`). // // actualObj, err := SomeFunction() -// if a.Error(err, "An error was expected") { -// assert.Equal(t, err, expectedError) +// if a.Error(err) { +// assert.Equal(t, expectedError, err) // } -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) Error(err error, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return Error(a.t, err, msgAndArgs...) } -// Exactly asserts that two objects are equal is value and type. +// Errorf asserts that a function returned an error (i.e. not `nil`). // -// a.Exactly(int32(123), int64(123), "123 and 123 should NOT be equal") +// actualObj, err := SomeFunction() +// if a.Errorf(err, "error message %s", "formatted") { +// assert.Equal(t, expectedErrorf, err) +// } +func (a *Assertions) Errorf(err error, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Errorf(a.t, err, msg, args...) +} + +// Exactly asserts that two objects are equal in value and type. // -// Returns whether the assertion was successful (true) or not (false). +// a.Exactly(int32(123), int64(123)) func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return Exactly(a.t, expected, actual, msgAndArgs...) } +// Exactlyf asserts that two objects are equal in value and type. +// +// a.Exactlyf(int32(123, "error message %s", "formatted"), int64(123)) +func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Exactlyf(a.t, expected, actual, msg, args...) +} + // Fail reports a failure through func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return Fail(a.t, failureMessage, msgAndArgs...) } // FailNow fails test func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return FailNow(a.t, failureMessage, msgAndArgs...) } +// FailNowf fails test +func (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return FailNowf(a.t, failureMessage, msg, args...) +} + +// Failf reports a failure through +func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Failf(a.t, failureMessage, msg, args...) +} + // False asserts that the specified value is false. // -// a.False(myBool, "myBool should be false") -// -// Returns whether the assertion was successful (true) or not (false). +// a.False(myBool) func (a *Assertions) False(value bool, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return False(a.t, value, msgAndArgs...) } +// Falsef asserts that the specified value is false. +// +// a.Falsef(myBool, "error message %s", "formatted") +func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Falsef(a.t, value, msg, args...) +} + +// FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. +func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return FileExists(a.t, path, msgAndArgs...) +} + +// FileExistsf checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. +func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return FileExistsf(a.t, path, msg, args...) +} + // HTTPBodyContains asserts that a specified handler returns a // body that contains a string. // -// a.HTTPBodyContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky") +// a.HTTPBodyContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") // // Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool { - return HTTPBodyContains(a.t, handler, method, url, values, str) +func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return HTTPBodyContains(a.t, handler, method, url, values, str, msgAndArgs...) +} + +// HTTPBodyContainsf asserts that a specified handler returns a +// body that contains a string. +// +// a.HTTPBodyContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return HTTPBodyContainsf(a.t, handler, method, url, values, str, msg, args...) } // HTTPBodyNotContains asserts that a specified handler returns a // body that does not contain a string. // -// a.HTTPBodyNotContains(myHandler, "www.google.com", nil, "I'm Feeling Lucky") +// a.HTTPBodyNotContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") // // Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}) bool { - return HTTPBodyNotContains(a.t, handler, method, url, values, str) +func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return HTTPBodyNotContains(a.t, handler, method, url, values, str, msgAndArgs...) +} + +// HTTPBodyNotContainsf asserts that a specified handler returns a +// body that does not contain a string. +// +// a.HTTPBodyNotContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return HTTPBodyNotContainsf(a.t, handler, method, url, values, str, msg, args...) } // HTTPError asserts that a specified handler returns an error status code. @@ -135,8 +360,23 @@ func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string // a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values) bool { - return HTTPError(a.t, handler, method, url, values) +func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return HTTPError(a.t, handler, method, url, values, msgAndArgs...) +} + +// HTTPErrorf asserts that a specified handler returns an error status code. +// +// a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// +// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). +func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return HTTPErrorf(a.t, handler, method, url, values, msg, args...) } // HTTPRedirect asserts that a specified handler returns a redirect status code. @@ -144,8 +384,23 @@ func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url stri // a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values) bool { - return HTTPRedirect(a.t, handler, method, url, values) +func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return HTTPRedirect(a.t, handler, method, url, values, msgAndArgs...) +} + +// HTTPRedirectf asserts that a specified handler returns a redirect status code. +// +// a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// +// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). +func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return HTTPRedirectf(a.t, handler, method, url, values, msg, args...) } // HTTPSuccess asserts that a specified handler returns a success status code. @@ -153,196 +408,549 @@ func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url s // a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil) // // Returns whether the assertion was successful (true) or not (false). -func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values) bool { - return HTTPSuccess(a.t, handler, method, url, values) +func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return HTTPSuccess(a.t, handler, method, url, values, msgAndArgs...) +} + +// HTTPSuccessf asserts that a specified handler returns a success status code. +// +// a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return HTTPSuccessf(a.t, handler, method, url, values, msg, args...) } // Implements asserts that an object is implemented by the specified interface. // -// a.Implements((*MyInterface)(nil), new(MyObject), "MyObject") +// a.Implements((*MyInterface)(nil), new(MyObject)) func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return Implements(a.t, interfaceObject, object, msgAndArgs...) } +// Implementsf asserts that an object is implemented by the specified interface. +// +// a.Implementsf((*MyInterface, "error message %s", "formatted")(nil), new(MyObject)) +func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Implementsf(a.t, interfaceObject, object, msg, args...) +} + // InDelta asserts that the two numerals are within delta of each other. // // a.InDelta(math.Pi, (22 / 7.0), 0.01) -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return InDelta(a.t, expected, actual, delta, msgAndArgs...) } +// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. +func (a *Assertions) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return InDeltaMapValues(a.t, expected, actual, delta, msgAndArgs...) +} + +// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. +func (a *Assertions) InDeltaMapValuesf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return InDeltaMapValuesf(a.t, expected, actual, delta, msg, args...) +} + // InDeltaSlice is the same as InDelta, except it compares two slices. func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...) } -// InEpsilon asserts that expected and actual have a relative error less than epsilon +// InDeltaSlicef is the same as InDelta, except it compares two slices. +func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return InDeltaSlicef(a.t, expected, actual, delta, msg, args...) +} + +// InDeltaf asserts that the two numerals are within delta of each other. // -// Returns whether the assertion was successful (true) or not (false). +// a.InDeltaf(math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01) +func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return InDeltaf(a.t, expected, actual, delta, msg, args...) +} + +// InEpsilon asserts that expected and actual have a relative error less than epsilon func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...) } -// InEpsilonSlice is the same as InEpsilon, except it compares two slices. -func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { - return InEpsilonSlice(a.t, expected, actual, delta, msgAndArgs...) +// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices. +func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...) +} + +// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices. +func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...) +} + +// InEpsilonf asserts that expected and actual have a relative error less than epsilon +func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return InEpsilonf(a.t, expected, actual, epsilon, msg, args...) } // IsType asserts that the specified objects are of the same type. func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return IsType(a.t, expectedType, object, msgAndArgs...) } +// IsTypef asserts that the specified objects are of the same type. +func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return IsTypef(a.t, expectedType, object, msg, args...) +} + // JSONEq asserts that two JSON strings are equivalent. // // a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return JSONEq(a.t, expected, actual, msgAndArgs...) } +// JSONEqf asserts that two JSON strings are equivalent. +// +// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") +func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return JSONEqf(a.t, expected, actual, msg, args...) +} + // Len asserts that the specified object has specific length. // Len also fails if the object has a type that len() not accept. // -// a.Len(mySlice, 3, "The size of slice is not 3") -// -// Returns whether the assertion was successful (true) or not (false). +// a.Len(mySlice, 3) func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return Len(a.t, object, length, msgAndArgs...) } +// Lenf asserts that the specified object has specific length. +// Lenf also fails if the object has a type that len() not accept. +// +// a.Lenf(mySlice, 3, "error message %s", "formatted") +func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Lenf(a.t, object, length, msg, args...) +} + // Nil asserts that the specified object is nil. // -// a.Nil(err, "err should be nothing") -// -// Returns whether the assertion was successful (true) or not (false). +// a.Nil(err) func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return Nil(a.t, object, msgAndArgs...) } +// Nilf asserts that the specified object is nil. +// +// a.Nilf(err, "error message %s", "formatted") +func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Nilf(a.t, object, msg, args...) +} + // NoError asserts that a function returned no error (i.e. `nil`). // // actualObj, err := SomeFunction() // if a.NoError(err) { -// assert.Equal(t, actualObj, expectedObj) +// assert.Equal(t, expectedObj, actualObj) // } -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return NoError(a.t, err, msgAndArgs...) } +// NoErrorf asserts that a function returned no error (i.e. `nil`). +// +// actualObj, err := SomeFunction() +// if a.NoErrorf(err, "error message %s", "formatted") { +// assert.Equal(t, expectedObj, actualObj) +// } +func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NoErrorf(a.t, err, msg, args...) +} + // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the // specified substring or element. // -// a.NotContains("Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'") -// a.NotContains(["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'") -// a.NotContains({"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'") -// -// Returns whether the assertion was successful (true) or not (false). +// a.NotContains("Hello World", "Earth") +// a.NotContains(["Hello", "World"], "Earth") +// a.NotContains({"Hello": "World"}, "Earth") func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return NotContains(a.t, s, contains, msgAndArgs...) } +// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the +// specified substring or element. +// +// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted") +// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted") +// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted") +func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NotContainsf(a.t, s, contains, msg, args...) +} + // NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either // a slice or a channel with len == 0. // // if a.NotEmpty(obj) { // assert.Equal(t, "two", obj[1]) // } -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return NotEmpty(a.t, object, msgAndArgs...) } +// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either +// a slice or a channel with len == 0. +// +// if a.NotEmptyf(obj, "error message %s", "formatted") { +// assert.Equal(t, "two", obj[1]) +// } +func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NotEmptyf(a.t, object, msg, args...) +} + // NotEqual asserts that the specified values are NOT equal. // -// a.NotEqual(obj1, obj2, "two objects shouldn't be equal") +// a.NotEqual(obj1, obj2) // -// Returns whether the assertion was successful (true) or not (false). +// Pointer variable equality is determined based on the equality of the +// referenced values (as opposed to the memory addresses). func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return NotEqual(a.t, expected, actual, msgAndArgs...) } +// NotEqualf asserts that the specified values are NOT equal. +// +// a.NotEqualf(obj1, obj2, "error message %s", "formatted") +// +// Pointer variable equality is determined based on the equality of the +// referenced values (as opposed to the memory addresses). +func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NotEqualf(a.t, expected, actual, msg, args...) +} + // NotNil asserts that the specified object is not nil. // -// a.NotNil(err, "err should be something") -// -// Returns whether the assertion was successful (true) or not (false). +// a.NotNil(err) func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return NotNil(a.t, object, msgAndArgs...) } +// NotNilf asserts that the specified object is not nil. +// +// a.NotNilf(err, "error message %s", "formatted") +func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NotNilf(a.t, object, msg, args...) +} + // NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. // -// a.NotPanics(func(){ -// RemainCalm() -// }, "Calling RemainCalm() should NOT panic") -// -// Returns whether the assertion was successful (true) or not (false). +// a.NotPanics(func(){ RemainCalm() }) func (a *Assertions) NotPanics(f PanicTestFunc, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return NotPanics(a.t, f, msgAndArgs...) } +// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic. +// +// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted") +func (a *Assertions) NotPanicsf(f PanicTestFunc, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NotPanicsf(a.t, f, msg, args...) +} + // NotRegexp asserts that a specified regexp does not match a string. // // a.NotRegexp(regexp.MustCompile("starts"), "it's starting") // a.NotRegexp("^start", "it's not starting") -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return NotRegexp(a.t, rx, str, msgAndArgs...) } -// NotZero asserts that i is not the zero value for its type and returns the truth. +// NotRegexpf asserts that a specified regexp does not match a string. +// +// a.NotRegexpf(regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting") +// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted") +func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NotRegexpf(a.t, rx, str, msg, args...) +} + +// NotSubset asserts that the specified list(array, slice...) contains not all +// elements given in the specified subset(array, slice...). +// +// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") +func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NotSubset(a.t, list, subset, msgAndArgs...) +} + +// NotSubsetf asserts that the specified list(array, slice...) contains not all +// elements given in the specified subset(array, slice...). +// +// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") +func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NotSubsetf(a.t, list, subset, msg, args...) +} + +// NotZero asserts that i is not the zero value for its type. func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return NotZero(a.t, i, msgAndArgs...) } +// NotZerof asserts that i is not the zero value for its type. +func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return NotZerof(a.t, i, msg, args...) +} + // Panics asserts that the code inside the specified PanicTestFunc panics. // -// a.Panics(func(){ -// GoCrazy() -// }, "Calling GoCrazy() should panic") -// -// Returns whether the assertion was successful (true) or not (false). +// a.Panics(func(){ GoCrazy() }) func (a *Assertions) Panics(f PanicTestFunc, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return Panics(a.t, f, msgAndArgs...) } +// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that +// the recovered panic value equals the expected panic value. +// +// a.PanicsWithValue("crazy error", func(){ GoCrazy() }) +func (a *Assertions) PanicsWithValue(expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return PanicsWithValue(a.t, expected, f, msgAndArgs...) +} + +// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that +// the recovered panic value equals the expected panic value. +// +// a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted") +func (a *Assertions) PanicsWithValuef(expected interface{}, f PanicTestFunc, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return PanicsWithValuef(a.t, expected, f, msg, args...) +} + +// Panicsf asserts that the code inside the specified PanicTestFunc panics. +// +// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted") +func (a *Assertions) Panicsf(f PanicTestFunc, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Panicsf(a.t, f, msg, args...) +} + // Regexp asserts that a specified regexp matches a string. // // a.Regexp(regexp.MustCompile("start"), "it's starting") // a.Regexp("start...$", "it's not starting") -// -// Returns whether the assertion was successful (true) or not (false). func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return Regexp(a.t, rx, str, msgAndArgs...) } +// Regexpf asserts that a specified regexp matches a string. +// +// a.Regexpf(regexp.MustCompile("start", "error message %s", "formatted"), "it's starting") +// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted") +func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Regexpf(a.t, rx, str, msg, args...) +} + +// Subset asserts that the specified list(array, slice...) contains all +// elements given in the specified subset(array, slice...). +// +// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") +func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Subset(a.t, list, subset, msgAndArgs...) +} + +// Subsetf asserts that the specified list(array, slice...) contains all +// elements given in the specified subset(array, slice...). +// +// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") +func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Subsetf(a.t, list, subset, msg, args...) +} + // True asserts that the specified value is true. // -// a.True(myBool, "myBool should be true") -// -// Returns whether the assertion was successful (true) or not (false). +// a.True(myBool) func (a *Assertions) True(value bool, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return True(a.t, value, msgAndArgs...) } +// Truef asserts that the specified value is true. +// +// a.Truef(myBool, "error message %s", "formatted") +func (a *Assertions) Truef(value bool, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Truef(a.t, value, msg, args...) +} + // WithinDuration asserts that the two times are within duration delta of each other. // -// a.WithinDuration(time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s") -// -// Returns whether the assertion was successful (true) or not (false). +// a.WithinDuration(time.Now(), time.Now(), 10*time.Second) func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return WithinDuration(a.t, expected, actual, delta, msgAndArgs...) } -// Zero asserts that i is the zero value for its type and returns the truth. +// WithinDurationf asserts that the two times are within duration delta of each other. +// +// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") +func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return WithinDurationf(a.t, expected, actual, delta, msg, args...) +} + +// Zero asserts that i is the zero value for its type. func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } return Zero(a.t, i, msgAndArgs...) } + +// Zerof asserts that i is the zero value for its type. +func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) bool { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + return Zerof(a.t, i, msg, args...) +} diff --git a/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl b/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl index 99f9acf..188bb9e 100644 --- a/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl +++ b/vendor/github.com/stretchr/testify/assert/assertion_forward.go.tmpl @@ -1,4 +1,5 @@ {{.CommentWithoutT "a"}} func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) bool { + if h, ok := a.t.(tHelper); ok { h.Helper() } return {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) } diff --git a/vendor/github.com/stretchr/testify/assert/assertions.go b/vendor/github.com/stretchr/testify/assert/assertions.go index 348d5f1..9bd4a80 100644 --- a/vendor/github.com/stretchr/testify/assert/assertions.go +++ b/vendor/github.com/stretchr/testify/assert/assertions.go @@ -4,8 +4,10 @@ import ( "bufio" "bytes" "encoding/json" + "errors" "fmt" "math" + "os" "reflect" "regexp" "runtime" @@ -18,11 +20,29 @@ import ( "github.com/pmezard/go-difflib/difflib" ) +//go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_format.go.tmpl + // TestingT is an interface wrapper around *testing.T type TestingT interface { Errorf(format string, args ...interface{}) } +// ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful +// for table driven tests. +type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{}) bool + +// ValueAssertionFunc is a common function prototype when validating a single value. Can be useful +// for table driven tests. +type ValueAssertionFunc func(TestingT, interface{}, ...interface{}) bool + +// BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful +// for table driven tests. +type BoolAssertionFunc func(TestingT, bool, ...interface{}) bool + +// ErrorAssertionFunc is a common function prototype when validating an error value. Can be useful +// for table driven tests. +type ErrorAssertionFunc func(TestingT, error, ...interface{}) bool + // Comparison a custom function that returns true on success and false on failure type Comparison func() (success bool) @@ -34,13 +54,23 @@ type Comparison func() (success bool) // // This function does no assertion of any kind. func ObjectsAreEqual(expected, actual interface{}) bool { - if expected == nil || actual == nil { return expected == actual } - return reflect.DeepEqual(expected, actual) + exp, ok := expected.([]byte) + if !ok { + return reflect.DeepEqual(expected, actual) + } + act, ok := actual.([]byte) + if !ok { + return false + } + if exp == nil || act == nil { + return exp == nil && act == nil + } + return bytes.Equal(exp, act) } // ObjectsAreEqualValues gets whether two objects are equal, or if their @@ -65,7 +95,7 @@ func ObjectsAreEqualValues(expected, actual interface{}) bool { /* CallerInfo is necessary because the assert functions use the testing object internally, causing it to print the file:line of the assert method, rather than where -the problem actually occured in calling code.*/ +the problem actually occurred in calling code.*/ // CallerInfo returns an array of strings containing the file and line number // of each stack frame leading from the current test to the assert call that @@ -82,7 +112,9 @@ func CallerInfo() []string { for i := 0; ; i++ { pc, file, line, ok = runtime.Caller(i) if !ok { - return nil + // The breaks below failed to terminate the loop, and we ran off the + // end of the call stack. + break } // This is a huge edge case, but it will panic if this is the case, see #180 @@ -90,18 +122,30 @@ func CallerInfo() []string { break } - parts := strings.Split(file, "/") - dir := parts[len(parts)-2] - file = parts[len(parts)-1] - if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" { - callers = append(callers, fmt.Sprintf("%s:%d", file, line)) - } - f := runtime.FuncForPC(pc) if f == nil { break } name = f.Name() + + // testing.tRunner is the standard library function that calls + // tests. Subtests are called directly by tRunner, without going through + // the Test/Benchmark/Example function that contains the t.Run calls, so + // with subtests we should break when we hit tRunner, without adding it + // to the list of callers. + if name == "testing.tRunner" { + break + } + + parts := strings.Split(file, "/") + file = parts[len(parts)-1] + if len(parts) > 1 { + dir := parts[len(parts)-2] + if (dir != "assert" && dir != "mock" && dir != "require") || file == "mock_test.go" { + callers = append(callers, fmt.Sprintf("%s:%d", file, line)) + } + } + // Drop the package segments := strings.Split(name, ".") name = segments[len(segments)-1] @@ -130,27 +174,16 @@ func isTest(name, prefix string) bool { return !unicode.IsLower(rune) } -// getWhitespaceString returns a string that is long enough to overwrite the default -// output from the go testing framework. -func getWhitespaceString() string { - - _, file, line, ok := runtime.Caller(1) - if !ok { - return "" - } - parts := strings.Split(file, "/") - file = parts[len(parts)-1] - - return strings.Repeat(" ", len(fmt.Sprintf("%s:%d: ", file, line))) - -} - func messageFromMsgAndArgs(msgAndArgs ...interface{}) string { if len(msgAndArgs) == 0 || msgAndArgs == nil { return "" } if len(msgAndArgs) == 1 { - return msgAndArgs[0].(string) + msg := msgAndArgs[0] + if msgAsStr, ok := msg.(string); ok { + return msgAsStr + } + return fmt.Sprintf("%+v", msg) } if len(msgAndArgs) > 1 { return fmt.Sprintf(msgAndArgs[0].(string), msgAndArgs[1:]...) @@ -158,22 +191,18 @@ func messageFromMsgAndArgs(msgAndArgs ...interface{}) string { return "" } -// Indents all lines of the message by appending a number of tabs to each line, in an output format compatible with Go's -// test printing (see inner comment for specifics) -func indentMessageLines(message string, tabs int) string { +// Aligns the provided message so that all lines after the first line start at the same location as the first line. +// Assumes that the first line starts at the correct location (after carriage return, tab, label, spacer and tab). +// The longestLabelLen parameter specifies the length of the longest label in the output (required becaues this is the +// basis on which the alignment occurs). +func indentMessageLines(message string, longestLabelLen int) string { outBuf := new(bytes.Buffer) for i, scanner := 0, bufio.NewScanner(strings.NewReader(message)); scanner.Scan(); i++ { + // no need to align first line because it starts at the correct location (after the label) if i != 0 { - outBuf.WriteRune('\n') - } - for ii := 0; ii < tabs; ii++ { - outBuf.WriteRune('\t') - // Bizarrely, all lines except the first need one fewer tabs prepended, so deliberately advance the counter - // by 1 prematurely. - if ii == 0 && i > 0 { - ii++ - } + // append alignLen+1 spaces to align with "{{longestLabel}}:" before adding tab + outBuf.WriteString("\n\t" + strings.Repeat(" ", longestLabelLen+1) + "\t") } outBuf.WriteString(scanner.Text()) } @@ -187,6 +216,9 @@ type failNower interface { // FailNow fails test func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } Fail(t, failureMessage, msgAndArgs...) // We cannot extend TestingT with FailNow() and @@ -205,46 +237,83 @@ func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool // Fail reports a failure through func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + content := []labeledContent{ + {"Error Trace", strings.Join(CallerInfo(), "\n\t\t\t")}, + {"Error", failureMessage}, + } + + // Add test name if the Go version supports it + if n, ok := t.(interface { + Name() string + }); ok { + content = append(content, labeledContent{"Test", n.Name()}) + } message := messageFromMsgAndArgs(msgAndArgs...) - - errorTrace := strings.Join(CallerInfo(), "\n\r\t\t\t") if len(message) > 0 { - t.Errorf("\r%s\r\tError Trace:\t%s\n"+ - "\r\tError:%s\n"+ - "\r\tMessages:\t%s\n\r", - getWhitespaceString(), - errorTrace, - indentMessageLines(failureMessage, 2), - message) - } else { - t.Errorf("\r%s\r\tError Trace:\t%s\n"+ - "\r\tError:%s\n\r", - getWhitespaceString(), - errorTrace, - indentMessageLines(failureMessage, 2)) + content = append(content, labeledContent{"Messages", message}) } + t.Errorf("\n%s", ""+labeledOutput(content...)) + return false } +type labeledContent struct { + label string + content string +} + +// labeledOutput returns a string consisting of the provided labeledContent. Each labeled output is appended in the following manner: +// +// \t{{label}}:{{align_spaces}}\t{{content}}\n +// +// The initial carriage return is required to undo/erase any padding added by testing.T.Errorf. The "\t{{label}}:" is for the label. +// If a label is shorter than the longest label provided, padding spaces are added to make all the labels match in length. Once this +// alignment is achieved, "\t{{content}}\n" is added for the output. +// +// If the content of the labeledOutput contains line breaks, the subsequent lines are aligned so that they start at the same location as the first line. +func labeledOutput(content ...labeledContent) string { + longestLabel := 0 + for _, v := range content { + if len(v.label) > longestLabel { + longestLabel = len(v.label) + } + } + var output string + for _, v := range content { + output += "\t" + v.label + ":" + strings.Repeat(" ", longestLabel-len(v.label)) + "\t" + indentMessageLines(v.content, longestLabel) + "\n" + } + return output +} + // Implements asserts that an object is implemented by the specified interface. // -// assert.Implements(t, (*MyInterface)(nil), new(MyObject), "MyObject") +// assert.Implements(t, (*MyInterface)(nil), new(MyObject)) func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) bool { - + if h, ok := t.(tHelper); ok { + h.Helper() + } interfaceType := reflect.TypeOf(interfaceObject).Elem() + if object == nil { + return Fail(t, fmt.Sprintf("Cannot check if nil implements %v", interfaceType), msgAndArgs...) + } if !reflect.TypeOf(object).Implements(interfaceType) { return Fail(t, fmt.Sprintf("%T must implement %v", object, interfaceType), msgAndArgs...) } return true - } // IsType asserts that the specified objects are of the same type. func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } if !ObjectsAreEqual(reflect.TypeOf(object), reflect.TypeOf(expectedType)) { return Fail(t, fmt.Sprintf("Object expected to be of type %v, but was %v", reflect.TypeOf(expectedType), reflect.TypeOf(object)), msgAndArgs...) @@ -255,50 +324,82 @@ func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs // Equal asserts that two objects are equal. // -// assert.Equal(t, 123, 123, "123 and 123 should be equal") +// assert.Equal(t, 123, 123) // -// Returns whether the assertion was successful (true) or not (false). +// Pointer variable equality is determined based on the equality of the +// referenced values (as opposed to the memory addresses). Function equality +// cannot be determined and will always fail. func Equal(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if err := validateEqualArgs(expected, actual); err != nil { + return Fail(t, fmt.Sprintf("Invalid operation: %#v == %#v (%s)", + expected, actual, err), msgAndArgs...) + } if !ObjectsAreEqual(expected, actual) { diff := diff(expected, actual) - return Fail(t, fmt.Sprintf("Not equal: %#v (expected)\n"+ - " != %#v (actual)%s", expected, actual, diff), msgAndArgs...) + expected, actual = formatUnequalValues(expected, actual) + return Fail(t, fmt.Sprintf("Not equal: \n"+ + "expected: %s\n"+ + "actual : %s%s", expected, actual, diff), msgAndArgs...) } return true } +// formatUnequalValues takes two values of arbitrary types and returns string +// representations appropriate to be presented to the user. +// +// If the values are not of like type, the returned strings will be prefixed +// with the type name, and the value will be enclosed in parenthesis similar +// to a type conversion in the Go grammar. +func formatUnequalValues(expected, actual interface{}) (e string, a string) { + if reflect.TypeOf(expected) != reflect.TypeOf(actual) { + return fmt.Sprintf("%T(%#v)", expected, expected), + fmt.Sprintf("%T(%#v)", actual, actual) + } + + return fmt.Sprintf("%#v", expected), + fmt.Sprintf("%#v", actual) +} + // EqualValues asserts that two objects are equal or convertable to the same types // and equal. // -// assert.EqualValues(t, uint32(123), int32(123), "123 and 123 should be equal") -// -// Returns whether the assertion was successful (true) or not (false). +// assert.EqualValues(t, uint32(123), int32(123)) func EqualValues(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } if !ObjectsAreEqualValues(expected, actual) { - return Fail(t, fmt.Sprintf("Not equal: %#v (expected)\n"+ - " != %#v (actual)", expected, actual), msgAndArgs...) + diff := diff(expected, actual) + expected, actual = formatUnequalValues(expected, actual) + return Fail(t, fmt.Sprintf("Not equal: \n"+ + "expected: %s\n"+ + "actual : %s%s", expected, actual, diff), msgAndArgs...) } return true } -// Exactly asserts that two objects are equal is value and type. +// Exactly asserts that two objects are equal in value and type. // -// assert.Exactly(t, int32(123), int64(123), "123 and 123 should NOT be equal") -// -// Returns whether the assertion was successful (true) or not (false). +// assert.Exactly(t, int32(123), int64(123)) func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } aType := reflect.TypeOf(expected) bType := reflect.TypeOf(actual) if aType != bType { - return Fail(t, fmt.Sprintf("Types expected to match exactly\n\r\t%v != %v", aType, bType), msgAndArgs...) + return Fail(t, fmt.Sprintf("Types expected to match exactly\n\t%v != %v", aType, bType), msgAndArgs...) } return Equal(t, expected, actual, msgAndArgs...) @@ -307,16 +408,28 @@ func Exactly(t TestingT, expected, actual interface{}, msgAndArgs ...interface{} // NotNil asserts that the specified object is not nil. // -// assert.NotNil(t, err, "err should be something") -// -// Returns whether the assertion was successful (true) or not (false). +// assert.NotNil(t, err) func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } if !isNil(object) { return true } return Fail(t, "Expected value not to be nil.", msgAndArgs...) } +// containsKind checks if a specified kind in the slice of kinds. +func containsKind(kinds []reflect.Kind, kind reflect.Kind) bool { + for i := 0; i < len(kinds); i++ { + if kind == kinds[i] { + return true + } + } + + return false +} + // isNil checks if a specified object is nil or not, without Failing. func isNil(object interface{}) bool { if object == nil { @@ -325,7 +438,14 @@ func isNil(object interface{}) bool { value := reflect.ValueOf(object) kind := value.Kind() - if kind >= reflect.Chan && kind <= reflect.Slice && value.IsNil() { + isNilableKind := containsKind( + []reflect.Kind{ + reflect.Chan, reflect.Func, + reflect.Interface, reflect.Map, + reflect.Ptr, reflect.Slice}, + kind) + + if isNilableKind && value.IsNil() { return true } @@ -334,85 +454,53 @@ func isNil(object interface{}) bool { // Nil asserts that the specified object is nil. // -// assert.Nil(t, err, "err should be nothing") -// -// Returns whether the assertion was successful (true) or not (false). +// assert.Nil(t, err) func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } if isNil(object) { return true } return Fail(t, fmt.Sprintf("Expected nil, but got: %#v", object), msgAndArgs...) } -var numericZeros = []interface{}{ - int(0), - int8(0), - int16(0), - int32(0), - int64(0), - uint(0), - uint8(0), - uint16(0), - uint32(0), - uint64(0), - float32(0), - float64(0), -} - // isEmpty gets whether the specified object is considered empty or not. func isEmpty(object interface{}) bool { + // get nil case out of the way if object == nil { return true - } else if object == "" { - return true - } else if object == false { - return true - } - - for _, v := range numericZeros { - if object == v { - return true - } } objValue := reflect.ValueOf(object) switch objValue.Kind() { - case reflect.Map: - fallthrough - case reflect.Slice, reflect.Chan: - { - return (objValue.Len() == 0) - } - case reflect.Struct: - switch object.(type) { - case time.Time: - return object.(time.Time).IsZero() - } + // collection types are empty when they have no element + case reflect.Array, reflect.Chan, reflect.Map, reflect.Slice: + return objValue.Len() == 0 + // pointers are empty if nil or if the value they point to is empty case reflect.Ptr: - { - if objValue.IsNil() { - return true - } - switch object.(type) { - case *time.Time: - return object.(*time.Time).IsZero() - default: - return false - } + if objValue.IsNil() { + return true } + deref := objValue.Elem().Interface() + return isEmpty(deref) + // for all other types, compare against the zero value + default: + zero := reflect.Zero(objValue.Type()) + return reflect.DeepEqual(object, zero.Interface()) } - return false } // Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either // a slice or a channel with len == 0. // // assert.Empty(t, obj) -// -// Returns whether the assertion was successful (true) or not (false). func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } pass := isEmpty(object) if !pass { @@ -429,9 +517,10 @@ func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { // if assert.NotEmpty(t, obj) { // assert.Equal(t, "two", obj[1]) // } -// -// Returns whether the assertion was successful (true) or not (false). func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } pass := !isEmpty(object) if !pass { @@ -457,10 +546,11 @@ func getLen(x interface{}) (ok bool, length int) { // Len asserts that the specified object has specific length. // Len also fails if the object has a type that len() not accept. // -// assert.Len(t, mySlice, 3, "The size of slice is not 3") -// -// Returns whether the assertion was successful (true) or not (false). +// assert.Len(t, mySlice, 3) func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } ok, l := getLen(object) if !ok { return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", object), msgAndArgs...) @@ -474,10 +564,16 @@ func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) // True asserts that the specified value is true. // -// assert.True(t, myBool, "myBool should be true") -// -// Returns whether the assertion was successful (true) or not (false). +// assert.True(t, myBool) func True(t TestingT, value bool, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if h, ok := t.(interface { + Helper() + }); ok { + h.Helper() + } if value != true { return Fail(t, "Should be true", msgAndArgs...) @@ -489,10 +585,11 @@ func True(t TestingT, value bool, msgAndArgs ...interface{}) bool { // False asserts that the specified value is false. // -// assert.False(t, myBool, "myBool should be false") -// -// Returns whether the assertion was successful (true) or not (false). +// assert.False(t, myBool) func False(t TestingT, value bool, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } if value != false { return Fail(t, "Should be false", msgAndArgs...) @@ -504,10 +601,18 @@ func False(t TestingT, value bool, msgAndArgs ...interface{}) bool { // NotEqual asserts that the specified values are NOT equal. // -// assert.NotEqual(t, obj1, obj2, "two objects shouldn't be equal") +// assert.NotEqual(t, obj1, obj2) // -// Returns whether the assertion was successful (true) or not (false). +// Pointer variable equality is determined based on the equality of the +// referenced values (as opposed to the memory addresses). func NotEqual(t TestingT, expected, actual interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if err := validateEqualArgs(expected, actual); err != nil { + return Fail(t, fmt.Sprintf("Invalid operation: %#v != %#v (%s)", + expected, actual, err), msgAndArgs...) + } if ObjectsAreEqual(expected, actual) { return Fail(t, fmt.Sprintf("Should not be: %#v\n", actual), msgAndArgs...) @@ -558,12 +663,13 @@ func includeElement(list interface{}, element interface{}) (ok, found bool) { // Contains asserts that the specified string, list(array, slice...) or map contains the // specified substring or element. // -// assert.Contains(t, "Hello World", "World", "But 'Hello World' does contain 'World'") -// assert.Contains(t, ["Hello", "World"], "World", "But ["Hello", "World"] does contain 'World'") -// assert.Contains(t, {"Hello": "World"}, "Hello", "But {'Hello': 'World'} does contain 'Hello'") -// -// Returns whether the assertion was successful (true) or not (false). +// assert.Contains(t, "Hello World", "World") +// assert.Contains(t, ["Hello", "World"], "World") +// assert.Contains(t, {"Hello": "World"}, "Hello") func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } ok, found := includeElement(s, contains) if !ok { @@ -580,12 +686,13 @@ func Contains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bo // NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the // specified substring or element. // -// assert.NotContains(t, "Hello World", "Earth", "But 'Hello World' does NOT contain 'Earth'") -// assert.NotContains(t, ["Hello", "World"], "Earth", "But ['Hello', 'World'] does NOT contain 'Earth'") -// assert.NotContains(t, {"Hello": "World"}, "Earth", "But {'Hello': 'World'} does NOT contain 'Earth'") -// -// Returns whether the assertion was successful (true) or not (false). +// assert.NotContains(t, "Hello World", "Earth") +// assert.NotContains(t, ["Hello", "World"], "Earth") +// assert.NotContains(t, {"Hello": "World"}, "Earth") func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } ok, found := includeElement(s, contains) if !ok { @@ -599,8 +706,156 @@ func NotContains(t TestingT, s, contains interface{}, msgAndArgs ...interface{}) } +// Subset asserts that the specified list(array, slice...) contains all +// elements given in the specified subset(array, slice...). +// +// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") +func Subset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if subset == nil { + return true // we consider nil to be equal to the nil set + } + + subsetValue := reflect.ValueOf(subset) + defer func() { + if e := recover(); e != nil { + ok = false + } + }() + + listKind := reflect.TypeOf(list).Kind() + subsetKind := reflect.TypeOf(subset).Kind() + + if listKind != reflect.Array && listKind != reflect.Slice { + return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...) + } + + if subsetKind != reflect.Array && subsetKind != reflect.Slice { + return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...) + } + + for i := 0; i < subsetValue.Len(); i++ { + element := subsetValue.Index(i).Interface() + ok, found := includeElement(list, element) + if !ok { + return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...) + } + if !found { + return Fail(t, fmt.Sprintf("\"%s\" does not contain \"%s\"", list, element), msgAndArgs...) + } + } + + return true +} + +// NotSubset asserts that the specified list(array, slice...) contains not all +// elements given in the specified subset(array, slice...). +// +// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") +func NotSubset(t TestingT, list, subset interface{}, msgAndArgs ...interface{}) (ok bool) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if subset == nil { + return Fail(t, fmt.Sprintf("nil is the empty set which is a subset of every set"), msgAndArgs...) + } + + subsetValue := reflect.ValueOf(subset) + defer func() { + if e := recover(); e != nil { + ok = false + } + }() + + listKind := reflect.TypeOf(list).Kind() + subsetKind := reflect.TypeOf(subset).Kind() + + if listKind != reflect.Array && listKind != reflect.Slice { + return Fail(t, fmt.Sprintf("%q has an unsupported type %s", list, listKind), msgAndArgs...) + } + + if subsetKind != reflect.Array && subsetKind != reflect.Slice { + return Fail(t, fmt.Sprintf("%q has an unsupported type %s", subset, subsetKind), msgAndArgs...) + } + + for i := 0; i < subsetValue.Len(); i++ { + element := subsetValue.Index(i).Interface() + ok, found := includeElement(list, element) + if !ok { + return Fail(t, fmt.Sprintf("\"%s\" could not be applied builtin len()", list), msgAndArgs...) + } + if !found { + return true + } + } + + return Fail(t, fmt.Sprintf("%q is a subset of %q", subset, list), msgAndArgs...) +} + +// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified +// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, +// the number of appearances of each of them in both lists should match. +// +// assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2]) +func ElementsMatch(t TestingT, listA, listB interface{}, msgAndArgs ...interface{}) (ok bool) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if isEmpty(listA) && isEmpty(listB) { + return true + } + + aKind := reflect.TypeOf(listA).Kind() + bKind := reflect.TypeOf(listB).Kind() + + if aKind != reflect.Array && aKind != reflect.Slice { + return Fail(t, fmt.Sprintf("%q has an unsupported type %s", listA, aKind), msgAndArgs...) + } + + if bKind != reflect.Array && bKind != reflect.Slice { + return Fail(t, fmt.Sprintf("%q has an unsupported type %s", listB, bKind), msgAndArgs...) + } + + aValue := reflect.ValueOf(listA) + bValue := reflect.ValueOf(listB) + + aLen := aValue.Len() + bLen := bValue.Len() + + if aLen != bLen { + return Fail(t, fmt.Sprintf("lengths don't match: %d != %d", aLen, bLen), msgAndArgs...) + } + + // Mark indexes in bValue that we already used + visited := make([]bool, bLen) + for i := 0; i < aLen; i++ { + element := aValue.Index(i).Interface() + found := false + for j := 0; j < bLen; j++ { + if visited[j] { + continue + } + if ObjectsAreEqual(bValue.Index(j).Interface(), element) { + visited[j] = true + found = true + break + } + } + if !found { + return Fail(t, fmt.Sprintf("element %s appears more times in %s than in %s", element, aValue, bValue), msgAndArgs...) + } + } + + return true +} + // Condition uses a Comparison to assert a complex condition. func Condition(t TestingT, comp Comparison, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } result := comp() if !result { Fail(t, "Condition failed!", msgAndArgs...) @@ -636,15 +891,34 @@ func didPanic(f PanicTestFunc) (bool, interface{}) { // Panics asserts that the code inside the specified PanicTestFunc panics. // -// assert.Panics(t, func(){ -// GoCrazy() -// }, "Calling GoCrazy() should panic") -// -// Returns whether the assertion was successful (true) or not (false). +// assert.Panics(t, func(){ GoCrazy() }) func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } if funcDidPanic, panicValue := didPanic(f); !funcDidPanic { - return Fail(t, fmt.Sprintf("func %#v should panic\n\r\tPanic value:\t%v", f, panicValue), msgAndArgs...) + return Fail(t, fmt.Sprintf("func %#v should panic\n\tPanic value:\t%#v", f, panicValue), msgAndArgs...) + } + + return true +} + +// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that +// the recovered panic value equals the expected panic value. +// +// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() }) +func PanicsWithValue(t TestingT, expected interface{}, f PanicTestFunc, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + + funcDidPanic, panicValue := didPanic(f) + if !funcDidPanic { + return Fail(t, fmt.Sprintf("func %#v should panic\n\tPanic value:\t%#v", f, panicValue), msgAndArgs...) + } + if panicValue != expected { + return Fail(t, fmt.Sprintf("func %#v should panic with value:\t%#v\n\tPanic value:\t%#v", f, expected, panicValue), msgAndArgs...) } return true @@ -652,15 +926,14 @@ func Panics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool { // NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. // -// assert.NotPanics(t, func(){ -// RemainCalm() -// }, "Calling RemainCalm() should NOT panic") -// -// Returns whether the assertion was successful (true) or not (false). +// assert.NotPanics(t, func(){ RemainCalm() }) func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } if funcDidPanic, panicValue := didPanic(f); funcDidPanic { - return Fail(t, fmt.Sprintf("func %#v should not panic\n\r\tPanic value:\t%v", f, panicValue), msgAndArgs...) + return Fail(t, fmt.Sprintf("func %#v should not panic\n\tPanic value:\t%v", f, panicValue), msgAndArgs...) } return true @@ -668,10 +941,11 @@ func NotPanics(t TestingT, f PanicTestFunc, msgAndArgs ...interface{}) bool { // WithinDuration asserts that the two times are within duration delta of each other. // -// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second, "The difference should not be more than 10s") -// -// Returns whether the assertion was successful (true) or not (false). +// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second) func WithinDuration(t TestingT, expected, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } dt := expected.Sub(actual) if dt < -delta || dt > delta { @@ -708,6 +982,8 @@ func toFloat(x interface{}) (float64, bool) { xf = float64(xn) case float64: xf = float64(xn) + case time.Duration: + xf = float64(xn) default: xok = false } @@ -718,9 +994,10 @@ func toFloat(x interface{}) (float64, bool) { // InDelta asserts that the two numerals are within delta of each other. // // assert.InDelta(t, math.Pi, (22 / 7.0), 0.01) -// -// Returns whether the assertion was successful (true) or not (false). func InDelta(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } af, aok := toFloat(expected) bf, bok := toFloat(actual) @@ -730,7 +1007,7 @@ func InDelta(t TestingT, expected, actual interface{}, delta float64, msgAndArgs } if math.IsNaN(af) { - return Fail(t, fmt.Sprintf("Actual must not be NaN"), msgAndArgs...) + return Fail(t, fmt.Sprintf("Expected must not be NaN"), msgAndArgs...) } if math.IsNaN(bf) { @@ -747,6 +1024,9 @@ func InDelta(t TestingT, expected, actual interface{}, delta float64, msgAndArgs // InDeltaSlice is the same as InDelta, except it compares two slices. func InDeltaSlice(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } if expected == nil || actual == nil || reflect.TypeOf(actual).Kind() != reflect.Slice || reflect.TypeOf(expected).Kind() != reflect.Slice { @@ -757,7 +1037,7 @@ func InDeltaSlice(t TestingT, expected, actual interface{}, delta float64, msgAn expectedSlice := reflect.ValueOf(expected) for i := 0; i < actualSlice.Len(); i++ { - result := InDelta(t, actualSlice.Index(i).Interface(), expectedSlice.Index(i).Interface(), delta) + result := InDelta(t, actualSlice.Index(i).Interface(), expectedSlice.Index(i).Interface(), delta, msgAndArgs...) if !result { return result } @@ -766,6 +1046,50 @@ func InDeltaSlice(t TestingT, expected, actual interface{}, delta float64, msgAn return true } +// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. +func InDeltaMapValues(t TestingT, expected, actual interface{}, delta float64, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if expected == nil || actual == nil || + reflect.TypeOf(actual).Kind() != reflect.Map || + reflect.TypeOf(expected).Kind() != reflect.Map { + return Fail(t, "Arguments must be maps", msgAndArgs...) + } + + expectedMap := reflect.ValueOf(expected) + actualMap := reflect.ValueOf(actual) + + if expectedMap.Len() != actualMap.Len() { + return Fail(t, "Arguments must have the same number of keys", msgAndArgs...) + } + + for _, k := range expectedMap.MapKeys() { + ev := expectedMap.MapIndex(k) + av := actualMap.MapIndex(k) + + if !ev.IsValid() { + return Fail(t, fmt.Sprintf("missing key %q in expected map", k), msgAndArgs...) + } + + if !av.IsValid() { + return Fail(t, fmt.Sprintf("missing key %q in actual map", k), msgAndArgs...) + } + + if !InDelta( + t, + ev.Interface(), + av.Interface(), + delta, + msgAndArgs..., + ) { + return false + } + } + + return true +} + func calcRelativeError(expected, actual interface{}) (float64, error) { af, aok := toFloat(expected) if !aok { @@ -776,23 +1100,24 @@ func calcRelativeError(expected, actual interface{}) (float64, error) { } bf, bok := toFloat(actual) if !bok { - return 0, fmt.Errorf("expected value %q cannot be converted to float", actual) + return 0, fmt.Errorf("actual value %q cannot be converted to float", actual) } return math.Abs(af-bf) / math.Abs(af), nil } // InEpsilon asserts that expected and actual have a relative error less than epsilon -// -// Returns whether the assertion was successful (true) or not (false). func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } actualEpsilon, err := calcRelativeError(expected, actual) if err != nil { return Fail(t, err.Error(), msgAndArgs...) } if actualEpsilon > epsilon { return Fail(t, fmt.Sprintf("Relative error is too high: %#v (expected)\n"+ - " < %#v (actual)", actualEpsilon, epsilon), msgAndArgs...) + " < %#v (actual)", epsilon, actualEpsilon), msgAndArgs...) } return true @@ -800,6 +1125,9 @@ func InEpsilon(t TestingT, expected, actual interface{}, epsilon float64, msgAnd // InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices. func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } if expected == nil || actual == nil || reflect.TypeOf(actual).Kind() != reflect.Slice || reflect.TypeOf(expected).Kind() != reflect.Slice { @@ -827,13 +1155,14 @@ func InEpsilonSlice(t TestingT, expected, actual interface{}, epsilon float64, m // // actualObj, err := SomeFunction() // if assert.NoError(t, err) { -// assert.Equal(t, actualObj, expectedObj) +// assert.Equal(t, expectedObj, actualObj) // } -// -// Returns whether the assertion was successful (true) or not (false). func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } if err != nil { - return Fail(t, fmt.Sprintf("Received unexpected error %q", err), msgAndArgs...) + return Fail(t, fmt.Sprintf("Received unexpected error:\n%+v", err), msgAndArgs...) } return true @@ -842,16 +1171,16 @@ func NoError(t TestingT, err error, msgAndArgs ...interface{}) bool { // Error asserts that a function returned an error (i.e. not `nil`). // // actualObj, err := SomeFunction() -// if assert.Error(t, err, "An error was expected") { -// assert.Equal(t, err, expectedError) +// if assert.Error(t, err) { +// assert.Equal(t, expectedError, err) // } -// -// Returns whether the assertion was successful (true) or not (false). func Error(t TestingT, err error, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } - message := messageFromMsgAndArgs(msgAndArgs...) if err == nil { - return Fail(t, "An error is expected but got nil. %s", message) + return Fail(t, "An error is expected but got nil.", msgAndArgs...) } return true @@ -861,20 +1190,23 @@ func Error(t TestingT, err error, msgAndArgs ...interface{}) bool { // and that it is equal to the provided error. // // actualObj, err := SomeFunction() -// if assert.Error(t, err, "An error was expected") { -// assert.Equal(t, err, expectedError) -// } -// -// Returns whether the assertion was successful (true) or not (false). +// assert.EqualError(t, err, expectedErrorString) func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) bool { - - message := messageFromMsgAndArgs(msgAndArgs...) - if !NotNil(t, theError, "An error is expected but got nil. %s", message) { + if h, ok := t.(tHelper); ok { + h.Helper() + } + if !Error(t, theError, msgAndArgs...) { return false } - s := "An error with value \"%s\" is expected but got \"%s\". %s" - return Equal(t, errString, theError.Error(), - s, errString, theError.Error(), message) + expected := errString + actual := theError.Error() + // don't need to use deep equals here, we know they are both strings + if expected != actual { + return Fail(t, fmt.Sprintf("Error message not equal:\n"+ + "expected: %q\n"+ + "actual : %q", expected, actual), msgAndArgs...) + } + return true } // matchRegexp return true if a specified regexp matches a string. @@ -895,9 +1227,10 @@ func matchRegexp(rx interface{}, str interface{}) bool { // // assert.Regexp(t, regexp.MustCompile("start"), "it's starting") // assert.Regexp(t, "start...$", "it's not starting") -// -// Returns whether the assertion was successful (true) or not (false). func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } match := matchRegexp(rx, str) @@ -912,9 +1245,10 @@ func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface // // assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") // assert.NotRegexp(t, "^start", "it's not starting") -// -// Returns whether the assertion was successful (true) or not (false). func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } match := matchRegexp(rx, str) if match { @@ -925,28 +1259,71 @@ func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interf } -// Zero asserts that i is the zero value for its type and returns the truth. +// Zero asserts that i is the zero value for its type. func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } if i != nil && !reflect.DeepEqual(i, reflect.Zero(reflect.TypeOf(i)).Interface()) { return Fail(t, fmt.Sprintf("Should be zero, but was %v", i), msgAndArgs...) } return true } -// NotZero asserts that i is not the zero value for its type and returns the truth. +// NotZero asserts that i is not the zero value for its type. func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } if i == nil || reflect.DeepEqual(i, reflect.Zero(reflect.TypeOf(i)).Interface()) { return Fail(t, fmt.Sprintf("Should not be zero, but was %v", i), msgAndArgs...) } return true } +// FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. +func FileExists(t TestingT, path string, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + info, err := os.Lstat(path) + if err != nil { + if os.IsNotExist(err) { + return Fail(t, fmt.Sprintf("unable to find file %q", path), msgAndArgs...) + } + return Fail(t, fmt.Sprintf("error when running os.Lstat(%q): %s", path, err), msgAndArgs...) + } + if info.IsDir() { + return Fail(t, fmt.Sprintf("%q is a directory", path), msgAndArgs...) + } + return true +} + +// DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. +func DirExists(t TestingT, path string, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + info, err := os.Lstat(path) + if err != nil { + if os.IsNotExist(err) { + return Fail(t, fmt.Sprintf("unable to find file %q", path), msgAndArgs...) + } + return Fail(t, fmt.Sprintf("error when running os.Lstat(%q): %s", path, err), msgAndArgs...) + } + if !info.IsDir() { + return Fail(t, fmt.Sprintf("%q is a file", path), msgAndArgs...) + } + return true +} + // JSONEq asserts that two JSON strings are equivalent. // // assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) -// -// Returns whether the assertion was successful (true) or not (false). func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } var expectedJSONAsInterface, actualJSONAsInterface interface{} if err := json.Unmarshal([]byte(expected), &expectedJSONAsInterface); err != nil { @@ -972,7 +1349,7 @@ func typeAndKind(v interface{}) (reflect.Type, reflect.Kind) { } // diff returns a diff of both values as long as both are of the same type and -// are a struct, map, slice or array. Otherwise it returns an empty string. +// are a struct, map, slice, array or string. Otherwise it returns an empty string. func diff(expected interface{}, actual interface{}) string { if expected == nil || actual == nil { return "" @@ -985,13 +1362,18 @@ func diff(expected interface{}, actual interface{}) string { return "" } - if ek != reflect.Struct && ek != reflect.Map && ek != reflect.Slice && ek != reflect.Array { + if ek != reflect.Struct && ek != reflect.Map && ek != reflect.Slice && ek != reflect.Array && ek != reflect.String { return "" } - spew.Config.SortKeys = true - e := spew.Sdump(expected) - a := spew.Sdump(actual) + var e, a string + if et != reflect.TypeOf("") { + e = spewConfig.Sdump(expected) + a = spewConfig.Sdump(actual) + } else { + e = expected.(string) + a = actual.(string) + } diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{ A: difflib.SplitLines(e), @@ -1005,3 +1387,30 @@ func diff(expected interface{}, actual interface{}) string { return "\n\nDiff:\n" + diff } + +// validateEqualArgs checks whether provided arguments can be safely used in the +// Equal/NotEqual functions. +func validateEqualArgs(expected, actual interface{}) error { + if isFunction(expected) || isFunction(actual) { + return errors.New("cannot take func type as argument") + } + return nil +} + +func isFunction(arg interface{}) bool { + if arg == nil { + return false + } + return reflect.TypeOf(arg).Kind() == reflect.Func +} + +var spewConfig = spew.ConfigState{ + Indent: " ", + DisablePointerAddresses: true, + DisableCapacities: true, + SortKeys: true, +} + +type tHelper interface { + Helper() +} diff --git a/vendor/github.com/stretchr/testify/assert/assertions_test.go b/vendor/github.com/stretchr/testify/assert/assertions_test.go new file mode 100644 index 0000000..00e2d21 --- /dev/null +++ b/vendor/github.com/stretchr/testify/assert/assertions_test.go @@ -0,0 +1,1803 @@ +package assert + +import ( + "bytes" + "encoding/json" + "errors" + "fmt" + "io" + "math" + "os" + "reflect" + "regexp" + "runtime" + "strings" + "testing" + "time" +) + +var ( + i interface{} + zeros = []interface{}{ + false, + byte(0), + complex64(0), + complex128(0), + float32(0), + float64(0), + int(0), + int8(0), + int16(0), + int32(0), + int64(0), + rune(0), + uint(0), + uint8(0), + uint16(0), + uint32(0), + uint64(0), + uintptr(0), + "", + [0]interface{}{}, + []interface{}(nil), + struct{ x int }{}, + (*interface{})(nil), + (func())(nil), + nil, + interface{}(nil), + map[interface{}]interface{}(nil), + (chan interface{})(nil), + (<-chan interface{})(nil), + (chan<- interface{})(nil), + } + nonZeros = []interface{}{ + true, + byte(1), + complex64(1), + complex128(1), + float32(1), + float64(1), + int(1), + int8(1), + int16(1), + int32(1), + int64(1), + rune(1), + uint(1), + uint8(1), + uint16(1), + uint32(1), + uint64(1), + uintptr(1), + "s", + [1]interface{}{1}, + []interface{}{}, + struct{ x int }{1}, + (*interface{})(&i), + (func())(func() {}), + interface{}(1), + map[interface{}]interface{}{}, + (chan interface{})(make(chan interface{})), + (<-chan interface{})(make(chan interface{})), + (chan<- interface{})(make(chan interface{})), + } +) + +// AssertionTesterInterface defines an interface to be used for testing assertion methods +type AssertionTesterInterface interface { + TestMethod() +} + +// AssertionTesterConformingObject is an object that conforms to the AssertionTesterInterface interface +type AssertionTesterConformingObject struct { +} + +func (a *AssertionTesterConformingObject) TestMethod() { +} + +// AssertionTesterNonConformingObject is an object that does not conform to the AssertionTesterInterface interface +type AssertionTesterNonConformingObject struct { +} + +func TestObjectsAreEqual(t *testing.T) { + + if !ObjectsAreEqual("Hello World", "Hello World") { + t.Error("objectsAreEqual should return true") + } + if !ObjectsAreEqual(123, 123) { + t.Error("objectsAreEqual should return true") + } + if !ObjectsAreEqual(123.5, 123.5) { + t.Error("objectsAreEqual should return true") + } + if !ObjectsAreEqual([]byte("Hello World"), []byte("Hello World")) { + t.Error("objectsAreEqual should return true") + } + if !ObjectsAreEqual(nil, nil) { + t.Error("objectsAreEqual should return true") + } + if ObjectsAreEqual(map[int]int{5: 10}, map[int]int{10: 20}) { + t.Error("objectsAreEqual should return false") + } + if ObjectsAreEqual('x', "x") { + t.Error("objectsAreEqual should return false") + } + if ObjectsAreEqual("x", 'x') { + t.Error("objectsAreEqual should return false") + } + if ObjectsAreEqual(0, 0.1) { + t.Error("objectsAreEqual should return false") + } + if ObjectsAreEqual(0.1, 0) { + t.Error("objectsAreEqual should return false") + } + if ObjectsAreEqual(uint32(10), int32(10)) { + t.Error("objectsAreEqual should return false") + } + if !ObjectsAreEqualValues(uint32(10), int32(10)) { + t.Error("ObjectsAreEqualValues should return true") + } + if ObjectsAreEqualValues(0, nil) { + t.Fail() + } + if ObjectsAreEqualValues(nil, 0) { + t.Fail() + } + +} + +func TestImplements(t *testing.T) { + + mockT := new(testing.T) + + if !Implements(mockT, (*AssertionTesterInterface)(nil), new(AssertionTesterConformingObject)) { + t.Error("Implements method should return true: AssertionTesterConformingObject implements AssertionTesterInterface") + } + if Implements(mockT, (*AssertionTesterInterface)(nil), new(AssertionTesterNonConformingObject)) { + t.Error("Implements method should return false: AssertionTesterNonConformingObject does not implements AssertionTesterInterface") + } + if Implements(mockT, (*AssertionTesterInterface)(nil), nil) { + t.Error("Implements method should return false: nil does not implement AssertionTesterInterface") + } + +} + +func TestIsType(t *testing.T) { + + mockT := new(testing.T) + + if !IsType(mockT, new(AssertionTesterConformingObject), new(AssertionTesterConformingObject)) { + t.Error("IsType should return true: AssertionTesterConformingObject is the same type as AssertionTesterConformingObject") + } + if IsType(mockT, new(AssertionTesterConformingObject), new(AssertionTesterNonConformingObject)) { + t.Error("IsType should return false: AssertionTesterConformingObject is not the same type as AssertionTesterNonConformingObject") + } + +} + +type myType string + +func TestEqual(t *testing.T) { + + mockT := new(testing.T) + + if !Equal(mockT, "Hello World", "Hello World") { + t.Error("Equal should return true") + } + if !Equal(mockT, 123, 123) { + t.Error("Equal should return true") + } + if !Equal(mockT, 123.5, 123.5) { + t.Error("Equal should return true") + } + if !Equal(mockT, []byte("Hello World"), []byte("Hello World")) { + t.Error("Equal should return true") + } + if !Equal(mockT, nil, nil) { + t.Error("Equal should return true") + } + if !Equal(mockT, int32(123), int32(123)) { + t.Error("Equal should return true") + } + if !Equal(mockT, uint64(123), uint64(123)) { + t.Error("Equal should return true") + } + if !Equal(mockT, myType("1"), myType("1")) { + t.Error("Equal should return true") + } + if !Equal(mockT, &struct{}{}, &struct{}{}) { + t.Error("Equal should return true (pointer equality is based on equality of underlying value)") + } + var m map[string]interface{} + if Equal(mockT, m["bar"], "something") { + t.Error("Equal should return false") + } + if Equal(mockT, myType("1"), myType("2")) { + t.Error("Equal should return false") + } +} + +// bufferT implements TestingT. Its implementation of Errorf writes the output that would be produced by +// testing.T.Errorf to an internal bytes.Buffer. +type bufferT struct { + buf bytes.Buffer +} + +func (t *bufferT) Errorf(format string, args ...interface{}) { + // implementation of decorate is copied from testing.T + decorate := func(s string) string { + _, file, line, ok := runtime.Caller(3) // decorate + log + public function. + if ok { + // Truncate file name at last file name separator. + if index := strings.LastIndex(file, "/"); index >= 0 { + file = file[index+1:] + } else if index = strings.LastIndex(file, "\\"); index >= 0 { + file = file[index+1:] + } + } else { + file = "???" + line = 1 + } + buf := new(bytes.Buffer) + // Every line is indented at least one tab. + buf.WriteByte('\t') + fmt.Fprintf(buf, "%s:%d: ", file, line) + lines := strings.Split(s, "\n") + if l := len(lines); l > 1 && lines[l-1] == "" { + lines = lines[:l-1] + } + for i, line := range lines { + if i > 0 { + // Second and subsequent lines are indented an extra tab. + buf.WriteString("\n\t\t") + } + buf.WriteString(line) + } + buf.WriteByte('\n') + return buf.String() + } + t.buf.WriteString(decorate(fmt.Sprintf(format, args...))) +} + +func TestStringEqual(t *testing.T) { + for i, currCase := range []struct { + equalWant string + equalGot string + msgAndArgs []interface{} + want string + }{ + {equalWant: "hi, \nmy name is", equalGot: "what,\nmy name is", want: "\tassertions.go:\\d+: \n\t+Error Trace:\t\n\t+Error:\\s+Not equal:\\s+\n\\s+expected: \"hi, \\\\nmy name is\"\n\\s+actual\\s+: \"what,\\\\nmy name is\"\n\\s+Diff:\n\\s+-+ Expected\n\\s+\\++ Actual\n\\s+@@ -1,2 \\+1,2 @@\n\\s+-hi, \n\\s+\\+what,\n\\s+my name is"}, + } { + mockT := &bufferT{} + Equal(mockT, currCase.equalWant, currCase.equalGot, currCase.msgAndArgs...) + Regexp(t, regexp.MustCompile(currCase.want), mockT.buf.String(), "Case %d", i) + } +} + +func TestEqualFormatting(t *testing.T) { + for i, currCase := range []struct { + equalWant string + equalGot string + msgAndArgs []interface{} + want string + }{ + {equalWant: "want", equalGot: "got", want: "\tassertions.go:\\d+: \n\t+Error Trace:\t\n\t+Error:\\s+Not equal:\\s+\n\\s+expected: \"want\"\n\\s+actual\\s+: \"got\"\n\\s+Diff:\n\\s+-+ Expected\n\\s+\\++ Actual\n\\s+@@ -1 \\+1 @@\n\\s+-want\n\\s+\\+got\n"}, + {equalWant: "want", equalGot: "got", msgAndArgs: []interface{}{"hello, %v!", "world"}, want: "\tassertions.go:[0-9]+: \n\t+Error Trace:\t\n\t+Error:\\s+Not equal:\\s+\n\\s+expected: \"want\"\n\\s+actual\\s+: \"got\"\n\\s+Diff:\n\\s+-+ Expected\n\\s+\\++ Actual\n\\s+@@ -1 \\+1 @@\n\\s+-want\n\\s+\\+got\n\\s+Messages:\\s+hello, world!\n"}, + {equalWant: "want", equalGot: "got", msgAndArgs: []interface{}{123}, want: "\tassertions.go:[0-9]+: \n\t+Error Trace:\t\n\t+Error:\\s+Not equal:\\s+\n\\s+expected: \"want\"\n\\s+actual\\s+: \"got\"\n\\s+Diff:\n\\s+-+ Expected\n\\s+\\++ Actual\n\\s+@@ -1 \\+1 @@\n\\s+-want\n\\s+\\+got\n\\s+Messages:\\s+123\n"}, + {equalWant: "want", equalGot: "got", msgAndArgs: []interface{}{struct{ a string }{"hello"}}, want: "\tassertions.go:[0-9]+: \n\t+Error Trace:\t\n\t+Error:\\s+Not equal:\\s+\n\\s+expected: \"want\"\n\\s+actual\\s+: \"got\"\n\\s+Diff:\n\\s+-+ Expected\n\\s+\\++ Actual\n\\s+@@ -1 \\+1 @@\n\\s+-want\n\\s+\\+got\n\\s+Messages:\\s+{a:hello}\n"}, + } { + mockT := &bufferT{} + Equal(mockT, currCase.equalWant, currCase.equalGot, currCase.msgAndArgs...) + Regexp(t, regexp.MustCompile(currCase.want), mockT.buf.String(), "Case %d", i) + } +} + +func TestFormatUnequalValues(t *testing.T) { + expected, actual := formatUnequalValues("foo", "bar") + Equal(t, `"foo"`, expected, "value should not include type") + Equal(t, `"bar"`, actual, "value should not include type") + + expected, actual = formatUnequalValues(123, 123) + Equal(t, `123`, expected, "value should not include type") + Equal(t, `123`, actual, "value should not include type") + + expected, actual = formatUnequalValues(int64(123), int32(123)) + Equal(t, `int64(123)`, expected, "value should include type") + Equal(t, `int32(123)`, actual, "value should include type") + + expected, actual = formatUnequalValues(int64(123), nil) + Equal(t, `int64(123)`, expected, "value should include type") + Equal(t, `()`, actual, "value should include type") + + type testStructType struct { + Val string + } + + expected, actual = formatUnequalValues(&testStructType{Val: "test"}, &testStructType{Val: "test"}) + Equal(t, `&assert.testStructType{Val:"test"}`, expected, "value should not include type annotation") + Equal(t, `&assert.testStructType{Val:"test"}`, actual, "value should not include type annotation") +} + +func TestNotNil(t *testing.T) { + + mockT := new(testing.T) + + if !NotNil(mockT, new(AssertionTesterConformingObject)) { + t.Error("NotNil should return true: object is not nil") + } + if NotNil(mockT, nil) { + t.Error("NotNil should return false: object is nil") + } + if NotNil(mockT, (*struct{})(nil)) { + t.Error("NotNil should return false: object is (*struct{})(nil)") + } + +} + +func TestNil(t *testing.T) { + + mockT := new(testing.T) + + if !Nil(mockT, nil) { + t.Error("Nil should return true: object is nil") + } + if !Nil(mockT, (*struct{})(nil)) { + t.Error("Nil should return true: object is (*struct{})(nil)") + } + if Nil(mockT, new(AssertionTesterConformingObject)) { + t.Error("Nil should return false: object is not nil") + } + +} + +func TestTrue(t *testing.T) { + + mockT := new(testing.T) + + if !True(mockT, true) { + t.Error("True should return true") + } + if True(mockT, false) { + t.Error("True should return false") + } + +} + +func TestFalse(t *testing.T) { + + mockT := new(testing.T) + + if !False(mockT, false) { + t.Error("False should return true") + } + if False(mockT, true) { + t.Error("False should return false") + } + +} + +func TestExactly(t *testing.T) { + + mockT := new(testing.T) + + a := float32(1) + b := float64(1) + c := float32(1) + d := float32(2) + + if Exactly(mockT, a, b) { + t.Error("Exactly should return false") + } + if Exactly(mockT, a, d) { + t.Error("Exactly should return false") + } + if !Exactly(mockT, a, c) { + t.Error("Exactly should return true") + } + + if Exactly(mockT, nil, a) { + t.Error("Exactly should return false") + } + if Exactly(mockT, a, nil) { + t.Error("Exactly should return false") + } + +} + +func TestNotEqual(t *testing.T) { + + mockT := new(testing.T) + + if !NotEqual(mockT, "Hello World", "Hello World!") { + t.Error("NotEqual should return true") + } + if !NotEqual(mockT, 123, 1234) { + t.Error("NotEqual should return true") + } + if !NotEqual(mockT, 123.5, 123.55) { + t.Error("NotEqual should return true") + } + if !NotEqual(mockT, []byte("Hello World"), []byte("Hello World!")) { + t.Error("NotEqual should return true") + } + if !NotEqual(mockT, nil, new(AssertionTesterConformingObject)) { + t.Error("NotEqual should return true") + } + funcA := func() int { return 23 } + funcB := func() int { return 42 } + if NotEqual(mockT, funcA, funcB) { + t.Error("NotEqual should return false") + } + + if NotEqual(mockT, "Hello World", "Hello World") { + t.Error("NotEqual should return false") + } + if NotEqual(mockT, 123, 123) { + t.Error("NotEqual should return false") + } + if NotEqual(mockT, 123.5, 123.5) { + t.Error("NotEqual should return false") + } + if NotEqual(mockT, []byte("Hello World"), []byte("Hello World")) { + t.Error("NotEqual should return false") + } + if NotEqual(mockT, new(AssertionTesterConformingObject), new(AssertionTesterConformingObject)) { + t.Error("NotEqual should return false") + } + if NotEqual(mockT, &struct{}{}, &struct{}{}) { + t.Error("NotEqual should return false") + } +} + +type A struct { + Name, Value string +} + +func TestContains(t *testing.T) { + + mockT := new(testing.T) + list := []string{"Foo", "Bar"} + complexList := []*A{ + {"b", "c"}, + {"d", "e"}, + {"g", "h"}, + {"j", "k"}, + } + simpleMap := map[interface{}]interface{}{"Foo": "Bar"} + + if !Contains(mockT, "Hello World", "Hello") { + t.Error("Contains should return true: \"Hello World\" contains \"Hello\"") + } + if Contains(mockT, "Hello World", "Salut") { + t.Error("Contains should return false: \"Hello World\" does not contain \"Salut\"") + } + + if !Contains(mockT, list, "Bar") { + t.Error("Contains should return true: \"[\"Foo\", \"Bar\"]\" contains \"Bar\"") + } + if Contains(mockT, list, "Salut") { + t.Error("Contains should return false: \"[\"Foo\", \"Bar\"]\" does not contain \"Salut\"") + } + if !Contains(mockT, complexList, &A{"g", "h"}) { + t.Error("Contains should return true: complexList contains {\"g\", \"h\"}") + } + if Contains(mockT, complexList, &A{"g", "e"}) { + t.Error("Contains should return false: complexList contains {\"g\", \"e\"}") + } + if Contains(mockT, complexList, &A{"g", "e"}) { + t.Error("Contains should return false: complexList contains {\"g\", \"e\"}") + } + if !Contains(mockT, simpleMap, "Foo") { + t.Error("Contains should return true: \"{\"Foo\": \"Bar\"}\" contains \"Foo\"") + } + if Contains(mockT, simpleMap, "Bar") { + t.Error("Contains should return false: \"{\"Foo\": \"Bar\"}\" does not contains \"Bar\"") + } +} + +func TestNotContains(t *testing.T) { + + mockT := new(testing.T) + list := []string{"Foo", "Bar"} + simpleMap := map[interface{}]interface{}{"Foo": "Bar"} + + if !NotContains(mockT, "Hello World", "Hello!") { + t.Error("NotContains should return true: \"Hello World\" does not contain \"Hello!\"") + } + if NotContains(mockT, "Hello World", "Hello") { + t.Error("NotContains should return false: \"Hello World\" contains \"Hello\"") + } + + if !NotContains(mockT, list, "Foo!") { + t.Error("NotContains should return true: \"[\"Foo\", \"Bar\"]\" does not contain \"Foo!\"") + } + if NotContains(mockT, list, "Foo") { + t.Error("NotContains should return false: \"[\"Foo\", \"Bar\"]\" contains \"Foo\"") + } + if NotContains(mockT, simpleMap, "Foo") { + t.Error("Contains should return true: \"{\"Foo\": \"Bar\"}\" contains \"Foo\"") + } + if !NotContains(mockT, simpleMap, "Bar") { + t.Error("Contains should return false: \"{\"Foo\": \"Bar\"}\" does not contains \"Bar\"") + } +} + +func TestSubset(t *testing.T) { + mockT := new(testing.T) + + if !Subset(mockT, []int{1, 2, 3}, nil) { + t.Error("Subset should return true: given subset is nil") + } + if !Subset(mockT, []int{1, 2, 3}, []int{}) { + t.Error("Subset should return true: any set contains the nil set") + } + if !Subset(mockT, []int{1, 2, 3}, []int{1, 2}) { + t.Error("Subset should return true: [1, 2, 3] contains [1, 2]") + } + if !Subset(mockT, []int{1, 2, 3}, []int{1, 2, 3}) { + t.Error("Subset should return true: [1, 2, 3] contains [1, 2, 3]") + } + if !Subset(mockT, []string{"hello", "world"}, []string{"hello"}) { + t.Error("Subset should return true: [\"hello\", \"world\"] contains [\"hello\"]") + } + + if Subset(mockT, []string{"hello", "world"}, []string{"hello", "testify"}) { + t.Error("Subset should return false: [\"hello\", \"world\"] does not contain [\"hello\", \"testify\"]") + } + if Subset(mockT, []int{1, 2, 3}, []int{4, 5}) { + t.Error("Subset should return false: [1, 2, 3] does not contain [4, 5]") + } + if Subset(mockT, []int{1, 2, 3}, []int{1, 5}) { + t.Error("Subset should return false: [1, 2, 3] does not contain [1, 5]") + } +} + +func TestNotSubset(t *testing.T) { + mockT := new(testing.T) + + if NotSubset(mockT, []int{1, 2, 3}, nil) { + t.Error("NotSubset should return false: given subset is nil") + } + if NotSubset(mockT, []int{1, 2, 3}, []int{}) { + t.Error("NotSubset should return false: any set contains the nil set") + } + if NotSubset(mockT, []int{1, 2, 3}, []int{1, 2}) { + t.Error("NotSubset should return false: [1, 2, 3] contains [1, 2]") + } + if NotSubset(mockT, []int{1, 2, 3}, []int{1, 2, 3}) { + t.Error("NotSubset should return false: [1, 2, 3] contains [1, 2, 3]") + } + if NotSubset(mockT, []string{"hello", "world"}, []string{"hello"}) { + t.Error("NotSubset should return false: [\"hello\", \"world\"] contains [\"hello\"]") + } + + if !NotSubset(mockT, []string{"hello", "world"}, []string{"hello", "testify"}) { + t.Error("NotSubset should return true: [\"hello\", \"world\"] does not contain [\"hello\", \"testify\"]") + } + if !NotSubset(mockT, []int{1, 2, 3}, []int{4, 5}) { + t.Error("NotSubset should return true: [1, 2, 3] does not contain [4, 5]") + } + if !NotSubset(mockT, []int{1, 2, 3}, []int{1, 5}) { + t.Error("NotSubset should return true: [1, 2, 3] does not contain [1, 5]") + } +} + +func TestNotSubsetNil(t *testing.T) { + mockT := new(testing.T) + NotSubset(mockT, []string{"foo"}, nil) + if !mockT.Failed() { + t.Error("NotSubset on nil set should have failed the test") + } +} + +func Test_includeElement(t *testing.T) { + + list1 := []string{"Foo", "Bar"} + list2 := []int{1, 2} + simpleMap := map[interface{}]interface{}{"Foo": "Bar"} + + ok, found := includeElement("Hello World", "World") + True(t, ok) + True(t, found) + + ok, found = includeElement(list1, "Foo") + True(t, ok) + True(t, found) + + ok, found = includeElement(list1, "Bar") + True(t, ok) + True(t, found) + + ok, found = includeElement(list2, 1) + True(t, ok) + True(t, found) + + ok, found = includeElement(list2, 2) + True(t, ok) + True(t, found) + + ok, found = includeElement(list1, "Foo!") + True(t, ok) + False(t, found) + + ok, found = includeElement(list2, 3) + True(t, ok) + False(t, found) + + ok, found = includeElement(list2, "1") + True(t, ok) + False(t, found) + + ok, found = includeElement(simpleMap, "Foo") + True(t, ok) + True(t, found) + + ok, found = includeElement(simpleMap, "Bar") + True(t, ok) + False(t, found) + + ok, found = includeElement(1433, "1") + False(t, ok) + False(t, found) +} + +func TestElementsMatch(t *testing.T) { + mockT := new(testing.T) + + if !ElementsMatch(mockT, nil, nil) { + t.Error("ElementsMatch should return true") + } + if !ElementsMatch(mockT, []int{}, []int{}) { + t.Error("ElementsMatch should return true") + } + if !ElementsMatch(mockT, []int{1}, []int{1}) { + t.Error("ElementsMatch should return true") + } + if !ElementsMatch(mockT, []int{1, 1}, []int{1, 1}) { + t.Error("ElementsMatch should return true") + } + if !ElementsMatch(mockT, []int{1, 2}, []int{1, 2}) { + t.Error("ElementsMatch should return true") + } + if !ElementsMatch(mockT, []int{1, 2}, []int{2, 1}) { + t.Error("ElementsMatch should return true") + } + if !ElementsMatch(mockT, [2]int{1, 2}, [2]int{2, 1}) { + t.Error("ElementsMatch should return true") + } + if !ElementsMatch(mockT, []string{"hello", "world"}, []string{"world", "hello"}) { + t.Error("ElementsMatch should return true") + } + if !ElementsMatch(mockT, []string{"hello", "hello"}, []string{"hello", "hello"}) { + t.Error("ElementsMatch should return true") + } + if !ElementsMatch(mockT, []string{"hello", "hello", "world"}, []string{"hello", "world", "hello"}) { + t.Error("ElementsMatch should return true") + } + if !ElementsMatch(mockT, [3]string{"hello", "hello", "world"}, [3]string{"hello", "world", "hello"}) { + t.Error("ElementsMatch should return true") + } + if !ElementsMatch(mockT, []int{}, nil) { + t.Error("ElementsMatch should return true") + } + + if ElementsMatch(mockT, []int{1}, []int{1, 1}) { + t.Error("ElementsMatch should return false") + } + if ElementsMatch(mockT, []int{1, 2}, []int{2, 2}) { + t.Error("ElementsMatch should return false") + } + if ElementsMatch(mockT, []string{"hello", "hello"}, []string{"hello"}) { + t.Error("ElementsMatch should return false") + } +} + +func TestCondition(t *testing.T) { + mockT := new(testing.T) + + if !Condition(mockT, func() bool { return true }, "Truth") { + t.Error("Condition should return true") + } + + if Condition(mockT, func() bool { return false }, "Lie") { + t.Error("Condition should return false") + } + +} + +func TestDidPanic(t *testing.T) { + + if funcDidPanic, _ := didPanic(func() { + panic("Panic!") + }); !funcDidPanic { + t.Error("didPanic should return true") + } + + if funcDidPanic, _ := didPanic(func() { + }); funcDidPanic { + t.Error("didPanic should return false") + } + +} + +func TestPanics(t *testing.T) { + + mockT := new(testing.T) + + if !Panics(mockT, func() { + panic("Panic!") + }) { + t.Error("Panics should return true") + } + + if Panics(mockT, func() { + }) { + t.Error("Panics should return false") + } + +} + +func TestPanicsWithValue(t *testing.T) { + + mockT := new(testing.T) + + if !PanicsWithValue(mockT, "Panic!", func() { + panic("Panic!") + }) { + t.Error("PanicsWithValue should return true") + } + + if PanicsWithValue(mockT, "Panic!", func() { + }) { + t.Error("PanicsWithValue should return false") + } + + if PanicsWithValue(mockT, "at the disco", func() { + panic("Panic!") + }) { + t.Error("PanicsWithValue should return false") + } +} + +func TestNotPanics(t *testing.T) { + + mockT := new(testing.T) + + if !NotPanics(mockT, func() { + }) { + t.Error("NotPanics should return true") + } + + if NotPanics(mockT, func() { + panic("Panic!") + }) { + t.Error("NotPanics should return false") + } + +} + +func TestNoError(t *testing.T) { + + mockT := new(testing.T) + + // start with a nil error + var err error + + True(t, NoError(mockT, err), "NoError should return True for nil arg") + + // now set an error + err = errors.New("some error") + + False(t, NoError(mockT, err), "NoError with error should return False") + + // returning an empty error interface + err = func() error { + var err *customError + if err != nil { + t.Fatal("err should be nil here") + } + return err + }() + + if err == nil { // err is not nil here! + t.Errorf("Error should be nil due to empty interface: %s", err) + } + + False(t, NoError(mockT, err), "NoError should fail with empty error interface") +} + +type customError struct{} + +func (*customError) Error() string { return "fail" } + +func TestError(t *testing.T) { + + mockT := new(testing.T) + + // start with a nil error + var err error + + False(t, Error(mockT, err), "Error should return False for nil arg") + + // now set an error + err = errors.New("some error") + + True(t, Error(mockT, err), "Error with error should return True") + + // go vet check + True(t, Errorf(mockT, err, "example with %s", "formatted message"), "Errorf with error should rturn True") + + // returning an empty error interface + err = func() error { + var err *customError + if err != nil { + t.Fatal("err should be nil here") + } + return err + }() + + if err == nil { // err is not nil here! + t.Errorf("Error should be nil due to empty interface: %s", err) + } + + True(t, Error(mockT, err), "Error should pass with empty error interface") +} + +func TestEqualError(t *testing.T) { + mockT := new(testing.T) + + // start with a nil error + var err error + False(t, EqualError(mockT, err, ""), + "EqualError should return false for nil arg") + + // now set an error + err = errors.New("some error") + False(t, EqualError(mockT, err, "Not some error"), + "EqualError should return false for different error string") + True(t, EqualError(mockT, err, "some error"), + "EqualError should return true") +} + +func Test_isEmpty(t *testing.T) { + + chWithValue := make(chan struct{}, 1) + chWithValue <- struct{}{} + + True(t, isEmpty("")) + True(t, isEmpty(nil)) + True(t, isEmpty([]string{})) + True(t, isEmpty(0)) + True(t, isEmpty(int32(0))) + True(t, isEmpty(int64(0))) + True(t, isEmpty(false)) + True(t, isEmpty(map[string]string{})) + True(t, isEmpty(new(time.Time))) + True(t, isEmpty(time.Time{})) + True(t, isEmpty(make(chan struct{}))) + False(t, isEmpty("something")) + False(t, isEmpty(errors.New("something"))) + False(t, isEmpty([]string{"something"})) + False(t, isEmpty(1)) + False(t, isEmpty(true)) + False(t, isEmpty(map[string]string{"Hello": "World"})) + False(t, isEmpty(chWithValue)) + +} + +func TestEmpty(t *testing.T) { + + mockT := new(testing.T) + chWithValue := make(chan struct{}, 1) + chWithValue <- struct{}{} + var tiP *time.Time + var tiNP time.Time + var s *string + var f *os.File + sP := &s + x := 1 + xP := &x + + type TString string + type TStruct struct { + x int + s []int + } + + True(t, Empty(mockT, ""), "Empty string is empty") + True(t, Empty(mockT, nil), "Nil is empty") + True(t, Empty(mockT, []string{}), "Empty string array is empty") + True(t, Empty(mockT, 0), "Zero int value is empty") + True(t, Empty(mockT, false), "False value is empty") + True(t, Empty(mockT, make(chan struct{})), "Channel without values is empty") + True(t, Empty(mockT, s), "Nil string pointer is empty") + True(t, Empty(mockT, f), "Nil os.File pointer is empty") + True(t, Empty(mockT, tiP), "Nil time.Time pointer is empty") + True(t, Empty(mockT, tiNP), "time.Time is empty") + True(t, Empty(mockT, TStruct{}), "struct with zero values is empty") + True(t, Empty(mockT, TString("")), "empty aliased string is empty") + True(t, Empty(mockT, sP), "ptr to nil value is empty") + + False(t, Empty(mockT, "something"), "Non Empty string is not empty") + False(t, Empty(mockT, errors.New("something")), "Non nil object is not empty") + False(t, Empty(mockT, []string{"something"}), "Non empty string array is not empty") + False(t, Empty(mockT, 1), "Non-zero int value is not empty") + False(t, Empty(mockT, true), "True value is not empty") + False(t, Empty(mockT, chWithValue), "Channel with values is not empty") + False(t, Empty(mockT, TStruct{x: 1}), "struct with initialized values is empty") + False(t, Empty(mockT, TString("abc")), "non-empty aliased string is empty") + False(t, Empty(mockT, xP), "ptr to non-nil value is not empty") +} + +func TestNotEmpty(t *testing.T) { + + mockT := new(testing.T) + chWithValue := make(chan struct{}, 1) + chWithValue <- struct{}{} + + False(t, NotEmpty(mockT, ""), "Empty string is empty") + False(t, NotEmpty(mockT, nil), "Nil is empty") + False(t, NotEmpty(mockT, []string{}), "Empty string array is empty") + False(t, NotEmpty(mockT, 0), "Zero int value is empty") + False(t, NotEmpty(mockT, false), "False value is empty") + False(t, NotEmpty(mockT, make(chan struct{})), "Channel without values is empty") + + True(t, NotEmpty(mockT, "something"), "Non Empty string is not empty") + True(t, NotEmpty(mockT, errors.New("something")), "Non nil object is not empty") + True(t, NotEmpty(mockT, []string{"something"}), "Non empty string array is not empty") + True(t, NotEmpty(mockT, 1), "Non-zero int value is not empty") + True(t, NotEmpty(mockT, true), "True value is not empty") + True(t, NotEmpty(mockT, chWithValue), "Channel with values is not empty") +} + +func Test_getLen(t *testing.T) { + falseCases := []interface{}{ + nil, + 0, + true, + false, + 'A', + struct{}{}, + } + for _, v := range falseCases { + ok, l := getLen(v) + False(t, ok, "Expected getLen fail to get length of %#v", v) + Equal(t, 0, l, "getLen should return 0 for %#v", v) + } + + ch := make(chan int, 5) + ch <- 1 + ch <- 2 + ch <- 3 + trueCases := []struct { + v interface{} + l int + }{ + {[]int{1, 2, 3}, 3}, + {[...]int{1, 2, 3}, 3}, + {"ABC", 3}, + {map[int]int{1: 2, 2: 4, 3: 6}, 3}, + {ch, 3}, + + {[]int{}, 0}, + {map[int]int{}, 0}, + {make(chan int), 0}, + + {[]int(nil), 0}, + {map[int]int(nil), 0}, + {(chan int)(nil), 0}, + } + + for _, c := range trueCases { + ok, l := getLen(c.v) + True(t, ok, "Expected getLen success to get length of %#v", c.v) + Equal(t, c.l, l) + } +} + +func TestLen(t *testing.T) { + mockT := new(testing.T) + + False(t, Len(mockT, nil, 0), "nil does not have length") + False(t, Len(mockT, 0, 0), "int does not have length") + False(t, Len(mockT, true, 0), "true does not have length") + False(t, Len(mockT, false, 0), "false does not have length") + False(t, Len(mockT, 'A', 0), "Rune does not have length") + False(t, Len(mockT, struct{}{}, 0), "Struct does not have length") + + ch := make(chan int, 5) + ch <- 1 + ch <- 2 + ch <- 3 + + cases := []struct { + v interface{} + l int + }{ + {[]int{1, 2, 3}, 3}, + {[...]int{1, 2, 3}, 3}, + {"ABC", 3}, + {map[int]int{1: 2, 2: 4, 3: 6}, 3}, + {ch, 3}, + + {[]int{}, 0}, + {map[int]int{}, 0}, + {make(chan int), 0}, + + {[]int(nil), 0}, + {map[int]int(nil), 0}, + {(chan int)(nil), 0}, + } + + for _, c := range cases { + True(t, Len(mockT, c.v, c.l), "%#v have %d items", c.v, c.l) + } + + cases = []struct { + v interface{} + l int + }{ + {[]int{1, 2, 3}, 4}, + {[...]int{1, 2, 3}, 2}, + {"ABC", 2}, + {map[int]int{1: 2, 2: 4, 3: 6}, 4}, + {ch, 2}, + + {[]int{}, 1}, + {map[int]int{}, 1}, + {make(chan int), 1}, + + {[]int(nil), 1}, + {map[int]int(nil), 1}, + {(chan int)(nil), 1}, + } + + for _, c := range cases { + False(t, Len(mockT, c.v, c.l), "%#v have %d items", c.v, c.l) + } +} + +func TestWithinDuration(t *testing.T) { + + mockT := new(testing.T) + a := time.Now() + b := a.Add(10 * time.Second) + + True(t, WithinDuration(mockT, a, b, 10*time.Second), "A 10s difference is within a 10s time difference") + True(t, WithinDuration(mockT, b, a, 10*time.Second), "A 10s difference is within a 10s time difference") + + False(t, WithinDuration(mockT, a, b, 9*time.Second), "A 10s difference is not within a 9s time difference") + False(t, WithinDuration(mockT, b, a, 9*time.Second), "A 10s difference is not within a 9s time difference") + + False(t, WithinDuration(mockT, a, b, -9*time.Second), "A 10s difference is not within a 9s time difference") + False(t, WithinDuration(mockT, b, a, -9*time.Second), "A 10s difference is not within a 9s time difference") + + False(t, WithinDuration(mockT, a, b, -11*time.Second), "A 10s difference is not within a 9s time difference") + False(t, WithinDuration(mockT, b, a, -11*time.Second), "A 10s difference is not within a 9s time difference") +} + +func TestInDelta(t *testing.T) { + mockT := new(testing.T) + + True(t, InDelta(mockT, 1.001, 1, 0.01), "|1.001 - 1| <= 0.01") + True(t, InDelta(mockT, 1, 1.001, 0.01), "|1 - 1.001| <= 0.01") + True(t, InDelta(mockT, 1, 2, 1), "|1 - 2| <= 1") + False(t, InDelta(mockT, 1, 2, 0.5), "Expected |1 - 2| <= 0.5 to fail") + False(t, InDelta(mockT, 2, 1, 0.5), "Expected |2 - 1| <= 0.5 to fail") + False(t, InDelta(mockT, "", nil, 1), "Expected non numerals to fail") + False(t, InDelta(mockT, 42, math.NaN(), 0.01), "Expected NaN for actual to fail") + False(t, InDelta(mockT, math.NaN(), 42, 0.01), "Expected NaN for expected to fail") + + cases := []struct { + a, b interface{} + delta float64 + }{ + {uint8(2), uint8(1), 1}, + {uint16(2), uint16(1), 1}, + {uint32(2), uint32(1), 1}, + {uint64(2), uint64(1), 1}, + + {int(2), int(1), 1}, + {int8(2), int8(1), 1}, + {int16(2), int16(1), 1}, + {int32(2), int32(1), 1}, + {int64(2), int64(1), 1}, + + {float32(2), float32(1), 1}, + {float64(2), float64(1), 1}, + } + + for _, tc := range cases { + True(t, InDelta(mockT, tc.a, tc.b, tc.delta), "Expected |%V - %V| <= %v", tc.a, tc.b, tc.delta) + } +} + +func TestInDeltaSlice(t *testing.T) { + mockT := new(testing.T) + + True(t, InDeltaSlice(mockT, + []float64{1.001, 0.999}, + []float64{1, 1}, + 0.1), "{1.001, 0.009} is element-wise close to {1, 1} in delta=0.1") + + True(t, InDeltaSlice(mockT, + []float64{1, 2}, + []float64{0, 3}, + 1), "{1, 2} is element-wise close to {0, 3} in delta=1") + + False(t, InDeltaSlice(mockT, + []float64{1, 2}, + []float64{0, 3}, + 0.1), "{1, 2} is not element-wise close to {0, 3} in delta=0.1") + + False(t, InDeltaSlice(mockT, "", nil, 1), "Expected non numeral slices to fail") +} + +func TestInDeltaMapValues(t *testing.T) { + mockT := new(testing.T) + + for _, tc := range []struct { + title string + expect interface{} + actual interface{} + f func(TestingT, bool, ...interface{}) bool + delta float64 + }{ + { + title: "Within delta", + expect: map[string]float64{ + "foo": 1.0, + "bar": 2.0, + }, + actual: map[string]float64{ + "foo": 1.01, + "bar": 1.99, + }, + delta: 0.1, + f: True, + }, + { + title: "Within delta", + expect: map[int]float64{ + 1: 1.0, + 2: 2.0, + }, + actual: map[int]float64{ + 1: 1.0, + 2: 1.99, + }, + delta: 0.1, + f: True, + }, + { + title: "Different number of keys", + expect: map[int]float64{ + 1: 1.0, + 2: 2.0, + }, + actual: map[int]float64{ + 1: 1.0, + }, + delta: 0.1, + f: False, + }, + { + title: "Within delta with zero value", + expect: map[string]float64{ + "zero": 0.0, + }, + actual: map[string]float64{ + "zero": 0.0, + }, + delta: 0.1, + f: True, + }, + { + title: "With missing key with zero value", + expect: map[string]float64{ + "zero": 0.0, + "foo": 0.0, + }, + actual: map[string]float64{ + "zero": 0.0, + "bar": 0.0, + }, + f: False, + }, + } { + tc.f(t, InDeltaMapValues(mockT, tc.expect, tc.actual, tc.delta), tc.title+"\n"+diff(tc.expect, tc.actual)) + } +} + +func TestInEpsilon(t *testing.T) { + mockT := new(testing.T) + + cases := []struct { + a, b interface{} + epsilon float64 + }{ + {uint8(2), uint16(2), .001}, + {2.1, 2.2, 0.1}, + {2.2, 2.1, 0.1}, + {-2.1, -2.2, 0.1}, + {-2.2, -2.1, 0.1}, + {uint64(100), uint8(101), 0.01}, + {0.1, -0.1, 2}, + {0.1, 0, 2}, + {time.Second, time.Second + time.Millisecond, 0.002}, + } + + for _, tc := range cases { + True(t, InEpsilon(t, tc.a, tc.b, tc.epsilon, "Expected %V and %V to have a relative difference of %v", tc.a, tc.b, tc.epsilon), "test: %q", tc) + } + + cases = []struct { + a, b interface{} + epsilon float64 + }{ + {uint8(2), int16(-2), .001}, + {uint64(100), uint8(102), 0.01}, + {2.1, 2.2, 0.001}, + {2.2, 2.1, 0.001}, + {2.1, -2.2, 1}, + {2.1, "bla-bla", 0}, + {0.1, -0.1, 1.99}, + {0, 0.1, 2}, // expected must be different to zero + {time.Second, time.Second + 10*time.Millisecond, 0.002}, + } + + for _, tc := range cases { + False(t, InEpsilon(mockT, tc.a, tc.b, tc.epsilon, "Expected %V and %V to have a relative difference of %v", tc.a, tc.b, tc.epsilon)) + } + +} + +func TestInEpsilonSlice(t *testing.T) { + mockT := new(testing.T) + + True(t, InEpsilonSlice(mockT, + []float64{2.2, 2.0}, + []float64{2.1, 2.1}, + 0.06), "{2.2, 2.0} is element-wise close to {2.1, 2.1} in espilon=0.06") + + False(t, InEpsilonSlice(mockT, + []float64{2.2, 2.0}, + []float64{2.1, 2.1}, + 0.04), "{2.2, 2.0} is not element-wise close to {2.1, 2.1} in espilon=0.04") + + False(t, InEpsilonSlice(mockT, "", nil, 1), "Expected non numeral slices to fail") +} + +func TestRegexp(t *testing.T) { + mockT := new(testing.T) + + cases := []struct { + rx, str string + }{ + {"^start", "start of the line"}, + {"end$", "in the end"}, + {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12.34"}, + } + + for _, tc := range cases { + True(t, Regexp(mockT, tc.rx, tc.str)) + True(t, Regexp(mockT, regexp.MustCompile(tc.rx), tc.str)) + False(t, NotRegexp(mockT, tc.rx, tc.str)) + False(t, NotRegexp(mockT, regexp.MustCompile(tc.rx), tc.str)) + } + + cases = []struct { + rx, str string + }{ + {"^asdfastart", "Not the start of the line"}, + {"end$", "in the end."}, + {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12a.34"}, + } + + for _, tc := range cases { + False(t, Regexp(mockT, tc.rx, tc.str), "Expected \"%s\" to not match \"%s\"", tc.rx, tc.str) + False(t, Regexp(mockT, regexp.MustCompile(tc.rx), tc.str)) + True(t, NotRegexp(mockT, tc.rx, tc.str)) + True(t, NotRegexp(mockT, regexp.MustCompile(tc.rx), tc.str)) + } +} + +func testAutogeneratedFunction() { + defer func() { + if err := recover(); err == nil { + panic("did not panic") + } + CallerInfo() + }() + t := struct { + io.Closer + }{} + var c io.Closer + c = t + c.Close() +} + +func TestCallerInfoWithAutogeneratedFunctions(t *testing.T) { + NotPanics(t, func() { + testAutogeneratedFunction() + }) +} + +func TestZero(t *testing.T) { + mockT := new(testing.T) + + for _, test := range zeros { + True(t, Zero(mockT, test, "%#v is not the %v zero value", test, reflect.TypeOf(test))) + } + + for _, test := range nonZeros { + False(t, Zero(mockT, test, "%#v is not the %v zero value", test, reflect.TypeOf(test))) + } +} + +func TestNotZero(t *testing.T) { + mockT := new(testing.T) + + for _, test := range zeros { + False(t, NotZero(mockT, test, "%#v is not the %v zero value", test, reflect.TypeOf(test))) + } + + for _, test := range nonZeros { + True(t, NotZero(mockT, test, "%#v is not the %v zero value", test, reflect.TypeOf(test))) + } +} + +func TestFileExists(t *testing.T) { + mockT := new(testing.T) + True(t, FileExists(mockT, "assertions.go")) + + mockT = new(testing.T) + False(t, FileExists(mockT, "random_file")) + + mockT = new(testing.T) + False(t, FileExists(mockT, "../_codegen")) +} + +func TestDirExists(t *testing.T) { + mockT := new(testing.T) + False(t, DirExists(mockT, "assertions.go")) + + mockT = new(testing.T) + False(t, DirExists(mockT, "random_dir")) + + mockT = new(testing.T) + True(t, DirExists(mockT, "../_codegen")) +} + +func TestJSONEq_EqualSONString(t *testing.T) { + mockT := new(testing.T) + True(t, JSONEq(mockT, `{"hello": "world", "foo": "bar"}`, `{"hello": "world", "foo": "bar"}`)) +} + +func TestJSONEq_EquivalentButNotEqual(t *testing.T) { + mockT := new(testing.T) + True(t, JSONEq(mockT, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)) +} + +func TestJSONEq_HashOfArraysAndHashes(t *testing.T) { + mockT := new(testing.T) + True(t, JSONEq(mockT, "{\r\n\t\"numeric\": 1.5,\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]],\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\"\r\n}", + "{\r\n\t\"numeric\": 1.5,\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\",\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]]\r\n}")) +} + +func TestJSONEq_Array(t *testing.T) { + mockT := new(testing.T) + True(t, JSONEq(mockT, `["foo", {"hello": "world", "nested": "hash"}]`, `["foo", {"nested": "hash", "hello": "world"}]`)) +} + +func TestJSONEq_HashAndArrayNotEquivalent(t *testing.T) { + mockT := new(testing.T) + False(t, JSONEq(mockT, `["foo", {"hello": "world", "nested": "hash"}]`, `{"foo": "bar", {"nested": "hash", "hello": "world"}}`)) +} + +func TestJSONEq_HashesNotEquivalent(t *testing.T) { + mockT := new(testing.T) + False(t, JSONEq(mockT, `{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`)) +} + +func TestJSONEq_ActualIsNotJSON(t *testing.T) { + mockT := new(testing.T) + False(t, JSONEq(mockT, `{"foo": "bar"}`, "Not JSON")) +} + +func TestJSONEq_ExpectedIsNotJSON(t *testing.T) { + mockT := new(testing.T) + False(t, JSONEq(mockT, "Not JSON", `{"foo": "bar", "hello": "world"}`)) +} + +func TestJSONEq_ExpectedAndActualNotJSON(t *testing.T) { + mockT := new(testing.T) + False(t, JSONEq(mockT, "Not JSON", "Not JSON")) +} + +func TestJSONEq_ArraysOfDifferentOrder(t *testing.T) { + mockT := new(testing.T) + False(t, JSONEq(mockT, `["foo", {"hello": "world", "nested": "hash"}]`, `[{ "hello": "world", "nested": "hash"}, "foo"]`)) +} + +func TestDiff(t *testing.T) { + expected := ` + +Diff: +--- Expected ++++ Actual +@@ -1,3 +1,3 @@ + (struct { foo string }) { +- foo: (string) (len=5) "hello" ++ foo: (string) (len=3) "bar" + } +` + actual := diff( + struct{ foo string }{"hello"}, + struct{ foo string }{"bar"}, + ) + Equal(t, expected, actual) + + expected = ` + +Diff: +--- Expected ++++ Actual +@@ -2,5 +2,5 @@ + (int) 1, +- (int) 2, + (int) 3, +- (int) 4 ++ (int) 5, ++ (int) 7 + } +` + actual = diff( + []int{1, 2, 3, 4}, + []int{1, 3, 5, 7}, + ) + Equal(t, expected, actual) + + expected = ` + +Diff: +--- Expected ++++ Actual +@@ -2,4 +2,4 @@ + (int) 1, +- (int) 2, +- (int) 3 ++ (int) 3, ++ (int) 5 + } +` + actual = diff( + []int{1, 2, 3, 4}[0:3], + []int{1, 3, 5, 7}[0:3], + ) + Equal(t, expected, actual) + + expected = ` + +Diff: +--- Expected ++++ Actual +@@ -1,6 +1,6 @@ + (map[string]int) (len=4) { +- (string) (len=4) "four": (int) 4, ++ (string) (len=4) "five": (int) 5, + (string) (len=3) "one": (int) 1, +- (string) (len=5) "three": (int) 3, +- (string) (len=3) "two": (int) 2 ++ (string) (len=5) "seven": (int) 7, ++ (string) (len=5) "three": (int) 3 + } +` + + actual = diff( + map[string]int{"one": 1, "two": 2, "three": 3, "four": 4}, + map[string]int{"one": 1, "three": 3, "five": 5, "seven": 7}, + ) + Equal(t, expected, actual) +} + +func TestDiffEmptyCases(t *testing.T) { + Equal(t, "", diff(nil, nil)) + Equal(t, "", diff(struct{ foo string }{}, nil)) + Equal(t, "", diff(nil, struct{ foo string }{})) + Equal(t, "", diff(1, 2)) + Equal(t, "", diff(1, 2)) + Equal(t, "", diff([]int{1}, []bool{true})) +} + +// Ensure there are no data races +func TestDiffRace(t *testing.T) { + t.Parallel() + + expected := map[string]string{ + "a": "A", + "b": "B", + "c": "C", + } + + actual := map[string]string{ + "d": "D", + "e": "E", + "f": "F", + } + + // run diffs in parallel simulating tests with t.Parallel() + numRoutines := 10 + rChans := make([]chan string, numRoutines) + for idx := range rChans { + rChans[idx] = make(chan string) + go func(ch chan string) { + defer close(ch) + ch <- diff(expected, actual) + }(rChans[idx]) + } + + for _, ch := range rChans { + for msg := range ch { + NotZero(t, msg) // dummy assert + } + } +} + +type mockTestingT struct { +} + +func (m *mockTestingT) Errorf(format string, args ...interface{}) {} + +func TestFailNowWithPlainTestingT(t *testing.T) { + mockT := &mockTestingT{} + + Panics(t, func() { + FailNow(mockT, "failed") + }, "should panic since mockT is missing FailNow()") +} + +type mockFailNowTestingT struct { +} + +func (m *mockFailNowTestingT) Errorf(format string, args ...interface{}) {} + +func (m *mockFailNowTestingT) FailNow() {} + +func TestFailNowWithFullTestingT(t *testing.T) { + mockT := &mockFailNowTestingT{} + + NotPanics(t, func() { + FailNow(mockT, "failed") + }, "should call mockT.FailNow() rather than panicking") +} + +func TestBytesEqual(t *testing.T) { + var cases = []struct { + a, b []byte + }{ + {make([]byte, 2), make([]byte, 2)}, + {make([]byte, 2), make([]byte, 2, 3)}, + {nil, make([]byte, 0)}, + } + for i, c := range cases { + Equal(t, reflect.DeepEqual(c.a, c.b), ObjectsAreEqual(c.a, c.b), "case %d failed", i+1) + } +} + +func BenchmarkBytesEqual(b *testing.B) { + const size = 1024 * 8 + s := make([]byte, size) + for i := range s { + s[i] = byte(i % 255) + } + s2 := make([]byte, size) + copy(s2, s) + + mockT := &mockFailNowTestingT{} + b.ResetTimer() + for i := 0; i < b.N; i++ { + Equal(mockT, s, s2) + } +} + +func TestEqualArgsValidation(t *testing.T) { + err := validateEqualArgs(time.Now, time.Now) + EqualError(t, err, "cannot take func type as argument") +} + +func ExampleComparisonAssertionFunc() { + t := &testing.T{} // provided by test + + adder := func(x, y int) int { + return x + y + } + + type args struct { + x int + y int + } + + tests := []struct { + name string + args args + expect int + assertion ComparisonAssertionFunc + }{ + {"2+2=4", args{2, 2}, 4, Equal}, + {"2+2!=5", args{2, 2}, 5, NotEqual}, + {"2+3==5", args{2, 3}, 5, Exactly}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.assertion(t, tt.expect, adder(tt.args.x, tt.args.y)) + }) + } +} + +func TestComparisonAssertionFunc(t *testing.T) { + type iface interface { + Name() string + } + + tests := []struct { + name string + expect interface{} + got interface{} + assertion ComparisonAssertionFunc + }{ + {"implements", (*iface)(nil), t, Implements}, + {"isType", (*testing.T)(nil), t, IsType}, + {"equal", t, t, Equal}, + {"equalValues", t, t, EqualValues}, + {"exactly", t, t, Exactly}, + {"notEqual", t, nil, NotEqual}, + {"notContains", []int{1, 2, 3}, 4, NotContains}, + {"subset", []int{1, 2, 3, 4}, []int{2, 3}, Subset}, + {"notSubset", []int{1, 2, 3, 4}, []int{0, 3}, NotSubset}, + {"elementsMatch", []byte("abc"), []byte("bac"), ElementsMatch}, + {"regexp", "^t.*y$", "testify", Regexp}, + {"notRegexp", "^t.*y$", "Testify", NotRegexp}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.assertion(t, tt.expect, tt.got) + }) + } +} + +func ExampleValueAssertionFunc() { + t := &testing.T{} // provided by test + + dumbParse := func(input string) interface{} { + var x interface{} + json.Unmarshal([]byte(input), &x) + return x + } + + tests := []struct { + name string + arg string + assertion ValueAssertionFunc + }{ + {"true is not nil", "true", NotNil}, + {"empty string is nil", "", Nil}, + {"zero is not nil", "0", NotNil}, + {"zero is zero", "0", Zero}, + {"false is zero", "false", Zero}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.assertion(t, dumbParse(tt.arg)) + }) + } +} + +func TestValueAssertionFunc(t *testing.T) { + tests := []struct { + name string + value interface{} + assertion ValueAssertionFunc + }{ + {"notNil", true, NotNil}, + {"nil", nil, Nil}, + {"empty", []int{}, Empty}, + {"notEmpty", []int{1}, NotEmpty}, + {"zero", false, Zero}, + {"notZero", 42, NotZero}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.assertion(t, tt.value) + }) + } +} + +func ExampleBoolAssertionFunc() { + t := &testing.T{} // provided by test + + isOkay := func(x int) bool { + return x >= 42 + } + + tests := []struct { + name string + arg int + assertion BoolAssertionFunc + }{ + {"-1 is bad", -1, False}, + {"42 is good", 42, True}, + {"41 is bad", 41, False}, + {"45 is cool", 45, True}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.assertion(t, isOkay(tt.arg)) + }) + } +} + +func TestBoolAssertionFunc(t *testing.T) { + tests := []struct { + name string + value bool + assertion BoolAssertionFunc + }{ + {"true", true, True}, + {"false", false, False}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.assertion(t, tt.value) + }) + } +} + +func ExampleErrorAssertionFunc() { + t := &testing.T{} // provided by test + + dumbParseNum := func(input string, v interface{}) error { + return json.Unmarshal([]byte(input), v) + } + + tests := []struct { + name string + arg string + assertion ErrorAssertionFunc + }{ + {"1.2 is number", "1.2", NoError}, + {"1.2.3 not number", "1.2.3", Error}, + {"true is not number", "true", Error}, + {"3 is number", "3", NoError}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var x float64 + tt.assertion(t, dumbParseNum(tt.arg, &x)) + }) + } +} + +func TestErrorAssertionFunc(t *testing.T) { + tests := []struct { + name string + err error + assertion ErrorAssertionFunc + }{ + {"noError", nil, NoError}, + {"error", errors.New("whoops"), Error}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.assertion(t, tt.err) + }) + } +} diff --git a/vendor/github.com/stretchr/testify/assert/forward_assertions.go b/vendor/github.com/stretchr/testify/assert/forward_assertions.go index b867e95..9ad5685 100644 --- a/vendor/github.com/stretchr/testify/assert/forward_assertions.go +++ b/vendor/github.com/stretchr/testify/assert/forward_assertions.go @@ -13,4 +13,4 @@ func New(t TestingT) *Assertions { } } -//go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl +//go:generate go run ../_codegen/main.go -output-package=assert -template=assertion_forward.go.tmpl -include-format-funcs diff --git a/vendor/github.com/stretchr/testify/assert/forward_assertions_test.go b/vendor/github.com/stretchr/testify/assert/forward_assertions_test.go new file mode 100644 index 0000000..22e1df1 --- /dev/null +++ b/vendor/github.com/stretchr/testify/assert/forward_assertions_test.go @@ -0,0 +1,611 @@ +package assert + +import ( + "errors" + "regexp" + "testing" + "time" +) + +func TestImplementsWrapper(t *testing.T) { + assert := New(new(testing.T)) + + if !assert.Implements((*AssertionTesterInterface)(nil), new(AssertionTesterConformingObject)) { + t.Error("Implements method should return true: AssertionTesterConformingObject implements AssertionTesterInterface") + } + if assert.Implements((*AssertionTesterInterface)(nil), new(AssertionTesterNonConformingObject)) { + t.Error("Implements method should return false: AssertionTesterNonConformingObject does not implements AssertionTesterInterface") + } +} + +func TestIsTypeWrapper(t *testing.T) { + assert := New(new(testing.T)) + + if !assert.IsType(new(AssertionTesterConformingObject), new(AssertionTesterConformingObject)) { + t.Error("IsType should return true: AssertionTesterConformingObject is the same type as AssertionTesterConformingObject") + } + if assert.IsType(new(AssertionTesterConformingObject), new(AssertionTesterNonConformingObject)) { + t.Error("IsType should return false: AssertionTesterConformingObject is not the same type as AssertionTesterNonConformingObject") + } + +} + +func TestEqualWrapper(t *testing.T) { + assert := New(new(testing.T)) + + if !assert.Equal("Hello World", "Hello World") { + t.Error("Equal should return true") + } + if !assert.Equal(123, 123) { + t.Error("Equal should return true") + } + if !assert.Equal(123.5, 123.5) { + t.Error("Equal should return true") + } + if !assert.Equal([]byte("Hello World"), []byte("Hello World")) { + t.Error("Equal should return true") + } + if !assert.Equal(nil, nil) { + t.Error("Equal should return true") + } +} + +func TestEqualValuesWrapper(t *testing.T) { + assert := New(new(testing.T)) + + if !assert.EqualValues(uint32(10), int32(10)) { + t.Error("EqualValues should return true") + } +} + +func TestNotNilWrapper(t *testing.T) { + assert := New(new(testing.T)) + + if !assert.NotNil(new(AssertionTesterConformingObject)) { + t.Error("NotNil should return true: object is not nil") + } + if assert.NotNil(nil) { + t.Error("NotNil should return false: object is nil") + } + +} + +func TestNilWrapper(t *testing.T) { + assert := New(new(testing.T)) + + if !assert.Nil(nil) { + t.Error("Nil should return true: object is nil") + } + if assert.Nil(new(AssertionTesterConformingObject)) { + t.Error("Nil should return false: object is not nil") + } + +} + +func TestTrueWrapper(t *testing.T) { + assert := New(new(testing.T)) + + if !assert.True(true) { + t.Error("True should return true") + } + if assert.True(false) { + t.Error("True should return false") + } + +} + +func TestFalseWrapper(t *testing.T) { + assert := New(new(testing.T)) + + if !assert.False(false) { + t.Error("False should return true") + } + if assert.False(true) { + t.Error("False should return false") + } + +} + +func TestExactlyWrapper(t *testing.T) { + assert := New(new(testing.T)) + + a := float32(1) + b := float64(1) + c := float32(1) + d := float32(2) + + if assert.Exactly(a, b) { + t.Error("Exactly should return false") + } + if assert.Exactly(a, d) { + t.Error("Exactly should return false") + } + if !assert.Exactly(a, c) { + t.Error("Exactly should return true") + } + + if assert.Exactly(nil, a) { + t.Error("Exactly should return false") + } + if assert.Exactly(a, nil) { + t.Error("Exactly should return false") + } + +} + +func TestNotEqualWrapper(t *testing.T) { + + assert := New(new(testing.T)) + + if !assert.NotEqual("Hello World", "Hello World!") { + t.Error("NotEqual should return true") + } + if !assert.NotEqual(123, 1234) { + t.Error("NotEqual should return true") + } + if !assert.NotEqual(123.5, 123.55) { + t.Error("NotEqual should return true") + } + if !assert.NotEqual([]byte("Hello World"), []byte("Hello World!")) { + t.Error("NotEqual should return true") + } + if !assert.NotEqual(nil, new(AssertionTesterConformingObject)) { + t.Error("NotEqual should return true") + } +} + +func TestContainsWrapper(t *testing.T) { + + assert := New(new(testing.T)) + list := []string{"Foo", "Bar"} + + if !assert.Contains("Hello World", "Hello") { + t.Error("Contains should return true: \"Hello World\" contains \"Hello\"") + } + if assert.Contains("Hello World", "Salut") { + t.Error("Contains should return false: \"Hello World\" does not contain \"Salut\"") + } + + if !assert.Contains(list, "Foo") { + t.Error("Contains should return true: \"[\"Foo\", \"Bar\"]\" contains \"Foo\"") + } + if assert.Contains(list, "Salut") { + t.Error("Contains should return false: \"[\"Foo\", \"Bar\"]\" does not contain \"Salut\"") + } + +} + +func TestNotContainsWrapper(t *testing.T) { + + assert := New(new(testing.T)) + list := []string{"Foo", "Bar"} + + if !assert.NotContains("Hello World", "Hello!") { + t.Error("NotContains should return true: \"Hello World\" does not contain \"Hello!\"") + } + if assert.NotContains("Hello World", "Hello") { + t.Error("NotContains should return false: \"Hello World\" contains \"Hello\"") + } + + if !assert.NotContains(list, "Foo!") { + t.Error("NotContains should return true: \"[\"Foo\", \"Bar\"]\" does not contain \"Foo!\"") + } + if assert.NotContains(list, "Foo") { + t.Error("NotContains should return false: \"[\"Foo\", \"Bar\"]\" contains \"Foo\"") + } + +} + +func TestConditionWrapper(t *testing.T) { + + assert := New(new(testing.T)) + + if !assert.Condition(func() bool { return true }, "Truth") { + t.Error("Condition should return true") + } + + if assert.Condition(func() bool { return false }, "Lie") { + t.Error("Condition should return false") + } + +} + +func TestDidPanicWrapper(t *testing.T) { + + if funcDidPanic, _ := didPanic(func() { + panic("Panic!") + }); !funcDidPanic { + t.Error("didPanic should return true") + } + + if funcDidPanic, _ := didPanic(func() { + }); funcDidPanic { + t.Error("didPanic should return false") + } + +} + +func TestPanicsWrapper(t *testing.T) { + + assert := New(new(testing.T)) + + if !assert.Panics(func() { + panic("Panic!") + }) { + t.Error("Panics should return true") + } + + if assert.Panics(func() { + }) { + t.Error("Panics should return false") + } + +} + +func TestNotPanicsWrapper(t *testing.T) { + + assert := New(new(testing.T)) + + if !assert.NotPanics(func() { + }) { + t.Error("NotPanics should return true") + } + + if assert.NotPanics(func() { + panic("Panic!") + }) { + t.Error("NotPanics should return false") + } + +} + +func TestNoErrorWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + // start with a nil error + var err error + + assert.True(mockAssert.NoError(err), "NoError should return True for nil arg") + + // now set an error + err = errors.New("Some error") + + assert.False(mockAssert.NoError(err), "NoError with error should return False") + +} + +func TestErrorWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + // start with a nil error + var err error + + assert.False(mockAssert.Error(err), "Error should return False for nil arg") + + // now set an error + err = errors.New("Some error") + + assert.True(mockAssert.Error(err), "Error with error should return True") + +} + +func TestEqualErrorWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + // start with a nil error + var err error + assert.False(mockAssert.EqualError(err, ""), + "EqualError should return false for nil arg") + + // now set an error + err = errors.New("some error") + assert.False(mockAssert.EqualError(err, "Not some error"), + "EqualError should return false for different error string") + assert.True(mockAssert.EqualError(err, "some error"), + "EqualError should return true") +} + +func TestEmptyWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + assert.True(mockAssert.Empty(""), "Empty string is empty") + assert.True(mockAssert.Empty(nil), "Nil is empty") + assert.True(mockAssert.Empty([]string{}), "Empty string array is empty") + assert.True(mockAssert.Empty(0), "Zero int value is empty") + assert.True(mockAssert.Empty(false), "False value is empty") + + assert.False(mockAssert.Empty("something"), "Non Empty string is not empty") + assert.False(mockAssert.Empty(errors.New("something")), "Non nil object is not empty") + assert.False(mockAssert.Empty([]string{"something"}), "Non empty string array is not empty") + assert.False(mockAssert.Empty(1), "Non-zero int value is not empty") + assert.False(mockAssert.Empty(true), "True value is not empty") + +} + +func TestNotEmptyWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + assert.False(mockAssert.NotEmpty(""), "Empty string is empty") + assert.False(mockAssert.NotEmpty(nil), "Nil is empty") + assert.False(mockAssert.NotEmpty([]string{}), "Empty string array is empty") + assert.False(mockAssert.NotEmpty(0), "Zero int value is empty") + assert.False(mockAssert.NotEmpty(false), "False value is empty") + + assert.True(mockAssert.NotEmpty("something"), "Non Empty string is not empty") + assert.True(mockAssert.NotEmpty(errors.New("something")), "Non nil object is not empty") + assert.True(mockAssert.NotEmpty([]string{"something"}), "Non empty string array is not empty") + assert.True(mockAssert.NotEmpty(1), "Non-zero int value is not empty") + assert.True(mockAssert.NotEmpty(true), "True value is not empty") + +} + +func TestLenWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + assert.False(mockAssert.Len(nil, 0), "nil does not have length") + assert.False(mockAssert.Len(0, 0), "int does not have length") + assert.False(mockAssert.Len(true, 0), "true does not have length") + assert.False(mockAssert.Len(false, 0), "false does not have length") + assert.False(mockAssert.Len('A', 0), "Rune does not have length") + assert.False(mockAssert.Len(struct{}{}, 0), "Struct does not have length") + + ch := make(chan int, 5) + ch <- 1 + ch <- 2 + ch <- 3 + + cases := []struct { + v interface{} + l int + }{ + {[]int{1, 2, 3}, 3}, + {[...]int{1, 2, 3}, 3}, + {"ABC", 3}, + {map[int]int{1: 2, 2: 4, 3: 6}, 3}, + {ch, 3}, + + {[]int{}, 0}, + {map[int]int{}, 0}, + {make(chan int), 0}, + + {[]int(nil), 0}, + {map[int]int(nil), 0}, + {(chan int)(nil), 0}, + } + + for _, c := range cases { + assert.True(mockAssert.Len(c.v, c.l), "%#v have %d items", c.v, c.l) + } +} + +func TestWithinDurationWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + a := time.Now() + b := a.Add(10 * time.Second) + + assert.True(mockAssert.WithinDuration(a, b, 10*time.Second), "A 10s difference is within a 10s time difference") + assert.True(mockAssert.WithinDuration(b, a, 10*time.Second), "A 10s difference is within a 10s time difference") + + assert.False(mockAssert.WithinDuration(a, b, 9*time.Second), "A 10s difference is not within a 9s time difference") + assert.False(mockAssert.WithinDuration(b, a, 9*time.Second), "A 10s difference is not within a 9s time difference") + + assert.False(mockAssert.WithinDuration(a, b, -9*time.Second), "A 10s difference is not within a 9s time difference") + assert.False(mockAssert.WithinDuration(b, a, -9*time.Second), "A 10s difference is not within a 9s time difference") + + assert.False(mockAssert.WithinDuration(a, b, -11*time.Second), "A 10s difference is not within a 9s time difference") + assert.False(mockAssert.WithinDuration(b, a, -11*time.Second), "A 10s difference is not within a 9s time difference") +} + +func TestInDeltaWrapper(t *testing.T) { + assert := New(new(testing.T)) + + True(t, assert.InDelta(1.001, 1, 0.01), "|1.001 - 1| <= 0.01") + True(t, assert.InDelta(1, 1.001, 0.01), "|1 - 1.001| <= 0.01") + True(t, assert.InDelta(1, 2, 1), "|1 - 2| <= 1") + False(t, assert.InDelta(1, 2, 0.5), "Expected |1 - 2| <= 0.5 to fail") + False(t, assert.InDelta(2, 1, 0.5), "Expected |2 - 1| <= 0.5 to fail") + False(t, assert.InDelta("", nil, 1), "Expected non numerals to fail") + + cases := []struct { + a, b interface{} + delta float64 + }{ + {uint8(2), uint8(1), 1}, + {uint16(2), uint16(1), 1}, + {uint32(2), uint32(1), 1}, + {uint64(2), uint64(1), 1}, + + {int(2), int(1), 1}, + {int8(2), int8(1), 1}, + {int16(2), int16(1), 1}, + {int32(2), int32(1), 1}, + {int64(2), int64(1), 1}, + + {float32(2), float32(1), 1}, + {float64(2), float64(1), 1}, + } + + for _, tc := range cases { + True(t, assert.InDelta(tc.a, tc.b, tc.delta), "Expected |%V - %V| <= %v", tc.a, tc.b, tc.delta) + } +} + +func TestInEpsilonWrapper(t *testing.T) { + assert := New(new(testing.T)) + + cases := []struct { + a, b interface{} + epsilon float64 + }{ + {uint8(2), uint16(2), .001}, + {2.1, 2.2, 0.1}, + {2.2, 2.1, 0.1}, + {-2.1, -2.2, 0.1}, + {-2.2, -2.1, 0.1}, + {uint64(100), uint8(101), 0.01}, + {0.1, -0.1, 2}, + } + + for _, tc := range cases { + True(t, assert.InEpsilon(tc.a, tc.b, tc.epsilon, "Expected %V and %V to have a relative difference of %v", tc.a, tc.b, tc.epsilon)) + } + + cases = []struct { + a, b interface{} + epsilon float64 + }{ + {uint8(2), int16(-2), .001}, + {uint64(100), uint8(102), 0.01}, + {2.1, 2.2, 0.001}, + {2.2, 2.1, 0.001}, + {2.1, -2.2, 1}, + {2.1, "bla-bla", 0}, + {0.1, -0.1, 1.99}, + } + + for _, tc := range cases { + False(t, assert.InEpsilon(tc.a, tc.b, tc.epsilon, "Expected %V and %V to have a relative difference of %v", tc.a, tc.b, tc.epsilon)) + } +} + +func TestRegexpWrapper(t *testing.T) { + + assert := New(new(testing.T)) + + cases := []struct { + rx, str string + }{ + {"^start", "start of the line"}, + {"end$", "in the end"}, + {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12.34"}, + } + + for _, tc := range cases { + True(t, assert.Regexp(tc.rx, tc.str)) + True(t, assert.Regexp(regexp.MustCompile(tc.rx), tc.str)) + False(t, assert.NotRegexp(tc.rx, tc.str)) + False(t, assert.NotRegexp(regexp.MustCompile(tc.rx), tc.str)) + } + + cases = []struct { + rx, str string + }{ + {"^asdfastart", "Not the start of the line"}, + {"end$", "in the end."}, + {"[0-9]{3}[.-]?[0-9]{2}[.-]?[0-9]{2}", "My phone number is 650.12a.34"}, + } + + for _, tc := range cases { + False(t, assert.Regexp(tc.rx, tc.str), "Expected \"%s\" to not match \"%s\"", tc.rx, tc.str) + False(t, assert.Regexp(regexp.MustCompile(tc.rx), tc.str)) + True(t, assert.NotRegexp(tc.rx, tc.str)) + True(t, assert.NotRegexp(regexp.MustCompile(tc.rx), tc.str)) + } +} + +func TestZeroWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + for _, test := range zeros { + assert.True(mockAssert.Zero(test), "Zero should return true for %v", test) + } + + for _, test := range nonZeros { + assert.False(mockAssert.Zero(test), "Zero should return false for %v", test) + } +} + +func TestNotZeroWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + for _, test := range zeros { + assert.False(mockAssert.NotZero(test), "Zero should return true for %v", test) + } + + for _, test := range nonZeros { + assert.True(mockAssert.NotZero(test), "Zero should return false for %v", test) + } +} + +func TestJSONEqWrapper_EqualSONString(t *testing.T) { + assert := New(new(testing.T)) + if !assert.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"hello": "world", "foo": "bar"}`) { + t.Error("JSONEq should return true") + } + +} + +func TestJSONEqWrapper_EquivalentButNotEqual(t *testing.T) { + assert := New(new(testing.T)) + if !assert.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) { + t.Error("JSONEq should return true") + } + +} + +func TestJSONEqWrapper_HashOfArraysAndHashes(t *testing.T) { + assert := New(new(testing.T)) + if !assert.JSONEq("{\r\n\t\"numeric\": 1.5,\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]],\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\"\r\n}", + "{\r\n\t\"numeric\": 1.5,\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\",\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]]\r\n}") { + t.Error("JSONEq should return true") + } +} + +func TestJSONEqWrapper_Array(t *testing.T) { + assert := New(new(testing.T)) + if !assert.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `["foo", {"nested": "hash", "hello": "world"}]`) { + t.Error("JSONEq should return true") + } + +} + +func TestJSONEqWrapper_HashAndArrayNotEquivalent(t *testing.T) { + assert := New(new(testing.T)) + if assert.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `{"foo": "bar", {"nested": "hash", "hello": "world"}}`) { + t.Error("JSONEq should return false") + } +} + +func TestJSONEqWrapper_HashesNotEquivalent(t *testing.T) { + assert := New(new(testing.T)) + if assert.JSONEq(`{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) { + t.Error("JSONEq should return false") + } +} + +func TestJSONEqWrapper_ActualIsNotJSON(t *testing.T) { + assert := New(new(testing.T)) + if assert.JSONEq(`{"foo": "bar"}`, "Not JSON") { + t.Error("JSONEq should return false") + } +} + +func TestJSONEqWrapper_ExpectedIsNotJSON(t *testing.T) { + assert := New(new(testing.T)) + if assert.JSONEq("Not JSON", `{"foo": "bar", "hello": "world"}`) { + t.Error("JSONEq should return false") + } +} + +func TestJSONEqWrapper_ExpectedAndActualNotJSON(t *testing.T) { + assert := New(new(testing.T)) + if assert.JSONEq("Not JSON", "Not JSON") { + t.Error("JSONEq should return false") + } +} + +func TestJSONEqWrapper_ArraysOfDifferentOrder(t *testing.T) { + assert := New(new(testing.T)) + if assert.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `[{ "hello": "world", "nested": "hash"}, "foo"]`) { + t.Error("JSONEq should return false") + } +} diff --git a/vendor/github.com/stretchr/testify/assert/http_assertions.go b/vendor/github.com/stretchr/testify/assert/http_assertions.go index e1b9442..df46fa7 100644 --- a/vendor/github.com/stretchr/testify/assert/http_assertions.go +++ b/vendor/github.com/stretchr/testify/assert/http_assertions.go @@ -8,16 +8,17 @@ import ( "strings" ) -// httpCode is a helper that returns HTTP code of the response. It returns -1 -// if building a new request fails. -func httpCode(handler http.HandlerFunc, method, url string, values url.Values) int { +// httpCode is a helper that returns HTTP code of the response. It returns -1 and +// an error if building a new request fails. +func httpCode(handler http.HandlerFunc, method, url string, values url.Values) (int, error) { w := httptest.NewRecorder() - req, err := http.NewRequest(method, url+"?"+values.Encode(), nil) + req, err := http.NewRequest(method, url, nil) if err != nil { - return -1 + return -1, err } + req.URL.RawQuery = values.Encode() handler(w, req) - return w.Code + return w.Code, nil } // HTTPSuccess asserts that a specified handler returns a success status code. @@ -25,12 +26,22 @@ func httpCode(handler http.HandlerFunc, method, url string, values url.Values) i // assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) // // Returns whether the assertion was successful (true) or not (false). -func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool { - code := httpCode(handler, method, url, values) - if code == -1 { +func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + code, err := httpCode(handler, method, url, values) + if err != nil { + Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) return false } - return code >= http.StatusOK && code <= http.StatusPartialContent + + isSuccessCode := code >= http.StatusOK && code <= http.StatusPartialContent + if !isSuccessCode { + Fail(t, fmt.Sprintf("Expected HTTP success status code for %q but received %d", url+"?"+values.Encode(), code)) + } + + return isSuccessCode } // HTTPRedirect asserts that a specified handler returns a redirect status code. @@ -38,12 +49,22 @@ func HTTPSuccess(t TestingT, handler http.HandlerFunc, method, url string, value // assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). -func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool { - code := httpCode(handler, method, url, values) - if code == -1 { +func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + code, err := httpCode(handler, method, url, values) + if err != nil { + Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) return false } - return code >= http.StatusMultipleChoices && code <= http.StatusTemporaryRedirect + + isRedirectCode := code >= http.StatusMultipleChoices && code <= http.StatusTemporaryRedirect + if !isRedirectCode { + Fail(t, fmt.Sprintf("Expected HTTP redirect status code for %q but received %d", url+"?"+values.Encode(), code)) + } + + return isRedirectCode } // HTTPError asserts that a specified handler returns an error status code. @@ -51,12 +72,22 @@ func HTTPRedirect(t TestingT, handler http.HandlerFunc, method, url string, valu // assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} // // Returns whether the assertion was successful (true) or not (false). -func HTTPError(t TestingT, handler http.HandlerFunc, method, url string, values url.Values) bool { - code := httpCode(handler, method, url, values) - if code == -1 { +func HTTPError(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + code, err := httpCode(handler, method, url, values) + if err != nil { + Fail(t, fmt.Sprintf("Failed to build test request, got error: %s", err)) return false } - return code >= http.StatusBadRequest + + isErrorCode := code >= http.StatusBadRequest + if !isErrorCode { + Fail(t, fmt.Sprintf("Expected HTTP error status code for %q but received %d", url+"?"+values.Encode(), code)) + } + + return isErrorCode } // HTTPBody is a helper that returns HTTP body of the response. It returns @@ -74,10 +105,13 @@ func HTTPBody(handler http.HandlerFunc, method, url string, values url.Values) s // HTTPBodyContains asserts that a specified handler returns a // body that contains a string. // -// assert.HTTPBodyContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky") +// assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") // // Returns whether the assertion was successful (true) or not (false). -func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}) bool { +func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } body := HTTPBody(handler, method, url, values) contains := strings.Contains(body, fmt.Sprint(str)) @@ -91,15 +125,18 @@ func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method, url string, // HTTPBodyNotContains asserts that a specified handler returns a // body that does not contain a string. // -// assert.HTTPBodyNotContains(t, myHandler, "www.google.com", nil, "I'm Feeling Lucky") +// assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") // // Returns whether the assertion was successful (true) or not (false). -func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}) bool { +func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } body := HTTPBody(handler, method, url, values) contains := strings.Contains(body, fmt.Sprint(str)) if contains { - Fail(t, "Expected response body for %s to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body) + Fail(t, fmt.Sprintf("Expected response body for \"%s\" to NOT contain \"%s\" but found \"%s\"", url+"?"+values.Encode(), str, body)) } return !contains diff --git a/vendor/github.com/stretchr/testify/assert/http_assertions_test.go b/vendor/github.com/stretchr/testify/assert/http_assertions_test.go new file mode 100644 index 0000000..112beaf --- /dev/null +++ b/vendor/github.com/stretchr/testify/assert/http_assertions_test.go @@ -0,0 +1,146 @@ +package assert + +import ( + "fmt" + "net/http" + "net/url" + "testing" +) + +func httpOK(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusOK) +} + +func httpRedirect(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusTemporaryRedirect) +} + +func httpError(w http.ResponseWriter, r *http.Request) { + w.WriteHeader(http.StatusInternalServerError) +} + +func TestHTTPSuccess(t *testing.T) { + assert := New(t) + + mockT1 := new(testing.T) + assert.Equal(HTTPSuccess(mockT1, httpOK, "GET", "/", nil), true) + assert.False(mockT1.Failed()) + + mockT2 := new(testing.T) + assert.Equal(HTTPSuccess(mockT2, httpRedirect, "GET", "/", nil), false) + assert.True(mockT2.Failed()) + + mockT3 := new(testing.T) + assert.Equal(HTTPSuccess(mockT3, httpError, "GET", "/", nil), false) + assert.True(mockT3.Failed()) +} + +func TestHTTPRedirect(t *testing.T) { + assert := New(t) + + mockT1 := new(testing.T) + assert.Equal(HTTPRedirect(mockT1, httpOK, "GET", "/", nil), false) + assert.True(mockT1.Failed()) + + mockT2 := new(testing.T) + assert.Equal(HTTPRedirect(mockT2, httpRedirect, "GET", "/", nil), true) + assert.False(mockT2.Failed()) + + mockT3 := new(testing.T) + assert.Equal(HTTPRedirect(mockT3, httpError, "GET", "/", nil), false) + assert.True(mockT3.Failed()) +} + +func TestHTTPError(t *testing.T) { + assert := New(t) + + mockT1 := new(testing.T) + assert.Equal(HTTPError(mockT1, httpOK, "GET", "/", nil), false) + assert.True(mockT1.Failed()) + + mockT2 := new(testing.T) + assert.Equal(HTTPError(mockT2, httpRedirect, "GET", "/", nil), false) + assert.True(mockT2.Failed()) + + mockT3 := new(testing.T) + assert.Equal(HTTPError(mockT3, httpError, "GET", "/", nil), true) + assert.False(mockT3.Failed()) +} + +func TestHTTPStatusesWrapper(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + assert.Equal(mockAssert.HTTPSuccess(httpOK, "GET", "/", nil), true) + assert.Equal(mockAssert.HTTPSuccess(httpRedirect, "GET", "/", nil), false) + assert.Equal(mockAssert.HTTPSuccess(httpError, "GET", "/", nil), false) + + assert.Equal(mockAssert.HTTPRedirect(httpOK, "GET", "/", nil), false) + assert.Equal(mockAssert.HTTPRedirect(httpRedirect, "GET", "/", nil), true) + assert.Equal(mockAssert.HTTPRedirect(httpError, "GET", "/", nil), false) + + assert.Equal(mockAssert.HTTPError(httpOK, "GET", "/", nil), false) + assert.Equal(mockAssert.HTTPError(httpRedirect, "GET", "/", nil), false) + assert.Equal(mockAssert.HTTPError(httpError, "GET", "/", nil), true) +} + +func httpHelloName(w http.ResponseWriter, r *http.Request) { + name := r.FormValue("name") + w.Write([]byte(fmt.Sprintf("Hello, %s!", name))) +} + +func TestHTTPRequestWithNoParams(t *testing.T) { + var got *http.Request + handler := func(w http.ResponseWriter, r *http.Request) { + got = r + w.WriteHeader(http.StatusOK) + } + + True(t, HTTPSuccess(t, handler, "GET", "/url", nil)) + + Empty(t, got.URL.Query()) + Equal(t, "/url", got.URL.RequestURI()) +} + +func TestHTTPRequestWithParams(t *testing.T) { + var got *http.Request + handler := func(w http.ResponseWriter, r *http.Request) { + got = r + w.WriteHeader(http.StatusOK) + } + params := url.Values{} + params.Add("id", "12345") + + True(t, HTTPSuccess(t, handler, "GET", "/url", params)) + + Equal(t, url.Values{"id": []string{"12345"}}, got.URL.Query()) + Equal(t, "/url?id=12345", got.URL.String()) + Equal(t, "/url?id=12345", got.URL.RequestURI()) +} + +func TestHttpBody(t *testing.T) { + assert := New(t) + mockT := new(testing.T) + + assert.True(HTTPBodyContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "Hello, World!")) + assert.True(HTTPBodyContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "World")) + assert.False(HTTPBodyContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "world")) + + assert.False(HTTPBodyNotContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "Hello, World!")) + assert.False(HTTPBodyNotContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "World")) + assert.True(HTTPBodyNotContains(mockT, httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "world")) +} + +func TestHttpBodyWrappers(t *testing.T) { + assert := New(t) + mockAssert := New(new(testing.T)) + + assert.True(mockAssert.HTTPBodyContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "Hello, World!")) + assert.True(mockAssert.HTTPBodyContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "World")) + assert.False(mockAssert.HTTPBodyContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "world")) + + assert.False(mockAssert.HTTPBodyNotContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "Hello, World!")) + assert.False(mockAssert.HTTPBodyNotContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "World")) + assert.True(mockAssert.HTTPBodyNotContains(httpHelloName, "GET", "/", url.Values{"name": []string{"World"}}, "world")) + +} diff --git a/vendor/github.com/stretchr/testify/doc.go b/vendor/github.com/stretchr/testify/doc.go new file mode 100644 index 0000000..377d5cc --- /dev/null +++ b/vendor/github.com/stretchr/testify/doc.go @@ -0,0 +1,22 @@ +// Package testify is a set of packages that provide many tools for testifying that your code will behave as you intend. +// +// testify contains the following packages: +// +// The assert package provides a comprehensive set of assertion functions that tie in to the Go testing system. +// +// The http package contains tools to make it easier to test http activity using the Go testing system. +// +// The mock package provides a system by which it is possible to mock your objects and verify calls are happening as expected. +// +// The suite package provides a basic structure for using structs as testing suites, and methods on those structs as tests. It includes setup/teardown functionality in the way of interfaces. +package testify + +// blank imports help docs. +import ( + // assert package + _ "github.com/stretchr/testify/assert" + // http package + _ "github.com/stretchr/testify/http" + // mock package + _ "github.com/stretchr/testify/mock" +) diff --git a/vendor/github.com/stretchr/testify/go.mod b/vendor/github.com/stretchr/testify/go.mod new file mode 100644 index 0000000..90e5dbe --- /dev/null +++ b/vendor/github.com/stretchr/testify/go.mod @@ -0,0 +1,7 @@ +module github.com/stretchr/testify + +require ( + github.com/davecgh/go-spew v1.1.0 + github.com/pmezard/go-difflib v1.0.0 + github.com/stretchr/objx v0.1.0 +) diff --git a/vendor/github.com/stretchr/testify/go.sum b/vendor/github.com/stretchr/testify/go.sum new file mode 100644 index 0000000..5b98bf3 --- /dev/null +++ b/vendor/github.com/stretchr/testify/go.sum @@ -0,0 +1,6 @@ +github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= diff --git a/vendor/github.com/stretchr/testify/http/doc.go b/vendor/github.com/stretchr/testify/http/doc.go new file mode 100644 index 0000000..695167c --- /dev/null +++ b/vendor/github.com/stretchr/testify/http/doc.go @@ -0,0 +1,2 @@ +// Package http DEPRECATED USE net/http/httptest +package http diff --git a/vendor/github.com/stretchr/testify/http/test_response_writer.go b/vendor/github.com/stretchr/testify/http/test_response_writer.go new file mode 100644 index 0000000..5c3f813 --- /dev/null +++ b/vendor/github.com/stretchr/testify/http/test_response_writer.go @@ -0,0 +1,49 @@ +package http + +import ( + "net/http" +) + +// TestResponseWriter DEPRECATED: We recommend you use http://golang.org/pkg/net/http/httptest instead. +type TestResponseWriter struct { + + // StatusCode is the last int written by the call to WriteHeader(int) + StatusCode int + + // Output is a string containing the written bytes using the Write([]byte) func. + Output string + + // header is the internal storage of the http.Header object + header http.Header +} + +// Header DEPRECATED: We recommend you use http://golang.org/pkg/net/http/httptest instead. +func (rw *TestResponseWriter) Header() http.Header { + + if rw.header == nil { + rw.header = make(http.Header) + } + + return rw.header +} + +// Write DEPRECATED: We recommend you use http://golang.org/pkg/net/http/httptest instead. +func (rw *TestResponseWriter) Write(bytes []byte) (int, error) { + + // assume 200 success if no header has been set + if rw.StatusCode == 0 { + rw.WriteHeader(200) + } + + // add these bytes to the output string + rw.Output = rw.Output + string(bytes) + + // return normal values + return 0, nil + +} + +// WriteHeader DEPRECATED: We recommend you use http://golang.org/pkg/net/http/httptest instead. +func (rw *TestResponseWriter) WriteHeader(i int) { + rw.StatusCode = i +} diff --git a/vendor/github.com/stretchr/testify/http/test_round_tripper.go b/vendor/github.com/stretchr/testify/http/test_round_tripper.go new file mode 100644 index 0000000..b1e32f1 --- /dev/null +++ b/vendor/github.com/stretchr/testify/http/test_round_tripper.go @@ -0,0 +1,17 @@ +package http + +import ( + "github.com/stretchr/testify/mock" + "net/http" +) + +// TestRoundTripper DEPRECATED USE net/http/httptest +type TestRoundTripper struct { + mock.Mock +} + +// RoundTrip DEPRECATED USE net/http/httptest +func (t *TestRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { + args := t.Called(req) + return args.Get(0).(*http.Response), args.Error(1) +} diff --git a/vendor/github.com/stretchr/testify/mock/doc.go b/vendor/github.com/stretchr/testify/mock/doc.go new file mode 100644 index 0000000..7324128 --- /dev/null +++ b/vendor/github.com/stretchr/testify/mock/doc.go @@ -0,0 +1,44 @@ +// Package mock provides a system by which it is possible to mock your objects +// and verify calls are happening as expected. +// +// Example Usage +// +// The mock package provides an object, Mock, that tracks activity on another object. It is usually +// embedded into a test object as shown below: +// +// type MyTestObject struct { +// // add a Mock object instance +// mock.Mock +// +// // other fields go here as normal +// } +// +// When implementing the methods of an interface, you wire your functions up +// to call the Mock.Called(args...) method, and return the appropriate values. +// +// For example, to mock a method that saves the name and age of a person and returns +// the year of their birth or an error, you might write this: +// +// func (o *MyTestObject) SavePersonDetails(firstname, lastname string, age int) (int, error) { +// args := o.Called(firstname, lastname, age) +// return args.Int(0), args.Error(1) +// } +// +// The Int, Error and Bool methods are examples of strongly typed getters that take the argument +// index position. Given this argument list: +// +// (12, true, "Something") +// +// You could read them out strongly typed like this: +// +// args.Int(0) +// args.Bool(1) +// args.String(2) +// +// For objects of your own type, use the generic Arguments.Get(index) method and make a type assertion: +// +// return args.Get(0).(*MyObject), args.Get(1).(*AnotherObjectOfMine) +// +// This may cause a panic if the object you are getting is nil (the type assertion will fail), in those +// cases you should check for nil first. +package mock diff --git a/vendor/github.com/stretchr/testify/mock/mock.go b/vendor/github.com/stretchr/testify/mock/mock.go new file mode 100644 index 0000000..d6694ed --- /dev/null +++ b/vendor/github.com/stretchr/testify/mock/mock.go @@ -0,0 +1,886 @@ +package mock + +import ( + "errors" + "fmt" + "reflect" + "regexp" + "runtime" + "strings" + "sync" + "time" + + "github.com/davecgh/go-spew/spew" + "github.com/pmezard/go-difflib/difflib" + "github.com/stretchr/objx" + "github.com/stretchr/testify/assert" +) + +// TestingT is an interface wrapper around *testing.T +type TestingT interface { + Logf(format string, args ...interface{}) + Errorf(format string, args ...interface{}) + FailNow() +} + +/* + Call +*/ + +// Call represents a method call and is used for setting expectations, +// as well as recording activity. +type Call struct { + Parent *Mock + + // The name of the method that was or will be called. + Method string + + // Holds the arguments of the method. + Arguments Arguments + + // Holds the arguments that should be returned when + // this method is called. + ReturnArguments Arguments + + // Holds the caller info for the On() call + callerInfo []string + + // The number of times to return the return arguments when setting + // expectations. 0 means to always return the value. + Repeatability int + + // Amount of times this call has been called + totalCalls int + + // Call to this method can be optional + optional bool + + // Holds a channel that will be used to block the Return until it either + // receives a message or is closed. nil means it returns immediately. + WaitFor <-chan time.Time + + waitTime time.Duration + + // Holds a handler used to manipulate arguments content that are passed by + // reference. It's useful when mocking methods such as unmarshalers or + // decoders. + RunFn func(Arguments) +} + +func newCall(parent *Mock, methodName string, callerInfo []string, methodArguments ...interface{}) *Call { + return &Call{ + Parent: parent, + Method: methodName, + Arguments: methodArguments, + ReturnArguments: make([]interface{}, 0), + callerInfo: callerInfo, + Repeatability: 0, + WaitFor: nil, + RunFn: nil, + } +} + +func (c *Call) lock() { + c.Parent.mutex.Lock() +} + +func (c *Call) unlock() { + c.Parent.mutex.Unlock() +} + +// Return specifies the return arguments for the expectation. +// +// Mock.On("DoSomething").Return(errors.New("failed")) +func (c *Call) Return(returnArguments ...interface{}) *Call { + c.lock() + defer c.unlock() + + c.ReturnArguments = returnArguments + + return c +} + +// Once indicates that that the mock should only return the value once. +// +// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Once() +func (c *Call) Once() *Call { + return c.Times(1) +} + +// Twice indicates that that the mock should only return the value twice. +// +// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Twice() +func (c *Call) Twice() *Call { + return c.Times(2) +} + +// Times indicates that that the mock should only return the indicated number +// of times. +// +// Mock.On("MyMethod", arg1, arg2).Return(returnArg1, returnArg2).Times(5) +func (c *Call) Times(i int) *Call { + c.lock() + defer c.unlock() + c.Repeatability = i + return c +} + +// WaitUntil sets the channel that will block the mock's return until its closed +// or a message is received. +// +// Mock.On("MyMethod", arg1, arg2).WaitUntil(time.After(time.Second)) +func (c *Call) WaitUntil(w <-chan time.Time) *Call { + c.lock() + defer c.unlock() + c.WaitFor = w + return c +} + +// After sets how long to block until the call returns +// +// Mock.On("MyMethod", arg1, arg2).After(time.Second) +func (c *Call) After(d time.Duration) *Call { + c.lock() + defer c.unlock() + c.waitTime = d + return c +} + +// Run sets a handler to be called before returning. It can be used when +// mocking a method such as unmarshalers that takes a pointer to a struct and +// sets properties in such struct +// +// Mock.On("Unmarshal", AnythingOfType("*map[string]interface{}").Return().Run(func(args Arguments) { +// arg := args.Get(0).(*map[string]interface{}) +// arg["foo"] = "bar" +// }) +func (c *Call) Run(fn func(args Arguments)) *Call { + c.lock() + defer c.unlock() + c.RunFn = fn + return c +} + +// Maybe allows the method call to be optional. Not calling an optional method +// will not cause an error while asserting expectations +func (c *Call) Maybe() *Call { + c.lock() + defer c.unlock() + c.optional = true + return c +} + +// On chains a new expectation description onto the mocked interface. This +// allows syntax like. +// +// Mock. +// On("MyMethod", 1).Return(nil). +// On("MyOtherMethod", 'a', 'b', 'c').Return(errors.New("Some Error")) +//go:noinline +func (c *Call) On(methodName string, arguments ...interface{}) *Call { + return c.Parent.On(methodName, arguments...) +} + +// Mock is the workhorse used to track activity on another object. +// For an example of its usage, refer to the "Example Usage" section at the top +// of this document. +type Mock struct { + // Represents the calls that are expected of + // an object. + ExpectedCalls []*Call + + // Holds the calls that were made to this mocked object. + Calls []Call + + // test is An optional variable that holds the test struct, to be used when an + // invalid mock call was made. + test TestingT + + // TestData holds any data that might be useful for testing. Testify ignores + // this data completely allowing you to do whatever you like with it. + testData objx.Map + + mutex sync.Mutex +} + +// TestData holds any data that might be useful for testing. Testify ignores +// this data completely allowing you to do whatever you like with it. +func (m *Mock) TestData() objx.Map { + + if m.testData == nil { + m.testData = make(objx.Map) + } + + return m.testData +} + +/* + Setting expectations +*/ + +// Test sets the test struct variable of the mock object +func (m *Mock) Test(t TestingT) { + m.mutex.Lock() + defer m.mutex.Unlock() + m.test = t +} + +// fail fails the current test with the given formatted format and args. +// In case that a test was defined, it uses the test APIs for failing a test, +// otherwise it uses panic. +func (m *Mock) fail(format string, args ...interface{}) { + m.mutex.Lock() + defer m.mutex.Unlock() + + if m.test == nil { + panic(fmt.Sprintf(format, args...)) + } + m.test.Errorf(format, args...) + m.test.FailNow() +} + +// On starts a description of an expectation of the specified method +// being called. +// +// Mock.On("MyMethod", arg1, arg2) +func (m *Mock) On(methodName string, arguments ...interface{}) *Call { + for _, arg := range arguments { + if v := reflect.ValueOf(arg); v.Kind() == reflect.Func { + panic(fmt.Sprintf("cannot use Func in expectations. Use mock.AnythingOfType(\"%T\")", arg)) + } + } + + m.mutex.Lock() + defer m.mutex.Unlock() + c := newCall(m, methodName, assert.CallerInfo(), arguments...) + m.ExpectedCalls = append(m.ExpectedCalls, c) + return c +} + +// /* +// Recording and responding to activity +// */ + +func (m *Mock) findExpectedCall(method string, arguments ...interface{}) (int, *Call) { + for i, call := range m.ExpectedCalls { + if call.Method == method && call.Repeatability > -1 { + + _, diffCount := call.Arguments.Diff(arguments) + if diffCount == 0 { + return i, call + } + + } + } + return -1, nil +} + +func (m *Mock) findClosestCall(method string, arguments ...interface{}) (*Call, string) { + var diffCount int + var closestCall *Call + var err string + + for _, call := range m.expectedCalls() { + if call.Method == method { + + errInfo, tempDiffCount := call.Arguments.Diff(arguments) + if tempDiffCount < diffCount || diffCount == 0 { + diffCount = tempDiffCount + closestCall = call + err = errInfo + } + + } + } + + return closestCall, err +} + +func callString(method string, arguments Arguments, includeArgumentValues bool) string { + + var argValsString string + if includeArgumentValues { + var argVals []string + for argIndex, arg := range arguments { + argVals = append(argVals, fmt.Sprintf("%d: %#v", argIndex, arg)) + } + argValsString = fmt.Sprintf("\n\t\t%s", strings.Join(argVals, "\n\t\t")) + } + + return fmt.Sprintf("%s(%s)%s", method, arguments.String(), argValsString) +} + +// Called tells the mock object that a method has been called, and gets an array +// of arguments to return. Panics if the call is unexpected (i.e. not preceded by +// appropriate .On .Return() calls) +// If Call.WaitFor is set, blocks until the channel is closed or receives a message. +func (m *Mock) Called(arguments ...interface{}) Arguments { + // get the calling function's name + pc, _, _, ok := runtime.Caller(1) + if !ok { + panic("Couldn't get the caller information") + } + functionPath := runtime.FuncForPC(pc).Name() + //Next four lines are required to use GCCGO function naming conventions. + //For Ex: github_com_docker_libkv_store_mock.WatchTree.pN39_github_com_docker_libkv_store_mock.Mock + //uses interface information unlike golang github.com/docker/libkv/store/mock.(*Mock).WatchTree + //With GCCGO we need to remove interface information starting from pN

. + re := regexp.MustCompile("\\.pN\\d+_") + if re.MatchString(functionPath) { + functionPath = re.Split(functionPath, -1)[0] + } + parts := strings.Split(functionPath, ".") + functionName := parts[len(parts)-1] + return m.MethodCalled(functionName, arguments...) +} + +// MethodCalled tells the mock object that the given method has been called, and gets +// an array of arguments to return. Panics if the call is unexpected (i.e. not preceded +// by appropriate .On .Return() calls) +// If Call.WaitFor is set, blocks until the channel is closed or receives a message. +func (m *Mock) MethodCalled(methodName string, arguments ...interface{}) Arguments { + m.mutex.Lock() + //TODO: could combine expected and closes in single loop + found, call := m.findExpectedCall(methodName, arguments...) + + if found < 0 { + // we have to fail here - because we don't know what to do + // as the return arguments. This is because: + // + // a) this is a totally unexpected call to this method, + // b) the arguments are not what was expected, or + // c) the developer has forgotten to add an accompanying On...Return pair. + + closestCall, mismatch := m.findClosestCall(methodName, arguments...) + m.mutex.Unlock() + + if closestCall != nil { + m.fail("\n\nmock: Unexpected Method Call\n-----------------------------\n\n%s\n\nThe closest call I have is: \n\n%s\n\n%s\nDiff: %s", + callString(methodName, arguments, true), + callString(methodName, closestCall.Arguments, true), + diffArguments(closestCall.Arguments, arguments), + strings.TrimSpace(mismatch), + ) + } else { + m.fail("\nassert: mock: I don't know what to return because the method call was unexpected.\n\tEither do Mock.On(\"%s\").Return(...) first, or remove the %s() call.\n\tThis method was unexpected:\n\t\t%s\n\tat: %s", methodName, methodName, callString(methodName, arguments, true), assert.CallerInfo()) + } + } + + if call.Repeatability == 1 { + call.Repeatability = -1 + } else if call.Repeatability > 1 { + call.Repeatability-- + } + call.totalCalls++ + + // add the call + m.Calls = append(m.Calls, *newCall(m, methodName, assert.CallerInfo(), arguments...)) + m.mutex.Unlock() + + // block if specified + if call.WaitFor != nil { + <-call.WaitFor + } else { + time.Sleep(call.waitTime) + } + + m.mutex.Lock() + runFn := call.RunFn + m.mutex.Unlock() + + if runFn != nil { + runFn(arguments) + } + + m.mutex.Lock() + returnArgs := call.ReturnArguments + m.mutex.Unlock() + + return returnArgs +} + +/* + Assertions +*/ + +type assertExpectationser interface { + AssertExpectations(TestingT) bool +} + +// AssertExpectationsForObjects asserts that everything specified with On and Return +// of the specified objects was in fact called as expected. +// +// Calls may have occurred in any order. +func AssertExpectationsForObjects(t TestingT, testObjects ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + for _, obj := range testObjects { + if m, ok := obj.(Mock); ok { + t.Logf("Deprecated mock.AssertExpectationsForObjects(myMock.Mock) use mock.AssertExpectationsForObjects(myMock)") + obj = &m + } + m := obj.(assertExpectationser) + if !m.AssertExpectations(t) { + t.Logf("Expectations didn't match for Mock: %+v", reflect.TypeOf(m)) + return false + } + } + return true +} + +// AssertExpectations asserts that everything specified with On and Return was +// in fact called as expected. Calls may have occurred in any order. +func (m *Mock) AssertExpectations(t TestingT) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + m.mutex.Lock() + defer m.mutex.Unlock() + var somethingMissing bool + var failedExpectations int + + // iterate through each expectation + expectedCalls := m.expectedCalls() + for _, expectedCall := range expectedCalls { + if !expectedCall.optional && !m.methodWasCalled(expectedCall.Method, expectedCall.Arguments) && expectedCall.totalCalls == 0 { + somethingMissing = true + failedExpectations++ + t.Logf("FAIL:\t%s(%s)\n\t\tat: %s", expectedCall.Method, expectedCall.Arguments.String(), expectedCall.callerInfo) + } else { + if expectedCall.Repeatability > 0 { + somethingMissing = true + failedExpectations++ + t.Logf("FAIL:\t%s(%s)\n\t\tat: %s", expectedCall.Method, expectedCall.Arguments.String(), expectedCall.callerInfo) + } else { + t.Logf("PASS:\t%s(%s)", expectedCall.Method, expectedCall.Arguments.String()) + } + } + } + + if somethingMissing { + t.Errorf("FAIL: %d out of %d expectation(s) were met.\n\tThe code you are testing needs to make %d more call(s).\n\tat: %s", len(expectedCalls)-failedExpectations, len(expectedCalls), failedExpectations, assert.CallerInfo()) + } + + return !somethingMissing +} + +// AssertNumberOfCalls asserts that the method was called expectedCalls times. +func (m *Mock) AssertNumberOfCalls(t TestingT, methodName string, expectedCalls int) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + m.mutex.Lock() + defer m.mutex.Unlock() + var actualCalls int + for _, call := range m.calls() { + if call.Method == methodName { + actualCalls++ + } + } + return assert.Equal(t, expectedCalls, actualCalls, fmt.Sprintf("Expected number of calls (%d) does not match the actual number of calls (%d).", expectedCalls, actualCalls)) +} + +// AssertCalled asserts that the method was called. +// It can produce a false result when an argument is a pointer type and the underlying value changed after calling the mocked method. +func (m *Mock) AssertCalled(t TestingT, methodName string, arguments ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + m.mutex.Lock() + defer m.mutex.Unlock() + if !m.methodWasCalled(methodName, arguments) { + var calledWithArgs []string + for _, call := range m.calls() { + calledWithArgs = append(calledWithArgs, fmt.Sprintf("%v", call.Arguments)) + } + if len(calledWithArgs) == 0 { + return assert.Fail(t, "Should have called with given arguments", + fmt.Sprintf("Expected %q to have been called with:\n%v\nbut no actual calls happened", methodName, arguments)) + } + return assert.Fail(t, "Should have called with given arguments", + fmt.Sprintf("Expected %q to have been called with:\n%v\nbut actual calls were:\n %v", methodName, arguments, strings.Join(calledWithArgs, "\n"))) + } + return true +} + +// AssertNotCalled asserts that the method was not called. +// It can produce a false result when an argument is a pointer type and the underlying value changed after calling the mocked method. +func (m *Mock) AssertNotCalled(t TestingT, methodName string, arguments ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + m.mutex.Lock() + defer m.mutex.Unlock() + if m.methodWasCalled(methodName, arguments) { + return assert.Fail(t, "Should not have called with given arguments", + fmt.Sprintf("Expected %q to not have been called with:\n%v\nbut actually it was.", methodName, arguments)) + } + return true +} + +func (m *Mock) methodWasCalled(methodName string, expected []interface{}) bool { + for _, call := range m.calls() { + if call.Method == methodName { + + _, differences := Arguments(expected).Diff(call.Arguments) + + if differences == 0 { + // found the expected call + return true + } + + } + } + // we didn't find the expected call + return false +} + +func (m *Mock) expectedCalls() []*Call { + return append([]*Call{}, m.ExpectedCalls...) +} + +func (m *Mock) calls() []Call { + return append([]Call{}, m.Calls...) +} + +/* + Arguments +*/ + +// Arguments holds an array of method arguments or return values. +type Arguments []interface{} + +const ( + // Anything is used in Diff and Assert when the argument being tested + // shouldn't be taken into consideration. + Anything = "mock.Anything" +) + +// AnythingOfTypeArgument is a string that contains the type of an argument +// for use when type checking. Used in Diff and Assert. +type AnythingOfTypeArgument string + +// AnythingOfType returns an AnythingOfTypeArgument object containing the +// name of the type to check for. Used in Diff and Assert. +// +// For example: +// Assert(t, AnythingOfType("string"), AnythingOfType("int")) +func AnythingOfType(t string) AnythingOfTypeArgument { + return AnythingOfTypeArgument(t) +} + +// argumentMatcher performs custom argument matching, returning whether or +// not the argument is matched by the expectation fixture function. +type argumentMatcher struct { + // fn is a function which accepts one argument, and returns a bool. + fn reflect.Value +} + +func (f argumentMatcher) Matches(argument interface{}) bool { + expectType := f.fn.Type().In(0) + expectTypeNilSupported := false + switch expectType.Kind() { + case reflect.Interface, reflect.Chan, reflect.Func, reflect.Map, reflect.Slice, reflect.Ptr: + expectTypeNilSupported = true + } + + argType := reflect.TypeOf(argument) + var arg reflect.Value + if argType == nil { + arg = reflect.New(expectType).Elem() + } else { + arg = reflect.ValueOf(argument) + } + + if argType == nil && !expectTypeNilSupported { + panic(errors.New("attempting to call matcher with nil for non-nil expected type")) + } + if argType == nil || argType.AssignableTo(expectType) { + result := f.fn.Call([]reflect.Value{arg}) + return result[0].Bool() + } + return false +} + +func (f argumentMatcher) String() string { + return fmt.Sprintf("func(%s) bool", f.fn.Type().In(0).Name()) +} + +// MatchedBy can be used to match a mock call based on only certain properties +// from a complex struct or some calculation. It takes a function that will be +// evaluated with the called argument and will return true when there's a match +// and false otherwise. +// +// Example: +// m.On("Do", MatchedBy(func(req *http.Request) bool { return req.Host == "example.com" })) +// +// |fn|, must be a function accepting a single argument (of the expected type) +// which returns a bool. If |fn| doesn't match the required signature, +// MatchedBy() panics. +func MatchedBy(fn interface{}) argumentMatcher { + fnType := reflect.TypeOf(fn) + + if fnType.Kind() != reflect.Func { + panic(fmt.Sprintf("assert: arguments: %s is not a func", fn)) + } + if fnType.NumIn() != 1 { + panic(fmt.Sprintf("assert: arguments: %s does not take exactly one argument", fn)) + } + if fnType.NumOut() != 1 || fnType.Out(0).Kind() != reflect.Bool { + panic(fmt.Sprintf("assert: arguments: %s does not return a bool", fn)) + } + + return argumentMatcher{fn: reflect.ValueOf(fn)} +} + +// Get Returns the argument at the specified index. +func (args Arguments) Get(index int) interface{} { + if index+1 > len(args) { + panic(fmt.Sprintf("assert: arguments: Cannot call Get(%d) because there are %d argument(s).", index, len(args))) + } + return args[index] +} + +// Is gets whether the objects match the arguments specified. +func (args Arguments) Is(objects ...interface{}) bool { + for i, obj := range args { + if obj != objects[i] { + return false + } + } + return true +} + +// Diff gets a string describing the differences between the arguments +// and the specified objects. +// +// Returns the diff string and number of differences found. +func (args Arguments) Diff(objects []interface{}) (string, int) { + //TODO: could return string as error and nil for No difference + + var output = "\n" + var differences int + + var maxArgCount = len(args) + if len(objects) > maxArgCount { + maxArgCount = len(objects) + } + + for i := 0; i < maxArgCount; i++ { + var actual, expected interface{} + var actualFmt, expectedFmt string + + if len(objects) <= i { + actual = "(Missing)" + actualFmt = "(Missing)" + } else { + actual = objects[i] + actualFmt = fmt.Sprintf("(%[1]T=%[1]v)", actual) + } + + if len(args) <= i { + expected = "(Missing)" + expectedFmt = "(Missing)" + } else { + expected = args[i] + expectedFmt = fmt.Sprintf("(%[1]T=%[1]v)", expected) + } + + if matcher, ok := expected.(argumentMatcher); ok { + if matcher.Matches(actual) { + output = fmt.Sprintf("%s\t%d: PASS: %s matched by %s\n", output, i, actualFmt, matcher) + } else { + differences++ + output = fmt.Sprintf("%s\t%d: FAIL: %s not matched by %s\n", output, i, actualFmt, matcher) + } + } else if reflect.TypeOf(expected) == reflect.TypeOf((*AnythingOfTypeArgument)(nil)).Elem() { + + // type checking + if reflect.TypeOf(actual).Name() != string(expected.(AnythingOfTypeArgument)) && reflect.TypeOf(actual).String() != string(expected.(AnythingOfTypeArgument)) { + // not match + differences++ + output = fmt.Sprintf("%s\t%d: FAIL: type %s != type %s - %s\n", output, i, expected, reflect.TypeOf(actual).Name(), actualFmt) + } + + } else { + + // normal checking + + if assert.ObjectsAreEqual(expected, Anything) || assert.ObjectsAreEqual(actual, Anything) || assert.ObjectsAreEqual(actual, expected) { + // match + output = fmt.Sprintf("%s\t%d: PASS: %s == %s\n", output, i, actualFmt, expectedFmt) + } else { + // not match + differences++ + output = fmt.Sprintf("%s\t%d: FAIL: %s != %s\n", output, i, actualFmt, expectedFmt) + } + } + + } + + if differences == 0 { + return "No differences.", differences + } + + return output, differences + +} + +// Assert compares the arguments with the specified objects and fails if +// they do not exactly match. +func (args Arguments) Assert(t TestingT, objects ...interface{}) bool { + if h, ok := t.(tHelper); ok { + h.Helper() + } + + // get the differences + diff, diffCount := args.Diff(objects) + + if diffCount == 0 { + return true + } + + // there are differences... report them... + t.Logf(diff) + t.Errorf("%sArguments do not match.", assert.CallerInfo()) + + return false + +} + +// String gets the argument at the specified index. Panics if there is no argument, or +// if the argument is of the wrong type. +// +// If no index is provided, String() returns a complete string representation +// of the arguments. +func (args Arguments) String(indexOrNil ...int) string { + + if len(indexOrNil) == 0 { + // normal String() method - return a string representation of the args + var argsStr []string + for _, arg := range args { + argsStr = append(argsStr, fmt.Sprintf("%s", reflect.TypeOf(arg))) + } + return strings.Join(argsStr, ",") + } else if len(indexOrNil) == 1 { + // Index has been specified - get the argument at that index + var index = indexOrNil[0] + var s string + var ok bool + if s, ok = args.Get(index).(string); !ok { + panic(fmt.Sprintf("assert: arguments: String(%d) failed because object wasn't correct type: %s", index, args.Get(index))) + } + return s + } + + panic(fmt.Sprintf("assert: arguments: Wrong number of arguments passed to String. Must be 0 or 1, not %d", len(indexOrNil))) + +} + +// Int gets the argument at the specified index. Panics if there is no argument, or +// if the argument is of the wrong type. +func (args Arguments) Int(index int) int { + var s int + var ok bool + if s, ok = args.Get(index).(int); !ok { + panic(fmt.Sprintf("assert: arguments: Int(%d) failed because object wasn't correct type: %v", index, args.Get(index))) + } + return s +} + +// Error gets the argument at the specified index. Panics if there is no argument, or +// if the argument is of the wrong type. +func (args Arguments) Error(index int) error { + obj := args.Get(index) + var s error + var ok bool + if obj == nil { + return nil + } + if s, ok = obj.(error); !ok { + panic(fmt.Sprintf("assert: arguments: Error(%d) failed because object wasn't correct type: %v", index, args.Get(index))) + } + return s +} + +// Bool gets the argument at the specified index. Panics if there is no argument, or +// if the argument is of the wrong type. +func (args Arguments) Bool(index int) bool { + var s bool + var ok bool + if s, ok = args.Get(index).(bool); !ok { + panic(fmt.Sprintf("assert: arguments: Bool(%d) failed because object wasn't correct type: %v", index, args.Get(index))) + } + return s +} + +func typeAndKind(v interface{}) (reflect.Type, reflect.Kind) { + t := reflect.TypeOf(v) + k := t.Kind() + + if k == reflect.Ptr { + t = t.Elem() + k = t.Kind() + } + return t, k +} + +func diffArguments(expected Arguments, actual Arguments) string { + if len(expected) != len(actual) { + return fmt.Sprintf("Provided %v arguments, mocked for %v arguments", len(expected), len(actual)) + } + + for x := range expected { + if diffString := diff(expected[x], actual[x]); diffString != "" { + return fmt.Sprintf("Difference found in argument %v:\n\n%s", x, diffString) + } + } + + return "" +} + +// diff returns a diff of both values as long as both are of the same type and +// are a struct, map, slice or array. Otherwise it returns an empty string. +func diff(expected interface{}, actual interface{}) string { + if expected == nil || actual == nil { + return "" + } + + et, ek := typeAndKind(expected) + at, _ := typeAndKind(actual) + + if et != at { + return "" + } + + if ek != reflect.Struct && ek != reflect.Map && ek != reflect.Slice && ek != reflect.Array { + return "" + } + + e := spewConfig.Sdump(expected) + a := spewConfig.Sdump(actual) + + diff, _ := difflib.GetUnifiedDiffString(difflib.UnifiedDiff{ + A: difflib.SplitLines(e), + B: difflib.SplitLines(a), + FromFile: "Expected", + FromDate: "", + ToFile: "Actual", + ToDate: "", + Context: 1, + }) + + return diff +} + +var spewConfig = spew.ConfigState{ + Indent: " ", + DisablePointerAddresses: true, + DisableCapacities: true, + SortKeys: true, +} + +type tHelper interface { + Helper() +} diff --git a/vendor/github.com/stretchr/testify/mock/mock_test.go b/vendor/github.com/stretchr/testify/mock/mock_test.go new file mode 100644 index 0000000..2608f5a --- /dev/null +++ b/vendor/github.com/stretchr/testify/mock/mock_test.go @@ -0,0 +1,1499 @@ +package mock + +import ( + "errors" + "fmt" + "regexp" + "runtime" + "sync" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +/* + Test objects +*/ + +// ExampleInterface represents an example interface. +type ExampleInterface interface { + TheExampleMethod(a, b, c int) (int, error) +} + +// TestExampleImplementation is a test implementation of ExampleInterface +type TestExampleImplementation struct { + Mock +} + +func (i *TestExampleImplementation) TheExampleMethod(a, b, c int) (int, error) { + args := i.Called(a, b, c) + return args.Int(0), errors.New("Whoops") +} + +//go:noinline +func (i *TestExampleImplementation) TheExampleMethod2(yesorno bool) { + i.Called(yesorno) +} + +type ExampleType struct { + ran bool +} + +func (i *TestExampleImplementation) TheExampleMethod3(et *ExampleType) error { + args := i.Called(et) + return args.Error(0) +} + +func (i *TestExampleImplementation) TheExampleMethod4(v ExampleInterface) error { + args := i.Called(v) + return args.Error(0) +} + +func (i *TestExampleImplementation) TheExampleMethod5(ch chan struct{}) error { + args := i.Called(ch) + return args.Error(0) +} + +func (i *TestExampleImplementation) TheExampleMethod6(m map[string]bool) error { + args := i.Called(m) + return args.Error(0) +} + +func (i *TestExampleImplementation) TheExampleMethod7(slice []bool) error { + args := i.Called(slice) + return args.Error(0) +} + +func (i *TestExampleImplementation) TheExampleMethodFunc(fn func(string) error) error { + args := i.Called(fn) + return args.Error(0) +} + +func (i *TestExampleImplementation) TheExampleMethodVariadic(a ...int) error { + args := i.Called(a) + return args.Error(0) +} + +func (i *TestExampleImplementation) TheExampleMethodVariadicInterface(a ...interface{}) error { + args := i.Called(a) + return args.Error(0) +} + +func (i *TestExampleImplementation) TheExampleMethodMixedVariadic(a int, b ...int) error { + args := i.Called(a, b) + return args.Error(0) +} + +type ExampleFuncType func(string) error + +func (i *TestExampleImplementation) TheExampleMethodFuncType(fn ExampleFuncType) error { + args := i.Called(fn) + return args.Error(0) +} + +// MockTestingT mocks a test struct +type MockTestingT struct { + logfCount, errorfCount, failNowCount int +} + +const mockTestingTFailNowCalled = "FailNow was called" + +func (m *MockTestingT) Logf(string, ...interface{}) { + m.logfCount++ +} + +func (m *MockTestingT) Errorf(string, ...interface{}) { + m.errorfCount++ +} + +// FailNow mocks the FailNow call. +// It panics in order to mimic the FailNow behavior in the sense that +// the execution stops. +// When expecting this method, the call that invokes it should use the following code: +// +// assert.PanicsWithValue(t, mockTestingTFailNowCalled, func() {...}) +func (m *MockTestingT) FailNow() { + m.failNowCount++ + + // this function should panic now to stop the execution as expected + panic(mockTestingTFailNowCalled) +} + +/* + Mock +*/ + +func Test_Mock_TestData(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + if assert.NotNil(t, mockedService.TestData()) { + + mockedService.TestData().Set("something", 123) + assert.Equal(t, 123, mockedService.TestData().Get("something").Data()) + } +} + +func Test_Mock_On(t *testing.T) { + + // make a test impl object + var mockedService = new(TestExampleImplementation) + + c := mockedService.On("TheExampleMethod") + assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls) + assert.Equal(t, "TheExampleMethod", c.Method) +} + +func Test_Mock_Chained_On(t *testing.T) { + // make a test impl object + var mockedService = new(TestExampleImplementation) + + // determine our current line number so we can assert the expected calls callerInfo properly + _, _, line, _ := runtime.Caller(0) + mockedService. + On("TheExampleMethod", 1, 2, 3). + Return(0). + On("TheExampleMethod3", AnythingOfType("*mock.ExampleType")). + Return(nil) + + expectedCalls := []*Call{ + { + Parent: &mockedService.Mock, + Method: "TheExampleMethod", + Arguments: []interface{}{1, 2, 3}, + ReturnArguments: []interface{}{0}, + callerInfo: []string{fmt.Sprintf("mock_test.go:%d", line+2)}, + }, + { + Parent: &mockedService.Mock, + Method: "TheExampleMethod3", + Arguments: []interface{}{AnythingOfType("*mock.ExampleType")}, + ReturnArguments: []interface{}{nil}, + callerInfo: []string{fmt.Sprintf("mock_test.go:%d", line+4)}, + }, + } + assert.Equal(t, expectedCalls, mockedService.ExpectedCalls) +} + +func Test_Mock_On_WithArgs(t *testing.T) { + + // make a test impl object + var mockedService = new(TestExampleImplementation) + + c := mockedService.On("TheExampleMethod", 1, 2, 3, 4) + + assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls) + assert.Equal(t, "TheExampleMethod", c.Method) + assert.Equal(t, Arguments{1, 2, 3, 4}, c.Arguments) +} + +func Test_Mock_On_WithFuncArg(t *testing.T) { + + // make a test impl object + var mockedService = new(TestExampleImplementation) + + c := mockedService. + On("TheExampleMethodFunc", AnythingOfType("func(string) error")). + Return(nil) + + assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls) + assert.Equal(t, "TheExampleMethodFunc", c.Method) + assert.Equal(t, 1, len(c.Arguments)) + assert.Equal(t, AnythingOfType("func(string) error"), c.Arguments[0]) + + fn := func(string) error { return nil } + + assert.NotPanics(t, func() { + mockedService.TheExampleMethodFunc(fn) + }) +} + +func Test_Mock_On_WithIntArgMatcher(t *testing.T) { + var mockedService TestExampleImplementation + + mockedService.On("TheExampleMethod", + MatchedBy(func(a int) bool { + return a == 1 + }), MatchedBy(func(b int) bool { + return b == 2 + }), MatchedBy(func(c int) bool { + return c == 3 + })).Return(0, nil) + + assert.Panics(t, func() { + mockedService.TheExampleMethod(1, 2, 4) + }) + assert.Panics(t, func() { + mockedService.TheExampleMethod(2, 2, 3) + }) + assert.NotPanics(t, func() { + mockedService.TheExampleMethod(1, 2, 3) + }) +} + +func TestMock_WithTest(t *testing.T) { + var ( + mockedService TestExampleImplementation + mockedTest MockTestingT + ) + + mockedService.Test(&mockedTest) + mockedService.On("TheExampleMethod", 1, 2, 3).Return(0, nil) + + // Test that on an expected call, the test was not failed + + mockedService.TheExampleMethod(1, 2, 3) + + // Assert that Errorf and FailNow were not called + assert.Equal(t, 0, mockedTest.errorfCount) + assert.Equal(t, 0, mockedTest.failNowCount) + + // Test that on unexpected call, the mocked test was called to fail the test + + assert.PanicsWithValue(t, mockTestingTFailNowCalled, func() { + mockedService.TheExampleMethod(1, 1, 1) + }) + + // Assert that Errorf and FailNow were called once + assert.Equal(t, 1, mockedTest.errorfCount) + assert.Equal(t, 1, mockedTest.failNowCount) +} + +func Test_Mock_On_WithPtrArgMatcher(t *testing.T) { + var mockedService TestExampleImplementation + + mockedService.On("TheExampleMethod3", + MatchedBy(func(a *ExampleType) bool { return a != nil && a.ran == true }), + ).Return(nil) + + mockedService.On("TheExampleMethod3", + MatchedBy(func(a *ExampleType) bool { return a != nil && a.ran == false }), + ).Return(errors.New("error")) + + mockedService.On("TheExampleMethod3", + MatchedBy(func(a *ExampleType) bool { return a == nil }), + ).Return(errors.New("error2")) + + assert.Equal(t, mockedService.TheExampleMethod3(&ExampleType{true}), nil) + assert.EqualError(t, mockedService.TheExampleMethod3(&ExampleType{false}), "error") + assert.EqualError(t, mockedService.TheExampleMethod3(nil), "error2") +} + +func Test_Mock_On_WithFuncArgMatcher(t *testing.T) { + var mockedService TestExampleImplementation + + fixture1, fixture2 := errors.New("fixture1"), errors.New("fixture2") + + mockedService.On("TheExampleMethodFunc", + MatchedBy(func(a func(string) error) bool { return a != nil && a("string") == fixture1 }), + ).Return(errors.New("fixture1")) + + mockedService.On("TheExampleMethodFunc", + MatchedBy(func(a func(string) error) bool { return a != nil && a("string") == fixture2 }), + ).Return(errors.New("fixture2")) + + mockedService.On("TheExampleMethodFunc", + MatchedBy(func(a func(string) error) bool { return a == nil }), + ).Return(errors.New("fixture3")) + + assert.EqualError(t, mockedService.TheExampleMethodFunc( + func(string) error { return fixture1 }), "fixture1") + assert.EqualError(t, mockedService.TheExampleMethodFunc( + func(string) error { return fixture2 }), "fixture2") + assert.EqualError(t, mockedService.TheExampleMethodFunc(nil), "fixture3") +} + +func Test_Mock_On_WithInterfaceArgMatcher(t *testing.T) { + var mockedService TestExampleImplementation + + mockedService.On("TheExampleMethod4", + MatchedBy(func(a ExampleInterface) bool { return a == nil }), + ).Return(errors.New("fixture1")) + + assert.EqualError(t, mockedService.TheExampleMethod4(nil), "fixture1") +} + +func Test_Mock_On_WithChannelArgMatcher(t *testing.T) { + var mockedService TestExampleImplementation + + mockedService.On("TheExampleMethod5", + MatchedBy(func(ch chan struct{}) bool { return ch == nil }), + ).Return(errors.New("fixture1")) + + assert.EqualError(t, mockedService.TheExampleMethod5(nil), "fixture1") +} + +func Test_Mock_On_WithMapArgMatcher(t *testing.T) { + var mockedService TestExampleImplementation + + mockedService.On("TheExampleMethod6", + MatchedBy(func(m map[string]bool) bool { return m == nil }), + ).Return(errors.New("fixture1")) + + assert.EqualError(t, mockedService.TheExampleMethod6(nil), "fixture1") +} + +func Test_Mock_On_WithSliceArgMatcher(t *testing.T) { + var mockedService TestExampleImplementation + + mockedService.On("TheExampleMethod7", + MatchedBy(func(slice []bool) bool { return slice == nil }), + ).Return(errors.New("fixture1")) + + assert.EqualError(t, mockedService.TheExampleMethod7(nil), "fixture1") +} + +func Test_Mock_On_WithVariadicFunc(t *testing.T) { + + // make a test impl object + var mockedService = new(TestExampleImplementation) + + c := mockedService. + On("TheExampleMethodVariadic", []int{1, 2, 3}). + Return(nil) + + assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls) + assert.Equal(t, 1, len(c.Arguments)) + assert.Equal(t, []int{1, 2, 3}, c.Arguments[0]) + + assert.NotPanics(t, func() { + mockedService.TheExampleMethodVariadic(1, 2, 3) + }) + assert.Panics(t, func() { + mockedService.TheExampleMethodVariadic(1, 2) + }) + +} + +func Test_Mock_On_WithMixedVariadicFunc(t *testing.T) { + + // make a test impl object + var mockedService = new(TestExampleImplementation) + + c := mockedService. + On("TheExampleMethodMixedVariadic", 1, []int{2, 3, 4}). + Return(nil) + + assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls) + assert.Equal(t, 2, len(c.Arguments)) + assert.Equal(t, 1, c.Arguments[0]) + assert.Equal(t, []int{2, 3, 4}, c.Arguments[1]) + + assert.NotPanics(t, func() { + mockedService.TheExampleMethodMixedVariadic(1, 2, 3, 4) + }) + assert.Panics(t, func() { + mockedService.TheExampleMethodMixedVariadic(1, 2, 3, 5) + }) + +} + +func Test_Mock_On_WithVariadicFuncWithInterface(t *testing.T) { + + // make a test impl object + var mockedService = new(TestExampleImplementation) + + c := mockedService.On("TheExampleMethodVariadicInterface", []interface{}{1, 2, 3}). + Return(nil) + + assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls) + assert.Equal(t, 1, len(c.Arguments)) + assert.Equal(t, []interface{}{1, 2, 3}, c.Arguments[0]) + + assert.NotPanics(t, func() { + mockedService.TheExampleMethodVariadicInterface(1, 2, 3) + }) + assert.Panics(t, func() { + mockedService.TheExampleMethodVariadicInterface(1, 2) + }) + +} + +func Test_Mock_On_WithVariadicFuncWithEmptyInterfaceArray(t *testing.T) { + + // make a test impl object + var mockedService = new(TestExampleImplementation) + + var expected []interface{} + c := mockedService. + On("TheExampleMethodVariadicInterface", expected). + Return(nil) + + assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls) + assert.Equal(t, 1, len(c.Arguments)) + assert.Equal(t, expected, c.Arguments[0]) + + assert.NotPanics(t, func() { + mockedService.TheExampleMethodVariadicInterface() + }) + assert.Panics(t, func() { + mockedService.TheExampleMethodVariadicInterface(1, 2) + }) + +} + +func Test_Mock_On_WithFuncPanics(t *testing.T) { + // make a test impl object + var mockedService = new(TestExampleImplementation) + + assert.Panics(t, func() { + mockedService.On("TheExampleMethodFunc", func(string) error { return nil }) + }) +} + +func Test_Mock_On_WithFuncTypeArg(t *testing.T) { + + // make a test impl object + var mockedService = new(TestExampleImplementation) + + c := mockedService. + On("TheExampleMethodFuncType", AnythingOfType("mock.ExampleFuncType")). + Return(nil) + + assert.Equal(t, []*Call{c}, mockedService.ExpectedCalls) + assert.Equal(t, 1, len(c.Arguments)) + assert.Equal(t, AnythingOfType("mock.ExampleFuncType"), c.Arguments[0]) + + fn := func(string) error { return nil } + assert.NotPanics(t, func() { + mockedService.TheExampleMethodFuncType(fn) + }) +} + +func Test_Mock_Return(t *testing.T) { + + // make a test impl object + var mockedService = new(TestExampleImplementation) + + c := mockedService. + On("TheExampleMethod", "A", "B", true). + Return(1, "two", true) + + require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) + + call := mockedService.ExpectedCalls[0] + + assert.Equal(t, "TheExampleMethod", call.Method) + assert.Equal(t, "A", call.Arguments[0]) + assert.Equal(t, "B", call.Arguments[1]) + assert.Equal(t, true, call.Arguments[2]) + assert.Equal(t, 1, call.ReturnArguments[0]) + assert.Equal(t, "two", call.ReturnArguments[1]) + assert.Equal(t, true, call.ReturnArguments[2]) + assert.Equal(t, 0, call.Repeatability) + assert.Nil(t, call.WaitFor) +} + +func Test_Mock_Return_WaitUntil(t *testing.T) { + + // make a test impl object + var mockedService = new(TestExampleImplementation) + ch := time.After(time.Second) + + c := mockedService.Mock. + On("TheExampleMethod", "A", "B", true). + WaitUntil(ch). + Return(1, "two", true) + + // assert that the call was created + require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) + + call := mockedService.ExpectedCalls[0] + + assert.Equal(t, "TheExampleMethod", call.Method) + assert.Equal(t, "A", call.Arguments[0]) + assert.Equal(t, "B", call.Arguments[1]) + assert.Equal(t, true, call.Arguments[2]) + assert.Equal(t, 1, call.ReturnArguments[0]) + assert.Equal(t, "two", call.ReturnArguments[1]) + assert.Equal(t, true, call.ReturnArguments[2]) + assert.Equal(t, 0, call.Repeatability) + assert.Equal(t, ch, call.WaitFor) +} + +func Test_Mock_Return_After(t *testing.T) { + + // make a test impl object + var mockedService = new(TestExampleImplementation) + + c := mockedService.Mock. + On("TheExampleMethod", "A", "B", true). + Return(1, "two", true). + After(time.Second) + + require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) + + call := mockedService.Mock.ExpectedCalls[0] + + assert.Equal(t, "TheExampleMethod", call.Method) + assert.Equal(t, "A", call.Arguments[0]) + assert.Equal(t, "B", call.Arguments[1]) + assert.Equal(t, true, call.Arguments[2]) + assert.Equal(t, 1, call.ReturnArguments[0]) + assert.Equal(t, "two", call.ReturnArguments[1]) + assert.Equal(t, true, call.ReturnArguments[2]) + assert.Equal(t, 0, call.Repeatability) + assert.NotEqual(t, nil, call.WaitFor) + +} + +func Test_Mock_Return_Run(t *testing.T) { + + // make a test impl object + var mockedService = new(TestExampleImplementation) + + fn := func(args Arguments) { + arg := args.Get(0).(*ExampleType) + arg.ran = true + } + + c := mockedService.Mock. + On("TheExampleMethod3", AnythingOfType("*mock.ExampleType")). + Return(nil). + Run(fn) + + require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) + + call := mockedService.Mock.ExpectedCalls[0] + + assert.Equal(t, "TheExampleMethod3", call.Method) + assert.Equal(t, AnythingOfType("*mock.ExampleType"), call.Arguments[0]) + assert.Equal(t, nil, call.ReturnArguments[0]) + assert.Equal(t, 0, call.Repeatability) + assert.NotEqual(t, nil, call.WaitFor) + assert.NotNil(t, call.Run) + + et := ExampleType{} + assert.Equal(t, false, et.ran) + mockedService.TheExampleMethod3(&et) + assert.Equal(t, true, et.ran) +} + +func Test_Mock_Return_Run_Out_Of_Order(t *testing.T) { + // make a test impl object + var mockedService = new(TestExampleImplementation) + f := func(args Arguments) { + arg := args.Get(0).(*ExampleType) + arg.ran = true + } + + c := mockedService.Mock. + On("TheExampleMethod3", AnythingOfType("*mock.ExampleType")). + Run(f). + Return(nil) + + require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) + + call := mockedService.Mock.ExpectedCalls[0] + + assert.Equal(t, "TheExampleMethod3", call.Method) + assert.Equal(t, AnythingOfType("*mock.ExampleType"), call.Arguments[0]) + assert.Equal(t, nil, call.ReturnArguments[0]) + assert.Equal(t, 0, call.Repeatability) + assert.NotEqual(t, nil, call.WaitFor) + assert.NotNil(t, call.Run) +} + +func Test_Mock_Return_Once(t *testing.T) { + + // make a test impl object + var mockedService = new(TestExampleImplementation) + + c := mockedService.On("TheExampleMethod", "A", "B", true). + Return(1, "two", true). + Once() + + require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) + + call := mockedService.ExpectedCalls[0] + + assert.Equal(t, "TheExampleMethod", call.Method) + assert.Equal(t, "A", call.Arguments[0]) + assert.Equal(t, "B", call.Arguments[1]) + assert.Equal(t, true, call.Arguments[2]) + assert.Equal(t, 1, call.ReturnArguments[0]) + assert.Equal(t, "two", call.ReturnArguments[1]) + assert.Equal(t, true, call.ReturnArguments[2]) + assert.Equal(t, 1, call.Repeatability) + assert.Nil(t, call.WaitFor) +} + +func Test_Mock_Return_Twice(t *testing.T) { + + // make a test impl object + var mockedService = new(TestExampleImplementation) + + c := mockedService. + On("TheExampleMethod", "A", "B", true). + Return(1, "two", true). + Twice() + + require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) + + call := mockedService.ExpectedCalls[0] + + assert.Equal(t, "TheExampleMethod", call.Method) + assert.Equal(t, "A", call.Arguments[0]) + assert.Equal(t, "B", call.Arguments[1]) + assert.Equal(t, true, call.Arguments[2]) + assert.Equal(t, 1, call.ReturnArguments[0]) + assert.Equal(t, "two", call.ReturnArguments[1]) + assert.Equal(t, true, call.ReturnArguments[2]) + assert.Equal(t, 2, call.Repeatability) + assert.Nil(t, call.WaitFor) +} + +func Test_Mock_Return_Times(t *testing.T) { + + // make a test impl object + var mockedService = new(TestExampleImplementation) + + c := mockedService. + On("TheExampleMethod", "A", "B", true). + Return(1, "two", true). + Times(5) + + require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) + + call := mockedService.ExpectedCalls[0] + + assert.Equal(t, "TheExampleMethod", call.Method) + assert.Equal(t, "A", call.Arguments[0]) + assert.Equal(t, "B", call.Arguments[1]) + assert.Equal(t, true, call.Arguments[2]) + assert.Equal(t, 1, call.ReturnArguments[0]) + assert.Equal(t, "two", call.ReturnArguments[1]) + assert.Equal(t, true, call.ReturnArguments[2]) + assert.Equal(t, 5, call.Repeatability) + assert.Nil(t, call.WaitFor) +} + +func Test_Mock_Return_Nothing(t *testing.T) { + + // make a test impl object + var mockedService = new(TestExampleImplementation) + + c := mockedService. + On("TheExampleMethod", "A", "B", true). + Return() + + require.Equal(t, []*Call{c}, mockedService.ExpectedCalls) + + call := mockedService.ExpectedCalls[0] + + assert.Equal(t, "TheExampleMethod", call.Method) + assert.Equal(t, "A", call.Arguments[0]) + assert.Equal(t, "B", call.Arguments[1]) + assert.Equal(t, true, call.Arguments[2]) + assert.Equal(t, 0, len(call.ReturnArguments)) +} + +func Test_Mock_findExpectedCall(t *testing.T) { + + m := new(Mock) + m.On("One", 1).Return("one") + m.On("Two", 2).Return("two") + m.On("Two", 3).Return("three") + + f, c := m.findExpectedCall("Two", 3) + + if assert.Equal(t, 2, f) { + if assert.NotNil(t, c) { + assert.Equal(t, "Two", c.Method) + assert.Equal(t, 3, c.Arguments[0]) + assert.Equal(t, "three", c.ReturnArguments[0]) + } + } + +} + +func Test_Mock_findExpectedCall_For_Unknown_Method(t *testing.T) { + + m := new(Mock) + m.On("One", 1).Return("one") + m.On("Two", 2).Return("two") + m.On("Two", 3).Return("three") + + f, _ := m.findExpectedCall("Two") + + assert.Equal(t, -1, f) + +} + +func Test_Mock_findExpectedCall_Respects_Repeatability(t *testing.T) { + + m := new(Mock) + m.On("One", 1).Return("one") + m.On("Two", 2).Return("two").Once() + m.On("Two", 3).Return("three").Twice() + m.On("Two", 3).Return("three").Times(8) + + f, c := m.findExpectedCall("Two", 3) + + if assert.Equal(t, 2, f) { + if assert.NotNil(t, c) { + assert.Equal(t, "Two", c.Method) + assert.Equal(t, 3, c.Arguments[0]) + assert.Equal(t, "three", c.ReturnArguments[0]) + } + } + +} + +func Test_callString(t *testing.T) { + + assert.Equal(t, `Method(int,bool,string)`, callString("Method", []interface{}{1, true, "something"}, false)) + +} + +func Test_Mock_Called(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.On("Test_Mock_Called", 1, 2, 3).Return(5, "6", true) + + returnArguments := mockedService.Called(1, 2, 3) + + if assert.Equal(t, 1, len(mockedService.Calls)) { + assert.Equal(t, "Test_Mock_Called", mockedService.Calls[0].Method) + assert.Equal(t, 1, mockedService.Calls[0].Arguments[0]) + assert.Equal(t, 2, mockedService.Calls[0].Arguments[1]) + assert.Equal(t, 3, mockedService.Calls[0].Arguments[2]) + } + + if assert.Equal(t, 3, len(returnArguments)) { + assert.Equal(t, 5, returnArguments[0]) + assert.Equal(t, "6", returnArguments[1]) + assert.Equal(t, true, returnArguments[2]) + } + +} + +func asyncCall(m *Mock, ch chan Arguments) { + ch <- m.Called(1, 2, 3) +} + +func Test_Mock_Called_blocks(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.Mock.On("asyncCall", 1, 2, 3).Return(5, "6", true).After(2 * time.Millisecond) + + ch := make(chan Arguments) + + go asyncCall(&mockedService.Mock, ch) + + select { + case <-ch: + t.Fatal("should have waited") + case <-time.After(1 * time.Millisecond): + } + + returnArguments := <-ch + + if assert.Equal(t, 1, len(mockedService.Mock.Calls)) { + assert.Equal(t, "asyncCall", mockedService.Mock.Calls[0].Method) + assert.Equal(t, 1, mockedService.Mock.Calls[0].Arguments[0]) + assert.Equal(t, 2, mockedService.Mock.Calls[0].Arguments[1]) + assert.Equal(t, 3, mockedService.Mock.Calls[0].Arguments[2]) + } + + if assert.Equal(t, 3, len(returnArguments)) { + assert.Equal(t, 5, returnArguments[0]) + assert.Equal(t, "6", returnArguments[1]) + assert.Equal(t, true, returnArguments[2]) + } + +} + +func Test_Mock_Called_For_Bounded_Repeatability(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService. + On("Test_Mock_Called_For_Bounded_Repeatability", 1, 2, 3). + Return(5, "6", true). + Once() + mockedService. + On("Test_Mock_Called_For_Bounded_Repeatability", 1, 2, 3). + Return(-1, "hi", false) + + returnArguments1 := mockedService.Called(1, 2, 3) + returnArguments2 := mockedService.Called(1, 2, 3) + + if assert.Equal(t, 2, len(mockedService.Calls)) { + assert.Equal(t, "Test_Mock_Called_For_Bounded_Repeatability", mockedService.Calls[0].Method) + assert.Equal(t, 1, mockedService.Calls[0].Arguments[0]) + assert.Equal(t, 2, mockedService.Calls[0].Arguments[1]) + assert.Equal(t, 3, mockedService.Calls[0].Arguments[2]) + + assert.Equal(t, "Test_Mock_Called_For_Bounded_Repeatability", mockedService.Calls[1].Method) + assert.Equal(t, 1, mockedService.Calls[1].Arguments[0]) + assert.Equal(t, 2, mockedService.Calls[1].Arguments[1]) + assert.Equal(t, 3, mockedService.Calls[1].Arguments[2]) + } + + if assert.Equal(t, 3, len(returnArguments1)) { + assert.Equal(t, 5, returnArguments1[0]) + assert.Equal(t, "6", returnArguments1[1]) + assert.Equal(t, true, returnArguments1[2]) + } + + if assert.Equal(t, 3, len(returnArguments2)) { + assert.Equal(t, -1, returnArguments2[0]) + assert.Equal(t, "hi", returnArguments2[1]) + assert.Equal(t, false, returnArguments2[2]) + } + +} + +func Test_Mock_Called_For_SetTime_Expectation(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.On("TheExampleMethod", 1, 2, 3).Return(5, "6", true).Times(4) + + mockedService.TheExampleMethod(1, 2, 3) + mockedService.TheExampleMethod(1, 2, 3) + mockedService.TheExampleMethod(1, 2, 3) + mockedService.TheExampleMethod(1, 2, 3) + assert.Panics(t, func() { + mockedService.TheExampleMethod(1, 2, 3) + }) + +} + +func Test_Mock_Called_Unexpected(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + // make sure it panics if no expectation was made + assert.Panics(t, func() { + mockedService.Called(1, 2, 3) + }, "Calling unexpected method should panic") + +} + +func Test_AssertExpectationsForObjects_Helper(t *testing.T) { + + var mockedService1 = new(TestExampleImplementation) + var mockedService2 = new(TestExampleImplementation) + var mockedService3 = new(TestExampleImplementation) + + mockedService1.On("Test_AssertExpectationsForObjects_Helper", 1).Return() + mockedService2.On("Test_AssertExpectationsForObjects_Helper", 2).Return() + mockedService3.On("Test_AssertExpectationsForObjects_Helper", 3).Return() + + mockedService1.Called(1) + mockedService2.Called(2) + mockedService3.Called(3) + + assert.True(t, AssertExpectationsForObjects(t, &mockedService1.Mock, &mockedService2.Mock, &mockedService3.Mock)) + assert.True(t, AssertExpectationsForObjects(t, mockedService1, mockedService2, mockedService3)) + +} + +func Test_AssertExpectationsForObjects_Helper_Failed(t *testing.T) { + + var mockedService1 = new(TestExampleImplementation) + var mockedService2 = new(TestExampleImplementation) + var mockedService3 = new(TestExampleImplementation) + + mockedService1.On("Test_AssertExpectationsForObjects_Helper_Failed", 1).Return() + mockedService2.On("Test_AssertExpectationsForObjects_Helper_Failed", 2).Return() + mockedService3.On("Test_AssertExpectationsForObjects_Helper_Failed", 3).Return() + + mockedService1.Called(1) + mockedService3.Called(3) + + tt := new(testing.T) + assert.False(t, AssertExpectationsForObjects(tt, &mockedService1.Mock, &mockedService2.Mock, &mockedService3.Mock)) + assert.False(t, AssertExpectationsForObjects(tt, mockedService1, mockedService2, mockedService3)) + +} + +func Test_Mock_AssertExpectations(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.On("Test_Mock_AssertExpectations", 1, 2, 3).Return(5, 6, 7) + + tt := new(testing.T) + assert.False(t, mockedService.AssertExpectations(tt)) + + // make the call now + mockedService.Called(1, 2, 3) + + // now assert expectations + assert.True(t, mockedService.AssertExpectations(tt)) + +} + +func Test_Mock_AssertExpectations_Placeholder_NoArgs(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.On("Test_Mock_AssertExpectations_Placeholder_NoArgs").Return(5, 6, 7).Once() + mockedService.On("Test_Mock_AssertExpectations_Placeholder_NoArgs").Return(7, 6, 5) + + tt := new(testing.T) + assert.False(t, mockedService.AssertExpectations(tt)) + + // make the call now + mockedService.Called() + + // now assert expectations + assert.True(t, mockedService.AssertExpectations(tt)) + +} + +func Test_Mock_AssertExpectations_Placeholder(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.On("Test_Mock_AssertExpectations_Placeholder", 1, 2, 3).Return(5, 6, 7).Once() + mockedService.On("Test_Mock_AssertExpectations_Placeholder", 3, 2, 1).Return(7, 6, 5) + + tt := new(testing.T) + assert.False(t, mockedService.AssertExpectations(tt)) + + // make the call now + mockedService.Called(1, 2, 3) + + // now assert expectations + assert.False(t, mockedService.AssertExpectations(tt)) + + // make call to the second expectation + mockedService.Called(3, 2, 1) + + // now assert expectations again + assert.True(t, mockedService.AssertExpectations(tt)) +} + +func Test_Mock_AssertExpectations_With_Pointers(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.On("Test_Mock_AssertExpectations_With_Pointers", &struct{ Foo int }{1}).Return(1) + mockedService.On("Test_Mock_AssertExpectations_With_Pointers", &struct{ Foo int }{2}).Return(2) + + tt := new(testing.T) + assert.False(t, mockedService.AssertExpectations(tt)) + + s := struct{ Foo int }{1} + // make the calls now + mockedService.Called(&s) + s.Foo = 2 + mockedService.Called(&s) + + // now assert expectations + assert.True(t, mockedService.AssertExpectations(tt)) + +} + +func Test_Mock_AssertExpectationsCustomType(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.On("TheExampleMethod3", AnythingOfType("*mock.ExampleType")).Return(nil).Once() + + tt := new(testing.T) + assert.False(t, mockedService.AssertExpectations(tt)) + + // make the call now + mockedService.TheExampleMethod3(&ExampleType{}) + + // now assert expectations + assert.True(t, mockedService.AssertExpectations(tt)) + +} + +func Test_Mock_AssertExpectations_With_Repeatability(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.On("Test_Mock_AssertExpectations_With_Repeatability", 1, 2, 3).Return(5, 6, 7).Twice() + + tt := new(testing.T) + assert.False(t, mockedService.AssertExpectations(tt)) + + // make the call now + mockedService.Called(1, 2, 3) + + assert.False(t, mockedService.AssertExpectations(tt)) + + mockedService.Called(1, 2, 3) + + // now assert expectations + assert.True(t, mockedService.AssertExpectations(tt)) + +} + +func Test_Mock_TwoCallsWithDifferentArguments(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.On("Test_Mock_TwoCallsWithDifferentArguments", 1, 2, 3).Return(5, 6, 7) + mockedService.On("Test_Mock_TwoCallsWithDifferentArguments", 4, 5, 6).Return(5, 6, 7) + + args1 := mockedService.Called(1, 2, 3) + assert.Equal(t, 5, args1.Int(0)) + assert.Equal(t, 6, args1.Int(1)) + assert.Equal(t, 7, args1.Int(2)) + + args2 := mockedService.Called(4, 5, 6) + assert.Equal(t, 5, args2.Int(0)) + assert.Equal(t, 6, args2.Int(1)) + assert.Equal(t, 7, args2.Int(2)) + +} + +func Test_Mock_AssertNumberOfCalls(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.On("Test_Mock_AssertNumberOfCalls", 1, 2, 3).Return(5, 6, 7) + + mockedService.Called(1, 2, 3) + assert.True(t, mockedService.AssertNumberOfCalls(t, "Test_Mock_AssertNumberOfCalls", 1)) + + mockedService.Called(1, 2, 3) + assert.True(t, mockedService.AssertNumberOfCalls(t, "Test_Mock_AssertNumberOfCalls", 2)) + +} + +func Test_Mock_AssertCalled(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.On("Test_Mock_AssertCalled", 1, 2, 3).Return(5, 6, 7) + + mockedService.Called(1, 2, 3) + + assert.True(t, mockedService.AssertCalled(t, "Test_Mock_AssertCalled", 1, 2, 3)) + +} + +func Test_Mock_AssertCalled_WithAnythingOfTypeArgument(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService. + On("Test_Mock_AssertCalled_WithAnythingOfTypeArgument", Anything, Anything, Anything). + Return() + + mockedService.Called(1, "two", []uint8("three")) + + assert.True(t, mockedService.AssertCalled(t, "Test_Mock_AssertCalled_WithAnythingOfTypeArgument", AnythingOfType("int"), AnythingOfType("string"), AnythingOfType("[]uint8"))) + +} + +func Test_Mock_AssertCalled_WithArguments(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.On("Test_Mock_AssertCalled_WithArguments", 1, 2, 3).Return(5, 6, 7) + + mockedService.Called(1, 2, 3) + + tt := new(testing.T) + assert.True(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments", 1, 2, 3)) + assert.False(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments", 2, 3, 4)) + +} + +func Test_Mock_AssertCalled_WithArguments_With_Repeatability(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.On("Test_Mock_AssertCalled_WithArguments_With_Repeatability", 1, 2, 3).Return(5, 6, 7).Once() + mockedService.On("Test_Mock_AssertCalled_WithArguments_With_Repeatability", 2, 3, 4).Return(5, 6, 7).Once() + + mockedService.Called(1, 2, 3) + mockedService.Called(2, 3, 4) + + tt := new(testing.T) + assert.True(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments_With_Repeatability", 1, 2, 3)) + assert.True(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments_With_Repeatability", 2, 3, 4)) + assert.False(t, mockedService.AssertCalled(tt, "Test_Mock_AssertCalled_WithArguments_With_Repeatability", 3, 4, 5)) + +} + +func Test_Mock_AssertNotCalled(t *testing.T) { + + var mockedService = new(TestExampleImplementation) + + mockedService.On("Test_Mock_AssertNotCalled", 1, 2, 3).Return(5, 6, 7) + + mockedService.Called(1, 2, 3) + + assert.True(t, mockedService.AssertNotCalled(t, "Test_Mock_NotCalled")) + +} + +func Test_Mock_AssertOptional(t *testing.T) { + // Optional called + var ms1 = new(TestExampleImplementation) + ms1.On("TheExampleMethod", 1, 2, 3).Maybe().Return(4, nil) + ms1.TheExampleMethod(1, 2, 3) + + tt1 := new(testing.T) + assert.Equal(t, true, ms1.AssertExpectations(tt1)) + + // Optional not called + var ms2 = new(TestExampleImplementation) + ms2.On("TheExampleMethod", 1, 2, 3).Maybe().Return(4, nil) + + tt2 := new(testing.T) + assert.Equal(t, true, ms2.AssertExpectations(tt2)) + + // Non-optional called + var ms3 = new(TestExampleImplementation) + ms3.On("TheExampleMethod", 1, 2, 3).Return(4, nil) + ms3.TheExampleMethod(1, 2, 3) + + tt3 := new(testing.T) + assert.Equal(t, true, ms3.AssertExpectations(tt3)) +} + +/* + Arguments helper methods +*/ +func Test_Arguments_Get(t *testing.T) { + + var args = Arguments([]interface{}{"string", 123, true}) + + assert.Equal(t, "string", args.Get(0).(string)) + assert.Equal(t, 123, args.Get(1).(int)) + assert.Equal(t, true, args.Get(2).(bool)) + +} + +func Test_Arguments_Is(t *testing.T) { + + var args = Arguments([]interface{}{"string", 123, true}) + + assert.True(t, args.Is("string", 123, true)) + assert.False(t, args.Is("wrong", 456, false)) + +} + +func Test_Arguments_Diff(t *testing.T) { + + var args = Arguments([]interface{}{"Hello World", 123, true}) + var diff string + var count int + diff, count = args.Diff([]interface{}{"Hello World", 456, "false"}) + + assert.Equal(t, 2, count) + assert.Contains(t, diff, `(int=456) != (int=123)`) + assert.Contains(t, diff, `(string=false) != (bool=true)`) + +} + +func Test_Arguments_Diff_DifferentNumberOfArgs(t *testing.T) { + + var args = Arguments([]interface{}{"string", 123, true}) + var diff string + var count int + diff, count = args.Diff([]interface{}{"string", 456, "false", "extra"}) + + assert.Equal(t, 3, count) + assert.Contains(t, diff, `(string=extra) != (Missing)`) + +} + +func Test_Arguments_Diff_WithAnythingArgument(t *testing.T) { + + var args = Arguments([]interface{}{"string", 123, true}) + var count int + _, count = args.Diff([]interface{}{"string", Anything, true}) + + assert.Equal(t, 0, count) + +} + +func Test_Arguments_Diff_WithAnythingArgument_InActualToo(t *testing.T) { + + var args = Arguments([]interface{}{"string", Anything, true}) + var count int + _, count = args.Diff([]interface{}{"string", 123, true}) + + assert.Equal(t, 0, count) + +} + +func Test_Arguments_Diff_WithAnythingOfTypeArgument(t *testing.T) { + + var args = Arguments([]interface{}{"string", AnythingOfType("int"), true}) + var count int + _, count = args.Diff([]interface{}{"string", 123, true}) + + assert.Equal(t, 0, count) + +} + +func Test_Arguments_Diff_WithAnythingOfTypeArgument_Failing(t *testing.T) { + + var args = Arguments([]interface{}{"string", AnythingOfType("string"), true}) + var count int + var diff string + diff, count = args.Diff([]interface{}{"string", 123, true}) + + assert.Equal(t, 1, count) + assert.Contains(t, diff, `string != type int - (int=123)`) + +} + +func Test_Arguments_Diff_WithArgMatcher(t *testing.T) { + matchFn := func(a int) bool { + return a == 123 + } + var args = Arguments([]interface{}{"string", MatchedBy(matchFn), true}) + + diff, count := args.Diff([]interface{}{"string", 124, true}) + assert.Equal(t, 1, count) + assert.Contains(t, diff, `(int=124) not matched by func(int) bool`) + + diff, count = args.Diff([]interface{}{"string", false, true}) + assert.Equal(t, 1, count) + assert.Contains(t, diff, `(bool=false) not matched by func(int) bool`) + + diff, count = args.Diff([]interface{}{"string", 123, false}) + assert.Contains(t, diff, `(int=123) matched by func(int) bool`) + + diff, count = args.Diff([]interface{}{"string", 123, true}) + assert.Equal(t, 0, count) + assert.Contains(t, diff, `No differences.`) +} + +func Test_Arguments_Assert(t *testing.T) { + + var args = Arguments([]interface{}{"string", 123, true}) + + assert.True(t, args.Assert(t, "string", 123, true)) + +} + +func Test_Arguments_String_Representation(t *testing.T) { + + var args = Arguments([]interface{}{"string", 123, true}) + assert.Equal(t, `string,int,bool`, args.String()) + +} + +func Test_Arguments_String(t *testing.T) { + + var args = Arguments([]interface{}{"string", 123, true}) + assert.Equal(t, "string", args.String(0)) + +} + +func Test_Arguments_Error(t *testing.T) { + + var err = errors.New("An Error") + var args = Arguments([]interface{}{"string", 123, true, err}) + assert.Equal(t, err, args.Error(3)) + +} + +func Test_Arguments_Error_Nil(t *testing.T) { + + var args = Arguments([]interface{}{"string", 123, true, nil}) + assert.Equal(t, nil, args.Error(3)) + +} + +func Test_Arguments_Int(t *testing.T) { + + var args = Arguments([]interface{}{"string", 123, true}) + assert.Equal(t, 123, args.Int(1)) + +} + +func Test_Arguments_Bool(t *testing.T) { + + var args = Arguments([]interface{}{"string", 123, true}) + assert.Equal(t, true, args.Bool(2)) + +} + +func Test_WaitUntil_Parallel(t *testing.T) { + + // make a test impl object + var mockedService = new(TestExampleImplementation) + + ch1 := make(chan time.Time) + ch2 := make(chan time.Time) + + mockedService.Mock.On("TheExampleMethod2", true).Return().WaitUntil(ch2).Run(func(args Arguments) { + ch1 <- time.Now() + }) + + mockedService.Mock.On("TheExampleMethod2", false).Return().WaitUntil(ch1) + + // Lock both goroutines on the .WaitUntil method + go func() { + mockedService.TheExampleMethod2(false) + }() + go func() { + mockedService.TheExampleMethod2(true) + }() + + // Allow the first call to execute, so the second one executes afterwards + ch2 <- time.Now() +} + +func Test_MockMethodCalled(t *testing.T) { + m := new(Mock) + m.On("foo", "hello").Return("world") + + retArgs := m.MethodCalled("foo", "hello") + require.True(t, len(retArgs) == 1) + require.Equal(t, "world", retArgs[0]) + m.AssertExpectations(t) +} + +// Test to validate fix for racy concurrent call access in MethodCalled() +func Test_MockReturnAndCalledConcurrent(t *testing.T) { + iterations := 1000 + m := &Mock{} + call := m.On("ConcurrencyTestMethod") + + wg := sync.WaitGroup{} + wg.Add(2) + + go func() { + for i := 0; i < iterations; i++ { + call.Return(10) + } + wg.Done() + }() + go func() { + for i := 0; i < iterations; i++ { + ConcurrencyTestMethod(m) + } + wg.Done() + }() + wg.Wait() +} + +type timer struct{ Mock } + +func (s *timer) GetTime(i int) string { + return s.Called(i).Get(0).(string) +} + +type tCustomLogger struct { + *testing.T + logs []string + errs []string +} + +func (tc *tCustomLogger) Logf(format string, args ...interface{}) { + tc.T.Logf(format, args...) + tc.logs = append(tc.logs, fmt.Sprintf(format, args...)) +} + +func (tc *tCustomLogger) Errorf(format string, args ...interface{}) { + tc.errs = append(tc.errs, fmt.Sprintf(format, args...)) +} + +func (tc *tCustomLogger) FailNow() {} + +func TestLoggingAssertExpectations(t *testing.T) { + m := new(timer) + m.On("GetTime", 0).Return("") + tcl := &tCustomLogger{t, []string{}, []string{}} + + AssertExpectationsForObjects(tcl, m, new(TestExampleImplementation)) + + require.Equal(t, 1, len(tcl.errs)) + assert.Regexp(t, regexp.MustCompile("(?s)FAIL: 0 out of 1 expectation\\(s\\) were met.*The code you are testing needs to make 1 more call\\(s\\).*"), tcl.errs[0]) + require.Equal(t, 2, len(tcl.logs)) + assert.Regexp(t, regexp.MustCompile("(?s)FAIL:\tGetTime\\(int\\).*"), tcl.logs[0]) + require.Equal(t, "Expectations didn't match for Mock: *mock.timer", tcl.logs[1]) +} + +func TestAfterTotalWaitTimeWhileExecution(t *testing.T) { + waitDuration := 1 + total, waitMs := 5, time.Millisecond*time.Duration(waitDuration) + aTimer := new(timer) + for i := 0; i < total; i++ { + aTimer.On("GetTime", i).After(waitMs).Return(fmt.Sprintf("Time%d", i)).Once() + } + time.Sleep(waitMs) + start := time.Now() + var results []string + + for i := 0; i < total; i++ { + results = append(results, aTimer.GetTime(i)) + } + + end := time.Now() + elapsedTime := end.Sub(start) + assert.True(t, elapsedTime > waitMs, fmt.Sprintf("Total elapsed time:%v should be atleast greater than %v", elapsedTime, waitMs)) + assert.Equal(t, total, len(results)) + for i := range results { + assert.Equal(t, fmt.Sprintf("Time%d", i), results[i], "Return value of method should be same") + } +} + +func TestArgumentMatcherToPrintMismatch(t *testing.T) { + defer func() { + if r := recover(); r != nil { + matchingExp := regexp.MustCompile( + `\s+mock: Unexpected Method Call\s+-*\s+GetTime\(int\)\s+0: 1\s+The closest call I have is:\s+GetTime\(mock.argumentMatcher\)\s+0: mock.argumentMatcher\{.*?\}\s+Diff:.*\(int=1\) not matched by func\(int\) bool`) + assert.Regexp(t, matchingExp, r) + } + }() + + m := new(timer) + m.On("GetTime", MatchedBy(func(i int) bool { return false })).Return("SomeTime").Once() + + res := m.GetTime(1) + require.Equal(t, "SomeTime", res) + m.AssertExpectations(t) +} + +func TestClosestCallMismatchedArgumentInformationShowsTheClosest(t *testing.T) { + defer func() { + if r := recover(); r != nil { + matchingExp := regexp.MustCompile(unexpectedCallRegex(`TheExampleMethod(int,int,int)`, `0: 1\s+1: 1\s+2: 2`, `0: 1\s+1: 1\s+2: 1`, `0: PASS: \(int=1\) == \(int=1\)\s+1: PASS: \(int=1\) == \(int=1\)\s+2: FAIL: \(int=2\) != \(int=1\)`)) + assert.Regexp(t, matchingExp, r) + } + }() + + m := new(TestExampleImplementation) + m.On("TheExampleMethod", 1, 1, 1).Return(1, nil).Once() + m.On("TheExampleMethod", 2, 2, 2).Return(2, nil).Once() + + m.TheExampleMethod(1, 1, 2) +} + +func TestClosestCallMismatchedArgumentValueInformation(t *testing.T) { + defer func() { + if r := recover(); r != nil { + matchingExp := regexp.MustCompile(unexpectedCallRegex(`GetTime(int)`, "0: 1", "0: 999", `0: FAIL: \(int=1\) != \(int=999\)`)) + assert.Regexp(t, matchingExp, r) + } + }() + + m := new(timer) + m.On("GetTime", 999).Return("SomeTime").Once() + + _ = m.GetTime(1) +} + +func unexpectedCallRegex(method, calledArg, expectedArg, diff string) string { + rMethod := regexp.QuoteMeta(method) + return fmt.Sprintf(`\s+mock: Unexpected Method Call\s+-*\s+%s\s+%s\s+The closest call I have is:\s+%s\s+%s\s+Diff: %s`, + rMethod, calledArg, rMethod, expectedArg, diff) +} + +//go:noinline +func ConcurrencyTestMethod(m *Mock) { + m.Called() +} diff --git a/vendor/github.com/stretchr/testify/package_test.go b/vendor/github.com/stretchr/testify/package_test.go new file mode 100644 index 0000000..7ac5d6d --- /dev/null +++ b/vendor/github.com/stretchr/testify/package_test.go @@ -0,0 +1,12 @@ +package testify + +import ( + "github.com/stretchr/testify/assert" + "testing" +) + +func TestImports(t *testing.T) { + if assert.Equal(t, 1, 1) != true { + t.Error("Something is wrong.") + } +} diff --git a/vendor/github.com/stretchr/testify/require/doc.go b/vendor/github.com/stretchr/testify/require/doc.go new file mode 100644 index 0000000..169de39 --- /dev/null +++ b/vendor/github.com/stretchr/testify/require/doc.go @@ -0,0 +1,28 @@ +// Package require implements the same assertions as the `assert` package but +// stops test execution when a test fails. +// +// Example Usage +// +// The following is a complete example using require in a standard test function: +// import ( +// "testing" +// "github.com/stretchr/testify/require" +// ) +// +// func TestSomething(t *testing.T) { +// +// var a string = "Hello" +// var b string = "Hello" +// +// require.Equal(t, a, b, "The two words should be the same.") +// +// } +// +// Assertions +// +// The `require` package have same global functions as in the `assert` package, +// but instead of returning a boolean result they call `t.FailNow()`. +// +// Every assertion function also takes an optional string message as the final argument, +// allowing custom error messages to be appended to the message the assertion method outputs. +package require diff --git a/vendor/github.com/stretchr/testify/require/forward_requirements.go b/vendor/github.com/stretchr/testify/require/forward_requirements.go new file mode 100644 index 0000000..ac71d40 --- /dev/null +++ b/vendor/github.com/stretchr/testify/require/forward_requirements.go @@ -0,0 +1,16 @@ +package require + +// Assertions provides assertion methods around the +// TestingT interface. +type Assertions struct { + t TestingT +} + +// New makes a new Assertions object for the specified TestingT. +func New(t TestingT) *Assertions { + return &Assertions{ + t: t, + } +} + +//go:generate go run ../_codegen/main.go -output-package=require -template=require_forward.go.tmpl -include-format-funcs diff --git a/vendor/github.com/stretchr/testify/require/forward_requirements_test.go b/vendor/github.com/stretchr/testify/require/forward_requirements_test.go new file mode 100644 index 0000000..b120ae3 --- /dev/null +++ b/vendor/github.com/stretchr/testify/require/forward_requirements_test.go @@ -0,0 +1,385 @@ +package require + +import ( + "errors" + "testing" + "time" +) + +func TestImplementsWrapper(t *testing.T) { + require := New(t) + + require.Implements((*AssertionTesterInterface)(nil), new(AssertionTesterConformingObject)) + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.Implements((*AssertionTesterInterface)(nil), new(AssertionTesterNonConformingObject)) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestIsTypeWrapper(t *testing.T) { + require := New(t) + require.IsType(new(AssertionTesterConformingObject), new(AssertionTesterConformingObject)) + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.IsType(new(AssertionTesterConformingObject), new(AssertionTesterNonConformingObject)) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestEqualWrapper(t *testing.T) { + require := New(t) + require.Equal(1, 1) + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.Equal(1, 2) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestNotEqualWrapper(t *testing.T) { + require := New(t) + require.NotEqual(1, 2) + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.NotEqual(2, 2) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestExactlyWrapper(t *testing.T) { + require := New(t) + + a := float32(1) + b := float32(1) + c := float64(1) + + require.Exactly(a, b) + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.Exactly(a, c) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestNotNilWrapper(t *testing.T) { + require := New(t) + require.NotNil(t, new(AssertionTesterConformingObject)) + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.NotNil(nil) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestNilWrapper(t *testing.T) { + require := New(t) + require.Nil(nil) + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.Nil(new(AssertionTesterConformingObject)) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestTrueWrapper(t *testing.T) { + require := New(t) + require.True(true) + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.True(false) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestFalseWrapper(t *testing.T) { + require := New(t) + require.False(false) + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.False(true) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestContainsWrapper(t *testing.T) { + require := New(t) + require.Contains("Hello World", "Hello") + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.Contains("Hello World", "Salut") + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestNotContainsWrapper(t *testing.T) { + require := New(t) + require.NotContains("Hello World", "Hello!") + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.NotContains("Hello World", "Hello") + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestPanicsWrapper(t *testing.T) { + require := New(t) + require.Panics(func() { + panic("Panic!") + }) + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.Panics(func() {}) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestNotPanicsWrapper(t *testing.T) { + require := New(t) + require.NotPanics(func() {}) + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.NotPanics(func() { + panic("Panic!") + }) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestNoErrorWrapper(t *testing.T) { + require := New(t) + require.NoError(nil) + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.NoError(errors.New("some error")) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestErrorWrapper(t *testing.T) { + require := New(t) + require.Error(errors.New("some error")) + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.Error(nil) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestEqualErrorWrapper(t *testing.T) { + require := New(t) + require.EqualError(errors.New("some error"), "some error") + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.EqualError(errors.New("some error"), "Not some error") + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestEmptyWrapper(t *testing.T) { + require := New(t) + require.Empty("") + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.Empty("x") + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestNotEmptyWrapper(t *testing.T) { + require := New(t) + require.NotEmpty("x") + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.NotEmpty("") + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestWithinDurationWrapper(t *testing.T) { + require := New(t) + a := time.Now() + b := a.Add(10 * time.Second) + + require.WithinDuration(a, b, 15*time.Second) + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.WithinDuration(a, b, 5*time.Second) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestInDeltaWrapper(t *testing.T) { + require := New(t) + require.InDelta(1.001, 1, 0.01) + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.InDelta(1, 2, 0.5) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestZeroWrapper(t *testing.T) { + require := New(t) + require.Zero(0) + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.Zero(1) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestNotZeroWrapper(t *testing.T) { + require := New(t) + require.NotZero(1) + + mockT := new(MockT) + mockRequire := New(mockT) + mockRequire.NotZero(0) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestJSONEqWrapper_EqualSONString(t *testing.T) { + mockT := new(MockT) + mockRequire := New(mockT) + + mockRequire.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"hello": "world", "foo": "bar"}`) + if mockT.Failed { + t.Error("Check should pass") + } +} + +func TestJSONEqWrapper_EquivalentButNotEqual(t *testing.T) { + mockT := new(MockT) + mockRequire := New(mockT) + + mockRequire.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) + if mockT.Failed { + t.Error("Check should pass") + } +} + +func TestJSONEqWrapper_HashOfArraysAndHashes(t *testing.T) { + mockT := new(MockT) + mockRequire := New(mockT) + + mockRequire.JSONEq("{\r\n\t\"numeric\": 1.5,\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]],\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\"\r\n}", + "{\r\n\t\"numeric\": 1.5,\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\",\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]]\r\n}") + if mockT.Failed { + t.Error("Check should pass") + } +} + +func TestJSONEqWrapper_Array(t *testing.T) { + mockT := new(MockT) + mockRequire := New(mockT) + + mockRequire.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `["foo", {"nested": "hash", "hello": "world"}]`) + if mockT.Failed { + t.Error("Check should pass") + } +} + +func TestJSONEqWrapper_HashAndArrayNotEquivalent(t *testing.T) { + mockT := new(MockT) + mockRequire := New(mockT) + + mockRequire.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `{"foo": "bar", {"nested": "hash", "hello": "world"}}`) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestJSONEqWrapper_HashesNotEquivalent(t *testing.T) { + mockT := new(MockT) + mockRequire := New(mockT) + + mockRequire.JSONEq(`{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestJSONEqWrapper_ActualIsNotJSON(t *testing.T) { + mockT := new(MockT) + mockRequire := New(mockT) + + mockRequire.JSONEq(`{"foo": "bar"}`, "Not JSON") + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestJSONEqWrapper_ExpectedIsNotJSON(t *testing.T) { + mockT := new(MockT) + mockRequire := New(mockT) + + mockRequire.JSONEq("Not JSON", `{"foo": "bar", "hello": "world"}`) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestJSONEqWrapper_ExpectedAndActualNotJSON(t *testing.T) { + mockT := new(MockT) + mockRequire := New(mockT) + + mockRequire.JSONEq("Not JSON", "Not JSON") + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestJSONEqWrapper_ArraysOfDifferentOrder(t *testing.T) { + mockT := new(MockT) + mockRequire := New(mockT) + + mockRequire.JSONEq(`["foo", {"hello": "world", "nested": "hash"}]`, `[{ "hello": "world", "nested": "hash"}, "foo"]`) + if !mockT.Failed { + t.Error("Check should fail") + } +} diff --git a/vendor/github.com/stretchr/testify/require/require.go b/vendor/github.com/stretchr/testify/require/require.go new file mode 100644 index 0000000..535f293 --- /dev/null +++ b/vendor/github.com/stretchr/testify/require/require.go @@ -0,0 +1,1227 @@ +/* +* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen +* THIS FILE MUST NOT BE EDITED BY HAND + */ + +package require + +import ( + assert "github.com/stretchr/testify/assert" + http "net/http" + url "net/url" + time "time" +) + +// Condition uses a Comparison to assert a complex condition. +func Condition(t TestingT, comp assert.Comparison, msgAndArgs ...interface{}) { + if assert.Condition(t, comp, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Conditionf uses a Comparison to assert a complex condition. +func Conditionf(t TestingT, comp assert.Comparison, msg string, args ...interface{}) { + if assert.Conditionf(t, comp, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Contains asserts that the specified string, list(array, slice...) or map contains the +// specified substring or element. +// +// assert.Contains(t, "Hello World", "World") +// assert.Contains(t, ["Hello", "World"], "World") +// assert.Contains(t, {"Hello": "World"}, "Hello") +func Contains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) { + if assert.Contains(t, s, contains, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Containsf asserts that the specified string, list(array, slice...) or map contains the +// specified substring or element. +// +// assert.Containsf(t, "Hello World", "World", "error message %s", "formatted") +// assert.Containsf(t, ["Hello", "World"], "World", "error message %s", "formatted") +// assert.Containsf(t, {"Hello": "World"}, "Hello", "error message %s", "formatted") +func Containsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) { + if assert.Containsf(t, s, contains, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. +func DirExists(t TestingT, path string, msgAndArgs ...interface{}) { + if assert.DirExists(t, path, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// DirExistsf checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. +func DirExistsf(t TestingT, path string, msg string, args ...interface{}) { + if assert.DirExistsf(t, path, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified +// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, +// the number of appearances of each of them in both lists should match. +// +// assert.ElementsMatch(t, [1, 3, 2, 3], [1, 3, 3, 2]) +func ElementsMatch(t TestingT, listA interface{}, listB interface{}, msgAndArgs ...interface{}) { + if assert.ElementsMatch(t, listA, listB, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified +// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, +// the number of appearances of each of them in both lists should match. +// +// assert.ElementsMatchf(t, [1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted") +func ElementsMatchf(t TestingT, listA interface{}, listB interface{}, msg string, args ...interface{}) { + if assert.ElementsMatchf(t, listA, listB, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either +// a slice or a channel with len == 0. +// +// assert.Empty(t, obj) +func Empty(t TestingT, object interface{}, msgAndArgs ...interface{}) { + if assert.Empty(t, object, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either +// a slice or a channel with len == 0. +// +// assert.Emptyf(t, obj, "error message %s", "formatted") +func Emptyf(t TestingT, object interface{}, msg string, args ...interface{}) { + if assert.Emptyf(t, object, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Equal asserts that two objects are equal. +// +// assert.Equal(t, 123, 123) +// +// Pointer variable equality is determined based on the equality of the +// referenced values (as opposed to the memory addresses). Function equality +// cannot be determined and will always fail. +func Equal(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { + if assert.Equal(t, expected, actual, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// EqualError asserts that a function returned an error (i.e. not `nil`) +// and that it is equal to the provided error. +// +// actualObj, err := SomeFunction() +// assert.EqualError(t, err, expectedErrorString) +func EqualError(t TestingT, theError error, errString string, msgAndArgs ...interface{}) { + if assert.EqualError(t, theError, errString, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// EqualErrorf asserts that a function returned an error (i.e. not `nil`) +// and that it is equal to the provided error. +// +// actualObj, err := SomeFunction() +// assert.EqualErrorf(t, err, expectedErrorString, "error message %s", "formatted") +func EqualErrorf(t TestingT, theError error, errString string, msg string, args ...interface{}) { + if assert.EqualErrorf(t, theError, errString, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// EqualValues asserts that two objects are equal or convertable to the same types +// and equal. +// +// assert.EqualValues(t, uint32(123), int32(123)) +func EqualValues(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { + if assert.EqualValues(t, expected, actual, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// EqualValuesf asserts that two objects are equal or convertable to the same types +// and equal. +// +// assert.EqualValuesf(t, uint32(123, "error message %s", "formatted"), int32(123)) +func EqualValuesf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { + if assert.EqualValuesf(t, expected, actual, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Equalf asserts that two objects are equal. +// +// assert.Equalf(t, 123, 123, "error message %s", "formatted") +// +// Pointer variable equality is determined based on the equality of the +// referenced values (as opposed to the memory addresses). Function equality +// cannot be determined and will always fail. +func Equalf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { + if assert.Equalf(t, expected, actual, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Error asserts that a function returned an error (i.e. not `nil`). +// +// actualObj, err := SomeFunction() +// if assert.Error(t, err) { +// assert.Equal(t, expectedError, err) +// } +func Error(t TestingT, err error, msgAndArgs ...interface{}) { + if assert.Error(t, err, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Errorf asserts that a function returned an error (i.e. not `nil`). +// +// actualObj, err := SomeFunction() +// if assert.Errorf(t, err, "error message %s", "formatted") { +// assert.Equal(t, expectedErrorf, err) +// } +func Errorf(t TestingT, err error, msg string, args ...interface{}) { + if assert.Errorf(t, err, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Exactly asserts that two objects are equal in value and type. +// +// assert.Exactly(t, int32(123), int64(123)) +func Exactly(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { + if assert.Exactly(t, expected, actual, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Exactlyf asserts that two objects are equal in value and type. +// +// assert.Exactlyf(t, int32(123, "error message %s", "formatted"), int64(123)) +func Exactlyf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { + if assert.Exactlyf(t, expected, actual, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Fail reports a failure through +func Fail(t TestingT, failureMessage string, msgAndArgs ...interface{}) { + if assert.Fail(t, failureMessage, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// FailNow fails test +func FailNow(t TestingT, failureMessage string, msgAndArgs ...interface{}) { + if assert.FailNow(t, failureMessage, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// FailNowf fails test +func FailNowf(t TestingT, failureMessage string, msg string, args ...interface{}) { + if assert.FailNowf(t, failureMessage, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Failf reports a failure through +func Failf(t TestingT, failureMessage string, msg string, args ...interface{}) { + if assert.Failf(t, failureMessage, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// False asserts that the specified value is false. +// +// assert.False(t, myBool) +func False(t TestingT, value bool, msgAndArgs ...interface{}) { + if assert.False(t, value, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Falsef asserts that the specified value is false. +// +// assert.Falsef(t, myBool, "error message %s", "formatted") +func Falsef(t TestingT, value bool, msg string, args ...interface{}) { + if assert.Falsef(t, value, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. +func FileExists(t TestingT, path string, msgAndArgs ...interface{}) { + if assert.FileExists(t, path, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// FileExistsf checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. +func FileExistsf(t TestingT, path string, msg string, args ...interface{}) { + if assert.FileExistsf(t, path, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// HTTPBodyContains asserts that a specified handler returns a +// body that contains a string. +// +// assert.HTTPBodyContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") +// +// Returns whether the assertion was successful (true) or not (false). +func HTTPBodyContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { + if assert.HTTPBodyContains(t, handler, method, url, values, str, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// HTTPBodyContainsf asserts that a specified handler returns a +// body that contains a string. +// +// assert.HTTPBodyContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") +// +// Returns whether the assertion was successful (true) or not (false). +func HTTPBodyContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { + if assert.HTTPBodyContainsf(t, handler, method, url, values, str, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// HTTPBodyNotContains asserts that a specified handler returns a +// body that does not contain a string. +// +// assert.HTTPBodyNotContains(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") +// +// Returns whether the assertion was successful (true) or not (false). +func HTTPBodyNotContains(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { + if assert.HTTPBodyNotContains(t, handler, method, url, values, str, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// HTTPBodyNotContainsf asserts that a specified handler returns a +// body that does not contain a string. +// +// assert.HTTPBodyNotContainsf(t, myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") +// +// Returns whether the assertion was successful (true) or not (false). +func HTTPBodyNotContainsf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { + if assert.HTTPBodyNotContainsf(t, handler, method, url, values, str, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// HTTPError asserts that a specified handler returns an error status code. +// +// assert.HTTPError(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// +// Returns whether the assertion was successful (true) or not (false). +func HTTPError(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { + if assert.HTTPError(t, handler, method, url, values, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// HTTPErrorf asserts that a specified handler returns an error status code. +// +// assert.HTTPErrorf(t, myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// +// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). +func HTTPErrorf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { + if assert.HTTPErrorf(t, handler, method, url, values, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// HTTPRedirect asserts that a specified handler returns a redirect status code. +// +// assert.HTTPRedirect(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// +// Returns whether the assertion was successful (true) or not (false). +func HTTPRedirect(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { + if assert.HTTPRedirect(t, handler, method, url, values, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// HTTPRedirectf asserts that a specified handler returns a redirect status code. +// +// assert.HTTPRedirectf(t, myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// +// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). +func HTTPRedirectf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { + if assert.HTTPRedirectf(t, handler, method, url, values, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// HTTPSuccess asserts that a specified handler returns a success status code. +// +// assert.HTTPSuccess(t, myHandler, "POST", "http://www.google.com", nil) +// +// Returns whether the assertion was successful (true) or not (false). +func HTTPSuccess(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { + if assert.HTTPSuccess(t, handler, method, url, values, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// HTTPSuccessf asserts that a specified handler returns a success status code. +// +// assert.HTTPSuccessf(t, myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") +// +// Returns whether the assertion was successful (true) or not (false). +func HTTPSuccessf(t TestingT, handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { + if assert.HTTPSuccessf(t, handler, method, url, values, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Implements asserts that an object is implemented by the specified interface. +// +// assert.Implements(t, (*MyInterface)(nil), new(MyObject)) +func Implements(t TestingT, interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) { + if assert.Implements(t, interfaceObject, object, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Implementsf asserts that an object is implemented by the specified interface. +// +// assert.Implementsf(t, (*MyInterface, "error message %s", "formatted")(nil), new(MyObject)) +func Implementsf(t TestingT, interfaceObject interface{}, object interface{}, msg string, args ...interface{}) { + if assert.Implementsf(t, interfaceObject, object, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// InDelta asserts that the two numerals are within delta of each other. +// +// assert.InDelta(t, math.Pi, (22 / 7.0), 0.01) +func InDelta(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { + if assert.InDelta(t, expected, actual, delta, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. +func InDeltaMapValues(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { + if assert.InDeltaMapValues(t, expected, actual, delta, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. +func InDeltaMapValuesf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { + if assert.InDeltaMapValuesf(t, expected, actual, delta, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// InDeltaSlice is the same as InDelta, except it compares two slices. +func InDeltaSlice(t TestingT, expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { + if assert.InDeltaSlice(t, expected, actual, delta, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// InDeltaSlicef is the same as InDelta, except it compares two slices. +func InDeltaSlicef(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { + if assert.InDeltaSlicef(t, expected, actual, delta, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// InDeltaf asserts that the two numerals are within delta of each other. +// +// assert.InDeltaf(t, math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01) +func InDeltaf(t TestingT, expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { + if assert.InDeltaf(t, expected, actual, delta, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// InEpsilon asserts that expected and actual have a relative error less than epsilon +func InEpsilon(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) { + if assert.InEpsilon(t, expected, actual, epsilon, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices. +func InEpsilonSlice(t TestingT, expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) { + if assert.InEpsilonSlice(t, expected, actual, epsilon, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices. +func InEpsilonSlicef(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) { + if assert.InEpsilonSlicef(t, expected, actual, epsilon, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// InEpsilonf asserts that expected and actual have a relative error less than epsilon +func InEpsilonf(t TestingT, expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) { + if assert.InEpsilonf(t, expected, actual, epsilon, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// IsType asserts that the specified objects are of the same type. +func IsType(t TestingT, expectedType interface{}, object interface{}, msgAndArgs ...interface{}) { + if assert.IsType(t, expectedType, object, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// IsTypef asserts that the specified objects are of the same type. +func IsTypef(t TestingT, expectedType interface{}, object interface{}, msg string, args ...interface{}) { + if assert.IsTypef(t, expectedType, object, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// JSONEq asserts that two JSON strings are equivalent. +// +// assert.JSONEq(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) +func JSONEq(t TestingT, expected string, actual string, msgAndArgs ...interface{}) { + if assert.JSONEq(t, expected, actual, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// JSONEqf asserts that two JSON strings are equivalent. +// +// assert.JSONEqf(t, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") +func JSONEqf(t TestingT, expected string, actual string, msg string, args ...interface{}) { + if assert.JSONEqf(t, expected, actual, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Len asserts that the specified object has specific length. +// Len also fails if the object has a type that len() not accept. +// +// assert.Len(t, mySlice, 3) +func Len(t TestingT, object interface{}, length int, msgAndArgs ...interface{}) { + if assert.Len(t, object, length, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Lenf asserts that the specified object has specific length. +// Lenf also fails if the object has a type that len() not accept. +// +// assert.Lenf(t, mySlice, 3, "error message %s", "formatted") +func Lenf(t TestingT, object interface{}, length int, msg string, args ...interface{}) { + if assert.Lenf(t, object, length, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Nil asserts that the specified object is nil. +// +// assert.Nil(t, err) +func Nil(t TestingT, object interface{}, msgAndArgs ...interface{}) { + if assert.Nil(t, object, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Nilf asserts that the specified object is nil. +// +// assert.Nilf(t, err, "error message %s", "formatted") +func Nilf(t TestingT, object interface{}, msg string, args ...interface{}) { + if assert.Nilf(t, object, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NoError asserts that a function returned no error (i.e. `nil`). +// +// actualObj, err := SomeFunction() +// if assert.NoError(t, err) { +// assert.Equal(t, expectedObj, actualObj) +// } +func NoError(t TestingT, err error, msgAndArgs ...interface{}) { + if assert.NoError(t, err, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NoErrorf asserts that a function returned no error (i.e. `nil`). +// +// actualObj, err := SomeFunction() +// if assert.NoErrorf(t, err, "error message %s", "formatted") { +// assert.Equal(t, expectedObj, actualObj) +// } +func NoErrorf(t TestingT, err error, msg string, args ...interface{}) { + if assert.NoErrorf(t, err, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the +// specified substring or element. +// +// assert.NotContains(t, "Hello World", "Earth") +// assert.NotContains(t, ["Hello", "World"], "Earth") +// assert.NotContains(t, {"Hello": "World"}, "Earth") +func NotContains(t TestingT, s interface{}, contains interface{}, msgAndArgs ...interface{}) { + if assert.NotContains(t, s, contains, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the +// specified substring or element. +// +// assert.NotContainsf(t, "Hello World", "Earth", "error message %s", "formatted") +// assert.NotContainsf(t, ["Hello", "World"], "Earth", "error message %s", "formatted") +// assert.NotContainsf(t, {"Hello": "World"}, "Earth", "error message %s", "formatted") +func NotContainsf(t TestingT, s interface{}, contains interface{}, msg string, args ...interface{}) { + if assert.NotContainsf(t, s, contains, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either +// a slice or a channel with len == 0. +// +// if assert.NotEmpty(t, obj) { +// assert.Equal(t, "two", obj[1]) +// } +func NotEmpty(t TestingT, object interface{}, msgAndArgs ...interface{}) { + if assert.NotEmpty(t, object, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either +// a slice or a channel with len == 0. +// +// if assert.NotEmptyf(t, obj, "error message %s", "formatted") { +// assert.Equal(t, "two", obj[1]) +// } +func NotEmptyf(t TestingT, object interface{}, msg string, args ...interface{}) { + if assert.NotEmptyf(t, object, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NotEqual asserts that the specified values are NOT equal. +// +// assert.NotEqual(t, obj1, obj2) +// +// Pointer variable equality is determined based on the equality of the +// referenced values (as opposed to the memory addresses). +func NotEqual(t TestingT, expected interface{}, actual interface{}, msgAndArgs ...interface{}) { + if assert.NotEqual(t, expected, actual, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NotEqualf asserts that the specified values are NOT equal. +// +// assert.NotEqualf(t, obj1, obj2, "error message %s", "formatted") +// +// Pointer variable equality is determined based on the equality of the +// referenced values (as opposed to the memory addresses). +func NotEqualf(t TestingT, expected interface{}, actual interface{}, msg string, args ...interface{}) { + if assert.NotEqualf(t, expected, actual, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NotNil asserts that the specified object is not nil. +// +// assert.NotNil(t, err) +func NotNil(t TestingT, object interface{}, msgAndArgs ...interface{}) { + if assert.NotNil(t, object, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NotNilf asserts that the specified object is not nil. +// +// assert.NotNilf(t, err, "error message %s", "formatted") +func NotNilf(t TestingT, object interface{}, msg string, args ...interface{}) { + if assert.NotNilf(t, object, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. +// +// assert.NotPanics(t, func(){ RemainCalm() }) +func NotPanics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) { + if assert.NotPanics(t, f, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic. +// +// assert.NotPanicsf(t, func(){ RemainCalm() }, "error message %s", "formatted") +func NotPanicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) { + if assert.NotPanicsf(t, f, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NotRegexp asserts that a specified regexp does not match a string. +// +// assert.NotRegexp(t, regexp.MustCompile("starts"), "it's starting") +// assert.NotRegexp(t, "^start", "it's not starting") +func NotRegexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) { + if assert.NotRegexp(t, rx, str, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NotRegexpf asserts that a specified regexp does not match a string. +// +// assert.NotRegexpf(t, regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting") +// assert.NotRegexpf(t, "^start", "it's not starting", "error message %s", "formatted") +func NotRegexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) { + if assert.NotRegexpf(t, rx, str, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NotSubset asserts that the specified list(array, slice...) contains not all +// elements given in the specified subset(array, slice...). +// +// assert.NotSubset(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") +func NotSubset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) { + if assert.NotSubset(t, list, subset, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NotSubsetf asserts that the specified list(array, slice...) contains not all +// elements given in the specified subset(array, slice...). +// +// assert.NotSubsetf(t, [1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") +func NotSubsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) { + if assert.NotSubsetf(t, list, subset, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NotZero asserts that i is not the zero value for its type. +func NotZero(t TestingT, i interface{}, msgAndArgs ...interface{}) { + if assert.NotZero(t, i, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// NotZerof asserts that i is not the zero value for its type. +func NotZerof(t TestingT, i interface{}, msg string, args ...interface{}) { + if assert.NotZerof(t, i, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Panics asserts that the code inside the specified PanicTestFunc panics. +// +// assert.Panics(t, func(){ GoCrazy() }) +func Panics(t TestingT, f assert.PanicTestFunc, msgAndArgs ...interface{}) { + if assert.Panics(t, f, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that +// the recovered panic value equals the expected panic value. +// +// assert.PanicsWithValue(t, "crazy error", func(){ GoCrazy() }) +func PanicsWithValue(t TestingT, expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) { + if assert.PanicsWithValue(t, expected, f, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that +// the recovered panic value equals the expected panic value. +// +// assert.PanicsWithValuef(t, "crazy error", func(){ GoCrazy() }, "error message %s", "formatted") +func PanicsWithValuef(t TestingT, expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) { + if assert.PanicsWithValuef(t, expected, f, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Panicsf asserts that the code inside the specified PanicTestFunc panics. +// +// assert.Panicsf(t, func(){ GoCrazy() }, "error message %s", "formatted") +func Panicsf(t TestingT, f assert.PanicTestFunc, msg string, args ...interface{}) { + if assert.Panicsf(t, f, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Regexp asserts that a specified regexp matches a string. +// +// assert.Regexp(t, regexp.MustCompile("start"), "it's starting") +// assert.Regexp(t, "start...$", "it's not starting") +func Regexp(t TestingT, rx interface{}, str interface{}, msgAndArgs ...interface{}) { + if assert.Regexp(t, rx, str, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Regexpf asserts that a specified regexp matches a string. +// +// assert.Regexpf(t, regexp.MustCompile("start", "error message %s", "formatted"), "it's starting") +// assert.Regexpf(t, "start...$", "it's not starting", "error message %s", "formatted") +func Regexpf(t TestingT, rx interface{}, str interface{}, msg string, args ...interface{}) { + if assert.Regexpf(t, rx, str, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Subset asserts that the specified list(array, slice...) contains all +// elements given in the specified subset(array, slice...). +// +// assert.Subset(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") +func Subset(t TestingT, list interface{}, subset interface{}, msgAndArgs ...interface{}) { + if assert.Subset(t, list, subset, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Subsetf asserts that the specified list(array, slice...) contains all +// elements given in the specified subset(array, slice...). +// +// assert.Subsetf(t, [1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") +func Subsetf(t TestingT, list interface{}, subset interface{}, msg string, args ...interface{}) { + if assert.Subsetf(t, list, subset, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// True asserts that the specified value is true. +// +// assert.True(t, myBool) +func True(t TestingT, value bool, msgAndArgs ...interface{}) { + if assert.True(t, value, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Truef asserts that the specified value is true. +// +// assert.Truef(t, myBool, "error message %s", "formatted") +func Truef(t TestingT, value bool, msg string, args ...interface{}) { + if assert.Truef(t, value, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// WithinDuration asserts that the two times are within duration delta of each other. +// +// assert.WithinDuration(t, time.Now(), time.Now(), 10*time.Second) +func WithinDuration(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) { + if assert.WithinDuration(t, expected, actual, delta, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// WithinDurationf asserts that the two times are within duration delta of each other. +// +// assert.WithinDurationf(t, time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") +func WithinDurationf(t TestingT, expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) { + if assert.WithinDurationf(t, expected, actual, delta, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Zero asserts that i is the zero value for its type. +func Zero(t TestingT, i interface{}, msgAndArgs ...interface{}) { + if assert.Zero(t, i, msgAndArgs...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} + +// Zerof asserts that i is the zero value for its type. +func Zerof(t TestingT, i interface{}, msg string, args ...interface{}) { + if assert.Zerof(t, i, msg, args...) { + return + } + if h, ok := t.(tHelper); ok { + h.Helper() + } + t.FailNow() +} diff --git a/vendor/github.com/stretchr/testify/require/require.go.tmpl b/vendor/github.com/stretchr/testify/require/require.go.tmpl new file mode 100644 index 0000000..6ffc751 --- /dev/null +++ b/vendor/github.com/stretchr/testify/require/require.go.tmpl @@ -0,0 +1,6 @@ +{{.Comment}} +func {{.DocInfo.Name}}(t TestingT, {{.Params}}) { + if assert.{{.DocInfo.Name}}(t, {{.ForwardedParams}}) { return } + if h, ok := t.(tHelper); ok { h.Helper() } + t.FailNow() +} diff --git a/vendor/github.com/stretchr/testify/require/require_forward.go b/vendor/github.com/stretchr/testify/require/require_forward.go new file mode 100644 index 0000000..9fe41db --- /dev/null +++ b/vendor/github.com/stretchr/testify/require/require_forward.go @@ -0,0 +1,957 @@ +/* +* CODE GENERATED AUTOMATICALLY WITH github.com/stretchr/testify/_codegen +* THIS FILE MUST NOT BE EDITED BY HAND + */ + +package require + +import ( + assert "github.com/stretchr/testify/assert" + http "net/http" + url "net/url" + time "time" +) + +// Condition uses a Comparison to assert a complex condition. +func (a *Assertions) Condition(comp assert.Comparison, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Condition(a.t, comp, msgAndArgs...) +} + +// Conditionf uses a Comparison to assert a complex condition. +func (a *Assertions) Conditionf(comp assert.Comparison, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Conditionf(a.t, comp, msg, args...) +} + +// Contains asserts that the specified string, list(array, slice...) or map contains the +// specified substring or element. +// +// a.Contains("Hello World", "World") +// a.Contains(["Hello", "World"], "World") +// a.Contains({"Hello": "World"}, "Hello") +func (a *Assertions) Contains(s interface{}, contains interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Contains(a.t, s, contains, msgAndArgs...) +} + +// Containsf asserts that the specified string, list(array, slice...) or map contains the +// specified substring or element. +// +// a.Containsf("Hello World", "World", "error message %s", "formatted") +// a.Containsf(["Hello", "World"], "World", "error message %s", "formatted") +// a.Containsf({"Hello": "World"}, "Hello", "error message %s", "formatted") +func (a *Assertions) Containsf(s interface{}, contains interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Containsf(a.t, s, contains, msg, args...) +} + +// DirExists checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. +func (a *Assertions) DirExists(path string, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + DirExists(a.t, path, msgAndArgs...) +} + +// DirExistsf checks whether a directory exists in the given path. It also fails if the path is a file rather a directory or there is an error checking whether it exists. +func (a *Assertions) DirExistsf(path string, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + DirExistsf(a.t, path, msg, args...) +} + +// ElementsMatch asserts that the specified listA(array, slice...) is equal to specified +// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, +// the number of appearances of each of them in both lists should match. +// +// a.ElementsMatch([1, 3, 2, 3], [1, 3, 3, 2]) +func (a *Assertions) ElementsMatch(listA interface{}, listB interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + ElementsMatch(a.t, listA, listB, msgAndArgs...) +} + +// ElementsMatchf asserts that the specified listA(array, slice...) is equal to specified +// listB(array, slice...) ignoring the order of the elements. If there are duplicate elements, +// the number of appearances of each of them in both lists should match. +// +// a.ElementsMatchf([1, 3, 2, 3], [1, 3, 3, 2], "error message %s", "formatted") +func (a *Assertions) ElementsMatchf(listA interface{}, listB interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + ElementsMatchf(a.t, listA, listB, msg, args...) +} + +// Empty asserts that the specified object is empty. I.e. nil, "", false, 0 or either +// a slice or a channel with len == 0. +// +// a.Empty(obj) +func (a *Assertions) Empty(object interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Empty(a.t, object, msgAndArgs...) +} + +// Emptyf asserts that the specified object is empty. I.e. nil, "", false, 0 or either +// a slice or a channel with len == 0. +// +// a.Emptyf(obj, "error message %s", "formatted") +func (a *Assertions) Emptyf(object interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Emptyf(a.t, object, msg, args...) +} + +// Equal asserts that two objects are equal. +// +// a.Equal(123, 123) +// +// Pointer variable equality is determined based on the equality of the +// referenced values (as opposed to the memory addresses). Function equality +// cannot be determined and will always fail. +func (a *Assertions) Equal(expected interface{}, actual interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Equal(a.t, expected, actual, msgAndArgs...) +} + +// EqualError asserts that a function returned an error (i.e. not `nil`) +// and that it is equal to the provided error. +// +// actualObj, err := SomeFunction() +// a.EqualError(err, expectedErrorString) +func (a *Assertions) EqualError(theError error, errString string, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + EqualError(a.t, theError, errString, msgAndArgs...) +} + +// EqualErrorf asserts that a function returned an error (i.e. not `nil`) +// and that it is equal to the provided error. +// +// actualObj, err := SomeFunction() +// a.EqualErrorf(err, expectedErrorString, "error message %s", "formatted") +func (a *Assertions) EqualErrorf(theError error, errString string, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + EqualErrorf(a.t, theError, errString, msg, args...) +} + +// EqualValues asserts that two objects are equal or convertable to the same types +// and equal. +// +// a.EqualValues(uint32(123), int32(123)) +func (a *Assertions) EqualValues(expected interface{}, actual interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + EqualValues(a.t, expected, actual, msgAndArgs...) +} + +// EqualValuesf asserts that two objects are equal or convertable to the same types +// and equal. +// +// a.EqualValuesf(uint32(123, "error message %s", "formatted"), int32(123)) +func (a *Assertions) EqualValuesf(expected interface{}, actual interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + EqualValuesf(a.t, expected, actual, msg, args...) +} + +// Equalf asserts that two objects are equal. +// +// a.Equalf(123, 123, "error message %s", "formatted") +// +// Pointer variable equality is determined based on the equality of the +// referenced values (as opposed to the memory addresses). Function equality +// cannot be determined and will always fail. +func (a *Assertions) Equalf(expected interface{}, actual interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Equalf(a.t, expected, actual, msg, args...) +} + +// Error asserts that a function returned an error (i.e. not `nil`). +// +// actualObj, err := SomeFunction() +// if a.Error(err) { +// assert.Equal(t, expectedError, err) +// } +func (a *Assertions) Error(err error, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Error(a.t, err, msgAndArgs...) +} + +// Errorf asserts that a function returned an error (i.e. not `nil`). +// +// actualObj, err := SomeFunction() +// if a.Errorf(err, "error message %s", "formatted") { +// assert.Equal(t, expectedErrorf, err) +// } +func (a *Assertions) Errorf(err error, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Errorf(a.t, err, msg, args...) +} + +// Exactly asserts that two objects are equal in value and type. +// +// a.Exactly(int32(123), int64(123)) +func (a *Assertions) Exactly(expected interface{}, actual interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Exactly(a.t, expected, actual, msgAndArgs...) +} + +// Exactlyf asserts that two objects are equal in value and type. +// +// a.Exactlyf(int32(123, "error message %s", "formatted"), int64(123)) +func (a *Assertions) Exactlyf(expected interface{}, actual interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Exactlyf(a.t, expected, actual, msg, args...) +} + +// Fail reports a failure through +func (a *Assertions) Fail(failureMessage string, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Fail(a.t, failureMessage, msgAndArgs...) +} + +// FailNow fails test +func (a *Assertions) FailNow(failureMessage string, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + FailNow(a.t, failureMessage, msgAndArgs...) +} + +// FailNowf fails test +func (a *Assertions) FailNowf(failureMessage string, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + FailNowf(a.t, failureMessage, msg, args...) +} + +// Failf reports a failure through +func (a *Assertions) Failf(failureMessage string, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Failf(a.t, failureMessage, msg, args...) +} + +// False asserts that the specified value is false. +// +// a.False(myBool) +func (a *Assertions) False(value bool, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + False(a.t, value, msgAndArgs...) +} + +// Falsef asserts that the specified value is false. +// +// a.Falsef(myBool, "error message %s", "formatted") +func (a *Assertions) Falsef(value bool, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Falsef(a.t, value, msg, args...) +} + +// FileExists checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. +func (a *Assertions) FileExists(path string, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + FileExists(a.t, path, msgAndArgs...) +} + +// FileExistsf checks whether a file exists in the given path. It also fails if the path points to a directory or there is an error when trying to check the file. +func (a *Assertions) FileExistsf(path string, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + FileExistsf(a.t, path, msg, args...) +} + +// HTTPBodyContains asserts that a specified handler returns a +// body that contains a string. +// +// a.HTTPBodyContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) HTTPBodyContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + HTTPBodyContains(a.t, handler, method, url, values, str, msgAndArgs...) +} + +// HTTPBodyContainsf asserts that a specified handler returns a +// body that contains a string. +// +// a.HTTPBodyContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) HTTPBodyContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + HTTPBodyContainsf(a.t, handler, method, url, values, str, msg, args...) +} + +// HTTPBodyNotContains asserts that a specified handler returns a +// body that does not contain a string. +// +// a.HTTPBodyNotContains(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) HTTPBodyNotContains(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + HTTPBodyNotContains(a.t, handler, method, url, values, str, msgAndArgs...) +} + +// HTTPBodyNotContainsf asserts that a specified handler returns a +// body that does not contain a string. +// +// a.HTTPBodyNotContainsf(myHandler, "GET", "www.google.com", nil, "I'm Feeling Lucky", "error message %s", "formatted") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) HTTPBodyNotContainsf(handler http.HandlerFunc, method string, url string, values url.Values, str interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + HTTPBodyNotContainsf(a.t, handler, method, url, values, str, msg, args...) +} + +// HTTPError asserts that a specified handler returns an error status code. +// +// a.HTTPError(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) HTTPError(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + HTTPError(a.t, handler, method, url, values, msgAndArgs...) +} + +// HTTPErrorf asserts that a specified handler returns an error status code. +// +// a.HTTPErrorf(myHandler, "POST", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// +// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). +func (a *Assertions) HTTPErrorf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + HTTPErrorf(a.t, handler, method, url, values, msg, args...) +} + +// HTTPRedirect asserts that a specified handler returns a redirect status code. +// +// a.HTTPRedirect(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) HTTPRedirect(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + HTTPRedirect(a.t, handler, method, url, values, msgAndArgs...) +} + +// HTTPRedirectf asserts that a specified handler returns a redirect status code. +// +// a.HTTPRedirectf(myHandler, "GET", "/a/b/c", url.Values{"a": []string{"b", "c"}} +// +// Returns whether the assertion was successful (true, "error message %s", "formatted") or not (false). +func (a *Assertions) HTTPRedirectf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + HTTPRedirectf(a.t, handler, method, url, values, msg, args...) +} + +// HTTPSuccess asserts that a specified handler returns a success status code. +// +// a.HTTPSuccess(myHandler, "POST", "http://www.google.com", nil) +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) HTTPSuccess(handler http.HandlerFunc, method string, url string, values url.Values, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + HTTPSuccess(a.t, handler, method, url, values, msgAndArgs...) +} + +// HTTPSuccessf asserts that a specified handler returns a success status code. +// +// a.HTTPSuccessf(myHandler, "POST", "http://www.google.com", nil, "error message %s", "formatted") +// +// Returns whether the assertion was successful (true) or not (false). +func (a *Assertions) HTTPSuccessf(handler http.HandlerFunc, method string, url string, values url.Values, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + HTTPSuccessf(a.t, handler, method, url, values, msg, args...) +} + +// Implements asserts that an object is implemented by the specified interface. +// +// a.Implements((*MyInterface)(nil), new(MyObject)) +func (a *Assertions) Implements(interfaceObject interface{}, object interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Implements(a.t, interfaceObject, object, msgAndArgs...) +} + +// Implementsf asserts that an object is implemented by the specified interface. +// +// a.Implementsf((*MyInterface, "error message %s", "formatted")(nil), new(MyObject)) +func (a *Assertions) Implementsf(interfaceObject interface{}, object interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Implementsf(a.t, interfaceObject, object, msg, args...) +} + +// InDelta asserts that the two numerals are within delta of each other. +// +// a.InDelta(math.Pi, (22 / 7.0), 0.01) +func (a *Assertions) InDelta(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + InDelta(a.t, expected, actual, delta, msgAndArgs...) +} + +// InDeltaMapValues is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. +func (a *Assertions) InDeltaMapValues(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + InDeltaMapValues(a.t, expected, actual, delta, msgAndArgs...) +} + +// InDeltaMapValuesf is the same as InDelta, but it compares all values between two maps. Both maps must have exactly the same keys. +func (a *Assertions) InDeltaMapValuesf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + InDeltaMapValuesf(a.t, expected, actual, delta, msg, args...) +} + +// InDeltaSlice is the same as InDelta, except it compares two slices. +func (a *Assertions) InDeltaSlice(expected interface{}, actual interface{}, delta float64, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + InDeltaSlice(a.t, expected, actual, delta, msgAndArgs...) +} + +// InDeltaSlicef is the same as InDelta, except it compares two slices. +func (a *Assertions) InDeltaSlicef(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + InDeltaSlicef(a.t, expected, actual, delta, msg, args...) +} + +// InDeltaf asserts that the two numerals are within delta of each other. +// +// a.InDeltaf(math.Pi, (22 / 7.0, "error message %s", "formatted"), 0.01) +func (a *Assertions) InDeltaf(expected interface{}, actual interface{}, delta float64, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + InDeltaf(a.t, expected, actual, delta, msg, args...) +} + +// InEpsilon asserts that expected and actual have a relative error less than epsilon +func (a *Assertions) InEpsilon(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + InEpsilon(a.t, expected, actual, epsilon, msgAndArgs...) +} + +// InEpsilonSlice is the same as InEpsilon, except it compares each value from two slices. +func (a *Assertions) InEpsilonSlice(expected interface{}, actual interface{}, epsilon float64, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + InEpsilonSlice(a.t, expected, actual, epsilon, msgAndArgs...) +} + +// InEpsilonSlicef is the same as InEpsilon, except it compares each value from two slices. +func (a *Assertions) InEpsilonSlicef(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + InEpsilonSlicef(a.t, expected, actual, epsilon, msg, args...) +} + +// InEpsilonf asserts that expected and actual have a relative error less than epsilon +func (a *Assertions) InEpsilonf(expected interface{}, actual interface{}, epsilon float64, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + InEpsilonf(a.t, expected, actual, epsilon, msg, args...) +} + +// IsType asserts that the specified objects are of the same type. +func (a *Assertions) IsType(expectedType interface{}, object interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + IsType(a.t, expectedType, object, msgAndArgs...) +} + +// IsTypef asserts that the specified objects are of the same type. +func (a *Assertions) IsTypef(expectedType interface{}, object interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + IsTypef(a.t, expectedType, object, msg, args...) +} + +// JSONEq asserts that two JSON strings are equivalent. +// +// a.JSONEq(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) +func (a *Assertions) JSONEq(expected string, actual string, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + JSONEq(a.t, expected, actual, msgAndArgs...) +} + +// JSONEqf asserts that two JSON strings are equivalent. +// +// a.JSONEqf(`{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`, "error message %s", "formatted") +func (a *Assertions) JSONEqf(expected string, actual string, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + JSONEqf(a.t, expected, actual, msg, args...) +} + +// Len asserts that the specified object has specific length. +// Len also fails if the object has a type that len() not accept. +// +// a.Len(mySlice, 3) +func (a *Assertions) Len(object interface{}, length int, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Len(a.t, object, length, msgAndArgs...) +} + +// Lenf asserts that the specified object has specific length. +// Lenf also fails if the object has a type that len() not accept. +// +// a.Lenf(mySlice, 3, "error message %s", "formatted") +func (a *Assertions) Lenf(object interface{}, length int, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Lenf(a.t, object, length, msg, args...) +} + +// Nil asserts that the specified object is nil. +// +// a.Nil(err) +func (a *Assertions) Nil(object interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Nil(a.t, object, msgAndArgs...) +} + +// Nilf asserts that the specified object is nil. +// +// a.Nilf(err, "error message %s", "formatted") +func (a *Assertions) Nilf(object interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Nilf(a.t, object, msg, args...) +} + +// NoError asserts that a function returned no error (i.e. `nil`). +// +// actualObj, err := SomeFunction() +// if a.NoError(err) { +// assert.Equal(t, expectedObj, actualObj) +// } +func (a *Assertions) NoError(err error, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NoError(a.t, err, msgAndArgs...) +} + +// NoErrorf asserts that a function returned no error (i.e. `nil`). +// +// actualObj, err := SomeFunction() +// if a.NoErrorf(err, "error message %s", "formatted") { +// assert.Equal(t, expectedObj, actualObj) +// } +func (a *Assertions) NoErrorf(err error, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NoErrorf(a.t, err, msg, args...) +} + +// NotContains asserts that the specified string, list(array, slice...) or map does NOT contain the +// specified substring or element. +// +// a.NotContains("Hello World", "Earth") +// a.NotContains(["Hello", "World"], "Earth") +// a.NotContains({"Hello": "World"}, "Earth") +func (a *Assertions) NotContains(s interface{}, contains interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotContains(a.t, s, contains, msgAndArgs...) +} + +// NotContainsf asserts that the specified string, list(array, slice...) or map does NOT contain the +// specified substring or element. +// +// a.NotContainsf("Hello World", "Earth", "error message %s", "formatted") +// a.NotContainsf(["Hello", "World"], "Earth", "error message %s", "formatted") +// a.NotContainsf({"Hello": "World"}, "Earth", "error message %s", "formatted") +func (a *Assertions) NotContainsf(s interface{}, contains interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotContainsf(a.t, s, contains, msg, args...) +} + +// NotEmpty asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either +// a slice or a channel with len == 0. +// +// if a.NotEmpty(obj) { +// assert.Equal(t, "two", obj[1]) +// } +func (a *Assertions) NotEmpty(object interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotEmpty(a.t, object, msgAndArgs...) +} + +// NotEmptyf asserts that the specified object is NOT empty. I.e. not nil, "", false, 0 or either +// a slice or a channel with len == 0. +// +// if a.NotEmptyf(obj, "error message %s", "formatted") { +// assert.Equal(t, "two", obj[1]) +// } +func (a *Assertions) NotEmptyf(object interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotEmptyf(a.t, object, msg, args...) +} + +// NotEqual asserts that the specified values are NOT equal. +// +// a.NotEqual(obj1, obj2) +// +// Pointer variable equality is determined based on the equality of the +// referenced values (as opposed to the memory addresses). +func (a *Assertions) NotEqual(expected interface{}, actual interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotEqual(a.t, expected, actual, msgAndArgs...) +} + +// NotEqualf asserts that the specified values are NOT equal. +// +// a.NotEqualf(obj1, obj2, "error message %s", "formatted") +// +// Pointer variable equality is determined based on the equality of the +// referenced values (as opposed to the memory addresses). +func (a *Assertions) NotEqualf(expected interface{}, actual interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotEqualf(a.t, expected, actual, msg, args...) +} + +// NotNil asserts that the specified object is not nil. +// +// a.NotNil(err) +func (a *Assertions) NotNil(object interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotNil(a.t, object, msgAndArgs...) +} + +// NotNilf asserts that the specified object is not nil. +// +// a.NotNilf(err, "error message %s", "formatted") +func (a *Assertions) NotNilf(object interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotNilf(a.t, object, msg, args...) +} + +// NotPanics asserts that the code inside the specified PanicTestFunc does NOT panic. +// +// a.NotPanics(func(){ RemainCalm() }) +func (a *Assertions) NotPanics(f assert.PanicTestFunc, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotPanics(a.t, f, msgAndArgs...) +} + +// NotPanicsf asserts that the code inside the specified PanicTestFunc does NOT panic. +// +// a.NotPanicsf(func(){ RemainCalm() }, "error message %s", "formatted") +func (a *Assertions) NotPanicsf(f assert.PanicTestFunc, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotPanicsf(a.t, f, msg, args...) +} + +// NotRegexp asserts that a specified regexp does not match a string. +// +// a.NotRegexp(regexp.MustCompile("starts"), "it's starting") +// a.NotRegexp("^start", "it's not starting") +func (a *Assertions) NotRegexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotRegexp(a.t, rx, str, msgAndArgs...) +} + +// NotRegexpf asserts that a specified regexp does not match a string. +// +// a.NotRegexpf(regexp.MustCompile("starts", "error message %s", "formatted"), "it's starting") +// a.NotRegexpf("^start", "it's not starting", "error message %s", "formatted") +func (a *Assertions) NotRegexpf(rx interface{}, str interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotRegexpf(a.t, rx, str, msg, args...) +} + +// NotSubset asserts that the specified list(array, slice...) contains not all +// elements given in the specified subset(array, slice...). +// +// a.NotSubset([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]") +func (a *Assertions) NotSubset(list interface{}, subset interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotSubset(a.t, list, subset, msgAndArgs...) +} + +// NotSubsetf asserts that the specified list(array, slice...) contains not all +// elements given in the specified subset(array, slice...). +// +// a.NotSubsetf([1, 3, 4], [1, 2], "But [1, 3, 4] does not contain [1, 2]", "error message %s", "formatted") +func (a *Assertions) NotSubsetf(list interface{}, subset interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotSubsetf(a.t, list, subset, msg, args...) +} + +// NotZero asserts that i is not the zero value for its type. +func (a *Assertions) NotZero(i interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotZero(a.t, i, msgAndArgs...) +} + +// NotZerof asserts that i is not the zero value for its type. +func (a *Assertions) NotZerof(i interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + NotZerof(a.t, i, msg, args...) +} + +// Panics asserts that the code inside the specified PanicTestFunc panics. +// +// a.Panics(func(){ GoCrazy() }) +func (a *Assertions) Panics(f assert.PanicTestFunc, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Panics(a.t, f, msgAndArgs...) +} + +// PanicsWithValue asserts that the code inside the specified PanicTestFunc panics, and that +// the recovered panic value equals the expected panic value. +// +// a.PanicsWithValue("crazy error", func(){ GoCrazy() }) +func (a *Assertions) PanicsWithValue(expected interface{}, f assert.PanicTestFunc, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + PanicsWithValue(a.t, expected, f, msgAndArgs...) +} + +// PanicsWithValuef asserts that the code inside the specified PanicTestFunc panics, and that +// the recovered panic value equals the expected panic value. +// +// a.PanicsWithValuef("crazy error", func(){ GoCrazy() }, "error message %s", "formatted") +func (a *Assertions) PanicsWithValuef(expected interface{}, f assert.PanicTestFunc, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + PanicsWithValuef(a.t, expected, f, msg, args...) +} + +// Panicsf asserts that the code inside the specified PanicTestFunc panics. +// +// a.Panicsf(func(){ GoCrazy() }, "error message %s", "formatted") +func (a *Assertions) Panicsf(f assert.PanicTestFunc, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Panicsf(a.t, f, msg, args...) +} + +// Regexp asserts that a specified regexp matches a string. +// +// a.Regexp(regexp.MustCompile("start"), "it's starting") +// a.Regexp("start...$", "it's not starting") +func (a *Assertions) Regexp(rx interface{}, str interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Regexp(a.t, rx, str, msgAndArgs...) +} + +// Regexpf asserts that a specified regexp matches a string. +// +// a.Regexpf(regexp.MustCompile("start", "error message %s", "formatted"), "it's starting") +// a.Regexpf("start...$", "it's not starting", "error message %s", "formatted") +func (a *Assertions) Regexpf(rx interface{}, str interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Regexpf(a.t, rx, str, msg, args...) +} + +// Subset asserts that the specified list(array, slice...) contains all +// elements given in the specified subset(array, slice...). +// +// a.Subset([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]") +func (a *Assertions) Subset(list interface{}, subset interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Subset(a.t, list, subset, msgAndArgs...) +} + +// Subsetf asserts that the specified list(array, slice...) contains all +// elements given in the specified subset(array, slice...). +// +// a.Subsetf([1, 2, 3], [1, 2], "But [1, 2, 3] does contain [1, 2]", "error message %s", "formatted") +func (a *Assertions) Subsetf(list interface{}, subset interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Subsetf(a.t, list, subset, msg, args...) +} + +// True asserts that the specified value is true. +// +// a.True(myBool) +func (a *Assertions) True(value bool, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + True(a.t, value, msgAndArgs...) +} + +// Truef asserts that the specified value is true. +// +// a.Truef(myBool, "error message %s", "formatted") +func (a *Assertions) Truef(value bool, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Truef(a.t, value, msg, args...) +} + +// WithinDuration asserts that the two times are within duration delta of each other. +// +// a.WithinDuration(time.Now(), time.Now(), 10*time.Second) +func (a *Assertions) WithinDuration(expected time.Time, actual time.Time, delta time.Duration, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + WithinDuration(a.t, expected, actual, delta, msgAndArgs...) +} + +// WithinDurationf asserts that the two times are within duration delta of each other. +// +// a.WithinDurationf(time.Now(), time.Now(), 10*time.Second, "error message %s", "formatted") +func (a *Assertions) WithinDurationf(expected time.Time, actual time.Time, delta time.Duration, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + WithinDurationf(a.t, expected, actual, delta, msg, args...) +} + +// Zero asserts that i is the zero value for its type. +func (a *Assertions) Zero(i interface{}, msgAndArgs ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Zero(a.t, i, msgAndArgs...) +} + +// Zerof asserts that i is the zero value for its type. +func (a *Assertions) Zerof(i interface{}, msg string, args ...interface{}) { + if h, ok := a.t.(tHelper); ok { + h.Helper() + } + Zerof(a.t, i, msg, args...) +} diff --git a/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl b/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl new file mode 100644 index 0000000..54124df --- /dev/null +++ b/vendor/github.com/stretchr/testify/require/require_forward.go.tmpl @@ -0,0 +1,5 @@ +{{.CommentWithoutT "a"}} +func (a *Assertions) {{.DocInfo.Name}}({{.Params}}) { + if h, ok := a.t.(tHelper); ok { h.Helper() } + {{.DocInfo.Name}}(a.t, {{.ForwardedParams}}) +} diff --git a/vendor/github.com/stretchr/testify/require/requirements.go b/vendor/github.com/stretchr/testify/require/requirements.go new file mode 100644 index 0000000..6b85c5e --- /dev/null +++ b/vendor/github.com/stretchr/testify/require/requirements.go @@ -0,0 +1,29 @@ +package require + +// TestingT is an interface wrapper around *testing.T +type TestingT interface { + Errorf(format string, args ...interface{}) + FailNow() +} + +type tHelper interface { + Helper() +} + +// ComparisonAssertionFunc is a common function prototype when comparing two values. Can be useful +// for table driven tests. +type ComparisonAssertionFunc func(TestingT, interface{}, interface{}, ...interface{}) + +// ValueAssertionFunc is a common function prototype when validating a single value. Can be useful +// for table driven tests. +type ValueAssertionFunc func(TestingT, interface{}, ...interface{}) + +// BoolAssertionFunc is a common function prototype when validating a bool value. Can be useful +// for table driven tests. +type BoolAssertionFunc func(TestingT, bool, ...interface{}) + +// ErrorAssertionFunc is a common function prototype when validating an error value. Can be useful +// for table driven tests. +type ErrorAssertionFunc func(TestingT, error, ...interface{}) + +//go:generate go run ../_codegen/main.go -output-package=require -template=require.go.tmpl -include-format-funcs diff --git a/vendor/github.com/stretchr/testify/require/requirements_test.go b/vendor/github.com/stretchr/testify/require/requirements_test.go new file mode 100644 index 0000000..39467d9 --- /dev/null +++ b/vendor/github.com/stretchr/testify/require/requirements_test.go @@ -0,0 +1,566 @@ +package require + +import ( + "encoding/json" + "errors" + "testing" + "time" +) + +// AssertionTesterInterface defines an interface to be used for testing assertion methods +type AssertionTesterInterface interface { + TestMethod() +} + +// AssertionTesterConformingObject is an object that conforms to the AssertionTesterInterface interface +type AssertionTesterConformingObject struct { +} + +func (a *AssertionTesterConformingObject) TestMethod() { +} + +// AssertionTesterNonConformingObject is an object that does not conform to the AssertionTesterInterface interface +type AssertionTesterNonConformingObject struct { +} + +type MockT struct { + Failed bool +} + +func (t *MockT) FailNow() { + t.Failed = true +} + +func (t *MockT) Errorf(format string, args ...interface{}) { + _, _ = format, args +} + +func TestImplements(t *testing.T) { + + Implements(t, (*AssertionTesterInterface)(nil), new(AssertionTesterConformingObject)) + + mockT := new(MockT) + Implements(mockT, (*AssertionTesterInterface)(nil), new(AssertionTesterNonConformingObject)) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestIsType(t *testing.T) { + + IsType(t, new(AssertionTesterConformingObject), new(AssertionTesterConformingObject)) + + mockT := new(MockT) + IsType(mockT, new(AssertionTesterConformingObject), new(AssertionTesterNonConformingObject)) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestEqual(t *testing.T) { + + Equal(t, 1, 1) + + mockT := new(MockT) + Equal(mockT, 1, 2) + if !mockT.Failed { + t.Error("Check should fail") + } + +} + +func TestNotEqual(t *testing.T) { + + NotEqual(t, 1, 2) + mockT := new(MockT) + NotEqual(mockT, 2, 2) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestExactly(t *testing.T) { + + a := float32(1) + b := float32(1) + c := float64(1) + + Exactly(t, a, b) + + mockT := new(MockT) + Exactly(mockT, a, c) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestNotNil(t *testing.T) { + + NotNil(t, new(AssertionTesterConformingObject)) + + mockT := new(MockT) + NotNil(mockT, nil) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestNil(t *testing.T) { + + Nil(t, nil) + + mockT := new(MockT) + Nil(mockT, new(AssertionTesterConformingObject)) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestTrue(t *testing.T) { + + True(t, true) + + mockT := new(MockT) + True(mockT, false) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestFalse(t *testing.T) { + + False(t, false) + + mockT := new(MockT) + False(mockT, true) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestContains(t *testing.T) { + + Contains(t, "Hello World", "Hello") + + mockT := new(MockT) + Contains(mockT, "Hello World", "Salut") + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestNotContains(t *testing.T) { + + NotContains(t, "Hello World", "Hello!") + + mockT := new(MockT) + NotContains(mockT, "Hello World", "Hello") + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestPanics(t *testing.T) { + + Panics(t, func() { + panic("Panic!") + }) + + mockT := new(MockT) + Panics(mockT, func() {}) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestNotPanics(t *testing.T) { + + NotPanics(t, func() {}) + + mockT := new(MockT) + NotPanics(mockT, func() { + panic("Panic!") + }) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestNoError(t *testing.T) { + + NoError(t, nil) + + mockT := new(MockT) + NoError(mockT, errors.New("some error")) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestError(t *testing.T) { + + Error(t, errors.New("some error")) + + mockT := new(MockT) + Error(mockT, nil) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestEqualError(t *testing.T) { + + EqualError(t, errors.New("some error"), "some error") + + mockT := new(MockT) + EqualError(mockT, errors.New("some error"), "Not some error") + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestEmpty(t *testing.T) { + + Empty(t, "") + + mockT := new(MockT) + Empty(mockT, "x") + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestNotEmpty(t *testing.T) { + + NotEmpty(t, "x") + + mockT := new(MockT) + NotEmpty(mockT, "") + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestWithinDuration(t *testing.T) { + + a := time.Now() + b := a.Add(10 * time.Second) + + WithinDuration(t, a, b, 15*time.Second) + + mockT := new(MockT) + WithinDuration(mockT, a, b, 5*time.Second) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestInDelta(t *testing.T) { + + InDelta(t, 1.001, 1, 0.01) + + mockT := new(MockT) + InDelta(mockT, 1, 2, 0.5) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestZero(t *testing.T) { + + Zero(t, "") + + mockT := new(MockT) + Zero(mockT, "x") + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestNotZero(t *testing.T) { + + NotZero(t, "x") + + mockT := new(MockT) + NotZero(mockT, "") + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestJSONEq_EqualSONString(t *testing.T) { + mockT := new(MockT) + JSONEq(mockT, `{"hello": "world", "foo": "bar"}`, `{"hello": "world", "foo": "bar"}`) + if mockT.Failed { + t.Error("Check should pass") + } +} + +func TestJSONEq_EquivalentButNotEqual(t *testing.T) { + mockT := new(MockT) + JSONEq(mockT, `{"hello": "world", "foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) + if mockT.Failed { + t.Error("Check should pass") + } +} + +func TestJSONEq_HashOfArraysAndHashes(t *testing.T) { + mockT := new(MockT) + JSONEq(mockT, "{\r\n\t\"numeric\": 1.5,\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]],\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\"\r\n}", + "{\r\n\t\"numeric\": 1.5,\r\n\t\"hash\": {\"nested\": \"hash\", \"nested_slice\": [\"this\", \"is\", \"nested\"]},\r\n\t\"string\": \"foo\",\r\n\t\"array\": [{\"foo\": \"bar\"}, 1, \"string\", [\"nested\", \"array\", 5.5]]\r\n}") + if mockT.Failed { + t.Error("Check should pass") + } +} + +func TestJSONEq_Array(t *testing.T) { + mockT := new(MockT) + JSONEq(mockT, `["foo", {"hello": "world", "nested": "hash"}]`, `["foo", {"nested": "hash", "hello": "world"}]`) + if mockT.Failed { + t.Error("Check should pass") + } +} + +func TestJSONEq_HashAndArrayNotEquivalent(t *testing.T) { + mockT := new(MockT) + JSONEq(mockT, `["foo", {"hello": "world", "nested": "hash"}]`, `{"foo": "bar", {"nested": "hash", "hello": "world"}}`) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestJSONEq_HashesNotEquivalent(t *testing.T) { + mockT := new(MockT) + JSONEq(mockT, `{"foo": "bar"}`, `{"foo": "bar", "hello": "world"}`) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestJSONEq_ActualIsNotJSON(t *testing.T) { + mockT := new(MockT) + JSONEq(mockT, `{"foo": "bar"}`, "Not JSON") + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestJSONEq_ExpectedIsNotJSON(t *testing.T) { + mockT := new(MockT) + JSONEq(mockT, "Not JSON", `{"foo": "bar", "hello": "world"}`) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestJSONEq_ExpectedAndActualNotJSON(t *testing.T) { + mockT := new(MockT) + JSONEq(mockT, "Not JSON", "Not JSON") + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func TestJSONEq_ArraysOfDifferentOrder(t *testing.T) { + mockT := new(MockT) + JSONEq(mockT, `["foo", {"hello": "world", "nested": "hash"}]`, `[{ "hello": "world", "nested": "hash"}, "foo"]`) + if !mockT.Failed { + t.Error("Check should fail") + } +} + +func ExampleComparisonAssertionFunc() { + t := &testing.T{} // provided by test + + adder := func(x, y int) int { + return x + y + } + + type args struct { + x int + y int + } + + tests := []struct { + name string + args args + expect int + assertion ComparisonAssertionFunc + }{ + {"2+2=4", args{2, 2}, 4, Equal}, + {"2+2!=5", args{2, 2}, 5, NotEqual}, + {"2+3==5", args{2, 3}, 5, Exactly}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.assertion(t, tt.expect, adder(tt.args.x, tt.args.y)) + }) + } +} + +func TestComparisonAssertionFunc(t *testing.T) { + type iface interface { + Name() string + } + + tests := []struct { + name string + expect interface{} + got interface{} + assertion ComparisonAssertionFunc + }{ + {"implements", (*iface)(nil), t, Implements}, + {"isType", (*testing.T)(nil), t, IsType}, + {"equal", t, t, Equal}, + {"equalValues", t, t, EqualValues}, + {"exactly", t, t, Exactly}, + {"notEqual", t, nil, NotEqual}, + {"notContains", []int{1, 2, 3}, 4, NotContains}, + {"subset", []int{1, 2, 3, 4}, []int{2, 3}, Subset}, + {"notSubset", []int{1, 2, 3, 4}, []int{0, 3}, NotSubset}, + {"elementsMatch", []byte("abc"), []byte("bac"), ElementsMatch}, + {"regexp", "^t.*y$", "testify", Regexp}, + {"notRegexp", "^t.*y$", "Testify", NotRegexp}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.assertion(t, tt.expect, tt.got) + }) + } +} + +func ExampleValueAssertionFunc() { + t := &testing.T{} // provided by test + + dumbParse := func(input string) interface{} { + var x interface{} + json.Unmarshal([]byte(input), &x) + return x + } + + tests := []struct { + name string + arg string + assertion ValueAssertionFunc + }{ + {"true is not nil", "true", NotNil}, + {"empty string is nil", "", Nil}, + {"zero is not nil", "0", NotNil}, + {"zero is zero", "0", Zero}, + {"false is zero", "false", Zero}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.assertion(t, dumbParse(tt.arg)) + }) + } +} + +func TestValueAssertionFunc(t *testing.T) { + tests := []struct { + name string + value interface{} + assertion ValueAssertionFunc + }{ + {"notNil", true, NotNil}, + {"nil", nil, Nil}, + {"empty", []int{}, Empty}, + {"notEmpty", []int{1}, NotEmpty}, + {"zero", false, Zero}, + {"notZero", 42, NotZero}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.assertion(t, tt.value) + }) + } +} + +func ExampleBoolAssertionFunc() { + t := &testing.T{} // provided by test + + isOkay := func(x int) bool { + return x >= 42 + } + + tests := []struct { + name string + arg int + assertion BoolAssertionFunc + }{ + {"-1 is bad", -1, False}, + {"42 is good", 42, True}, + {"41 is bad", 41, False}, + {"45 is cool", 45, True}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.assertion(t, isOkay(tt.arg)) + }) + } +} + +func TestBoolAssertionFunc(t *testing.T) { + tests := []struct { + name string + value bool + assertion BoolAssertionFunc + }{ + {"true", true, True}, + {"false", false, False}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.assertion(t, tt.value) + }) + } +} + +func ExampleErrorAssertionFunc() { + t := &testing.T{} // provided by test + + dumbParseNum := func(input string, v interface{}) error { + return json.Unmarshal([]byte(input), v) + } + + tests := []struct { + name string + arg string + assertion ErrorAssertionFunc + }{ + {"1.2 is number", "1.2", NoError}, + {"1.2.3 not number", "1.2.3", Error}, + {"true is not number", "true", Error}, + {"3 is number", "3", NoError}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + var x float64 + tt.assertion(t, dumbParseNum(tt.arg, &x)) + }) + } +} + +func TestErrorAssertionFunc(t *testing.T) { + tests := []struct { + name string + err error + assertion ErrorAssertionFunc + }{ + {"noError", nil, NoError}, + {"error", errors.New("whoops"), Error}, + } + + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + tt.assertion(t, tt.err) + }) + } +} diff --git a/vendor/github.com/stretchr/testify/suite/doc.go b/vendor/github.com/stretchr/testify/suite/doc.go new file mode 100644 index 0000000..f91a245 --- /dev/null +++ b/vendor/github.com/stretchr/testify/suite/doc.go @@ -0,0 +1,65 @@ +// Package suite contains logic for creating testing suite structs +// and running the methods on those structs as tests. The most useful +// piece of this package is that you can create setup/teardown methods +// on your testing suites, which will run before/after the whole suite +// or individual tests (depending on which interface(s) you +// implement). +// +// A testing suite is usually built by first extending the built-in +// suite functionality from suite.Suite in testify. Alternatively, +// you could reproduce that logic on your own if you wanted (you +// just need to implement the TestingSuite interface from +// suite/interfaces.go). +// +// After that, you can implement any of the interfaces in +// suite/interfaces.go to add setup/teardown functionality to your +// suite, and add any methods that start with "Test" to add tests. +// Methods that do not match any suite interfaces and do not begin +// with "Test" will not be run by testify, and can safely be used as +// helper methods. +// +// Once you've built your testing suite, you need to run the suite +// (using suite.Run from testify) inside any function that matches the +// identity that "go test" is already looking for (i.e. +// func(*testing.T)). +// +// Regular expression to select test suites specified command-line +// argument "-run". Regular expression to select the methods +// of test suites specified command-line argument "-m". +// Suite object has assertion methods. +// +// A crude example: +// // Basic imports +// import ( +// "testing" +// "github.com/stretchr/testify/assert" +// "github.com/stretchr/testify/suite" +// ) +// +// // Define the suite, and absorb the built-in basic suite +// // functionality from testify - including a T() method which +// // returns the current testing context +// type ExampleTestSuite struct { +// suite.Suite +// VariableThatShouldStartAtFive int +// } +// +// // Make sure that VariableThatShouldStartAtFive is set to five +// // before each test +// func (suite *ExampleTestSuite) SetupTest() { +// suite.VariableThatShouldStartAtFive = 5 +// } +// +// // All methods that begin with "Test" are run as tests within a +// // suite. +// func (suite *ExampleTestSuite) TestExample() { +// assert.Equal(suite.T(), 5, suite.VariableThatShouldStartAtFive) +// suite.Equal(5, suite.VariableThatShouldStartAtFive) +// } +// +// // In order for 'go test' to run this suite, we need to create +// // a normal test function and pass our suite to suite.Run +// func TestExampleTestSuite(t *testing.T) { +// suite.Run(t, new(ExampleTestSuite)) +// } +package suite diff --git a/vendor/github.com/stretchr/testify/suite/interfaces.go b/vendor/github.com/stretchr/testify/suite/interfaces.go new file mode 100644 index 0000000..b37cb04 --- /dev/null +++ b/vendor/github.com/stretchr/testify/suite/interfaces.go @@ -0,0 +1,46 @@ +package suite + +import "testing" + +// TestingSuite can store and return the current *testing.T context +// generated by 'go test'. +type TestingSuite interface { + T() *testing.T + SetT(*testing.T) +} + +// SetupAllSuite has a SetupSuite method, which will run before the +// tests in the suite are run. +type SetupAllSuite interface { + SetupSuite() +} + +// SetupTestSuite has a SetupTest method, which will run before each +// test in the suite. +type SetupTestSuite interface { + SetupTest() +} + +// TearDownAllSuite has a TearDownSuite method, which will run after +// all the tests in the suite have been run. +type TearDownAllSuite interface { + TearDownSuite() +} + +// TearDownTestSuite has a TearDownTest method, which will run after +// each test in the suite. +type TearDownTestSuite interface { + TearDownTest() +} + +// BeforeTest has a function to be executed right before the test +// starts and receives the suite and test names as input +type BeforeTest interface { + BeforeTest(suiteName, testName string) +} + +// AfterTest has a function to be executed right after the test +// finishes and receives the suite and test names as input +type AfterTest interface { + AfterTest(suiteName, testName string) +} diff --git a/vendor/github.com/stretchr/testify/suite/suite.go b/vendor/github.com/stretchr/testify/suite/suite.go new file mode 100644 index 0000000..5cea8f8 --- /dev/null +++ b/vendor/github.com/stretchr/testify/suite/suite.go @@ -0,0 +1,160 @@ +package suite + +import ( + "flag" + "fmt" + "os" + "reflect" + "regexp" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +var allTestsFilter = func(_, _ string) (bool, error) { return true, nil } +var matchMethod = flag.String("testify.m", "", "regular expression to select tests of the testify suite to run") + +// Suite is a basic testing suite with methods for storing and +// retrieving the current *testing.T context. +type Suite struct { + *assert.Assertions + require *require.Assertions + t *testing.T +} + +// T retrieves the current *testing.T context. +func (suite *Suite) T() *testing.T { + return suite.t +} + +// SetT sets the current *testing.T context. +func (suite *Suite) SetT(t *testing.T) { + suite.t = t + suite.Assertions = assert.New(t) + suite.require = require.New(t) +} + +// Require returns a require context for suite. +func (suite *Suite) Require() *require.Assertions { + if suite.require == nil { + suite.require = require.New(suite.T()) + } + return suite.require +} + +// Assert returns an assert context for suite. Normally, you can call +// `suite.NoError(expected, actual)`, but for situations where the embedded +// methods are overridden (for example, you might want to override +// assert.Assertions with require.Assertions), this method is provided so you +// can call `suite.Assert().NoError()`. +func (suite *Suite) Assert() *assert.Assertions { + if suite.Assertions == nil { + suite.Assertions = assert.New(suite.T()) + } + return suite.Assertions +} + +func failOnPanic(t *testing.T) { + r := recover() + if r != nil { + t.Errorf("test panicked: %v", r) + t.FailNow() + } +} + +// Run provides suite functionality around golang subtests. It should be +// called in place of t.Run(name, func(t *testing.T)) in test suite code. +// The passed-in func will be executed as a subtest with a fresh instance of t. +// Provides compatibility with go test pkg -run TestSuite/TestName/SubTestName. +func (suite *Suite) Run(name string, subtest func()) bool { + oldT := suite.T() + defer suite.SetT(oldT) + return oldT.Run(name, func(t *testing.T) { + suite.SetT(t) + subtest() + }) +} + +// Run takes a testing suite and runs all of the tests attached +// to it. +func Run(t *testing.T, suite TestingSuite) { + suite.SetT(t) + defer failOnPanic(t) + + if setupAllSuite, ok := suite.(SetupAllSuite); ok { + setupAllSuite.SetupSuite() + } + defer func() { + if tearDownAllSuite, ok := suite.(TearDownAllSuite); ok { + tearDownAllSuite.TearDownSuite() + } + }() + + methodFinder := reflect.TypeOf(suite) + tests := []testing.InternalTest{} + for index := 0; index < methodFinder.NumMethod(); index++ { + method := methodFinder.Method(index) + ok, err := methodFilter(method.Name) + if err != nil { + fmt.Fprintf(os.Stderr, "testify: invalid regexp for -m: %s\n", err) + os.Exit(1) + } + if ok { + test := testing.InternalTest{ + Name: method.Name, + F: func(t *testing.T) { + parentT := suite.T() + suite.SetT(t) + defer failOnPanic(t) + + if setupTestSuite, ok := suite.(SetupTestSuite); ok { + setupTestSuite.SetupTest() + } + if beforeTestSuite, ok := suite.(BeforeTest); ok { + beforeTestSuite.BeforeTest(methodFinder.Elem().Name(), method.Name) + } + defer func() { + if afterTestSuite, ok := suite.(AfterTest); ok { + afterTestSuite.AfterTest(methodFinder.Elem().Name(), method.Name) + } + if tearDownTestSuite, ok := suite.(TearDownTestSuite); ok { + tearDownTestSuite.TearDownTest() + } + suite.SetT(parentT) + }() + method.Func.Call([]reflect.Value{reflect.ValueOf(suite)}) + }, + } + tests = append(tests, test) + } + } + runTests(t, tests) +} + +func runTests(t testing.TB, tests []testing.InternalTest) { + r, ok := t.(runner) + if !ok { // backwards compatibility with Go 1.6 and below + if !testing.RunTests(allTestsFilter, tests) { + t.Fail() + } + return + } + + for _, test := range tests { + r.Run(test.Name, test.F) + } +} + +// Filtering method according to set regular expression +// specified command-line argument -m +func methodFilter(name string) (bool, error) { + if ok, _ := regexp.MatchString("^Test", name); !ok { + return false, nil + } + return regexp.MatchString(*matchMethod, name) +} + +type runner interface { + Run(name string, f func(t *testing.T)) bool +} diff --git a/vendor/github.com/stretchr/testify/suite/suite_test.go b/vendor/github.com/stretchr/testify/suite/suite_test.go new file mode 100644 index 0000000..6dfba08 --- /dev/null +++ b/vendor/github.com/stretchr/testify/suite/suite_test.go @@ -0,0 +1,412 @@ +package suite + +import ( + "errors" + "io/ioutil" + "os" + "testing" + "time" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +// SuiteRequireTwice is intended to test the usage of suite.Require in two +// different tests +type SuiteRequireTwice struct{ Suite } + +// TestSuiteRequireTwice checks for regressions of issue #149 where +// suite.requirements was not initialised in suite.SetT() +// A regression would result on these tests panicking rather than failing. +func TestSuiteRequireTwice(t *testing.T) { + ok := testing.RunTests( + allTestsFilter, + []testing.InternalTest{{ + Name: "TestSuiteRequireTwice", + F: func(t *testing.T) { + suite := new(SuiteRequireTwice) + Run(t, suite) + }, + }}, + ) + assert.Equal(t, false, ok) +} + +func (s *SuiteRequireTwice) TestRequireOne() { + r := s.Require() + r.Equal(1, 2) +} + +func (s *SuiteRequireTwice) TestRequireTwo() { + r := s.Require() + r.Equal(1, 2) +} + +type panickingSuite struct { + Suite + panicInSetupSuite bool + panicInSetupTest bool + panicInBeforeTest bool + panicInTest bool + panicInAfterTest bool + panicInTearDownTest bool + panicInTearDownSuite bool +} + +func (s *panickingSuite) SetupSuite() { + if s.panicInSetupSuite { + panic("oops in setup suite") + } +} + +func (s *panickingSuite) SetupTest() { + if s.panicInSetupTest { + panic("oops in setup test") + } +} + +func (s *panickingSuite) BeforeTest(_, _ string) { + if s.panicInBeforeTest { + panic("oops in before test") + } +} + +func (s *panickingSuite) Test() { + if s.panicInTest { + panic("oops in test") + } +} + +func (s *panickingSuite) AfterTest(_, _ string) { + if s.panicInAfterTest { + panic("oops in after test") + } +} + +func (s *panickingSuite) TearDownTest() { + if s.panicInTearDownTest { + panic("oops in tear down test") + } +} + +func (s *panickingSuite) TearDownSuite() { + if s.panicInTearDownSuite { + panic("oops in tear down suite") + } +} + +func TestSuiteRecoverPanic(t *testing.T) { + ok := true + panickingTests := []testing.InternalTest{ + { + Name: "TestPanicInSetupSuite", + F: func(t *testing.T) { Run(t, &panickingSuite{panicInSetupSuite: true}) }, + }, + { + Name: "TestPanicInSetupTest", + F: func(t *testing.T) { Run(t, &panickingSuite{panicInSetupTest: true}) }, + }, + { + Name: "TestPanicInBeforeTest", + F: func(t *testing.T) { Run(t, &panickingSuite{panicInBeforeTest: true}) }, + }, + { + Name: "TestPanicInTest", + F: func(t *testing.T) { Run(t, &panickingSuite{panicInTest: true}) }, + }, + { + Name: "TestPanicInAfterTest", + F: func(t *testing.T) { Run(t, &panickingSuite{panicInAfterTest: true}) }, + }, + { + Name: "TestPanicInTearDownTest", + F: func(t *testing.T) { Run(t, &panickingSuite{panicInTearDownTest: true}) }, + }, + { + Name: "TestPanicInTearDownSuite", + F: func(t *testing.T) { Run(t, &panickingSuite{panicInTearDownSuite: true}) }, + }, + } + + require.NotPanics(t, func() { + ok = testing.RunTests(allTestsFilter, panickingTests) + }) + + assert.False(t, ok) +} + +// This suite is intended to store values to make sure that only +// testing-suite-related methods are run. It's also a fully +// functional example of a testing suite, using setup/teardown methods +// and a helper method that is ignored by testify. To make this look +// more like a real world example, all tests in the suite perform some +// type of assertion. +type SuiteTester struct { + // Include our basic suite logic. + Suite + + // Keep counts of how many times each method is run. + SetupSuiteRunCount int + TearDownSuiteRunCount int + SetupTestRunCount int + TearDownTestRunCount int + TestOneRunCount int + TestTwoRunCount int + TestSubtestRunCount int + NonTestMethodRunCount int + + SuiteNameBefore []string + TestNameBefore []string + + SuiteNameAfter []string + TestNameAfter []string + + TimeBefore []time.Time + TimeAfter []time.Time +} + +type SuiteSkipTester struct { + // Include our basic suite logic. + Suite + + // Keep counts of how many times each method is run. + SetupSuiteRunCount int + TearDownSuiteRunCount int +} + +// The SetupSuite method will be run by testify once, at the very +// start of the testing suite, before any tests are run. +func (suite *SuiteTester) SetupSuite() { + suite.SetupSuiteRunCount++ +} + +func (suite *SuiteTester) BeforeTest(suiteName, testName string) { + suite.SuiteNameBefore = append(suite.SuiteNameBefore, suiteName) + suite.TestNameBefore = append(suite.TestNameBefore, testName) + suite.TimeBefore = append(suite.TimeBefore, time.Now()) +} + +func (suite *SuiteTester) AfterTest(suiteName, testName string) { + suite.SuiteNameAfter = append(suite.SuiteNameAfter, suiteName) + suite.TestNameAfter = append(suite.TestNameAfter, testName) + suite.TimeAfter = append(suite.TimeAfter, time.Now()) +} + +func (suite *SuiteSkipTester) SetupSuite() { + suite.SetupSuiteRunCount++ + suite.T().Skip() +} + +// The TearDownSuite method will be run by testify once, at the very +// end of the testing suite, after all tests have been run. +func (suite *SuiteTester) TearDownSuite() { + suite.TearDownSuiteRunCount++ +} + +func (suite *SuiteSkipTester) TearDownSuite() { + suite.TearDownSuiteRunCount++ +} + +// The SetupTest method will be run before every test in the suite. +func (suite *SuiteTester) SetupTest() { + suite.SetupTestRunCount++ +} + +// The TearDownTest method will be run after every test in the suite. +func (suite *SuiteTester) TearDownTest() { + suite.TearDownTestRunCount++ +} + +// Every method in a testing suite that begins with "Test" will be run +// as a test. TestOne is an example of a test. For the purposes of +// this example, we've included assertions in the tests, since most +// tests will issue assertions. +func (suite *SuiteTester) TestOne() { + beforeCount := suite.TestOneRunCount + suite.TestOneRunCount++ + assert.Equal(suite.T(), suite.TestOneRunCount, beforeCount+1) + suite.Equal(suite.TestOneRunCount, beforeCount+1) +} + +// TestTwo is another example of a test. +func (suite *SuiteTester) TestTwo() { + beforeCount := suite.TestTwoRunCount + suite.TestTwoRunCount++ + assert.NotEqual(suite.T(), suite.TestTwoRunCount, beforeCount) + suite.NotEqual(suite.TestTwoRunCount, beforeCount) +} + +func (suite *SuiteTester) TestSkip() { + suite.T().Skip() +} + +// NonTestMethod does not begin with "Test", so it will not be run by +// testify as a test in the suite. This is useful for creating helper +// methods for your tests. +func (suite *SuiteTester) NonTestMethod() { + suite.NonTestMethodRunCount++ +} + +func (suite *SuiteTester) TestSubtest() { + suite.TestSubtestRunCount++ + + for _, t := range []struct { + testName string + }{ + {"first"}, + {"second"}, + } { + suiteT := suite.T() + suite.Run(t.testName, func() { + // We should get a different *testing.T for subtests, so that + // go test recognizes them as proper subtests for output formatting + // and running individual subtests + subTestT := suite.T() + suite.NotEqual(subTestT, suiteT) + }) + suite.Equal(suiteT, suite.T()) + } +} + +// TestRunSuite will be run by the 'go test' command, so within it, we +// can run our suite using the Run(*testing.T, TestingSuite) function. +func TestRunSuite(t *testing.T) { + suiteTester := new(SuiteTester) + Run(t, suiteTester) + + // Normally, the test would end here. The following are simply + // some assertions to ensure that the Run function is working as + // intended - they are not part of the example. + + // The suite was only run once, so the SetupSuite and TearDownSuite + // methods should have each been run only once. + assert.Equal(t, suiteTester.SetupSuiteRunCount, 1) + assert.Equal(t, suiteTester.TearDownSuiteRunCount, 1) + + assert.Equal(t, len(suiteTester.SuiteNameAfter), 4) + assert.Equal(t, len(suiteTester.SuiteNameBefore), 4) + assert.Equal(t, len(suiteTester.TestNameAfter), 4) + assert.Equal(t, len(suiteTester.TestNameBefore), 4) + + assert.Contains(t, suiteTester.TestNameAfter, "TestOne") + assert.Contains(t, suiteTester.TestNameAfter, "TestTwo") + assert.Contains(t, suiteTester.TestNameAfter, "TestSkip") + assert.Contains(t, suiteTester.TestNameAfter, "TestSubtest") + + assert.Contains(t, suiteTester.TestNameBefore, "TestOne") + assert.Contains(t, suiteTester.TestNameBefore, "TestTwo") + assert.Contains(t, suiteTester.TestNameBefore, "TestSkip") + assert.Contains(t, suiteTester.TestNameBefore, "TestSubtest") + + for _, suiteName := range suiteTester.SuiteNameAfter { + assert.Equal(t, "SuiteTester", suiteName) + } + + for _, suiteName := range suiteTester.SuiteNameBefore { + assert.Equal(t, "SuiteTester", suiteName) + } + + for _, when := range suiteTester.TimeAfter { + assert.False(t, when.IsZero()) + } + + for _, when := range suiteTester.TimeBefore { + assert.False(t, when.IsZero()) + } + + // There are four test methods (TestOne, TestTwo, TestSkip, and TestSubtest), so + // the SetupTest and TearDownTest methods (which should be run once for + // each test) should have been run four times. + assert.Equal(t, suiteTester.SetupTestRunCount, 4) + assert.Equal(t, suiteTester.TearDownTestRunCount, 4) + + // Each test should have been run once. + assert.Equal(t, suiteTester.TestOneRunCount, 1) + assert.Equal(t, suiteTester.TestTwoRunCount, 1) + assert.Equal(t, suiteTester.TestSubtestRunCount, 1) + + // Methods that don't match the test method identifier shouldn't + // have been run at all. + assert.Equal(t, suiteTester.NonTestMethodRunCount, 0) + + suiteSkipTester := new(SuiteSkipTester) + Run(t, suiteSkipTester) + + // The suite was only run once, so the SetupSuite and TearDownSuite + // methods should have each been run only once, even though SetupSuite + // called Skip() + assert.Equal(t, suiteSkipTester.SetupSuiteRunCount, 1) + assert.Equal(t, suiteSkipTester.TearDownSuiteRunCount, 1) + +} + +func TestSuiteGetters(t *testing.T) { + suite := new(SuiteTester) + suite.SetT(t) + assert.NotNil(t, suite.Assert()) + assert.Equal(t, suite.Assertions, suite.Assert()) + assert.NotNil(t, suite.Require()) + assert.Equal(t, suite.require, suite.Require()) +} + +type SuiteLoggingTester struct { + Suite +} + +func (s *SuiteLoggingTester) TestLoggingPass() { + s.T().Log("TESTLOGPASS") +} + +func (s *SuiteLoggingTester) TestLoggingFail() { + s.T().Log("TESTLOGFAIL") + assert.NotNil(s.T(), nil) // expected to fail +} + +type StdoutCapture struct { + oldStdout *os.File + readPipe *os.File +} + +func (sc *StdoutCapture) StartCapture() { + sc.oldStdout = os.Stdout + sc.readPipe, os.Stdout, _ = os.Pipe() +} + +func (sc *StdoutCapture) StopCapture() (string, error) { + if sc.oldStdout == nil || sc.readPipe == nil { + return "", errors.New("StartCapture not called before StopCapture") + } + os.Stdout.Close() + os.Stdout = sc.oldStdout + bytes, err := ioutil.ReadAll(sc.readPipe) + if err != nil { + return "", err + } + return string(bytes), nil +} + +func TestSuiteLogging(t *testing.T) { + suiteLoggingTester := new(SuiteLoggingTester) + capture := StdoutCapture{} + internalTest := testing.InternalTest{ + Name: "SomeTest", + F: func(subT *testing.T) { + Run(subT, suiteLoggingTester) + }, + } + capture.StartCapture() + testing.RunTests(allTestsFilter, []testing.InternalTest{internalTest}) + output, err := capture.StopCapture() + require.NoError(t, err, "Got an error trying to capture stdout and stderr!") + require.NotEmpty(t, output, "output content must not be empty") + + // Failed tests' output is always printed + assert.Contains(t, output, "TESTLOGFAIL") + + if testing.Verbose() { + // In verbose mode, output from successful tests is also printed + assert.Contains(t, output, "TESTLOGPASS") + } else { + assert.NotContains(t, output, "TESTLOGPASS") + } +} diff --git a/vendor/vendor.json b/vendor/vendor.json deleted file mode 100644 index 812848e..0000000 --- a/vendor/vendor.json +++ /dev/null @@ -1,31 +0,0 @@ -{ - "comment": "", - "ignore": "test", - "package": [ - { - "checksumSHA1": "hcwvwW3c+NPM+g4nyv1prqgNrC4=", - "path": "git.apache.org/thrift.git/lib/go/thrift", - "revision": "2007783e874d524a46b818598a45078448ecc53e", - "revisionTime": "2016-08-09T19:04:53Z" - }, - { - "checksumSHA1": "GcaTbmmzSGqTb2X6qnNtmDyew1Q=", - "path": "github.com/pkg/errors", - "revision": "a2d6902c6d2a2f194eb3fb474981ab7867c81505", - "revisionTime": "2016-06-27T22:23:52Z" - }, - { - "checksumSHA1": "5SYLEhADhdBVZAGPVHWggQl7H8k=", - "path": "github.com/samuel/go-zookeeper/zk", - "revision": "1d7be4effb13d2d908342d349d71a284a7542693", - "revisionTime": "2016-10-28T23:23:40Z" - }, - { - "checksumSHA1": "iydUphwYqZRq3WhstEdGsbvBAKs=", - "path": "github.com/stretchr/testify/assert", - "revision": "d77da356e56a7428ad25149ca77381849a6a5232", - "revisionTime": "2016-06-15T09:26:46Z" - } - ], - "rootPath": "github.com/rdelval/gorealis" -} diff --git a/zk.go b/zk.go index a301fcd..4bc9ede 100644 --- a/zk.go +++ b/zk.go @@ -16,80 +16,167 @@ package realis import ( "encoding/json" - "fmt" - "github.com/pkg/errors" - "github.com/samuel/go-zookeeper/zk" "strconv" "strings" "time" + + "github.com/pkg/errors" + "github.com/samuel/go-zookeeper/zk" ) -type Endpoint struct { +type endpoint struct { Host string `json:"host"` Port int `json:"port"` } -type ServiceInstance struct { - Service Endpoint `json:"serviceEndpoint"` - AdditionalEndpoints map[string]Endpoint `json:"additionalEndpoints"` +type serviceInstance struct { + Service endpoint `json:"serviceEndpoint"` + AdditionalEndpoints map[string]endpoint `json:"additionalEndpoints"` Status string `json:"status"` } -type NoopLogger struct{} - -func (NoopLogger) Printf(format string, a ...interface{}) { +type zkConfig struct { + endpoints []string + path string + backoff Backoff + timeout time.Duration + logger logger } -// Loads leader from ZK endpoint. +// ZKOpt - Configuration option for the Zookeeper client used. +type ZKOpt func(z *zkConfig) + +// ZKEndpoints - Endpoints on which a Zookeeper instance is running to be used by the client. +func ZKEndpoints(endpoints ...string) ZKOpt { + return func(z *zkConfig) { + z.endpoints = endpoints + } +} + +// ZKPath - Path to look for information in when connected to Zookeeper. +func ZKPath(path string) ZKOpt { + return func(z *zkConfig) { + z.path = path + } +} + +// ZKBackoff - Configuration for Retry mechanism used when connecting to Zookeeper. +// TODO(rdelvalle): Determine if this is really necessary as the ZK library already has a retry built in. +func ZKBackoff(b Backoff) ZKOpt { + return func(z *zkConfig) { + z.backoff = b + } +} + +// ZKTimeout - How long to wait on a response from the Zookeeper instance before considering it dead. +func ZKTimeout(d time.Duration) ZKOpt { + return func(z *zkConfig) { + z.timeout = d + } +} + +// ZKLogger - Attach a logger to the Zookeeper client in order to debug issues. +func ZKLogger(l logger) ZKOpt { + return func(z *zkConfig) { + z.logger = l + } +} + +// LeaderFromZK - Retrieves current Aurora leader from ZK. func LeaderFromZK(cluster Cluster) (string, error) { - - endpoints := strings.Split(cluster.ZK, ",") - - //TODO (rdelvalle): When enabling debugging, change logger here - c, _, err := zk.Connect(endpoints, time.Second*10, func(c *zk.Conn) { c.SetLogger(NoopLogger{}) }) - if err != nil { - return "", errors.Wrap(err, "Failed to connect to Zookeeper at "+cluster.ZK) - } - - defer c.Close() - - children, _, _, err := c.ChildrenW(cluster.SchedZKPath) - if err != nil { - return "", errors.Wrapf(err, "Path %s doesn't exist on Zookeeper ", cluster.SchedZKPath) - } - - serviceInst := new(ServiceInstance) - - for _, child := range children { - - // Only the leader will start with member_ - if strings.HasPrefix(child, "member_") { - - data, _, err := c.Get(cluster.SchedZKPath + "/" + child) - if err != nil { - return "", errors.Wrap(err, "Error fetching contents of leader") - } - - err = json.Unmarshal([]byte(data), serviceInst) - if err != nil { - return "", errors.Wrap(err, "Unable to unmarshall contents of leader") - } - - // Should only be one endpoint - if len(serviceInst.AdditionalEndpoints) > 1 { - fmt.Errorf("Ambiguous end points schemes") - } - - var scheme, host, port string - for k, v := range serviceInst.AdditionalEndpoints { - scheme = k - host = v.Host - port = strconv.Itoa(v.Port) - } - - return scheme + "://" + host + ":" + port, nil - } - } - - return "", errors.New("No leader found") + return LeaderFromZKOpts(ZKEndpoints(strings.Split(cluster.ZK, ",")...), ZKPath(cluster.SchedZKPath)) +} + +// LeaderFromZKOpts - Retrieves current Aurora leader from ZK with a custom configuration. +func LeaderFromZKOpts(options ...ZKOpt) (string, error) { + var leaderURL string + + // Load the default configuration for Zookeeper followed by overriding values with those provided by the caller. + config := &zkConfig{backoff: defaultBackoff, timeout: time.Second * 10, logger: NoopLogger{}} + for _, opt := range options { + opt(config) + } + + if len(config.endpoints) == 0 { + return "", errors.New("no Zookeeper endpoints supplied") + } + + if config.path == "" { + return "", errors.New("no Zookeeper path supplied") + } + + // Create a closure that allows us to use the ExponentialBackoff function. + retryErr := ExponentialBackoff(config.backoff, config.logger, func() (bool, error) { + + c, _, err := zk.Connect(config.endpoints, config.timeout, func(c *zk.Conn) { c.SetLogger(config.logger) }) + if err != nil { + return false, NewTemporaryError(errors.Wrap(err, "failed to connect to Zookeeper")) + } + + defer c.Close() + + // Open up descriptor for the ZK path given + children, _, _, err := c.ChildrenW(config.path) + if err != nil { + + // Sentinel error check as there is no other way to check. + if err == zk.ErrInvalidPath { + return false, errors.Wrapf(err, "path %s is an invalid Zookeeper path", config.path) + } + + return false, NewTemporaryError(errors.Wrapf(err, "path %s doesn't exist on Zookeeper ", config.path)) + } + + // Search for the leader through all the children in the given path + for _, child := range children { + + // Only the leader will start with member_ + if strings.HasPrefix(child, "member_") { + + childPath := config.path + "/" + child + data, _, err := c.Get(childPath) + if err != nil { + if err == zk.ErrInvalidPath { + return false, errors.Wrapf(err, "path %s is an invalid Zookeeper path", childPath) + } + + return false, NewTemporaryError(errors.Wrap(err, "unable to fetch contents of leader")) + } + + var serviceInst serviceInstance + err = json.Unmarshal([]byte(data), &serviceInst) + if err != nil { + return false, NewTemporaryError(errors.Wrap(err, "unable to unmarshal contents of leader")) + } + + // Should only be one endpoint. + // This should never be encountered as it would indicate Aurora + // writing bad info into Zookeeper but is kept here as a safety net. + if len(serviceInst.AdditionalEndpoints) > 1 { + return false, + NewTemporaryError(errors.New("ambiguous endpoints in json blob, Aurora wrote bad info to ZK")) + } + + var scheme, host, port string + for k, v := range serviceInst.AdditionalEndpoints { + scheme = k + host = v.Host + port = strconv.Itoa(v.Port) + } + + leaderURL = scheme + "://" + host + ":" + port + return true, nil + } + } + + // Leader data might not be available yet, try to fetch again. + return false, NewTemporaryError(errors.New("no leader found")) + }) + + if retryErr != nil { + config.logger.Printf("failed to determine leader after %v attempts", config.backoff.Steps) + return "", retryErr + } + + return leaderURL, nil } diff --git a/zk_test.go b/zk_test.go new file mode 100644 index 0000000..b4e5d22 --- /dev/null +++ b/zk_test.go @@ -0,0 +1,70 @@ +/** + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package realis_test + +import ( + "log" + "os" + "testing" + "time" + + realis "github.com/paypal/gorealis" + "github.com/stretchr/testify/assert" +) + +var backoff = realis.Backoff{ // Reduce penalties for this test to make it quick + Steps: 5, + Duration: 1 * time.Second, + Factor: 1.0, + Jitter: 0.1, +} + +// Test for behavior when no endpoints are given to the ZK leader finding function. +func TestZKNoEndpoints(t *testing.T) { + _, err := realis.LeaderFromZKOpts() + + assert.Error(t, err) +} + +// Test for behavior when no path is given to the ZK leader finding function. +func TestZKNoPath(t *testing.T) { + _, err := realis.LeaderFromZKOpts(realis.ZKEndpoints("127.0.0.1:2181")) + + assert.Error(t, err) +} + +// Test for behavior when a valid but non-existent path is given to the ZK leader finding function. +func TestZKPathDoesntExist(t *testing.T) { + _, err := realis.LeaderFromZKOpts(realis.ZKEndpoints("127.0.0.1:2181"), + realis.ZKPath("/somepath"), + realis.ZKBackoff(backoff), + realis.ZKLogger(log.New(os.Stdout, "realis-debug: ", log.Ldate))) + + assert.True(t, realis.IsTimeout(err), "a non-existent path should result in a timeout behaving error") + + retryErr := realis.ToRetryCount(err) + assert.NotNil(t, retryErr, "conversion to retry error failed") + assert.Equal(t, backoff.Steps, retryErr.RetryCount(), "retry count is off") +} + +// Test for behavior when an invalid Zookeeper path is passed. Should fail right away. +func TestZKBadPath(t *testing.T) { + _, err := realis.LeaderFromZKOpts(realis.ZKEndpoints("127.0.0.1:2181"), + realis.ZKPath("invalidpath"), + realis.ZKBackoff(backoff), + realis.ZKLogger(log.New(os.Stdout, "realis-debug: ", log.Ldate))) + + assert.False(t, realis.IsTimeout(err), "a bad path should result in a NON-timeout behaving error") +}