Fail vs. fatal on store startup (#24170)
If the store fails to initialize (e.g. run a migration), it would `log.Fatal` and then `os.Exit`. Unfortunately, this trips up `TestMain`, which happily keeps running tests, now guaranteed to fail. Avoid this by instead returning an error from the store initialization, handling appropriately at the layer above.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c030bb44f5
Коммит
e39b485c4b
@@ -204,7 +204,11 @@ func New(sc ServiceConfig, options ...Option) (*PlatformService, error) {
|
||||
// Timer layer
|
||||
// |
|
||||
// Cache layer
|
||||
ps.sqlStore = sqlstore.New(ps.Config().SqlSettings, ps.metricsIFace)
|
||||
var err error
|
||||
ps.sqlStore, err = sqlstore.New(ps.Config().SqlSettings, ps.metricsIFace)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
searchStore := searchlayer.NewSearchLayer(
|
||||
retrylayer.New(ps.sqlStore),
|
||||
|
||||
@@ -31,7 +31,10 @@ func (p *MyPlugin) OnConfigurationChange() error {
|
||||
func (p *MyPlugin) MessageWillBePosted(_ *plugin.Context, _ *model.Post) (*model.Post, string) {
|
||||
settings := p.API.GetUnsanitizedConfig().SqlSettings
|
||||
settings.Trace = model.NewBool(false)
|
||||
store := sqlstore.New(settings, nil)
|
||||
store, err := sqlstore.New(settings, nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
store.GetMasterX().Close()
|
||||
|
||||
for _, isMaster := range []bool{true, false} {
|
||||
|
||||
Ссылка в новой задаче
Block a user