Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default timeout to generated rpc code #48

Merged
merged 5 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions internal/tlast/tlgen_tlo.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,6 @@ func (tl TL) GenerateTLO(version uint32) (tls.SchemaV4, error) {
}
}
var mc paramScope
left := tls.CombinatorLeft{}
args := make([]tls.Arg, 0, len(c.TemplateArguments)+len(c.Fields))
for i, ta := range c.TemplateArguments {
var tag int32
Expand Down Expand Up @@ -224,7 +223,7 @@ func (tl TL) GenerateTLO(version uint32) (tls.SchemaV4, error) {
mc.append(f.FieldName, f.FieldType.Type.String(), len(c.TemplateArguments)+i)
}
}
left = tls.CombinatorLeft0{
left := tls.CombinatorLeft0{
ArgsNum: uint32(len(args)),
Args: args,
}.AsUnion()
Expand Down
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.Duration // 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.

Loading