mirror of
https://github.com/jeremyd/ergo.git
synced 2026-07-17 21:18:11 -07:00
Add support for Unix domain sockets.
This adds a new configuration option, socket-path, instead of using host.
This commit is contained in:
@@ -12,6 +12,7 @@ type Config struct {
|
||||
Enabled bool
|
||||
Host string
|
||||
Port int
|
||||
SocketPath string `yaml:"socket-path"`
|
||||
User string
|
||||
Password string
|
||||
HistoryDatabase string `yaml:"history-database"`
|
||||
|
||||
@@ -88,7 +88,9 @@ func (mysql *MySQL) getExpireTime() (expireTime time.Duration) {
|
||||
|
||||
func (m *MySQL) Open() (err error) {
|
||||
var address string
|
||||
if m.config.Port != 0 {
|
||||
if m.config.SocketPath != "" {
|
||||
address = fmt.Sprintf("unix(%s)", m.config.SocketPath)
|
||||
} else if m.config.Port != 0 {
|
||||
address = fmt.Sprintf("tcp(%s:%d)", m.config.Host, m.config.Port)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user