Skip to content

Commit

Permalink
Fixed hardcoded name in healthchecks.
Browse files Browse the repository at this point in the history
  • Loading branch information
martin-stanchev committed Oct 20, 2021
1 parent 4db233e commit 21ecde3
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func main() {
}

healthCheckEndpoint = baseURL.ResolveReference(healthCheckEndpoint)
hc := resources.NewHealthCheck(kafkaConsumer, healthCheckEndpoint.String(), requestStatusCode)
hc := resources.NewHealthCheck(kafkaConsumer, healthCheckEndpoint.String(), requestStatusCode, serviceName)

dispatcher, history := createDispatcher(*delay, *historySize, log)

Expand Down
2 changes: 1 addition & 1 deletion app_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func TestPushNotifications(t *testing.T) {
defer server.Close()

// handler
hc := resources.NewHealthCheck(queue, apiGatewayGTGURL, nil)
hc := resources.NewHealthCheck(queue, apiGatewayGTGURL, nil, "notifications-push")

keyProcessor := resources.NewKeyProcessor(server.URL+apiGatewayValidateURL, server.URL+apiGatewayPoliciesURL, http.DefaultClient, l)
s := resources.NewSubHandler(d, keyProcessor, reg, heartbeat, l, []string{"Article", "ContentPackage", "Audio"},
Expand Down
6 changes: 4 additions & 2 deletions resources/healthchecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ type HealthCheck struct {
consumer KafkaConsumer
StatusFunc RequestStatusFn
apiGatewayGTGAddress string
serviceName string
}

func NewHealthCheck(kafkaConsumer KafkaConsumer, apiGatewayGTGAddress string, statusFunc RequestStatusFn) *HealthCheck {
func NewHealthCheck(kafkaConsumer KafkaConsumer, apiGatewayGTGAddress string, statusFunc RequestStatusFn, serviceName string) *HealthCheck {
return &HealthCheck{
consumer: kafkaConsumer,
apiGatewayGTGAddress: apiGatewayGTGAddress,
StatusFunc: statusFunc,
serviceName: serviceName,
}
}

Expand All @@ -40,7 +42,7 @@ func (h *HealthCheck) Health() func(w http.ResponseWriter, r *http.Request) {
hc := fthealth.TimedHealthCheck{
HealthCheck: fthealth.HealthCheck{
SystemCode: "upp-notifications-push",
Name: "Notifications Push",
Name: h.serviceName,
Description: "Checks if all the dependent services are reachable and healthy.",
Checks: checks,
},
Expand Down
2 changes: 1 addition & 1 deletion resources/healthchecks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestHealthcheck(t *testing.T) {
test := test
t.Run(name, func(t *testing.T) {
t.Parallel()
hc := NewHealthCheck(test.kafkaConsumerMock, "randomAddress", test.statusFn)
hc := NewHealthCheck(test.kafkaConsumerMock, "randomAddress", test.statusFn, "notifications-push")

req, err := http.NewRequest("GET", "/__health", nil)
if err != nil {
Expand Down

0 comments on commit 21ecde3

Please sign in to comment.