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 ba19b02 commit ec0fffa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions cmd/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ func Run() {
logPath = envString("LOG_PATH", logPath)
logLevel = envString("LOG_LEVEL", logLevel)
devCors = envString("DEV_CORS", devCors)
rateBucketNum = envInt("RATE_BUCKET", rateBucketNum)

logger = logging.SetLogging(logger, logPath, logLevel)

Expand Down Expand Up @@ -168,3 +169,13 @@ func envString(env string, fallback *string) *string {
}
return &e
}

func envInt(env string, fallback *int) *int {
e := os.Getenv(env)
if e == "" {
_ = os.Setenv(env, strconv.Itoa(*fallback))
return fallback
}
num, _ := strconv.Atoi(e)
return &num
}

0 comments on commit ec0fffa

Please sign in to comment.