openreplay/backend/internal/config/common/config.go
Kraiem Taha Yassine 767d2f6f0c
V1.8.2 workers app name (#772)
* feat(backend): added application name to postgres connection

Co-authored-by: Alexander Zavorotynskiy <zavorotynskiy@pm.me>
2023-01-23 09:08:14 +01:00

34 lines
722 B
Go

package common
import "strings"
type Config struct {
ConfigFilePath string `env:"CONFIG_FILE_PATH"`
MessageSizeLimit int `env:"QUEUE_MESSAGE_SIZE_LIMIT,default=1048576"`
}
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
}