Skip to content

Commit 1982f90

Browse files
authored
feat(ratelimiter): add uri-dict-name flag (#892)
* build(dependencies): bump go-fastly to latest v7.5.5 * feat(ratelimiter): add uri-dict-name flag
1 parent 76a5b8d commit 1982f90

File tree

4 files changed

+15
-3
lines changed

4 files changed

+15
-3
lines changed

Diff for: go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ require (
2929
)
3030

3131
require (
32-
github.com/fastly/go-fastly/v7 v7.5.2
32+
github.com/fastly/go-fastly/v7 v7.5.5
3333
github.com/kennygrant/sanitize v1.2.4
3434
github.com/mholt/archiver v3.1.1+incompatible
3535
github.com/otiai10/copy v1.9.0

Diff for: go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ github.com/dsnet/compress v0.0.2-0.20210315054119-f66993602bf5/go.mod h1:qssHWj6
1818
github.com/dsnet/golib v0.0.0-20171103203638-1ea166775780/go.mod h1:Lj+Z9rebOhdfkVLjJ8T6VcRQv3SXugXy999NBtR9aFY=
1919
github.com/dustinkirkland/golang-petname v0.0.0-20191129215211-8e5a1ed0cff0 h1:90Ly+6UfUypEF6vvvW5rQIv9opIL8CbmW9FT20LDQoY=
2020
github.com/dustinkirkland/golang-petname v0.0.0-20191129215211-8e5a1ed0cff0/go.mod h1:V+Qd57rJe8gd4eiGzZyg4h54VLHmYVVw54iMnlAMrF8=
21-
github.com/fastly/go-fastly/v7 v7.5.2 h1:6TfHEScwdP3ErhAZRcsh7VC55W1ssBML/nwvKWvOMOc=
22-
github.com/fastly/go-fastly/v7 v7.5.2/go.mod h1:/Z2GD7NuxV3vVMAyrtckg1WvZVnCuM2Z8ok/z70XTEQ=
21+
github.com/fastly/go-fastly/v7 v7.5.5 h1:M3ePbU6a8BTPZzjaPoU4+O+pQspiBalF5HgVNomHlJI=
22+
github.com/fastly/go-fastly/v7 v7.5.5/go.mod h1:/Z2GD7NuxV3vVMAyrtckg1WvZVnCuM2Z8ok/z70XTEQ=
2323
github.com/fastly/kingpin v2.1.12-0.20191105091915-95d230a53780+incompatible h1:FhrXlfhgGCS+uc6YwyiFUt04alnjpoX7vgDKJxS6Qbk=
2424
github.com/fastly/kingpin v2.1.12-0.20191105091915-95d230a53780+incompatible/go.mod h1:U8UynVoU1SQaqD2I4ZqgYd5lx3A1ipQYn4aSt2Y5h6c=
2525
github.com/fatih/color v1.14.1 h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w=

Diff for: pkg/commands/ratelimit/create.go

+6
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ func NewCreateCommand(parent cmd.Registerer, g *global.Data, m manifest.Data) *C
9191
Description: cmd.FlagServiceDesc,
9292
Dst: &c.serviceName.Value,
9393
})
94+
c.CmdClause.Flag("uri-dict-name", "The name of an Edge Dictionary containing URIs as keys").StringVar(&c.uriDictName)
9495
c.CmdClause.Flag("window-size", "Number of seconds during which the RPS limit must be exceeded in order to trigger a violation").HintOptions(rateLimitWindowSizeFlagOpts...).EnumVar(&c.windowSize, rateLimitWindowSizeFlagOpts...)
9596

9697
return &c
@@ -117,6 +118,7 @@ type CreateCommand struct {
117118
rpsLimit int
118119
serviceName cmd.OptionalServiceNameID
119120
serviceVersion cmd.OptionalServiceVersion
121+
uriDictName string
120122
windowSize string
121123
}
122124

@@ -236,6 +238,10 @@ func (c *CreateCommand) constructInput() *fastly.CreateERLInput {
236238
input.RpsLimit = fastly.Int(c.rpsLimit)
237239
}
238240

241+
if c.uriDictName != "" {
242+
input.URIDictionaryName = fastly.String(c.uriDictName)
243+
}
244+
239245
if c.windowSize != "" {
240246
for _, w := range fastly.ERLWindowSizes {
241247
if c.windowSize == fmt.Sprint(w) {

Diff for: pkg/commands/ratelimit/update.go

+6
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func NewUpdateCommand(parent cmd.Registerer, g *global.Data, m manifest.Data) *U
4343
c.CmdClause.Flag("response-object-name", "Name of existing response object. Required if action is response_object").StringVar(&c.responseObjectName)
4444
c.CmdClause.Flag("response-status", "HTTP response status code (e.g. 429)").IntVar(&c.responseStatus)
4545
c.CmdClause.Flag("rps-limit", "Upper limit of requests per second allowed by the rate limiter").IntVar(&c.rpsLimit)
46+
c.CmdClause.Flag("uri-dict-name", "The name of an Edge Dictionary containing URIs as keys").StringVar(&c.uriDictName)
4647
c.CmdClause.Flag("window-size", "Number of seconds during which the RPS limit must be exceeded in order to trigger a violation").HintOptions(rateLimitWindowSizeFlagOpts...).EnumVar(&c.windowSize, rateLimitWindowSizeFlagOpts...)
4748

4849
return &c
@@ -67,6 +68,7 @@ type UpdateCommand struct {
6768
responseObjectName string
6869
responseStatus int
6970
rpsLimit int
71+
uriDictName string
7072
windowSize string
7173
}
7274

@@ -167,6 +169,10 @@ func (c *UpdateCommand) constructInput() *fastly.UpdateERLInput {
167169
input.RpsLimit = fastly.Int(c.rpsLimit)
168170
}
169171

172+
if c.uriDictName != "" {
173+
input.URIDictionaryName = fastly.String(c.uriDictName)
174+
}
175+
170176
// NOTE: rateLimitWindowSizes is defined in ./create.go
171177
if c.windowSize != "" {
172178
for _, w := range fastly.ERLWindowSizes {

0 commit comments

Comments
 (0)