[MM-48626] Move plugins environment out of Channels (#21730)

Этот коммит содержится в:
Ibrahim Serdar Acikgoz
2022-12-21 16:11:57 +03:00
коммит произвёл GitHub
родитель 0ce7c5e3da
Коммит dcf499b51d
40 изменённых файлов: 537 добавлений и 447 удалений

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

@@ -10,6 +10,7 @@ import (
"sync"
"time"
"github.com/mattermost/mattermost-server/v6/app/platform"
"github.com/mattermost/mattermost-server/v6/model"
"github.com/mattermost/mattermost-server/v6/plugin"
)
@@ -19,7 +20,7 @@ import (
// a new entry tracked centrally in a map. Further requests operate on the
// object ID.
type DriverImpl struct {
s *Server
ps *platform.PlatformService
connMut sync.RWMutex
connMap map[string]*sql.Conn
txMut sync.Mutex
@@ -30,9 +31,9 @@ type DriverImpl struct {
rowsMap map[string]driver.Rows
}
func NewDriverImpl(s *Server) *DriverImpl {
func NewDriverImpl(s *platform.PlatformService) *DriverImpl {
return &DriverImpl{
s: s,
ps: s,
connMap: make(map[string]*sql.Conn),
txMap: make(map[string]driver.Tx),
stMap: make(map[string]driver.Stmt),
@@ -41,11 +42,11 @@ func NewDriverImpl(s *Server) *DriverImpl {
}
func (d *DriverImpl) Conn(isMaster bool) (string, error) {
dbFunc := d.s.Platform().Store.GetInternalMasterDB
dbFunc := d.ps.Store.GetInternalMasterDB
if !isMaster {
dbFunc = d.s.Platform().Store.GetInternalReplicaDB
dbFunc = d.ps.Store.GetInternalReplicaDB
}
timeout := time.Duration(*d.s.Config().SqlSettings.QueryTimeout) * time.Second
timeout := time.Duration(*d.ps.Config().SqlSettings.QueryTimeout) * time.Second
ctx, cancel := context.WithTimeout(context.Background(), timeout)
defer cancel()
conn, err := dbFunc().Conn(ctx)