You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "beelis (via GitHub)" <gi...@apache.org> on 2025/03/25 11:43:09 UTC
[I] [Enhancement] Pulsar Functions Go: Return error on NewOutputMessage to enable error handling [pulsar]
beelis opened a new issue, #24121:
URL: https://github.com/apache/pulsar/issues/24121
### Search before asking
- [x] I searched in the [issues](https://github.com/apache/pulsar/issues) and found nothing similar.
### Motivation
When an error occurs during the sending of a message using `NewOutputMessage`, the go function exits with a panic. This behavior prevents the application from handling the error gracefully, as it bypasses any error-handling logic.
Errors should be returned by `NewOutputMessage `so they can be handled by the calling code, rather than causing a panic.
### Solution
Adapt the outputMessage in the context as following
```go
goInstance.context.outputMessage = func(topic string) (pulsar.Producer, error) {
producer, err := goInstance.getProducer(topic)
if err != nil {
log.Errorf("getting producer failed, error is:%v", err)
return nil, err
}
return producer, nil
}
```
### Alternatives
_No response_
### Anything else?
_No response_
### Are you willing to submit a PR?
- [x] I'm willing to submit a PR!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [Enhancement] Pulsar Functions Go: Return error on NewOutputMessage to enable error handling [pulsar]
Posted by "nodece (via GitHub)" <gi...@apache.org>.
nodece closed issue #24121: [Enhancement] Pulsar Functions Go: Return error on NewOutputMessage to enable error handling
URL: https://github.com/apache/pulsar/issues/24121
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org