gofr-dev / gofr

An opinionated GoLang framework for accelerated microservice development. Built in support for databases and observability.
https://gofr.dev
Apache License 2.0
3.6k stars 236 forks source link

bug: pubsub connection attempts in endless loop #1129

Open mfreeman451 opened 1 month ago

mfreeman451 commented 1 month ago

Describe the bug While attempting to run all of the go tests in this project from my personal machine, which I understand probably doesn't have the proper test environment, I noticed the pubsub tests attempting to make a connection to the pubsub in an endless loop.

{"level":"ERROR","time":"2024-10-18T15:18:45.425787-05:00","message":"error in subscription for topic products: consumer group id not provided","gofrVersion":"dev"}
{"level":"ERROR","time":"2024-10-18T15:18:45.425809-05:00","message":"cannot subscribe as consumer_id is not provided in configs","gofrVersion":"dev"}
{"level":"ERROR","time":"2024-10-18T15:18:45.425798-05:00","message":"error in subscription for topic order-logs: consumer group id not provided","gofrVersion":"dev"}
{"level":"ERROR","time":"2024-10-18T15:18:45.42582-05:00","message":"cannot subscribe as consumer_id is not provided in configs","gofrVersion":"dev"}
{"level":"ERROR","time":"2024-10-18T15:18:45.425826-05:00","message":"error while reading from topic order-logs, err: consumer group id not provided","gofrVersion":"dev"}
{"level":"ERROR","time":"2024-10-18T15:18:45.42583-05:00","message":"error in subscription for topic order-logs: consumer group id not provided","gofrVersion":"dev"}
{"level":"ERROR","time":"2024-10-18T15:18:45.425815-05:00","message":"error while reading from topic products, err: consumer group id not provided","gofrVersion":"dev"}

I think we should consider implementing some kind of exponential retry/backoff strategy here and consider returning an error.

To Reproduce Steps to reproduce the behavior, if applicable:

  1. The code is

go test -v ./...


2. The error is

{"level":"ERROR","time":"2024-10-18T15:18:45.425787-05:00","message":"error in subscription for topic products: consumer group id not provided","gofrVersion":"dev"} {"level":"ERROR","time":"2024-10-18T15:18:45.425809-05:00","message":"cannot subscribe as consumer_id is not provided in configs","gofrVersion":"dev"} {"level":"ERROR","time":"2024-10-18T15:18:45.425798-05:00","message":"error in subscription for topic order-logs: consumer group id not provided","gofrVersion":"dev"} {"level":"ERROR","time":"2024-10-18T15:18:45.42582-05:00","message":"cannot subscribe as consumer_id is not provided in configs","gofrVersion":"dev"} {"level":"ERROR","time":"2024-10-18T15:18:45.425826-05:00","message":"error while reading from topic order-logs, err: consumer group id not provided","gofrVersion":"dev"} {"level":"ERROR","time":"2024-10-18T15:18:45.42583-05:00","message":"error in subscription for topic order-logs: consumer group id not provided","gofrVersion":"dev"} {"level":"ERROR","time":"2024-10-18T15:18:45.425815-05:00","message":"error while reading from topic products, err: consumer group id not provided","gofrVersion":"dev"}



**Expected behavior**
Should return an error eventually.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Environments (please complete the following information):**
- OS: [e.g. Linux]
- gofr version [e.g. v1.5.0]
- go version [e.g. 1.21]

**More description**
Add any other context about the problem here.
vipul-rawat commented 1 month ago

@mfreeman451 This is not a retry connection, but a subscription issue with Kafka where when it is trying to subscribe to the topic, the consumer group ID is not provided, and it throws the error that you mentioned.

I think we should look for a solution where the subscription cannot start until the pubsub is connected and ready.