Skip to content

Commit bf9a405

Browse files
authored
Merge pull request #1666 from borzovplus/pass-error-to-onDead
Pass error to onDead callback args
2 parents 4103f2f + f98235b commit bf9a405

File tree

5 files changed

+6
-6
lines changed

5 files changed

+6
-6
lines changed

telegram/client.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ type Client struct {
6262
connsCounter atomic.Int64
6363
create connConstructor // immutable
6464
resolver dcs.Resolver // immutable
65-
onDead func() // immutable
65+
onDead func(error) // immutable
6666
newConnBackoff func() backoff.BackOff // immutable
6767
defaultMode manager.ConnMode // immutable
6868

telegram/conn_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func (c *Client) createConn(
7575
id int64,
7676
mode manager.ConnMode,
7777
setup manager.SetupCallback,
78-
onDead func(),
78+
onDead func(error),
7979
) pool.Conn {
8080
opts, s := c.session.Options(c.opts)
8181
opts.Logger = c.log.Named("conn").With(

telegram/internal/manager/conn.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ type Conn struct {
5454
setup SetupCallback // nilable
5555

5656
// onDead is called on connection death.
57-
onDead func()
57+
onDead func(error)
5858

5959
// Wrappers for external world, like logs or PRNG.
6060
// Should be immutable.
@@ -127,7 +127,7 @@ func (c *Conn) Run(ctx context.Context) (err error) {
127127
if err != nil && ctx.Err() == nil {
128128
c.log.Debug("Connection dead", zap.Error(err))
129129
if c.onDead != nil {
130-
c.onDead()
130+
c.onDead(err)
131131
}
132132
}
133133
}()

telegram/internal/manager/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ type ConnOptions struct {
2222
Device DeviceConfig
2323
Handler Handler
2424
Setup SetupCallback
25-
OnDead func()
25+
OnDead func(error)
2626
Backoff func(ctx context.Context) backoff.BackOff
2727
}
2828

telegram/options.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ type Options struct {
4949
// ReconnectionBackoff configures and returns reconnection backoff object.
5050
ReconnectionBackoff func() backoff.BackOff
5151
// OnDead will be called on connection dead.
52-
OnDead func()
52+
OnDead func(error)
5353
// MigrationTimeout configures migration timeout.
5454
MigrationTimeout time.Duration
5555

0 commit comments

Comments
 (0)