diff --git a/cmd/service/service.go b/cmd/service/service.go index f713d9c..fbc1db1 100644 --- a/cmd/service/service.go +++ b/cmd/service/service.go @@ -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 ) diff --git a/cmd/service/service_gen.go b/cmd/service/service_gen.go index aa949fd..5c48bde 100644 --- a/cmd/service/service_gen.go +++ b/cmd/service/service_gen.go @@ -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