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

Fix health check endpoint #262

Merged
merged 1 commit into from
May 24, 2019
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
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ serve_docs:
################################

api_docs:
@echo "Installing swagger-merger" && yarn global add swagger-merger
@echo "Installing swagger-merger" && npm install swagger-merger -g
@swagger-merger -i $(PWD)/swagger/index.yaml -o $(PWD)/docs/api_docs/bundle.yaml

checks:
Expand Down
11 changes: 9 additions & 2 deletions docs/api_docs/bundle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ info:
Flagr is a feature flagging, A/B testing and dynamic configuration
microservice. The base path for all the APIs is "/api/v1".
title: Flagr
version: 1.1.0
version: 1.1.2
tags:
- name: flag
description: Everything about the flag
Expand Down Expand Up @@ -759,7 +759,9 @@ paths:
description: Check if Flagr is healthy
responses:
'200':
description: OK
description: status of health check
schema:
$ref: '#/definitions/health'
default:
description: generic error response
schema:
Expand Down Expand Up @@ -1218,6 +1220,11 @@ definitions:
type: array
items:
$ref: '#/definitions/evalResult'
health:
type: object
properties:
status:
type: string
error:
type: object
required:
Expand Down
2 changes: 1 addition & 1 deletion docs/home.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Install Dependencies.

- Go
- Make (for Makefile)
- Yarn (for building UI)
- Yarn and NPM (for building UI)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plan to migrate to npm only in the near future.

- SQLite3 (for testing)

Build from source.
Expand Down
1 change: 1 addition & 0 deletions integration_tests/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ step_1_test_health()

shakedown GET $flagr_url/health
status 200
content_type 'application/json'
}

step_2_test_crud_flag()
Expand Down
5 changes: 4 additions & 1 deletion pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package handler
import (
"github.com/checkr/flagr/pkg/config"
"github.com/checkr/flagr/pkg/entity"
"github.com/checkr/flagr/swagger_gen/models"
"github.com/checkr/flagr/swagger_gen/restapi/operations"
"github.com/checkr/flagr/swagger_gen/restapi/operations/constraint"
"github.com/checkr/flagr/swagger_gen/restapi/operations/distribution"
Expand Down Expand Up @@ -83,7 +84,9 @@ func setupEvaluation(api *operations.FlagrAPI) {

func setupHealth(api *operations.FlagrAPI) {
api.HealthGetHealthHandler = health.GetHealthHandlerFunc(
func(health.GetHealthParams) middleware.Responder { return &health.GetHealthOK{} },
func(health.GetHealthParams) middleware.Responder {
return health.NewGetHealthOK().WithPayload(&models.Health{Status: "OK"})
},
)
}

Expand Down
4 changes: 3 additions & 1 deletion swagger/health.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ get:
description: Check if Flagr is healthy
responses:
200:
description: OK
description: status of health check
schema:
$ref: "#/definitions/health"
default:
description: generic error response
schema:
Expand Down
9 changes: 8 additions & 1 deletion swagger/index.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ info:
Flagr is a feature flagging, A/B testing and dynamic configuration microservice.
The base path for all the APIs is "/api/v1".
title: Flagr
version: 1.1.0
version: 1.1.2
tags:
- name: flag
description: Everything about the flag
Expand Down Expand Up @@ -507,6 +507,13 @@ definitions:
items:
$ref: "#/definitions/evalResult"

# Health check
health:
type: object
properties:
status:
type: string

# Default Error
error:
type: object
Expand Down
43 changes: 43 additions & 0 deletions swagger_gen/models/health.go

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

2 changes: 1 addition & 1 deletion swagger_gen/restapi/doc.go

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

30 changes: 26 additions & 4 deletions swagger_gen/restapi/embedded_spec.go

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

26 changes: 23 additions & 3 deletions swagger_gen/restapi/operations/health/get_health_responses.go

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