Add KVStore service and Log service for Focalboard multi product architecture (#20563)
* add KVStore service, add Log service
Этот коммит содержится в:
@@ -14,6 +14,14 @@ import (
|
|||||||
"github.com/mattermost/mattermost-server/v6/store"
|
"github.com/mattermost/mattermost-server/v6/store"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
type kvStoreWrapper struct {
|
||||||
|
srv *Server
|
||||||
|
}
|
||||||
|
|
||||||
|
func (k *kvStoreWrapper) SetPluginKeyWithOptions(pluginID string, key string, value []byte, options model.PluginKVSetOptions) (bool, *model.AppError) {
|
||||||
|
return k.srv.setPluginKeyWithOptions(pluginID, key, value, options)
|
||||||
|
}
|
||||||
|
|
||||||
func getKeyHash(key string) string {
|
func getKeyHash(key string) string {
|
||||||
hash := sha256.New()
|
hash := sha256.New()
|
||||||
hash.Write([]byte(key))
|
hash.Write([]byte(key))
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ const (
|
|||||||
BotKey ServiceKey = "bot"
|
BotKey ServiceKey = "bot"
|
||||||
LogKey ServiceKey = "log"
|
LogKey ServiceKey = "log"
|
||||||
HooksKey ServiceKey = "hooks"
|
HooksKey ServiceKey = "hooks"
|
||||||
|
KVStoreKey ServiceKey = "kvstore"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
type Server struct {
|
||||||
@@ -369,10 +370,6 @@ func NewServer(options ...Option) (*Server, error) {
|
|||||||
}
|
}
|
||||||
s.filestore = backend
|
s.filestore = backend
|
||||||
|
|
||||||
channelWrapper := &channelsWrapper{
|
|
||||||
srv: s,
|
|
||||||
}
|
|
||||||
|
|
||||||
s.licenseWrapper = &licenseWrapper{
|
s.licenseWrapper = &licenseWrapper{
|
||||||
srv: s,
|
srv: s,
|
||||||
}
|
}
|
||||||
@@ -381,14 +378,6 @@ func NewServer(options ...Option) (*Server, error) {
|
|||||||
srv: s,
|
srv: s,
|
||||||
}
|
}
|
||||||
|
|
||||||
fileInfoWrapper := &fileInfoWrapper{
|
|
||||||
srv: s,
|
|
||||||
}
|
|
||||||
|
|
||||||
cloudWrapper := &cloudWrapper{
|
|
||||||
cloud: s.Cloud,
|
|
||||||
}
|
|
||||||
|
|
||||||
s.teamService, err = teams.New(teams.ServiceConfig{
|
s.teamService, err = teams.New(teams.ServiceConfig{
|
||||||
TeamStore: s.Store.Team(),
|
TeamStore: s.Store.Team(),
|
||||||
ChannelStore: s.Store.Channel(),
|
ChannelStore: s.Store.Channel(),
|
||||||
@@ -403,15 +392,16 @@ func NewServer(options ...Option) (*Server, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
serviceMap := map[ServiceKey]interface{}{
|
serviceMap := map[ServiceKey]interface{}{
|
||||||
ChannelKey: channelWrapper,
|
ChannelKey: &channelsWrapper{srv: s},
|
||||||
ConfigKey: s.configStore,
|
ConfigKey: s.configStore,
|
||||||
LicenseKey: s.licenseWrapper,
|
LicenseKey: s.licenseWrapper,
|
||||||
FilestoreKey: s.filestore,
|
FilestoreKey: s.filestore,
|
||||||
FileInfoStoreKey: fileInfoWrapper,
|
FileInfoStoreKey: &fileInfoWrapper{srv: s},
|
||||||
ClusterKey: s.clusterWrapper,
|
ClusterKey: s.clusterWrapper,
|
||||||
UserKey: New(ServerConnector(s.Channels())),
|
UserKey: New(ServerConnector(s.Channels())),
|
||||||
LogKey: s.GetLogger(),
|
LogKey: s.GetLogger(),
|
||||||
CloudKey: cloudWrapper,
|
CloudKey: &cloudWrapper{cloud: s.Cloud},
|
||||||
|
KVStoreKey: &kvStoreWrapper{srv: s},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Step 8: Initialize products.
|
// Step 8: Initialize products.
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/mattermost/mattermost-server/v6/app/request"
|
"github.com/mattermost/mattermost-server/v6/app/request"
|
||||||
"github.com/mattermost/mattermost-server/v6/model"
|
"github.com/mattermost/mattermost-server/v6/model"
|
||||||
"github.com/mattermost/mattermost-server/v6/shared/filestore"
|
"github.com/mattermost/mattermost-server/v6/shared/filestore"
|
||||||
|
"github.com/mattermost/mattermost-server/v6/shared/mlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
// RouterService enables registering the product router to the server. After registering the
|
// RouterService enables registering the product router to the server. After registering the
|
||||||
@@ -48,7 +49,6 @@ type PermissionService interface {
|
|||||||
type ClusterService interface {
|
type ClusterService interface {
|
||||||
PublishPluginClusterEvent(productID string, ev model.PluginClusterEvent, opts model.PluginClusterEventSendOptions) error
|
PublishPluginClusterEvent(productID string, ev model.PluginClusterEvent, opts model.PluginClusterEventSendOptions) error
|
||||||
PublishWebSocketEvent(productID string, event string, payload map[string]interface{}, broadcast *model.WebsocketBroadcast)
|
PublishWebSocketEvent(productID string, event string, payload map[string]interface{}, broadcast *model.WebsocketBroadcast)
|
||||||
SetPluginKeyWithOptions(productID string, key string, value []byte, options model.PluginKVSetOptions) (bool, *model.AppError)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChannelService provides channel related API The service implementation is provided by
|
// ChannelService provides channel related API The service implementation is provided by
|
||||||
@@ -153,3 +153,17 @@ type FileInfoStoreService interface {
|
|||||||
type CloudService interface {
|
type CloudService interface {
|
||||||
GetCloudLimits() (*model.ProductLimits, error)
|
GetCloudLimits() (*model.ProductLimits, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// KVStoreService is the API for accessing the KVStore service APIs.
|
||||||
|
//
|
||||||
|
// The service shall be registered via app.KVStoreKey service key.
|
||||||
|
type KVStoreService interface {
|
||||||
|
SetPluginKeyWithOptions(pluginID string, key string, value []byte, options model.PluginKVSetOptions) (bool, *model.AppError)
|
||||||
|
}
|
||||||
|
|
||||||
|
// LogService is the API for accessing the log service APIs.
|
||||||
|
//
|
||||||
|
// The service shall be registered via app.LogKey service key.
|
||||||
|
type LogService interface {
|
||||||
|
mlog.LoggerIFace
|
||||||
|
}
|
||||||
|
|||||||
@@ -30,14 +30,18 @@ const (
|
|||||||
|
|
||||||
type LoggerIFace interface {
|
type LoggerIFace interface {
|
||||||
IsLevelEnabled(Level) bool
|
IsLevelEnabled(Level) bool
|
||||||
|
Trace(string, ...Field)
|
||||||
Debug(string, ...Field)
|
Debug(string, ...Field)
|
||||||
Info(string, ...Field)
|
Info(string, ...Field)
|
||||||
Warn(string, ...Field)
|
Warn(string, ...Field)
|
||||||
Error(string, ...Field)
|
Error(string, ...Field)
|
||||||
Critical(string, ...Field)
|
Critical(string, ...Field)
|
||||||
|
Fatal(string, ...Field)
|
||||||
Log(Level, string, ...Field)
|
Log(Level, string, ...Field)
|
||||||
LogM([]Level, string, ...Field)
|
LogM([]Level, string, ...Field)
|
||||||
With(fields ...Field) *Logger
|
With(fields ...Field) *Logger
|
||||||
|
Flush() error
|
||||||
|
StdLogger(level Level) *log.Logger
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type and function aliases from Logr to limit the spread of dependencies.
|
// Type and function aliases from Logr to limit the spread of dependencies.
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user