Repository navigation
Improve and clarify doc comments for public API - #230
Conversation
negasus
left a comment
There was a problem hiding this comment.
Thanks for improving the documentation. The handler registration and matching descriptions are useful, but two new behavioral guarantees in options.go do not match the implementation; please address the inline comments. Please also update the branch and resolve the conflicts with the current base. For the widespread Telegram documentation-link changes, please preserve the conventional Go doc-comment opening with the documented symbol's name, rather than replacing it with a generic 'See Telegram API docs:' sentence. The link can follow that opening.
|
|
||
| // WithNotAsyncHandlers allows to run handlers in the main goroutine | ||
| // WithNotAsyncHandlers returns Option that runs handlers in the main goroutine. | ||
| // This ensures handlers execute sequentially instead of concurrently. |
There was a problem hiding this comment.
This option does not guarantee sequential execution across all updates. Start/StartWebhook launch b.workers worker goroutines, and each worker calls ProcessUpdate. WithNotAsyncHandlers runs the handler synchronously in that calling goroutine, so WithWorkers(2) can still execute two handlers concurrently. It also does not move execution to the main goroutine. Please describe this as synchronous execution in the calling goroutine (the worker for queued updates), with sequential processing per worker, rather than a global serialization guarantee.
|
|
||
| // WithErrorsHandler allows to set handler for errors | ||
| // WithErrorsHandler returns Option that sets handler for errors. | ||
| // This handler will be called whenever an error occurs during bot operation. |
There was a problem hiding this comment.
The new 'whenever an error occurs during bot operation' guarantee is too broad. Errors from explicit API calls such as SendMessage are returned to the caller through rawRequest; they are not automatically forwarded to errorsHandler. Please clarify that this callback receives errors reported internally by the library (such as polling/webhook processing errors), and that callers must still handle errors returned by API methods. Otherwise users may incorrectly rely on this callback as a catch-all error handler.
Describe bot options, handler registration and matching from their current behavior. WithErrorsHandler receives only errors reported by the library, and WithNotAsyncHandlers does not serialize handlers across workers. Keep the existing Telegram documentation links. Make shouldBeEscaped a constant.
84f2c7f to
95ae62d
Compare
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #230 +/- ##
=======================================
Coverage 63.69% 63.69%
=======================================
Files 40 40
Lines 3449 3449
=======================================
Hits 2197 2197
- Misses 1194 1195 +1
+ Partials 58 57 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks for the review. I rebuilt the branch on current
I also checked the other new comments against the current code and corrected a few, including |
Problem
Closes #229
Changes
ProcessUpdatebased on current behavior.common.goand makeshouldBeEscapeda constant.