Skip to content

Commit

Permalink
fix(t): internal error -503 Timedout. #373
Browse files Browse the repository at this point in the history
  • Loading branch information
iyear committed Nov 20, 2023
1 parent 5573c82 commit 114a92f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
3 changes: 1 addition & 2 deletions app/dl/dl.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"github.com/AlecAivazis/survey/v2"
"github.com/fatih/color"
"github.com/go-faster/errors"
"github.com/gotd/contrib/middleware/floodwait"
"github.com/spf13/viper"
"go.uber.org/multierr"
"go.uber.org/zap"
Expand Down Expand Up @@ -56,7 +55,7 @@ func Run(ctx context.Context, opts *Options) error {
}

return tgc.RunWithAuth(ctx, c, func(ctx context.Context) (rerr error) {
pool := dcpool.NewPool(c, int64(viper.GetInt(consts.FlagPoolSize)), floodwait.NewSimpleWaiter())
pool := dcpool.NewPool(c, int64(viper.GetInt(consts.FlagPoolSize)), tgc.DefaultMiddlewares...)
defer multierr.AppendInvoke(&rerr, multierr.Close(pool))

parsers := []parser{
Expand Down
3 changes: 1 addition & 2 deletions app/forward/forward.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"github.com/antonmedv/expr"
"github.com/antonmedv/expr/vm"
"github.com/go-faster/errors"
"github.com/gotd/contrib/middleware/floodwait"
"github.com/gotd/td/telegram/peers"
pw "github.com/jedib0t/go-pretty/v6/progress"
"github.com/spf13/viper"
Expand Down Expand Up @@ -56,7 +55,7 @@ func Run(ctx context.Context, opts Options) error {
ctx = tctx.WithKV(ctx, kvd)

return tgc.RunWithAuth(ctx, c, func(ctx context.Context) (rerr error) {
pool := dcpool.NewPool(c, int64(viper.GetInt(consts.FlagPoolSize)), floodwait.NewSimpleWaiter())
pool := dcpool.NewPool(c, int64(viper.GetInt(consts.FlagPoolSize)), tgc.DefaultMiddlewares...)
defer multierr.AppendInvoke(&rerr, multierr.Close(pool))

ctx = tctx.WithPool(ctx, pool)
Expand Down
7 changes: 5 additions & 2 deletions app/internal/tgc/tgc.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,13 @@ import (
"github.com/iyear/tdl/pkg/key"
"github.com/iyear/tdl/pkg/kv"
"github.com/iyear/tdl/pkg/logger"
"github.com/iyear/tdl/pkg/retry"
"github.com/iyear/tdl/pkg/storage"
"github.com/iyear/tdl/pkg/utils"
)

var DefaultMiddlewares = []telegram.Middleware{retry.New(5), floodwait.NewSimpleWaiter()}

func New(ctx context.Context, login bool, middlewares ...telegram.Middleware) (*telegram.Client, kv.KV, error) {
var (
kvd kv.KV
Expand Down Expand Up @@ -102,9 +105,9 @@ func New(ctx context.Context, login bool, middlewares ...telegram.Middleware) (*
}

func NoLogin(ctx context.Context, middlewares ...telegram.Middleware) (*telegram.Client, kv.KV, error) {
return New(ctx, false, append(middlewares, floodwait.NewSimpleWaiter())...)
return New(ctx, false, append(middlewares, DefaultMiddlewares...)...)
}

func Login(ctx context.Context, middlewares ...telegram.Middleware) (*telegram.Client, kv.KV, error) {
return New(ctx, true, append(middlewares, floodwait.NewSimpleWaiter())...)
return New(ctx, true, append(middlewares, DefaultMiddlewares...)...)
}
3 changes: 1 addition & 2 deletions app/up/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (

"github.com/fatih/color"
"github.com/go-faster/errors"
"github.com/gotd/contrib/middleware/floodwait"
"github.com/spf13/viper"
"go.uber.org/multierr"

Expand Down Expand Up @@ -37,7 +36,7 @@ func Run(ctx context.Context, opts *Options) error {
}

return tgc.RunWithAuth(ctx, c, func(ctx context.Context) (rerr error) {
pool := dcpool.NewPool(c, int64(viper.GetInt(consts.FlagPoolSize)), floodwait.NewSimpleWaiter())
pool := dcpool.NewPool(c, int64(viper.GetInt(consts.FlagPoolSize)), tgc.DefaultMiddlewares...)
defer multierr.AppendInvoke(&rerr, multierr.Close(pool))

options := uploader.Options{
Expand Down

0 comments on commit 114a92f

Please sign in to comment.