MM-27169: Remove uneeded fields from App (#15408)

* MM-27169: Remove uneeded fields from App

https://mattermost.atlassian.net/browse/MM-27169

* run app-layers

* Bring back searchengine

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Agniva De Sarker
2020-09-16 21:46:44 +05:30
коммит произвёл GitHub
родитель f0fc51244c
Коммит b329635b23
4 изменённых файлов: 23 добавлений и 41 удалений

Просмотреть файл

@@ -27,8 +27,10 @@ import (
type App struct {
srv *Server
log *mlog.Logger
notificationsLog *mlog.Logger
// XXX: This is required because removing this needs BleveEngine
// to be registered in (h *MainHelper) setupStore, but that creates
// a cyclic dependency as bleve tests themselves import testlib.
searchEngine *searchengine.Broker
t goi18n.TranslateFunc
session model.Session
@@ -38,17 +40,6 @@ type App struct {
userAgent string
acceptLanguage string
cluster einterfaces.ClusterInterface
compliance einterfaces.ComplianceInterface
dataRetention einterfaces.DataRetentionInterface
searchEngine *searchengine.Broker
messageExport einterfaces.MessageExportInterface
metrics einterfaces.MetricsInterface
httpService httpservice.HTTPService
imageProxy *imageproxy.ImageProxy
timezones *timezones.Timezones
context context.Context
}
@@ -426,10 +417,10 @@ func (a *App) Srv() *Server {
return a.srv
}
func (a *App) Log() *mlog.Logger {
return a.log
return a.srv.Log
}
func (a *App) NotificationsLog() *mlog.Logger {
return a.notificationsLog
return a.srv.NotificationsLog
}
func (a *App) T(translationID string, args ...interface{}) string {
return a.t(translationID, args...)
@@ -456,13 +447,13 @@ func (a *App) AccountMigration() einterfaces.AccountMigrationInterface {
return a.srv.AccountMigration
}
func (a *App) Cluster() einterfaces.ClusterInterface {
return a.cluster
return a.srv.Cluster
}
func (a *App) Compliance() einterfaces.ComplianceInterface {
return a.compliance
return a.srv.Compliance
}
func (a *App) DataRetention() einterfaces.DataRetentionInterface {
return a.dataRetention
return a.srv.DataRetention
}
func (a *App) SearchEngine() *searchengine.Broker {
return a.searchEngine
@@ -471,10 +462,10 @@ func (a *App) Ldap() einterfaces.LdapInterface {
return a.srv.Ldap
}
func (a *App) MessageExport() einterfaces.MessageExportInterface {
return a.messageExport
return a.srv.MessageExport
}
func (a *App) Metrics() einterfaces.MetricsInterface {
return a.metrics
return a.srv.Metrics
}
func (a *App) Notification() einterfaces.NotificationInterface {
return a.srv.Notification
@@ -483,13 +474,13 @@ func (a *App) Saml() einterfaces.SamlInterface {
return a.srv.Saml
}
func (a *App) HTTPService() httpservice.HTTPService {
return a.httpService
return a.srv.HTTPService
}
func (a *App) ImageProxy() *imageproxy.ImageProxy {
return a.imageProxy
return a.srv.ImageProxy
}
func (a *App) Timezones() *timezones.Timezones {
return a.timezones
return a.srv.timezones
}
func (a *App) Context() context.Context {
return a.context
@@ -526,6 +517,8 @@ func (a *App) SetServer(srv *Server) {
func (a *App) GetT() goi18n.TranslateFunc {
return a.t
}
// TODO: change this to make a server method.
func (a *App) SetLog(l *mlog.Logger) {
a.log = l
a.srv.Log = l
}

Просмотреть файл

@@ -296,6 +296,8 @@ type AppIface interface {
// the member's group memberships and the configuration of those groups to the syncable. This method should only
// be invoked on group-synced (aka group-constrained) syncables.
SyncSyncableRoles(syncableID string, syncableType model.GroupSyncableType) *model.AppError
// TODO: change this to make a server method.
SetLog(l *mlog.Logger)
// TeamMembersMinusGroupMembers returns the set of users on the given team minus the set of users in the given
// groups.
//
@@ -893,7 +895,6 @@ type AppIface interface {
SetContext(c context.Context)
SetDefaultProfileImage(user *model.User) *model.AppError
SetIpAddress(s string)
SetLog(l *mlog.Logger)
SetPath(s string)
SetPhase2PermissionsMigrationStatus(isComplete bool) error
SetPluginKey(pluginId string, key string, value []byte) *model.AppError

Просмотреть файл

@@ -97,18 +97,6 @@ type AppOptionCreator func() []AppOption
func ServerConnector(s *Server) AppOption {
return func(a *App) {
a.srv = s
a.log = s.Log
a.notificationsLog = s.NotificationsLog
a.cluster = s.Cluster
a.compliance = s.Compliance
a.dataRetention = s.DataRetention
a.searchEngine = s.SearchEngine
a.messageExport = s.MessageExport
a.metrics = s.Metrics
a.httpService = s.HTTPService
a.imageProxy = s.ImageProxy
a.timezones = s.timezones
}
}

Просмотреть файл

@@ -31,6 +31,10 @@ func (a *App) TestElasticsearch(cfg *model.Config) *model.AppError {
return nil
}
func (a *App) SetSearchEngine(se *searchengine.Broker) {
a.searchEngine = se
}
func (a *App) PurgeElasticsearchIndexes() *model.AppError {
engine := a.SearchEngine().ElasticsearchEngine
if engine == nil {
@@ -56,7 +60,3 @@ func (a *App) PurgeBleveIndexes() *model.AppError {
}
return nil
}
func (a *App) SetSearchEngine(se *searchengine.Broker) {
a.searchEngine = se
}