2017-10-09 14:59:48 -07:00
|
|
|
// Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
|
// See License.txt for license information.
|
|
|
|
|
|
|
|
|
|
package app
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"github.com/mattermost/mattermost-server/store"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Option func(a *App)
|
|
|
|
|
|
|
|
|
|
// By default, the app will use the store specified by the configuration. This allows you to
|
|
|
|
|
// construct an app with a different store.
|
|
|
|
|
//
|
2017-10-16 08:09:43 -07:00
|
|
|
// The override parameter must be either a store.Store or func(App) store.Store.
|
|
|
|
|
func StoreOverride(override interface{}) Option {
|
2017-10-09 14:59:48 -07:00
|
|
|
return func(a *App) {
|
2017-10-16 08:09:43 -07:00
|
|
|
switch o := override.(type) {
|
2017-10-09 14:59:48 -07:00
|
|
|
case store.Store:
|
|
|
|
|
a.newStore = func() store.Store {
|
2017-10-16 08:09:43 -07:00
|
|
|
return o
|
2017-10-09 14:59:48 -07:00
|
|
|
}
|
2017-10-12 12:24:54 -07:00
|
|
|
case func(*App) store.Store:
|
|
|
|
|
a.newStore = func() store.Store {
|
2017-10-16 08:09:43 -07:00
|
|
|
return o(a)
|
2017-10-12 12:24:54 -07:00
|
|
|
}
|
2017-10-09 14:59:48 -07:00
|
|
|
default:
|
|
|
|
|
panic("invalid StoreOverride")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-11-16 08:40:26 -06:00
|
|
|
|
|
|
|
|
func ConfigFile(file string) Option {
|
|
|
|
|
return func(a *App) {
|
|
|
|
|
a.configFile = file
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-01-11 15:23:41 -06:00
|
|
|
|
|
|
|
|
func DisableConfigWatch(a *App) {
|
|
|
|
|
a.disableConfigWatch = true
|
|
|
|
|
}
|