diff --git a/pkg/commands/backend/backend_test.go b/pkg/commands/backend/backend_test.go index 8f3307c00..fd4a0235a 100644 --- a/pkg/commands/backend/backend_test.go +++ b/pkg/commands/backend/backend_test.go @@ -495,6 +495,8 @@ var listBackendsJSONOutput = strings.TrimSpace(` "Hostname": null, "KeepAliveTime": null, "MaxConn": null, + "MaxUse": null, + "MaxLifetime": null, "MaxTLSVersion": null, "MinTLSVersion": null, "Name": "test.com", @@ -535,6 +537,8 @@ var listBackendsJSONOutput = strings.TrimSpace(` "Hostname": null, "KeepAliveTime": null, "MaxConn": null, + "MaxUse": null, + "MaxLifetime": null, "MaxTLSVersion": null, "MinTLSVersion": null, "Name": "example.com", @@ -585,6 +589,8 @@ var listBackendsVerboseOutput = strings.Join([]string{ " Override host: ", " Connect timeout: 0", " Max connections: 0", + " Max connection use: 0", + " Max connection lifetime: 0", " First byte timeout: 0", " Between bytes timeout: 0", " Auto loadbalance: false", @@ -614,6 +620,8 @@ var listBackendsVerboseOutput = strings.Join([]string{ " Override host: ", " Connect timeout: 0", " Max connections: 0", + " Max connection use: 0", + " Max connection lifetime: 0", " First byte timeout: 0", " Between bytes timeout: 0", " Auto loadbalance: false", @@ -663,6 +671,8 @@ var describeBackendOutput = strings.Join([]string{ "Override host: ", "Connect timeout: 0", "Max connections: 0", + "Max connection use: 0", + "Max connection lifetime: 0", "First byte timeout: 0", "Between bytes timeout: 0", "Auto loadbalance: false", diff --git a/pkg/commands/backend/create.go b/pkg/commands/backend/create.go index 878602683..4954cb76b 100644 --- a/pkg/commands/backend/create.go +++ b/pkg/commands/backend/create.go @@ -33,6 +33,8 @@ type CreateCommand struct { firstByteTimeout argparser.OptionalInt healthCheck argparser.OptionalString maxConn argparser.OptionalInt + maxUse argparser.OptionalInt + maxLifetime argparser.OptionalInt maxTLSVersion argparser.OptionalString minTLSVersion argparser.OptionalString name argparser.OptionalString @@ -90,6 +92,8 @@ func NewCreateCommand(parent argparser.Registerer, g *global.Data) *CreateComman c.CmdClause.Flag("first-byte-timeout", "How long to wait for the first bytes in milliseconds").Action(c.firstByteTimeout.Set).IntVar(&c.firstByteTimeout.Value) c.CmdClause.Flag("healthcheck", "The name of the healthcheck to use with this backend").Action(c.healthCheck.Set).StringVar(&c.healthCheck.Value) c.CmdClause.Flag("max-conn", "Maximum number of connections").Action(c.maxConn.Set).IntVar(&c.maxConn.Value) + c.CmdClause.Flag("max-use", "Maximum number of times an HTTP keepalive connection can be used").Action(c.maxUse.Set).IntVar(&c.maxUse.Value) + c.CmdClause.Flag("max-lifetime", "Upper bound in milliseconds for how long an HTTP keepalive connection can be open before it is no longer used").Action(c.maxLifetime.Set).IntVar(&c.maxLifetime.Value) c.CmdClause.Flag("max-tls-version", "Maximum allowed TLS version on SSL connections to this backend").Action(c.maxTLSVersion.Set).StringVar(&c.maxTLSVersion.Value) c.CmdClause.Flag("min-tls-version", "Minimum allowed TLS version on SSL connections to this backend").Action(c.minTLSVersion.Set).StringVar(&c.minTLSVersion.Value) c.CmdClause.Flag("name", "Backend name").Short('n').Action(c.name.Set).StringVar(&c.name.Value) @@ -181,6 +185,12 @@ func (c *CreateCommand) Exec(_ io.Reader, out io.Writer) error { if c.maxConn.WasSet { input.MaxConn = &c.maxConn.Value } + if c.maxUse.WasSet { + input.MaxUse = &c.maxUse.Value + } + if c.maxLifetime.WasSet { + input.MaxLifetime = &c.maxLifetime.Value + } if c.maxTLSVersion.WasSet { input.MaxTLSVersion = &c.maxTLSVersion.Value } diff --git a/pkg/commands/backend/describe.go b/pkg/commands/backend/describe.go index c20f60a4b..a8be0fdf2 100644 --- a/pkg/commands/backend/describe.go +++ b/pkg/commands/backend/describe.go @@ -112,6 +112,8 @@ func (c *DescribeCommand) print(out io.Writer, b *fastly.Backend) error { fmt.Fprintf(out, "Override host: %v\n", fastly.ToValue(b.OverrideHost)) fmt.Fprintf(out, "Connect timeout: %v\n", fastly.ToValue(b.ConnectTimeout)) fmt.Fprintf(out, "Max connections: %v\n", fastly.ToValue(b.MaxConn)) + fmt.Fprintf(out, "Max connection use: %v\n", fastly.ToValue(b.MaxUse)) + fmt.Fprintf(out, "Max connection lifetime: %v\n", fastly.ToValue(b.MaxLifetime)) fmt.Fprintf(out, "First byte timeout: %v\n", fastly.ToValue(b.FirstByteTimeout)) fmt.Fprintf(out, "Between bytes timeout: %v\n", fastly.ToValue(b.BetweenBytesTimeout)) fmt.Fprintf(out, "Auto loadbalance: %v\n", fastly.ToValue(b.AutoLoadbalance)) diff --git a/pkg/commands/backend/update.go b/pkg/commands/backend/update.go index 9d48db064..45a95f91a 100644 --- a/pkg/commands/backend/update.go +++ b/pkg/commands/backend/update.go @@ -32,6 +32,8 @@ type UpdateCommand struct { HealthCheck argparser.OptionalString Hostname argparser.OptionalString MaxConn argparser.OptionalInt + MaxUse argparser.OptionalInt + MaxLifetime argparser.OptionalInt MaxTLSVersion argparser.OptionalString MinTLSVersion argparser.OptionalString NewName argparser.OptionalString @@ -88,6 +90,8 @@ func NewUpdateCommand(parent argparser.Registerer, g *global.Data) *UpdateComman c.CmdClause.Flag("first-byte-timeout", "How long to wait for the first bytes in milliseconds").Action(c.FirstByteTimeout.Set).IntVar(&c.FirstByteTimeout.Value) c.CmdClause.Flag("healthcheck", "The name of the healthcheck to use with this backend").Action(c.HealthCheck.Set).StringVar(&c.HealthCheck.Value) c.CmdClause.Flag("max-conn", "Maximum number of connections").Action(c.MaxConn.Set).IntVar(&c.MaxConn.Value) + c.CmdClause.Flag("max-use", "Maximum number of times an HTTP keepalive connection can be used").Action(c.maxUse.Set).IntVar(&c.maxUse.Value) + c.CmdClause.Flag("max-lifetime", "Upper bound in milliseconds for how long an HTTP keepalive connection can be open before it is no longer used").Action(c.maxLifetime.Set).IntVar(&c.maxLifetime.Value) c.CmdClause.Flag("max-tls-version", "Maximum allowed TLS version on SSL connections to this backend").Action(c.MaxTLSVersion.Set).StringVar(&c.MaxTLSVersion.Value) c.CmdClause.Flag("min-tls-version", "Minimum allowed TLS version on SSL connections to this backend").Action(c.MinTLSVersion.Set).StringVar(&c.MinTLSVersion.Value) c.CmdClause.Flag("new-name", "New backend name").Action(c.NewName.Set).StringVar(&c.NewName.Value) @@ -198,6 +202,14 @@ func (c *UpdateCommand) Exec(_ io.Reader, out io.Writer) error { input.MaxConn = &c.MaxConn.Value } + if c.MaxUse.WasSet { + input.MaxUse = &c.MaxUse.Value + } + + if c.MaxLifetime.WasSet { + input.MaxLifetime = &c.MaxLifetime.Value + } + if c.FirstByteTimeout.WasSet { input.FirstByteTimeout = &c.FirstByteTimeout.Value } diff --git a/pkg/text/backend.go b/pkg/text/backend.go index a1886668a..402a48bb8 100644 --- a/pkg/text/backend.go +++ b/pkg/text/backend.go @@ -22,6 +22,8 @@ func PrintBackend(out io.Writer, prefix string, b *fastly.Backend) { fmt.Fprintf(out, "Override host: %v\n", fastly.ToValue(b.OverrideHost)) fmt.Fprintf(out, "Connect timeout: %v\n", fastly.ToValue(b.ConnectTimeout)) fmt.Fprintf(out, "Max connections: %v\n", fastly.ToValue(b.MaxConn)) + fmt.Fprintf(out, "Max connection use: %v\n", fastly.ToValue(b.MaxUse)) + fmt.Fprintf(out, "Max connection lifetime: %v\n", fastly.ToValue(b.MaxLifetime)) fmt.Fprintf(out, "First byte timeout: %v\n", fastly.ToValue(b.FirstByteTimeout)) fmt.Fprintf(out, "Between bytes timeout: %v\n", fastly.ToValue(b.BetweenBytesTimeout)) fmt.Fprintf(out, "Auto loadbalance: %v\n", fastly.ToValue(b.AutoLoadbalance))