googleapis / googleapis/google-cloud-go
pubsub: error handling for Pub/Sub subscriber client in scenarios like broken connection or expired
- Dominant language
- Go
- Stars
- 4.5k
- Forks
- 1.6k
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 109
Description
We’re using the Pub/Sub Go SDK to build a program that publishes and subscribes to messages. Our subscriber runs as a long-running process that continuously pulls messages from Pub/Sub.
We’d like to implement custom error handling for scenarios such as:
- The connection to the Pub/Sub service is broken or interrupted
- The authorization credentials expire or become invalid
so that our program cannot detect or start recover at runtime.
In other messaging systems, SDKs often provide built-in hooks for handling such errors.
- For instance, the Kafka Confluent SDK (github.com/cloudevents/sdk-go/protocol/kafka_confluent/v2) provides an error handler option: 👉 [WithErrorHandler](https://pkg.go.dev/github.com/cloudevents/sdk-go/protocol/kafka_confluent/v2#WithErrorHandler)
- The Paho MQTT Go SDK also provides similar error handling hooks to react to connection or protocol errors: 👉 [OnClientError in ClientConfig](https://pkg.go.dev/github.com/eclipse/paho.golang/paho#ClientConfig)
Is there a similar mechanism in the Pub/Sub Go SDK to catch or handle these kinds of errors during long-running subscription calls?
Contributor guide
Assessment
This issue has not been assessed yet.