* feat(backend): redshift connector draft * fix(backend): fixed memory leak, empty string ddos * feat(backend): draft for sessions part * feat(backend): session handler * fix(backend): fixed wrong columns list in sessionToCSV convertor * feat(backend): load session info from db/cache if there is nothing in memory when sessionEnd event recieved * feat(backend): added filters for connector * feat(backend): memory leak fix + extra cache for sessions * feat(backend): moved table names as an env variable * fix(backend): added timeout for last session messages to avoid memory leak * fix(backend): fixed last memory leak * feat(backend): moved redshift connector to ee folder
51 lines
1.2 KiB
Go
51 lines
1.2 KiB
Go
package common
|
|
|
|
import "strings"
|
|
|
|
// Common config for all services
|
|
|
|
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
|
|
}
|
|
|
|
// Postgres config
|
|
|
|
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
|
|
}
|
|
|
|
// Redshift config
|
|
|
|
type Redshift struct {
|
|
ConnectioString string `env:"REDSHIFT_STRING"`
|
|
Host string `env:"REDSHIFT_HOST"`
|
|
Port int `env:"REDSHIFT_PORT"`
|
|
User string `env:"REDSHIFT_USER"`
|
|
Password string `env:"REDSHIFT_PASSWORD"`
|
|
Database string `env:"REDSHIFT_DATABASE"`
|
|
}
|