func New() (*Mongo, error) { c, err := container.FindOrCreate(containerName, "mongo:latest") if err != nil { return nil, err } connStr := "mongodb://" + c.Addr(internalPort) session, err := mgo.Dial(connStr) if err != nil { c.Close() return nil, err } return &Mongo{ ConnStr: connStr, Session: session, c: c, }, nil }
func New() (*InfluxDB, error) { c, err := container.FindOrCreate(containerName, "influxdb:latest") if err != nil { return nil, err } addr := "http://" + c.Addr(internalPort) influxClient, err := client.NewHTTPClient(client.HTTPConfig{ Addr: addr, Timeout: time.Second, }) if err != nil { return nil, err } return &InfluxDB{ c: c, addr: addr, Client: influxClient, }, nil }
func New() (*MySQL, error) { c, err := container.FindOrCreate(containerName, "mysql:latest", "--env=MYSQL_ROOT_PASSWORD="******"root:%s@tcp(%s)/", Password, c.Addr(internalPort)) x, err := sql.Open("mysql", connStr) if err != nil { c.Close() return nil, err } return &MySQL{ ConnStr: connStr, DB: x, c: c, }, nil }