Browse Source

storeFac use single sqlFac

pull/230/head
yedf2 4 years ago
parent
commit
ad5dbd906f
  1. 18
      dtmsvr/storage/registry/registry.go

18
dtmsvr/storage/registry/registry.go

@ -18,6 +18,12 @@ type StorageFactory interface {
GetStorage() storage.Store GetStorage() storage.Store
} }
var sqlFac = &SingletonFactory{
creatorFunction: func() storage.Store {
return &sql.Store{}
},
}
var storeFactorys = map[string]StorageFactory{ var storeFactorys = map[string]StorageFactory{
"boltdb": &SingletonFactory{ "boltdb": &SingletonFactory{
creatorFunction: func() storage.Store { creatorFunction: func() storage.Store {
@ -29,16 +35,8 @@ var storeFactorys = map[string]StorageFactory{
return &redis.Store{} return &redis.Store{}
}, },
}, },
"mysql": &SingletonFactory{ "mysql": sqlFac,
creatorFunction: func() storage.Store { "postgres": sqlFac,
return &sql.Store{}
},
},
"postgres": &SingletonFactory{
creatorFunction: func() storage.Store {
return &sql.Store{}
},
},
} }
// GetStore returns storage.Store // GetStore returns storage.Store

Loading…
Cancel
Save