Skip to content

Commit

Permalink
调整个限流参数
Browse files Browse the repository at this point in the history
  • Loading branch information
icowan committed Feb 25, 2020
1 parent 388c572 commit ba19b02
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ var (
logPath = fs.String("log-path", "", "logging file path.")
logLevel = fs.String("log-level", "all", "logging level.")
devCors = fs.String("dev-cors", "false", "is develop")
rateBucketNum = 10
rateBucketNum = fs.Int("rate-bucket", 10, "rate bucket num")
err error
)

Expand Down
4 changes: 2 additions & 2 deletions cmd/service/service_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ func addDefaultServiceMiddleware(logger log.Logger, mw []service.Middleware) []s
func addDefaultEndpointMiddleware(logger log.Logger, mw map[string][]kitendpoint.Middleware) map[string][]kitendpoint.Middleware {
mw["Post"] = append(mw["Post"],
endpoint.LoggingMiddleware(logger),
endpoint.NewTokenBucketLimitter(rate.NewLimiter(rate.Every(time.Second*1), rateBucketNum)),
endpoint.NewTokenBucketLimitter(rate.NewLimiter(rate.Every(time.Second*1), *rateBucketNum)),
)

mw["Get"] = append(mw["Get"],
endpoint.LoggingMiddleware(logger),
endpoint.NewTokenBucketLimitter(rate.NewLimiter(rate.Every(time.Second*1), rateBucketNum*10)),
endpoint.NewTokenBucketLimitter(rate.NewLimiter(rate.Every(time.Second*1), *rateBucketNum*100)),
)

return mw
Expand Down

0 comments on commit ba19b02

Please sign in to comment.