openreplay/backend/internal/config/common/config.go
Alexander f561593b1a
Memory control manager (#1067)
* feat(backend): added a mechanism to control memory consumption

* feat(backend): extra log for system allocation

* feat(backend): implemented new memory manager in db and heuristics service
2023-04-11 16:01:37 +02:00

36 lines
881 B
Go

package common
import "strings"
type Config struct {
ConfigFilePath string `env:"CONFIG_FILE_PATH"`
MessageSizeLimit int `env:"QUEUE_MESSAGE_SIZE_LIMIT,default=1048576"`
MaxMemoryUsage uint64 `env:"MAX_MEMORY_USAGE,default=80"`
MemoryLimitMB uint64 `env:"MEMORY_LIMIT_MB,default=0"` // 0 means take limit from OS (cgroup)
}
type Configer interface {
GetConfigPath() string
}
func (c *Config) GetConfigPath() string {
return c.ConfigFilePath
}
type Postgres struct {
Postgres string `env:"POSTGRES_STRING,required"`
ApplicationName string `env:"SERVICE_NAME,default='worker'"`
}
func (cfg *Postgres) String() string {
str := cfg.Postgres
if !strings.Contains(cfg.Postgres, "application_name") {
if strings.Contains(cfg.Postgres, "?") {
str += "&"
} else {
str += "?"
}
str += "application_name=" + cfg.ApplicationName
}
return str
}