Skip to content

Commit

Permalink
Change kafka consumer groups per deployment
Browse files Browse the repository at this point in the history
Fix healthcheck return values
  • Loading branch information
dtvalk-ov committed Apr 19, 2022
1 parent 0a5ee38 commit 79979c0
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ service:
name: list-notifications-push
env:
TOPIC: "PublicationNotificationEvents"
GROUP_ID: "list-notifications-push"
CONSUMER_BACKOFF: "2"
NOTIFICATIONS_RESOURCE: "lists"
CONTENT_TYPE_WHITELIST: "application/vnd.ft-upp-list+json"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ service:
env:
TOPIC: "PublicationNotificationEvents"
METADATA_TOPIC: "PostConceptAnnotations"
GROUP_ID: "notifications-push"
CONSUMER_BACKOFF: "2"
NOTIFICATIONS_RESOURCE: "content"
CONTENT_URI_WHITELIST: "^http://(methode|wordpress-article|content|upp)(-collection|-content-placeholder|-notifications-creator)?(-mapper|-unfolder|)(-pr|-iw)?(-uk-.*)?\\.svc\\.ft\\.com(:\\d{2,5})?/(content|complementarycontent)/[\\w-]+.*$"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ service:
name: page-notifications-push
env:
TOPIC: "PublicationNotificationEvents"
GROUP_ID: "page-notifications-push"
CONSUMER_BACKOFF: "2"
NOTIFICATIONS_RESOURCE: "pages"
CONTENT_TYPE_WHITELIST: "application/vnd.ft-upp-page+json"
Expand Down
5 changes: 1 addition & 4 deletions helm/notifications-push/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ spec:
name: global-config
key: api.host.with.protocol
- name: GROUP_ID
# set this as the pod name so it's unique per instance
valueFrom:
fieldRef:
fieldPath: metadata.name
value: {{ .Values.env.GROUP_ID }}
- name: TOPIC
value: {{ .Values.env.TOPIC }}
- name: METADATA_TOPIC
Expand Down
2 changes: 1 addition & 1 deletion push_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type notificationSystem interface {
func startService(srv *http.Server, n notificationSystem, consumer *kafka.Consumer, msgHandler queueConsumer.MessageQueueHandler, log *logger.UPPLogger) func(time.Duration) {
go n.Start()

consumer.Start(msgHandler.HandleMessage)
go consumer.Start(msgHandler.HandleMessage)

go func() {
err := srv.ListenAndServe()
Expand Down
7 changes: 4 additions & 3 deletions resources/healthchecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package resources
import (
"context"
"errors"
"fmt"
"net/http"
"time"

Expand Down Expand Up @@ -94,15 +95,15 @@ func (h *HealthCheck) checkKafkaConsumerReachable() (string, error) {
if err == nil {
return "Connectivity to kafka is OK.", nil
}
return "Error connecting to kafka", err
return "", err
}

func (h *HealthCheck) checkKafkaConsumerLag() (string, error) {
err := h.consumer.MonitorCheck()
if err == nil {
return "Kafka consumer is not lagging", nil
}
return "Kafka consumer is lagging behind", err
return "", err
}

// checks if apiGateway service is available
Expand Down Expand Up @@ -131,5 +132,5 @@ func (h *HealthCheck) checkAPIGatewayService() (string, error) {
return "ApiGateway service is working", nil
}

return "", errors.New("unable to verify ApiGateway service is working")
return "", fmt.Errorf("unable to verify ApiGateway service is working")
}

0 comments on commit 79979c0

Please sign in to comment.