Created
February 26, 2015 21:30
-
-
Save gabesullice/e1935a75ccba1e16b294 to your computer and use it in GitHub Desktop.
Go lang DB Connection Config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func NewStorage(settings ...StorageConfig) *Storage { | |
var s Storage | |
s.ConnectOpts = r.ConnectOpts{ | |
Address: "localhost:28015", | |
Database: "dbname", | |
MaxIdle: 10, | |
Timeout: time.Second * 10, | |
} | |
for _, setting := range settings { | |
setting.Configure(&s) | |
} | |
session, err := r.Connect(s.ConnectOpts) | |
if err != nil { | |
log.Fatalln(err.Error()) | |
} | |
s.Session = session | |
return &s | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment