File tree Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Expand file tree Collapse file tree 2 files changed +16
-12
lines changed Original file line number Diff line number Diff line change @@ -77,15 +77,15 @@ func (q *budget) Stop() {
7777
7878// Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
7979func (q * budget ) Acquire (ctx context.Context ) error {
80+ if err := ctx .Err (); err != nil {
81+ return xerrors .WithStackTrace (err )
82+ }
8083 select {
84+ case <- q .done :
85+ return xerrors .WithStackTrace (errClosedBudget )
86+ case <- q .quota :
87+ return nil
8188 case <- ctx .Done ():
82- return ctx .Err ()
83- default :
84- select {
85- case <- q .quota :
86- return nil
87- case <- ctx .Done ():
88- return xerrors .WithStackTrace (ctx .Err ())
89- }
89+ return xerrors .WithStackTrace (ctx .Err ())
9090 }
9191}
Original file line number Diff line number Diff line change @@ -6,7 +6,11 @@ import (
66 "github.com/ydb-platform/ydb-go-sdk/v3/internal/xerrors"
77)
88
9- // ErrNoQuota is a special error for no quota provided by external retry budget
10- //
11- // Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
12- var ErrNoQuota = xerrors .Wrap (errors .New ("no retry quota" ))
9+ var (
10+ // ErrNoQuota is a special error for no quota provided by external retry budget
11+ //
12+ // Experimental: https://github.com/ydb-platform/ydb-go-sdk/blob/master/VERSIONING.md#experimental
13+ ErrNoQuota = xerrors .Wrap (errors .New ("no retry quota" ))
14+
15+ errClosedBudget = xerrors .Wrap (errors .New ("retry budget closed" ))
16+ )
You can’t perform that action at this time.
0 commit comments