github.com/coincircle/mattermost-server@v4.8.1-0.20180321182714-9d701c704416+incompatible/app/options.go (about) 1 // Copyright (c) 2017-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package app 5 6 import ( 7 "github.com/mattermost/mattermost-server/store" 8 ) 9 10 type Option func(a *App) 11 12 // By default, the app will use the store specified by the configuration. This allows you to 13 // construct an app with a different store. 14 // 15 // The override parameter must be either a store.Store or func(App) store.Store. 16 func StoreOverride(override interface{}) Option { 17 return func(a *App) { 18 switch o := override.(type) { 19 case store.Store: 20 a.newStore = func() store.Store { 21 return o 22 } 23 case func(*App) store.Store: 24 a.newStore = func() store.Store { 25 return o(a) 26 } 27 default: 28 panic("invalid StoreOverride") 29 } 30 } 31 } 32 33 func ConfigFile(file string) Option { 34 return func(a *App) { 35 a.configFile = file 36 } 37 } 38 39 func DisableConfigWatch(a *App) { 40 a.disableConfigWatch = true 41 }