Add Store service for Focalboard multi-product architecture (#20568)

* add Store service
Этот коммит содержится в:
Doug Lauder
2022-06-30 08:28:37 -04:00
коммит произвёл GitHub
родитель 1d9fa3c333
Коммит 91877c3016
3 изменённых файлов: 25 добавлений и 0 удалений

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

@@ -102,6 +102,7 @@ const (
LogKey ServiceKey = "log"
HooksKey ServiceKey = "hooks"
KVStoreKey ServiceKey = "kvstore"
StoreKey ServiceKey = "storekey"
)
type Server struct {
@@ -402,6 +403,7 @@ func NewServer(options ...Option) (*Server, error) {
LogKey: s.GetLogger(),
CloudKey: &cloudWrapper{cloud: s.Cloud},
KVStoreKey: &kvStoreWrapper{srv: s},
StoreKey: store.NewStoreServiceAdapter(s.Store),
}
// Step 8: Initialize products.

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

@@ -4,6 +4,7 @@
package product
import (
"database/sql"
"io"
"github.com/gorilla/mux"
@@ -167,3 +168,10 @@ type KVStoreService interface {
type LogService interface {
mlog.LoggerIFace
}
// StoreService is the API for accessing the Store service APIs.
//
// The service shall be registered via app.StoreKey service key.
type StoreService interface {
GetMasterDB() *sql.DB
}

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

@@ -1021,3 +1021,18 @@ type SidebarCategorySearchOpts struct {
TeamID string
ExcludeTeam bool
}
// StoreServiceAdapter provides a simple Store wrapper for use with products.
type StoreServiceAdapter struct {
store Store
}
func NewStoreServiceAdapter(store Store) *StoreServiceAdapter {
return &StoreServiceAdapter{
store: store,
}
}
func (a *StoreServiceAdapter) GetMasterDB() *sql.DB {
return a.store.GetInternalMasterDB()
}