mirror of https://github.com/perkeep/perkeep.git
mysqlindexer: connect; ping
Change-Id: Ic9a8422dc10c8514a4f10a14a878c5729068d56f
This commit is contained in:
parent
9561cf3142
commit
c8e19a90d0
|
@ -72,12 +72,16 @@ func newFromConfig(ld blobserver.Loader, config jsonconfig.Obj) (blobserver.Stor
|
|||
if err := config.Validate(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// TODO: connect; set is.db
|
||||
// TODO: ping it; see if it's alive; else return err
|
||||
db, err := sql.Open("mymysql", is.database + "/" + is.user + "/" + is.password)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
is.db = db
|
||||
if err := is.ping(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
indexer := index.New(is)
|
||||
|
||||
version, err := is.SchemaVersion()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error getting schema version (need to init database?): %v", err)
|
||||
|
@ -99,10 +103,10 @@ func init() {
|
|||
blobserver.RegisterStorageConstructor("mysqlindexer", blobserver.StorageConstructor(newFromConfig))
|
||||
}
|
||||
|
||||
func (mi *myIndexStorage) IsAlive() (ok bool, err error) {
|
||||
func (mi *myIndexStorage) ping() error {
|
||||
// TODO(bradfitz): something more efficient here?
|
||||
_, err = mi.SchemaVersion()
|
||||
return err == nil, err
|
||||
_, err := mi.SchemaVersion()
|
||||
return err
|
||||
}
|
||||
|
||||
func (mi *myIndexStorage) SchemaVersion() (version int, err error) {
|
||||
|
|
Loading…
Reference in New Issue