Skip to content

Commit

Permalink
feat: added utility method to database config
Browse files Browse the repository at this point in the history
  • Loading branch information
RiccardoM committed Nov 29, 2022
1 parent 7c07bba commit f3d31c9
Showing 1 changed file with 27 additions and 2 deletions.
29 changes: 27 additions & 2 deletions database/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,37 @@ type Config struct {
PartitionBatchSize int64 `yaml:"partition_batch"`
}

func (c *Config) GetUser() string {
func (c *Config) getURL() *url.URL {
parsedURL, err := url.Parse(c.URL)
if err != nil {
panic(err)
}
return parsedURL.User.Username()
return parsedURL
}

func (c *Config) GetUser() string {
return c.getURL().User.Username()
}

func (c *Config) GetPassword() string {
password, _ := c.getURL().User.Password()
return password
}

func (c *Config) GetHost() string {
return c.getURL().Host
}

func (c *Config) GetPort() string {
return c.getURL().Port()
}

func (c *Config) GetSchema() string {
return c.getURL().Query().Get("search_path")
}

func (c *Config) GetSSLMode() string {
return c.getURL().Query().Get("sslmode")
}

func NewDatabaseConfig(
Expand Down

0 comments on commit f3d31c9

Please sign in to comment.