Skip to content

Commit

Permalink
default timeout in tl clients
Browse files Browse the repository at this point in the history
  • Loading branch information
hrissan committed Aug 22, 2024
1 parent 42ce2c1 commit d073a3d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
7 changes: 6 additions & 1 deletion internal/tlcodegen/qt_namespace.qtpl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ package {%s= gen.GlobalPackageName + name %}
import (
{%- if gen.options.GenerateRPCCode && anyFunctions -%}
"context"
"time"

{%q= gen.options.BasicRPCPath %}
{%q= gen.BasicPackageNameFull %}
Expand All @@ -34,7 +35,8 @@ type Client struct {
Client *rpc.Client
Network string // should be either "tcp4" or "unix"
Address string
ActorID int64 // should be non-zero when using rpc-proxy
ActorID int64 // should be >0 for routing via rpc-proxy
Timeout time.Time // used if not set in extra or ctx
}

{%= writeClientsCode(gen.GlobalPackageName, namespace.types, directImports, ourTypes) %}
Expand Down Expand Up @@ -122,6 +124,9 @@ func (c *Client) {%s= typeString %}(ctx context.Context, args {%s= typeString %}
if extra != nil {
req.Extra = *extra
}
if _, ok := ctx.Deadline(); !ok {
rpc.UpdateExtraTimeout(&req.Extra, c.Timeout)
}
req.Body, err = args.WriteBoxedGeneral(req.Body)
if err != nil {
return internal.ErrorClientWrite("{%s= tlName %}", err)
Expand Down
7 changes: 6 additions & 1 deletion internal/tlcodegen/qt_namespace.qtpl.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 7 additions & 23 deletions internal/tlcodegen/test/gen/schema/meta/meta.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d073a3d

Please sign in to comment.