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
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1bcf08aa4b
Коммит
da265fbaf7
@@ -7,22 +7,22 @@ import (
|
||||
"github.com/mattermost/mattermost-server/store"
|
||||
)
|
||||
|
||||
type Option func(a *App)
|
||||
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(a *App) {
|
||||
return func(s *Server) {
|
||||
switch o := override.(type) {
|
||||
case store.Store:
|
||||
a.Srv.newStore = func() store.Store {
|
||||
s.newStore = func() store.Store {
|
||||
return o
|
||||
}
|
||||
case func(*App) store.Store:
|
||||
a.Srv.newStore = func() store.Store {
|
||||
return o(a)
|
||||
case func(*Server) store.Store:
|
||||
s.newStore = func() store.Store {
|
||||
return o(s)
|
||||
}
|
||||
default:
|
||||
panic("invalid StoreOverride")
|
||||
@@ -31,11 +31,34 @@ func StoreOverride(override interface{}) Option {
|
||||
}
|
||||
|
||||
func ConfigFile(file string) Option {
|
||||
return func(a *App) {
|
||||
a.Srv.configFile = file
|
||||
return func(s *Server) {
|
||||
s.configFile = file
|
||||
}
|
||||
}
|
||||
|
||||
func DisableConfigWatch(a *App) {
|
||||
a.Srv.disableConfigWatch = true
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user