This reverts commit 280bc7f97e.
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6a9c4ad56b
Коммит
ea3ff49b35
@@ -633,7 +633,6 @@ type AppIface interface {
|
||||
GetComplianceReports(page, perPage int) (model.Compliances, *model.AppError)
|
||||
GetCookieDomain() string
|
||||
GetCustomStatus(userID string) (*model.CustomStatus, *model.AppError)
|
||||
GetDebugBarInfo() (*model.DebugBarInfo, *model.AppError)
|
||||
GetDefaultProfileImage(user *model.User) ([]byte, *model.AppError)
|
||||
GetDeletedChannels(c request.CTX, teamID string, offset int, limit int, userID string) (model.ChannelList, *model.AppError)
|
||||
GetDraft(userID, channelID, rootID string) (*model.Draft, *model.AppError)
|
||||
@@ -741,7 +740,6 @@ type AppIface interface {
|
||||
GetProfileImage(user *model.User) ([]byte, bool, *model.AppError)
|
||||
GetPublicChannelsByIdsForTeam(c request.CTX, teamID string, channelIDs []string) (model.ChannelList, *model.AppError)
|
||||
GetPublicChannelsForTeam(c request.CTX, teamID string, offset int, limit int) (model.ChannelList, *model.AppError)
|
||||
GetQueryExplain(query string, args []interface{}) (string, *model.AppError)
|
||||
GetReactionsForPost(postID string) ([]*model.Reaction, *model.AppError)
|
||||
GetRecentSearchesForUser(userID string) ([]*model.SearchParams, *model.AppError)
|
||||
GetRecentlyActiveUsersForTeam(teamID string) (map[string]*model.User, *model.AppError)
|
||||
|
||||
@@ -1,87 +0,0 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package app
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"runtime"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
)
|
||||
|
||||
func (a *App) GetDebugBarInfo() (*model.DebugBarInfo, *model.AppError) {
|
||||
sessionsCount, err := a.Srv().Store().Session().AnalyticsSessionCount()
|
||||
if err != nil {
|
||||
return nil, model.NewAppError("GetDebugBarInfo", "debugbar.info.session-count.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
// Here we are getting information regarding Elastic Search
|
||||
var elasticServerVersion string
|
||||
var elasticServerPlugins []string
|
||||
if a.Srv().Platform().SearchEngine.ElasticsearchEngine != nil {
|
||||
elasticServerVersion = a.Srv().Platform().SearchEngine.ElasticsearchEngine.GetFullVersion()
|
||||
elasticServerPlugins = a.Srv().Platform().SearchEngine.ElasticsearchEngine.GetPlugins()
|
||||
}
|
||||
|
||||
// Here we are getting information regarding LDAP
|
||||
ldapInterface := a.Channels().Ldap
|
||||
var vendorName, vendorVersion string
|
||||
if ldapInterface != nil {
|
||||
vendorName, vendorVersion = ldapInterface.GetVendorNameAndVendorVersion()
|
||||
}
|
||||
|
||||
// Here we are getting information regarding the database (mysql/postgres + current schema version)
|
||||
databaseType, databaseVersion := a.Srv().DatabaseTypeAndSchemaVersion()
|
||||
|
||||
info := model.DebugBarInfo{
|
||||
SessionsCount: sessionsCount,
|
||||
GoVersion: runtime.Version(),
|
||||
Goroutines: runtime.NumGoroutine(),
|
||||
Cpus: runtime.NumCPU(),
|
||||
CgoCalls: runtime.NumCgoCall(),
|
||||
ServerOS: runtime.GOOS,
|
||||
ServerArchitecture: runtime.GOARCH,
|
||||
ServerVersion: model.CurrentVersion,
|
||||
BuildHash: model.BuildHash,
|
||||
DatabaseType: databaseType,
|
||||
DatabaseVersion: databaseVersion,
|
||||
LdapVendorName: vendorName,
|
||||
LdapVendorVersion: vendorVersion,
|
||||
ElasticServerVersion: elasticServerVersion,
|
||||
ElasticServerPlugins: elasticServerPlugins,
|
||||
}
|
||||
|
||||
runtime.ReadMemStats(&info.GoMemStats)
|
||||
|
||||
totalSockets := a.TotalWebsocketConnections()
|
||||
totalMasterDb := a.Srv().Store().TotalMasterDbConnections()
|
||||
totalReadDb := a.Srv().Store().TotalReadDbConnections()
|
||||
|
||||
// If in HA mode then aggregate all the stats
|
||||
if a.Cluster() != nil && *a.Config().ClusterSettings.Enable {
|
||||
stats, appErr := a.Cluster().GetClusterStats()
|
||||
if appErr != nil {
|
||||
return nil, appErr
|
||||
}
|
||||
|
||||
for _, stat := range stats {
|
||||
totalSockets = totalSockets + stat.TotalWebsocketConnections
|
||||
totalMasterDb = totalMasterDb + stat.TotalMasterDbConnections
|
||||
totalReadDb = totalReadDb + stat.TotalReadDbConnections
|
||||
}
|
||||
}
|
||||
|
||||
info.WebSocketConnections = totalSockets
|
||||
info.MasterDBConnections = totalMasterDb
|
||||
info.ReadDBConnections = totalReadDb
|
||||
|
||||
return &info, nil
|
||||
}
|
||||
|
||||
func (a *App) GetQueryExplain(query string, args []interface{}) (string, *model.AppError) {
|
||||
explain, err := a.Srv().Store().Explain(query, args)
|
||||
if err != nil {
|
||||
return "", model.NewAppError("GetQueryExplain", "debugbar.query_explain.error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
return explain, nil
|
||||
}
|
||||
@@ -861,11 +861,7 @@ func (es *Service) sendEmailWithCustomReplyTo(to, subject, htmlBody, replyToAddr
|
||||
|
||||
category = getSendGridCategory(category, license.IsCloud())
|
||||
|
||||
err := mail.SendMailUsingConfig(to, subject, htmlBody, mailConfig, license != nil && *license.Features.Compliance, "", "", "", "", category)
|
||||
if es.debugBar != nil && es.debugBar() != nil && es.debugBar().IsEnabled() {
|
||||
es.debugBar().SendEmailSent(to, subject, htmlBody, nil, mailConfig, license != nil && *license.Features.Compliance, "", "", "", "", category, err)
|
||||
}
|
||||
return err
|
||||
return mail.SendMailUsingConfig(to, subject, htmlBody, mailConfig, license != nil && *license.Features.Compliance, "", "", "", "", category)
|
||||
}
|
||||
|
||||
func (es *Service) sendMailWithCC(to, subject, htmlBody, ccMail, category string) error {
|
||||
@@ -874,11 +870,7 @@ func (es *Service) sendMailWithCC(to, subject, htmlBody, ccMail, category string
|
||||
|
||||
category = getSendGridCategory(category, license.IsCloud())
|
||||
|
||||
err := mail.SendMailUsingConfig(to, subject, htmlBody, mailConfig, license != nil && *license.Features.Compliance, "", "", "", ccMail, category)
|
||||
if es.debugBar != nil && es.debugBar() != nil && es.debugBar().IsEnabled() {
|
||||
es.debugBar().SendEmailSent(to, subject, htmlBody, nil, mailConfig, license != nil && *license.Features.Compliance, "", "", "", ccMail, category, err)
|
||||
}
|
||||
return err
|
||||
return mail.SendMailUsingConfig(to, subject, htmlBody, mailConfig, license != nil && *license.Features.Compliance, "", "", "", ccMail, category)
|
||||
}
|
||||
|
||||
func (es *Service) SendMailWithEmbeddedFilesAndCustomReplyTo(to, subject, htmlBody, replyToAddress string, embeddedFiles map[string]io.Reader, category string) error {
|
||||
@@ -887,11 +879,7 @@ func (es *Service) SendMailWithEmbeddedFilesAndCustomReplyTo(to, subject, htmlBo
|
||||
|
||||
category = getSendGridCategory(category, license.IsCloud())
|
||||
|
||||
err := mail.SendMailWithEmbeddedFilesUsingConfig(to, subject, htmlBody, embeddedFiles, mailConfig, license != nil && *license.Features.Compliance, "", "", "", "", category)
|
||||
if es.debugBar != nil && es.debugBar() != nil && es.debugBar().IsEnabled() {
|
||||
es.debugBar().SendEmailSent(to, subject, htmlBody, embeddedFiles, mailConfig, license != nil && *license.Features.Compliance, "", "", "", "", category, err)
|
||||
}
|
||||
return err
|
||||
return mail.SendMailWithEmbeddedFilesUsingConfig(to, subject, htmlBody, embeddedFiles, mailConfig, license != nil && *license.Features.Compliance, "", "", "", "", category)
|
||||
}
|
||||
|
||||
func (es *Service) SendMailWithEmbeddedFiles(to, subject, htmlBody string, embeddedFiles map[string]io.Reader, messageID string, inReplyTo string, references string, category string) error {
|
||||
@@ -900,11 +888,7 @@ func (es *Service) SendMailWithEmbeddedFiles(to, subject, htmlBody string, embed
|
||||
|
||||
category = getSendGridCategory(category, license.IsCloud())
|
||||
|
||||
err := mail.SendMailWithEmbeddedFilesUsingConfig(to, subject, htmlBody, embeddedFiles, mailConfig, license != nil && *license.Features.Compliance, messageID, inReplyTo, references, "", category)
|
||||
if es.debugBar != nil && es.debugBar() != nil && es.debugBar().IsEnabled() {
|
||||
es.debugBar().SendEmailSent(to, subject, htmlBody, embeddedFiles, mailConfig, license != nil && *license.Features.Compliance, messageID, inReplyTo, references, "", category, err)
|
||||
}
|
||||
return err
|
||||
return mail.SendMailWithEmbeddedFilesUsingConfig(to, subject, htmlBody, embeddedFiles, mailConfig, license != nil && *license.Features.Compliance, messageID, inReplyTo, references, "", category)
|
||||
}
|
||||
|
||||
func (es *Service) InvalidateVerifyEmailTokensForUser(userID string) *model.AppError {
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"github.com/throttled/throttled"
|
||||
"github.com/throttled/throttled/store/memstore"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/app/platform/debugbar"
|
||||
"github.com/mattermost/mattermost-server/v6/app/users"
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/i18n"
|
||||
@@ -43,9 +42,8 @@ func condenseSiteURL(siteURL string) string {
|
||||
}
|
||||
|
||||
type Service struct {
|
||||
config func() *model.Config
|
||||
license func() *model.License
|
||||
debugBar func() *debugbar.DebugBar
|
||||
config func() *model.Config
|
||||
license func() *model.License
|
||||
|
||||
userService *users.UserService
|
||||
store store.Store
|
||||
@@ -59,7 +57,6 @@ type Service struct {
|
||||
type ServiceConfig struct {
|
||||
ConfigFn func() *model.Config
|
||||
LicenseFn func() *model.License
|
||||
DebugBar func() *debugbar.DebugBar
|
||||
|
||||
TemplatesContainer *templates.Container
|
||||
UserService *users.UserService
|
||||
@@ -74,7 +71,6 @@ func NewService(config ServiceConfig) (*Service, error) {
|
||||
config: config.ConfigFn,
|
||||
templatesContainer: config.TemplatesContainer,
|
||||
license: config.LicenseFn,
|
||||
debugBar: config.DebugBar,
|
||||
store: config.Store,
|
||||
userService: config.UserService,
|
||||
}
|
||||
|
||||
@@ -5872,28 +5872,6 @@ func (a *OpenTracingAppLayer) GetCustomStatus(userID string) (*model.CustomStatu
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetDebugBarInfo() (*model.DebugBarInfo, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetDebugBarInfo")
|
||||
|
||||
a.ctx = newCtx
|
||||
a.app.Srv().Store().SetContext(newCtx)
|
||||
defer func() {
|
||||
a.app.Srv().Store().SetContext(origCtx)
|
||||
a.ctx = origCtx
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.GetDebugBarInfo()
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
ext.Error.Set(span, true)
|
||||
}
|
||||
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetDefaultProfileImage(user *model.User) ([]byte, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetDefaultProfileImage")
|
||||
@@ -8582,28 +8560,6 @@ func (a *OpenTracingAppLayer) GetPublicKey(name string) ([]byte, *model.AppError
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetQueryExplain(query string, args []interface{}) (string, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetQueryExplain")
|
||||
|
||||
a.ctx = newCtx
|
||||
a.app.Srv().Store().SetContext(newCtx)
|
||||
defer func() {
|
||||
a.app.Srv().Store().SetContext(origCtx)
|
||||
a.ctx = origCtx
|
||||
}()
|
||||
|
||||
defer span.Finish()
|
||||
resultVar0, resultVar1 := a.app.GetQueryExplain(query, args)
|
||||
|
||||
if resultVar1 != nil {
|
||||
span.LogFields(spanlog.Error(resultVar1))
|
||||
ext.Error.Set(span, true)
|
||||
}
|
||||
|
||||
return resultVar0, resultVar1
|
||||
}
|
||||
|
||||
func (a *OpenTracingAppLayer) GetReactionsForPost(postID string) ([]*model.Reaction, *model.AppError) {
|
||||
origCtx := a.ctx
|
||||
span, newCtx := tracing.StartSpanWithParentByContext(a.ctx, "app.GetReactionsForPost")
|
||||
|
||||
@@ -286,7 +286,6 @@ func (ps *PlatformService) LimitedClientConfigWithComputed() map[string]string {
|
||||
// These properties are not configurable, but nevertheless represent configuration expected
|
||||
// by the client.
|
||||
respCfg["NoAccounts"] = strconv.FormatBool(ps.IsFirstUserAccount())
|
||||
respCfg["DebugBar"] = strconv.FormatBool(ps.DebugBar.IsEnabled())
|
||||
|
||||
return respCfg
|
||||
}
|
||||
@@ -301,7 +300,6 @@ func (ps *PlatformService) ClientConfigWithComputed() map[string]string {
|
||||
// These properties are not configurable, but nevertheless represent configuration expected
|
||||
// by the client.
|
||||
respCfg["NoAccounts"] = strconv.FormatBool(ps.IsFirstUserAccount())
|
||||
respCfg["DebugBar"] = strconv.FormatBool(ps.DebugBar.IsEnabled())
|
||||
respCfg["MaxPostSize"] = strconv.Itoa(ps.MaxPostSize())
|
||||
respCfg["UpgradedFromTE"] = strconv.FormatBool(ps.isUpgradedFromTE())
|
||||
respCfg["InstallationDate"] = ""
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package debugbar
|
||||
|
||||
import (
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mail"
|
||||
)
|
||||
|
||||
const (
|
||||
socketEventName = "debugbar"
|
||||
)
|
||||
|
||||
type DebugBar struct {
|
||||
publish func(*model.WebSocketEvent)
|
||||
enabled bool
|
||||
}
|
||||
|
||||
func New(publish func(*model.WebSocketEvent)) *DebugBar {
|
||||
return &DebugBar{
|
||||
publish: publish,
|
||||
enabled: os.Getenv("MM_ENABLE_DEBUG_BAR") == "true",
|
||||
}
|
||||
}
|
||||
|
||||
func (db *DebugBar) IsEnabled() bool {
|
||||
return db.enabled
|
||||
}
|
||||
|
||||
func (db *DebugBar) SendLogEvent(logLevel string, logMessage string, fields map[string]string) {
|
||||
event := model.NewWebSocketEvent(socketEventName, "", "", "", nil, "")
|
||||
event.Add("time", model.GetMillis())
|
||||
event.Add("type", "log-line")
|
||||
event.Add("level", logLevel)
|
||||
event.Add("message", logMessage)
|
||||
event.Add("fields", fields)
|
||||
db.publish(event)
|
||||
}
|
||||
|
||||
func (db *DebugBar) SendApiCall(endpoint, method, statusCode string, elapsed float64) {
|
||||
if endpoint == "getSystemInfo" || endpoint == "getQueryExplain" {
|
||||
return
|
||||
}
|
||||
event := model.NewWebSocketEvent(socketEventName, "", "", "", nil, "")
|
||||
event.Add("time", model.GetMillis())
|
||||
event.Add("type", "api-call")
|
||||
event.Add("endpoint", endpoint)
|
||||
event.Add("method", method)
|
||||
event.Add("statusCode", statusCode)
|
||||
event.Add("duration", elapsed)
|
||||
db.publish(event)
|
||||
}
|
||||
|
||||
func (db *DebugBar) SendStoreCall(method string, success bool, elapsed float64, params map[string]any) {
|
||||
event := model.NewWebSocketEvent(socketEventName, "", "", "", nil, "")
|
||||
event.Add("time", model.GetMillis())
|
||||
event.Add("type", "store-call")
|
||||
event.Add("method", method)
|
||||
event.Add("params", params)
|
||||
event.Add("success", success)
|
||||
event.Add("duration", elapsed)
|
||||
db.publish(event)
|
||||
}
|
||||
|
||||
func (db *DebugBar) SendSqlQuery(query string, elapsed float64, args ...any) {
|
||||
if strings.HasPrefix(query, "EXPLAIN ") {
|
||||
return
|
||||
}
|
||||
event := model.NewWebSocketEvent(socketEventName, "", "", "", nil, "")
|
||||
event.Add("time", model.GetMillis())
|
||||
event.Add("type", "sql-query")
|
||||
event.Add("query", query)
|
||||
event.Add("args", args)
|
||||
event.Add("duration", elapsed)
|
||||
db.publish(event)
|
||||
}
|
||||
|
||||
func (db *DebugBar) SendEmailSent(to, subject, htmlBody string, embeddedFiles map[string]io.Reader, config *mail.SMTPConfig, enableComplianceFeatures bool, messageID string, inReplyTo string, references string, ccMail string, category string, err error) {
|
||||
event := model.NewWebSocketEvent(socketEventName, "", "", "", nil, "")
|
||||
event.Add("time", model.GetMillis())
|
||||
event.Add("type", "email-sent")
|
||||
event.Add("to", to)
|
||||
event.Add("subject", subject)
|
||||
event.Add("htmlBody", htmlBody)
|
||||
event.Add("embeddedFiles", embeddedFiles)
|
||||
event.Add("SMTPConfig", config)
|
||||
event.Add("enableComplianceFeatures", enableComplianceFeatures)
|
||||
event.Add("messageID", messageID)
|
||||
event.Add("inReplyTo", inReplyTo)
|
||||
event.Add("references", references)
|
||||
event.Add("cc", ccMail)
|
||||
event.Add("category", category)
|
||||
event.Add("err", err)
|
||||
db.publish(event)
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package debugbar
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
||||
"github.com/mattermost/logr/v2"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
)
|
||||
|
||||
type DebugBarLogTarget struct {
|
||||
debugBar *DebugBar
|
||||
}
|
||||
|
||||
type DebugBarLogFilter struct{}
|
||||
|
||||
func (_ *DebugBarLogFilter) GetEnabledLevel(level logr.Level) (logr.Level, bool) {
|
||||
return level, true
|
||||
}
|
||||
|
||||
type DebugBarLogFormatter struct{}
|
||||
|
||||
func (_ *DebugBarLogFormatter) IsStacktraceNeeded() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (_ *DebugBarLogFormatter) Format(rec *logr.LogRec, level logr.Level, buf *bytes.Buffer) (*bytes.Buffer, error) {
|
||||
return bytes.NewBuffer([]byte{}), nil
|
||||
}
|
||||
|
||||
func NewDebugBarLogTarget(debugBar *DebugBar) *DebugBarLogTarget {
|
||||
return &DebugBarLogTarget{debugBar: debugBar}
|
||||
}
|
||||
|
||||
func (dblt *DebugBarLogTarget) Init() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dblt *DebugBarLogTarget) Shutdown() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (dblt *DebugBarLogTarget) Write(p []byte, rec *logr.LogRec) (int, error) {
|
||||
dblt.debugBar.SendLogEvent(rec.Level().Name, rec.Msg(), dblt.fieldsToStringsMap(rec.Fields()...))
|
||||
return len(p), nil
|
||||
}
|
||||
|
||||
func (dblt *DebugBarLogTarget) fieldsToStringsMap(fields ...mlog.Field) map[string]string {
|
||||
result := map[string]string{}
|
||||
for _, field := range fields {
|
||||
value := &bytes.Buffer{}
|
||||
field.ValueString(value, nil)
|
||||
result[field.Key] = value.String()
|
||||
}
|
||||
return result
|
||||
}
|
||||
@@ -13,8 +13,6 @@ import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/mattermost/logr/v2"
|
||||
"github.com/mattermost/mattermost-server/v6/app/platform/debugbar"
|
||||
"github.com/mattermost/mattermost-server/v6/config"
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
@@ -80,13 +78,6 @@ func (ps *PlatformService) initLogging() error {
|
||||
}
|
||||
}
|
||||
|
||||
if ps.DebugBar.IsEnabled() {
|
||||
err := ps.logger.AddTarget(debugbar.NewDebugBarLogTarget(ps.DebugBar), "debugbar", &debugbar.DebugBarLogFilter{}, &debugbar.DebugBarLogFormatter{}, logr.DefaultMaxQueueSize)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,6 @@ import (
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/app/featureflag"
|
||||
"github.com/mattermost/mattermost-server/v6/app/platform/debugbar"
|
||||
"github.com/mattermost/mattermost-server/v6/config"
|
||||
"github.com/mattermost/mattermost-server/v6/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/jobs"
|
||||
@@ -24,7 +23,6 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v6/shared/filestore"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
"github.com/mattermost/mattermost-server/v6/store"
|
||||
"github.com/mattermost/mattermost-server/v6/store/debugbarlayer"
|
||||
"github.com/mattermost/mattermost-server/v6/store/localcachelayer"
|
||||
"github.com/mattermost/mattermost-server/v6/store/retrylayer"
|
||||
"github.com/mattermost/mattermost-server/v6/store/searchlayer"
|
||||
@@ -36,11 +34,9 @@ import (
|
||||
// responsible for non-entity related functionalities that are required
|
||||
// by a product such as database access, configuration access, licensing etc.
|
||||
type PlatformService struct {
|
||||
sqlStore *sqlstore.SqlStore
|
||||
DebugBar *debugbar.DebugBar
|
||||
Store store.Store
|
||||
newStore func() (store.Store, error)
|
||||
LastUserID string
|
||||
sqlStore *sqlstore.SqlStore
|
||||
Store store.Store
|
||||
newStore func() (store.Store, error)
|
||||
|
||||
WebSocketRouter *WebSocketRouter
|
||||
|
||||
@@ -129,7 +125,6 @@ func New(sc ServiceConfig, options ...Option) (*PlatformService, error) {
|
||||
licenseListeners: map[string]func(*model.License, *model.License){},
|
||||
additionalClusterHandlers: map[model.ClusterEvent]einterfaces.ClusterMessageHandler{},
|
||||
}
|
||||
ps.DebugBar = debugbar.New(ps.Publish)
|
||||
|
||||
// Step 1: Cache provider.
|
||||
// At the moment we only have this implementation
|
||||
@@ -191,7 +186,7 @@ func New(sc ServiceConfig, options ...Option) (*PlatformService, error) {
|
||||
// Depends on Step 0 (config), 1 (cacheProvider), 3 (search engine), 5 (metrics) and cluster.
|
||||
if ps.newStore == nil {
|
||||
ps.newStore = func() (store.Store, error) {
|
||||
ps.sqlStore = sqlstore.New(ps.Config().SqlSettings, ps.metricsIFace, ps.DebugBar.SendSqlQuery)
|
||||
ps.sqlStore = sqlstore.New(ps.Config().SqlSettings, ps.metricsIFace)
|
||||
|
||||
lcl, err2 := localcachelayer.NewLocalCacheLayer(
|
||||
retrylayer.New(ps.sqlStore),
|
||||
@@ -219,15 +214,10 @@ func New(sc ServiceConfig, options ...Option) (*PlatformService, error) {
|
||||
ps.sqlStore.UpdateLicense(newLicense)
|
||||
})
|
||||
|
||||
timerStore := timerlayer.New(
|
||||
return timerlayer.New(
|
||||
searchStore,
|
||||
ps.metricsIFace,
|
||||
)
|
||||
|
||||
if ps.DebugBar.IsEnabled() {
|
||||
return debugbarlayer.New(timerStore, ps.DebugBar), nil
|
||||
}
|
||||
return timerStore, nil
|
||||
), nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -142,8 +142,6 @@ func TestMetrics(t *testing.T) {
|
||||
mockMetricsImpl.On("Register").Return()
|
||||
mockMetricsImpl.On("ObserveStoreMethodDuration", mock.Anything, mock.Anything, mock.Anything).Return()
|
||||
mockMetricsImpl.On("RegisterDBCollector", mock.AnythingOfType("*sql.DB"), "master")
|
||||
mockMetricsImpl.On("IncrementWebsocketEvent", "debugbar")
|
||||
mockMetricsImpl.On("IncrementWebSocketBroadcastBufferSize", mock.AnythingOfType("string"), float64(1))
|
||||
|
||||
th := Setup(t, StartMetrics(), func(ps *PlatformService) error {
|
||||
ps.metricsIFace = mockMetricsImpl
|
||||
|
||||
@@ -31,7 +31,7 @@ func (p *MyPlugin) OnConfigurationChange() error {
|
||||
func (p *MyPlugin) MessageWillBePosted(_ *plugin.Context, _ *model.Post) (*model.Post, string) {
|
||||
settings := p.API.GetUnsanitizedConfig().SqlSettings
|
||||
settings.Trace = model.NewBool(false)
|
||||
store := sqlstore.New(settings, nil, nil)
|
||||
store := sqlstore.New(settings, nil)
|
||||
store.GetMasterX().Close()
|
||||
|
||||
for _, isMaster := range []bool{true, false} {
|
||||
|
||||
@@ -29,7 +29,6 @@ import (
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/app/email"
|
||||
"github.com/mattermost/mattermost-server/v6/app/platform"
|
||||
"github.com/mattermost/mattermost-server/v6/app/platform/debugbar"
|
||||
"github.com/mattermost/mattermost-server/v6/app/request"
|
||||
"github.com/mattermost/mattermost-server/v6/app/teams"
|
||||
"github.com/mattermost/mattermost-server/v6/app/users"
|
||||
@@ -144,14 +143,6 @@ type Server struct {
|
||||
hooksManager *product.HooksManager
|
||||
}
|
||||
|
||||
func (s *Server) DebugBar() *debugbar.DebugBar {
|
||||
if s.platform != nil {
|
||||
return s.platform.DebugBar
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) Store() store.Store {
|
||||
if s.platform != nil {
|
||||
return s.platform.Store
|
||||
@@ -375,7 +366,6 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
emailService, err := email.NewService(email.ServiceConfig{
|
||||
ConfigFn: s.platform.Config,
|
||||
LicenseFn: s.License,
|
||||
DebugBar: s.DebugBar,
|
||||
TemplatesContainer: s.TemplatesContainer(),
|
||||
UserService: s.userService,
|
||||
Store: s.GetStore(),
|
||||
|
||||
Ссылка в новой задаче
Block a user