gctcli: Add command line parameter to ignore default context timeout (#1258)

This commit is contained in:
Scott
2023-07-10 11:18:02 +10:00
committed by GitHub
parent 1962782812
commit 7671a453f0

View File

@@ -30,6 +30,7 @@ var (
timeout time.Duration
exchangeCreds account.Credentials
verbose bool
ignoreTimeout bool
)
const defaultTimeout = time.Second * 30
@@ -56,7 +57,9 @@ func setupClient(c *cli.Context) (*grpc.ClientConn, context.CancelFunc, error) {
}
var cancel context.CancelFunc
c.Context, cancel = context.WithTimeout(c.Context, timeout)
if !ignoreTimeout {
c.Context, cancel = context.WithTimeout(c.Context, timeout)
}
if !exchangeCreds.IsEmpty() {
flag, values := exchangeCreds.GetMetaData()
c.Context = metadata.AppendToOutgoingContext(c.Context, flag, values)
@@ -146,6 +149,12 @@ func main() {
Usage: "allows the request to generate a more verbose outputs server side",
Destination: &verbose,
},
&cli.BoolFlag{
Name: "ignoretimeout",
Aliases: []string{"it"},
Usage: "ignores the context timeout for requests",
Destination: &ignoreTimeout,
},
}
app.Commands = []*cli.Command{
getInfoCommand,