Move cluster, webhub and store out of Server (#20899)

Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2022-10-06 11:04:21 +03:00
коммит произвёл GitHub
родитель 203df2f537
Коммит 5e69c6b02f
222 изменённых файлов: 9093 добавлений и 7710 удалений

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

@@ -5,18 +5,20 @@ package wsapi
import (
"github.com/mattermost/mattermost-server/v6/app"
"github.com/mattermost/mattermost-server/v6/app/platform"
)
type API struct {
App *app.App
Router *app.WebSocketRouter
Router *platform.WebSocketRouter
}
func Init(s *app.Server) {
a := app.New(app.ServerConnector(s.Channels()))
router := s.Platform().WebSocketRouter
api := &API{
App: a,
Router: s.WebSocketRouter,
Router: router,
}
api.InitUser()

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

@@ -14,7 +14,7 @@ func (api *API) InitStatus() {
}
func (api *API) getStatuses(req *model.WebSocketRequest) (map[string]any, *model.AppError) {
statusMap := api.App.GetAllStatuses()
statusMap := api.App.Srv().Platform().GetAllStatuses()
return model.StatusMapToInterfaceMap(statusMap), nil
}
@@ -25,7 +25,7 @@ func (api *API) getStatusesByIds(req *model.WebSocketRequest) (map[string]any, *
return nil, NewInvalidWebSocketParamError(req.Action, "user_ids")
}
statusMap, err := api.App.GetStatusesByIds(userIds)
statusMap, err := api.App.Srv().Platform().GetStatusesByIds(userIds)
if err != nil {
return nil, err
}

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

@@ -16,7 +16,7 @@ func (api *API) InitUser() {
func (api *API) userTyping(req *model.WebSocketRequest) (map[string]any, *model.AppError) {
api.App.ExtendSessionExpiryIfNeeded(&req.Session)
if api.App.Srv().Busy.IsBusy() {
if api.App.Srv().Platform().Busy.IsBusy() {
// this is considered a non-critical service and will be disabled when server busy.
return nil, NewServerBusyWebSocketError(req.Action)
}

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

@@ -7,6 +7,7 @@ import (
"net/http"
"github.com/mattermost/mattermost-server/v6/app"
"github.com/mattermost/mattermost-server/v6/app/platform"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/shared/i18n"
"github.com/mattermost/mattermost-server/v6/shared/mlog"
@@ -21,10 +22,10 @@ type webSocketHandler struct {
handlerFunc func(*model.WebSocketRequest) (map[string]any, *model.AppError)
}
func (wh webSocketHandler) ServeWebSocket(conn *app.WebConn, r *model.WebSocketRequest) {
func (wh webSocketHandler) ServeWebSocket(conn *platform.WebConn, r *model.WebSocketRequest) {
mlog.Debug("Websocket request", mlog.String("action", r.Action))
hub := wh.app.GetHubForUserId(conn.UserId)
hub := wh.app.Srv().Platform().GetHubForUserId(conn.UserId)
if hub == nil {
return
}