Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reimplement influx backup using new APIs #116

Merged
merged 6 commits into from
Jun 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions api/client.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions api/contract/cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,12 @@ components:
$ref: "./openapi/src/common/schemas/WritePrecision.yml"
LineProtocolError:
$ref: "./openapi/src/common/schemas/LineProtocolError.yml"
LineProtocolErrorCode:
$ref: "./openapi/src/common/schemas/LineProtocolErrorCode.yml"
LineProtocolLengthError:
$ref: "./openapi/src/common/schemas/LineProtocolLengthError.yml"
LineProtocolLengthErrorCode:
$ref: "./openapi/src/common/schemas/LineProtocolLengthErrorCode.yml"
SchemaType:
$ref: "./openapi/src/common/schemas/SchemaType.yml"
ColumnDataType:
Expand Down
46 changes: 46 additions & 0 deletions api/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ import (
"strings"
)

type ApiError interface {
error
ErrorCode() ErrorCode
}

// Extensions to let our API error types be used as "standard" errors.

func (o *Error) Error() string {
Expand All @@ -22,6 +27,10 @@ func (o *Error) Error() string {
return fmt.Sprintf("<%s>", o.Code)
}

func (o *Error) ErrorCode() ErrorCode {
return o.Code
}

func (o *HealthCheck) Error() string {
if o.Status == HEALTHCHECKSTATUS_PASS {
// Make sure we aren't misusing HealthCheck responses.
Expand All @@ -36,10 +45,47 @@ func (o *HealthCheck) Error() string {
return fmt.Sprintf("health check failed: %s", message)
}

func (o *HealthCheck) ErrorCode() ErrorCode {
if o.Status == HEALTHCHECKSTATUS_PASS {
// Make sure we aren't misusing HealthCheck responses.
panic("successful healthcheck used as an error!")
}

return ERRORCODE_INTERNAL_ERROR
}

func (o *LineProtocolError) Error() string {
return o.Message
}

func (o *LineProtocolError) ErrorCode() ErrorCode {
switch o.Code {
case LINEPROTOCOLERRORCODE_CONFLICT:
return ERRORCODE_CONFLICT
case LINEPROTOCOLERRORCODE_EMPTY_VALUE:
return ERRORCODE_EMPTY_VALUE
case LINEPROTOCOLERRORCODE_NOT_FOUND:
return ERRORCODE_NOT_FOUND
case LINEPROTOCOLERRORCODE_UNAVAILABLE:
return ERRORCODE_UNAVAILABLE
case LINEPROTOCOLERRORCODE_INTERNAL_ERROR:
return ERRORCODE_INTERNAL_ERROR
case LINEPROTOCOLERRORCODE_INVALID:
fallthrough
default:
return ERRORCODE_INVALID
}
}

func (o *LineProtocolLengthError) Error() string {
return o.Message
}

func (o *LineProtocolLengthError) ErrorCode() ErrorCode {
switch o.Code {
case LINEPROTOCOLLENGTHERRORCODE_INVALID:
fallthrough
default:
return ERRORCODE_INVALID
}
}
13 changes: 6 additions & 7 deletions api/model_line_protocol_error.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

87 changes: 87 additions & 0 deletions api/model_line_protocol_error_code.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 6 additions & 7 deletions api/model_line_protocol_length_error.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

82 changes: 82 additions & 0 deletions api/model_line_protocol_length_error_code.gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading