Skip to content

Commit

Permalink
MAX_EVENTS env var, default 1k
Browse files Browse the repository at this point in the history
  • Loading branch information
metachris committed Oct 23, 2024
1 parent 346dabf commit a97926a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/system-api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
"github.com/go-chi/chi/v5/middleware"
)

var MaxEvents = 100
var MaxEvents = common.GetEnvInt("MAX_EVENTS", 1000)

type HTTPServerConfig struct {
ListenAddr string
Expand Down
16 changes: 16 additions & 0 deletions common/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package common

import (
"os"
"strconv"
)

func GetEnvInt(key string, defaultValue int) int {
if value, ok := os.LookupEnv(key); ok {
val, err := strconv.Atoi(value)
if err == nil {
return val
}
}
return defaultValue
}

0 comments on commit a97926a

Please sign in to comment.