client,gotd: refactor connection event handling

This might cause regressions if the onSession handler was load bearing
This commit is contained in:
Tulir Asokan
2025-12-04 14:44:40 +02:00
parent c83a361c0b
commit 2cac8f8b4a
5 changed files with 53 additions and 55 deletions
+1 -1
View File
@@ -64,7 +64,7 @@ type Client struct {
resolver dcs.Resolver // immutable
onDead func() // immutable
onAuthError func(error) // immutable
onConnected func() // immutable
onConnected func(*tg.User) // immutable
newConnBackoff func() backoff.BackOff // immutable
defaultMode manager.ConnMode // immutable
+1 -1
View File
@@ -43,7 +43,7 @@ func (c *Client) runUntilRestart(ctx context.Context) error {
c.log.Info("Got self", zap.String("username", self.Username))
if c.onConnected != nil {
c.onConnected()
c.onConnected(self)
}
return nil
})
+1 -1
View File
@@ -56,7 +56,7 @@ type Options struct {
OnAuthError func(error)
// OnConnected will be called when the connection has been established and
// the user has been fetched successfully.
OnConnected func()
OnConnected func(*tg.User)
// MigrationTimeout configures migration timeout.
MigrationTimeout time.Duration