Add KVStore service and Log service for Focalboard multi product architecture (#20563)

* add KVStore service, add Log service
Этот коммит содержится в:
Doug Lauder
2022-06-29 09:08:34 -04:00
коммит произвёл GitHub
родитель 90c687b728
Коммит 7e4024665c
4 изменённых файлов: 32 добавлений и 16 удалений

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

@@ -14,6 +14,14 @@ import (
"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 {
hash := sha256.New()
hash.Write([]byte(key))

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

@@ -101,6 +101,7 @@ const (
BotKey ServiceKey = "bot"
LogKey ServiceKey = "log"
HooksKey ServiceKey = "hooks"
KVStoreKey ServiceKey = "kvstore"
)
type Server struct {
@@ -369,10 +370,6 @@ func NewServer(options ...Option) (*Server, error) {
}
s.filestore = backend
channelWrapper := &channelsWrapper{
srv: s,
}
s.licenseWrapper = &licenseWrapper{
srv: s,
}
@@ -381,14 +378,6 @@ func NewServer(options ...Option) (*Server, error) {
srv: s,
}
fileInfoWrapper := &fileInfoWrapper{
srv: s,
}
cloudWrapper := &cloudWrapper{
cloud: s.Cloud,
}
s.teamService, err = teams.New(teams.ServiceConfig{
TeamStore: s.Store.Team(),
ChannelStore: s.Store.Channel(),
@@ -403,15 +392,16 @@ func NewServer(options ...Option) (*Server, error) {
}
serviceMap := map[ServiceKey]interface{}{
ChannelKey: channelWrapper,
ChannelKey: &channelsWrapper{srv: s},
ConfigKey: s.configStore,
LicenseKey: s.licenseWrapper,
FilestoreKey: s.filestore,
FileInfoStoreKey: fileInfoWrapper,
FileInfoStoreKey: &fileInfoWrapper{srv: s},
ClusterKey: s.clusterWrapper,
UserKey: New(ServerConnector(s.Channels())),
LogKey: s.GetLogger(),
CloudKey: cloudWrapper,
CloudKey: &cloudWrapper{cloud: s.Cloud},
KVStoreKey: &kvStoreWrapper{srv: s},
}
// Step 8: Initialize products.

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

@@ -11,6 +11,7 @@ import (
"github.com/mattermost/mattermost-server/v6/app/request"
"github.com/mattermost/mattermost-server/v6/model"
"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
@@ -48,7 +49,6 @@ type PermissionService interface {
type ClusterService interface {
PublishPluginClusterEvent(productID string, ev model.PluginClusterEvent, opts model.PluginClusterEventSendOptions) error
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
@@ -153,3 +153,17 @@ type FileInfoStoreService interface {
type CloudService interface {
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 {
IsLevelEnabled(Level) bool
Trace(string, ...Field)
Debug(string, ...Field)
Info(string, ...Field)
Warn(string, ...Field)
Error(string, ...Field)
Critical(string, ...Field)
Fatal(string, ...Field)
Log(Level, string, ...Field)
LogM([]Level, string, ...Field)
With(fields ...Field) *Logger
Flush() error
StdLogger(level Level) *log.Logger
}
// Type and function aliases from Logr to limit the spread of dependencies.