Skip to content

Enhance bot management with Len method and export Managed type#467

Open
anhnmt wants to merge 2 commits into
gotd:mainfrom
anhnmt:pool
Open

Enhance bot management with Len method and export Managed type#467
anhnmt wants to merge 2 commits into
gotd:mainfrom
anhnmt:pool

Conversation

@anhnmt

@anhnmt anhnmt commented Jul 12, 2026

Copy link
Copy Markdown

Adds two small extensions to the pool package needed by downstream
consumers that manage bots outside of Pool.Do:

  • Pool.Len() returns the number of bots currently tracked by the pool.
    Useful for monitoring/metrics and health checks that need visibility
    into pool size without reaching into internals.

  • Managed is now exported, along with its Bot() accessor. Some
    consumers need to hold a reference to a specific managed bot (e.g.
    for per-bot lifecycle tracking, activity logging, or diagnostics)
    rather than only invoking it through Pool.Do's callback style.

Bot() returns the underlying *botapi.Bot without waiting for
readiness; callers that need a ready/authorized bot should still go
through Pool.Do, which blocks on the ready channel before invoking
the callback. Bot() is intended for read-only access where the
caller already knows the bot's state (e.g. it was reached via Do).

No behavioral changes to existing Pool semantics — this only widens
the public surface.

anhnmt added 2 commits July 12, 2026 22:07
Make bot management accessible from outside the pool package by exporting the Managed type, renaming acquire/start to Acquire/Start, and adding a Bot() accessor.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant