config: add runtime flags (#5050)

This commit is contained in:
Denis Mishin 2024-04-04 17:51:04 -04:00 committed by GitHub
parent be9bfd9c3f
commit e7b3d3b6e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 372 additions and 214 deletions

24
config/runtime_flags.go Normal file
View file

@ -0,0 +1,24 @@
package config
import "golang.org/x/exp/maps"
// RuntimeFlagGRPCDatabrokerKeepalive enables gRPC keepalive to the databroker service
var RuntimeFlagGRPCDatabrokerKeepalive = runtimeFlag("grpc_databroker_keepalive", false)
// RuntimeFlag is a runtime flag that can flip on/off certain features
type RuntimeFlag string
// RuntimeFlags is a map of runtime flags
type RuntimeFlags map[RuntimeFlag]bool
func runtimeFlag(txt string, def bool) RuntimeFlag {
key := RuntimeFlag(txt)
defaultRuntimeFlags[key] = def
return key
}
var defaultRuntimeFlags = map[RuntimeFlag]bool{}
func DefaultRuntimeFlags() RuntimeFlags {
return maps.Clone(defaultRuntimeFlags)
}