You've already forked focalboard
mirror of
https://github.com/mattermost/focalboard.git
synced 2025-09-16 08:56:19 +02:00
Multi product architecture (#3381)
- provides support for compiling Boards directly into the Mattermost suite server - a ServicesAPI interface replaces the PluginAPI to allow for implementations coming from pluginAPI and suite server. - a new product package provides a place to register Boards as a suite product and handles life-cycle events - a new boards package replaces much of the mattermost-plugin logic, allowing this to be shared between plugin and product - Boards now uses module workspaces; run make setup-go-work
This commit is contained in:
committed by
GitHub
parent
3d753a15e5
commit
4b0fb92fba
@@ -13,7 +13,6 @@ import (
|
||||
"github.com/mattermost/focalboard/server/utils"
|
||||
|
||||
mmModel "github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/plugin"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
)
|
||||
|
||||
@@ -35,11 +34,11 @@ type PluginAdapterInterface interface {
|
||||
}
|
||||
|
||||
type PluginAdapter struct {
|
||||
api plugin.API
|
||||
api servicesAPI
|
||||
auth auth.AuthInterface
|
||||
staleThreshold time.Duration
|
||||
store Store
|
||||
logger *mlog.Logger
|
||||
logger mlog.LoggerIFace
|
||||
|
||||
listenersMU sync.RWMutex
|
||||
listeners map[string]*PluginAdapterClient
|
||||
@@ -50,7 +49,14 @@ type PluginAdapter struct {
|
||||
listenersByBlock map[string][]*PluginAdapterClient
|
||||
}
|
||||
|
||||
func NewPluginAdapter(api plugin.API, auth auth.AuthInterface, store Store, logger *mlog.Logger) *PluginAdapter {
|
||||
// servicesAPI is the interface required by the PluginAdapter to interact with
|
||||
// the mattermost-server.
|
||||
type servicesAPI interface {
|
||||
PublishWebSocketEvent(event string, payload map[string]interface{}, broadcast *mmModel.WebsocketBroadcast)
|
||||
PublishPluginClusterEvent(ev mmModel.PluginClusterEvent, opts mmModel.PluginClusterEventSendOptions) error
|
||||
}
|
||||
|
||||
func NewPluginAdapter(api servicesAPI, auth auth.AuthInterface, store Store, logger mlog.LoggerIFace) *PluginAdapter {
|
||||
return &PluginAdapter{
|
||||
api: api,
|
||||
auth: auth,
|
||||
|
@@ -4,6 +4,7 @@ import (
|
||||
"encoding/json"
|
||||
|
||||
mmModel "github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||
)
|
||||
|
||||
type ClusterMessage struct {
|
||||
@@ -16,9 +17,9 @@ type ClusterMessage struct {
|
||||
func (pa *PluginAdapter) sendMessageToCluster(id string, clusterMessage *ClusterMessage) {
|
||||
b, err := json.Marshal(clusterMessage)
|
||||
if err != nil {
|
||||
pa.api.LogError("couldn't get JSON bytes from cluster message",
|
||||
"id", id,
|
||||
"err", err,
|
||||
pa.logger.Error("couldn't get JSON bytes from cluster message",
|
||||
mlog.String("id", id),
|
||||
mlog.Err(err),
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -29,21 +30,21 @@ func (pa *PluginAdapter) sendMessageToCluster(id string, clusterMessage *Cluster
|
||||
}
|
||||
|
||||
if err := pa.api.PublishPluginClusterEvent(event, opts); err != nil {
|
||||
pa.api.LogError("error publishing cluster event",
|
||||
"id", id,
|
||||
"err", err,
|
||||
pa.logger.Error("error publishing cluster event",
|
||||
mlog.String("id", id),
|
||||
mlog.Err(err),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
func (pa *PluginAdapter) HandleClusterEvent(ev mmModel.PluginClusterEvent) {
|
||||
pa.api.LogDebug("received cluster event", "id", ev.Id)
|
||||
pa.logger.Debug("received cluster event", mlog.String("id", ev.Id))
|
||||
|
||||
var clusterMessage ClusterMessage
|
||||
if err := json.Unmarshal(ev.Data, &clusterMessage); err != nil {
|
||||
pa.api.LogError("cannot unmarshal cluster message data",
|
||||
"id", ev.Id,
|
||||
"err", err,
|
||||
pa.logger.Error("cannot unmarshal cluster message data",
|
||||
mlog.String("id", ev.Id),
|
||||
mlog.Err(err),
|
||||
)
|
||||
return
|
||||
}
|
||||
@@ -61,9 +62,9 @@ func (pa *PluginAdapter) HandleClusterEvent(ev mmModel.PluginClusterEvent) {
|
||||
}
|
||||
if action == "" {
|
||||
// no action was specified in the event; assume block change and warn.
|
||||
pa.api.LogWarn("cannot determine action from cluster message data",
|
||||
"id", ev.Id,
|
||||
"payload", clusterMessage.Payload,
|
||||
pa.logger.Warn("cannot determine action from cluster message data",
|
||||
mlog.String("id", ev.Id),
|
||||
mlog.Map("payload", clusterMessage.Payload),
|
||||
)
|
||||
return
|
||||
}
|
||||
|
@@ -51,7 +51,7 @@ type Server struct {
|
||||
auth *auth.Auth
|
||||
singleUserToken string
|
||||
isMattermostAuth bool
|
||||
logger *mlog.Logger
|
||||
logger mlog.LoggerIFace
|
||||
store Store
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ func (wss *websocketSession) isAuthenticated() bool {
|
||||
}
|
||||
|
||||
// NewServer creates a new Server.
|
||||
func NewServer(auth *auth.Auth, singleUserToken string, isMattermostAuth bool, logger *mlog.Logger, store Store) *Server {
|
||||
func NewServer(auth *auth.Auth, singleUserToken string, isMattermostAuth bool, logger mlog.LoggerIFace, store Store) *Server {
|
||||
return &Server{
|
||||
listeners: make(map[*websocketSession]bool),
|
||||
listenersByTeam: make(map[string][]*websocketSession),
|
||||
|
Reference in New Issue
Block a user