mirror of
https://github.com/bloomberg/goldpinger.git
synced 2026-02-14 18:09:50 +00:00
Make it return 418 on cluster health problem
Signed-off-by: Mikolaj Pawlikowski <mikolaj@pawlikowski.pl>
This commit is contained in:
@@ -29,8 +29,8 @@ func (o *ClusterHealthReader) ReadResponse(response runtime.ClientResponse, cons
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
case 503:
|
||||
result := NewClusterHealthServiceUnavailable()
|
||||
case 418:
|
||||
result := NewClusterHealthIMATeapot()
|
||||
if err := result.readResponse(response, consumer, o.formats); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -72,27 +72,27 @@ func (o *ClusterHealthOK) readResponse(response runtime.ClientResponse, consumer
|
||||
return nil
|
||||
}
|
||||
|
||||
// NewClusterHealthServiceUnavailable creates a ClusterHealthServiceUnavailable with default headers values
|
||||
func NewClusterHealthServiceUnavailable() *ClusterHealthServiceUnavailable {
|
||||
return &ClusterHealthServiceUnavailable{}
|
||||
// NewClusterHealthIMATeapot creates a ClusterHealthIMATeapot with default headers values
|
||||
func NewClusterHealthIMATeapot() *ClusterHealthIMATeapot {
|
||||
return &ClusterHealthIMATeapot{}
|
||||
}
|
||||
|
||||
/* ClusterHealthServiceUnavailable describes a response with status code 503, with default header values.
|
||||
/* ClusterHealthIMATeapot describes a response with status code 418, with default header values.
|
||||
|
||||
Unhealthy cluster
|
||||
*/
|
||||
type ClusterHealthServiceUnavailable struct {
|
||||
type ClusterHealthIMATeapot struct {
|
||||
Payload *models.ClusterHealthResults
|
||||
}
|
||||
|
||||
func (o *ClusterHealthServiceUnavailable) Error() string {
|
||||
return fmt.Sprintf("[GET /cluster_health][%d] clusterHealthServiceUnavailable %+v", 503, o.Payload)
|
||||
func (o *ClusterHealthIMATeapot) Error() string {
|
||||
return fmt.Sprintf("[GET /cluster_health][%d] clusterHealthIMATeapot %+v", 418, o.Payload)
|
||||
}
|
||||
func (o *ClusterHealthServiceUnavailable) GetPayload() *models.ClusterHealthResults {
|
||||
func (o *ClusterHealthIMATeapot) GetPayload() *models.ClusterHealthResults {
|
||||
return o.Payload
|
||||
}
|
||||
|
||||
func (o *ClusterHealthServiceUnavailable) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
func (o *ClusterHealthIMATeapot) readResponse(response runtime.ClientResponse, consumer runtime.Consumer, formats strfmt.Registry) error {
|
||||
|
||||
o.Payload = new(models.ClusterHealthResults)
|
||||
|
||||
|
||||
@@ -108,7 +108,7 @@ func configureAPI(api *operations.GoldpingerAPI) http.Handler {
|
||||
if payload.OK {
|
||||
return operations.NewClusterHealthOK().WithPayload(payload)
|
||||
} else {
|
||||
return operations.NewClusterHealthServiceUnavailable().WithPayload(payload)
|
||||
return operations.NewClusterHealthIMATeapot().WithPayload(payload)
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ func init() {
|
||||
"$ref": "#/definitions/ClusterHealthResults"
|
||||
}
|
||||
},
|
||||
"503": {
|
||||
"418": {
|
||||
"description": "Unhealthy cluster",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ClusterHealthResults"
|
||||
@@ -400,7 +400,7 @@ func init() {
|
||||
"$ref": "#/definitions/ClusterHealthResults"
|
||||
}
|
||||
},
|
||||
"503": {
|
||||
"418": {
|
||||
"description": "Unhealthy cluster",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ClusterHealthResults"
|
||||
|
||||
@@ -57,14 +57,14 @@ func (o *ClusterHealthOK) WriteResponse(rw http.ResponseWriter, producer runtime
|
||||
}
|
||||
}
|
||||
|
||||
// ClusterHealthServiceUnavailableCode is the HTTP code returned for type ClusterHealthServiceUnavailable
|
||||
const ClusterHealthServiceUnavailableCode int = 503
|
||||
// ClusterHealthIMATeapotCode is the HTTP code returned for type ClusterHealthIMATeapot
|
||||
const ClusterHealthIMATeapotCode int = 418
|
||||
|
||||
/*ClusterHealthServiceUnavailable Unhealthy cluster
|
||||
/*ClusterHealthIMATeapot Unhealthy cluster
|
||||
|
||||
swagger:response clusterHealthServiceUnavailable
|
||||
swagger:response clusterHealthIMATeapot
|
||||
*/
|
||||
type ClusterHealthServiceUnavailable struct {
|
||||
type ClusterHealthIMATeapot struct {
|
||||
|
||||
/*
|
||||
In: Body
|
||||
@@ -72,27 +72,27 @@ type ClusterHealthServiceUnavailable struct {
|
||||
Payload *models.ClusterHealthResults `json:"body,omitempty"`
|
||||
}
|
||||
|
||||
// NewClusterHealthServiceUnavailable creates ClusterHealthServiceUnavailable with default headers values
|
||||
func NewClusterHealthServiceUnavailable() *ClusterHealthServiceUnavailable {
|
||||
// NewClusterHealthIMATeapot creates ClusterHealthIMATeapot with default headers values
|
||||
func NewClusterHealthIMATeapot() *ClusterHealthIMATeapot {
|
||||
|
||||
return &ClusterHealthServiceUnavailable{}
|
||||
return &ClusterHealthIMATeapot{}
|
||||
}
|
||||
|
||||
// WithPayload adds the payload to the cluster health service unavailable response
|
||||
func (o *ClusterHealthServiceUnavailable) WithPayload(payload *models.ClusterHealthResults) *ClusterHealthServiceUnavailable {
|
||||
// WithPayload adds the payload to the cluster health i m a teapot response
|
||||
func (o *ClusterHealthIMATeapot) WithPayload(payload *models.ClusterHealthResults) *ClusterHealthIMATeapot {
|
||||
o.Payload = payload
|
||||
return o
|
||||
}
|
||||
|
||||
// SetPayload sets the payload to the cluster health service unavailable response
|
||||
func (o *ClusterHealthServiceUnavailable) SetPayload(payload *models.ClusterHealthResults) {
|
||||
// SetPayload sets the payload to the cluster health i m a teapot response
|
||||
func (o *ClusterHealthIMATeapot) SetPayload(payload *models.ClusterHealthResults) {
|
||||
o.Payload = payload
|
||||
}
|
||||
|
||||
// WriteResponse to the client
|
||||
func (o *ClusterHealthServiceUnavailable) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
func (o *ClusterHealthIMATeapot) WriteResponse(rw http.ResponseWriter, producer runtime.Producer) {
|
||||
|
||||
rw.WriteHeader(503)
|
||||
rw.WriteHeader(418)
|
||||
if o.Payload != nil {
|
||||
payload := o.Payload
|
||||
if err := producer.Produce(rw, payload); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user