Files
mattermost/app/options.go
Christopher Speller da265fbaf7 Moving app from singular to being created for every request (#9889)
* Moving app from singular to being created for every request.

* Automatic refactor

* Adding license header

* Feedback fixes
2018-11-28 10:56:21 -08:00

65 lines
1.4 KiB
Go

// 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(s *Server)
// By default, the app will use the store specified by the configuration. This allows you to
// construct an app with a different store.
//
// The override parameter must be either a store.Store or func(App) store.Store.
func StoreOverride(override interface{}) Option {
return func(s *Server) {
switch o := override.(type) {
case store.Store:
s.newStore = func() store.Store {
return o
}
case func(*Server) store.Store:
s.newStore = func() store.Store {
return o(s)
}
default:
panic("invalid StoreOverride")
}
}
}
func ConfigFile(file string) Option {
return func(s *Server) {
s.configFile = file
}
}
func DisableConfigWatch(s *Server) {
s.disableConfigWatch = true
}
type AppOption func(a *App)
type AppOptionCreator func() []AppOption
func ServerConnector(s *Server) AppOption {
return func(a *App) {
a.Srv = s
a.Log = s.Log
a.HTTPService = s.HTTPService
a.AccountMigration = s.AccountMigration
a.Cluster = s.Cluster
a.Compliance = s.Compliance
a.DataRetention = s.DataRetention
a.Elasticsearch = s.Elasticsearch
a.Ldap = s.Ldap
a.MessageExport = s.MessageExport
a.Metrics = s.Metrics
a.Mfa = s.Mfa
a.Saml = s.Saml
}
}