Remove the remaining fields from *app.Server (#19113)
We move these fields to Channels: ``` uploadLockMapMut sync.Mutex uploadLockMap map[string]bool imgDecoder *imaging.Decoder imgEncoder *imaging.Encoder dndTaskMut sync.Mutex dndTask *model.ScheduledTask ``` I think this PR should conclue the initial phase of migrating stuff from Server to Channels. The remaining task would be to focus on continue to create the remaining services from the common things like users, teams, push notifications, clustering for other products to consume. https://community-daily.mattermost.com/boards/workspace/zyoahc9uapdn3xdptac6jb69ic/285b80a3-257d-41f6-8cf4-ed80ca9d92e5/495cdb4d-c13a-4992-8eb9-80cfee2819a4/87df1e15-588e-49ff-8bd1-ffa9651b8c82 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
6d361db638
Коммит
129f0aabd3
@@ -38,7 +38,6 @@ import (
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/app/email"
|
||||
"github.com/mattermost/mattermost-server/v6/app/featureflag"
|
||||
"github.com/mattermost/mattermost-server/v6/app/imaging"
|
||||
"github.com/mattermost/mattermost-server/v6/app/request"
|
||||
"github.com/mattermost/mattermost-server/v6/app/teams"
|
||||
"github.com/mattermost/mattermost-server/v6/app/users"
|
||||
@@ -174,23 +173,11 @@ type Server struct {
|
||||
|
||||
tracer *tracing.Tracer
|
||||
|
||||
// These are used to prevent concurrent upload requests
|
||||
// for a given upload session which could cause inconsistencies
|
||||
// and data corruption.
|
||||
uploadLockMapMut sync.Mutex
|
||||
uploadLockMap map[string]bool
|
||||
|
||||
featureFlagSynchronizer *featureflag.Synchronizer
|
||||
featureFlagStop chan struct{}
|
||||
featureFlagStopped chan struct{}
|
||||
featureFlagSynchronizerMutex sync.Mutex
|
||||
|
||||
imgDecoder *imaging.Decoder
|
||||
imgEncoder *imaging.Encoder
|
||||
|
||||
dndTaskMut sync.Mutex
|
||||
dndTask *model.ScheduledTask
|
||||
|
||||
products map[string]Product
|
||||
}
|
||||
|
||||
@@ -207,7 +194,6 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
},
|
||||
licenseListeners: map[string]func(*model.License, *model.License){},
|
||||
hashSeed: maphash.MakeSeed(),
|
||||
uploadLockMap: map[string]bool{},
|
||||
timezones: timezones.New(),
|
||||
products: make(map[string]Product),
|
||||
}
|
||||
@@ -492,20 +478,6 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
|
||||
s.setupFeatureFlags()
|
||||
|
||||
var imgErr error
|
||||
s.imgDecoder, imgErr = imaging.NewDecoder(imaging.DecoderOptions{
|
||||
ConcurrencyLevel: runtime.NumCPU(),
|
||||
})
|
||||
if imgErr != nil {
|
||||
return nil, errors.Wrap(imgErr, "failed to create image decoder")
|
||||
}
|
||||
s.imgEncoder, imgErr = imaging.NewEncoder(imaging.EncoderOptions{
|
||||
ConcurrencyLevel: runtime.NumCPU(),
|
||||
})
|
||||
if imgErr != nil {
|
||||
return nil, errors.Wrap(imgErr, "failed to create image encoder")
|
||||
}
|
||||
|
||||
s.initJobs()
|
||||
|
||||
s.clusterLeaderListenerId = s.AddClusterLeaderChangedListener(func() {
|
||||
@@ -1027,12 +999,6 @@ func (s *Server) Shutdown() {
|
||||
}
|
||||
}
|
||||
|
||||
s.dndTaskMut.Lock()
|
||||
if s.dndTask != nil {
|
||||
s.dndTask.Cancel()
|
||||
}
|
||||
s.dndTaskMut.Unlock()
|
||||
|
||||
mlog.Info("Server stopped")
|
||||
|
||||
// Stop products.
|
||||
@@ -2257,18 +2223,18 @@ func (s *Server) ReadFile(path string) ([]byte, *model.AppError) {
|
||||
}
|
||||
|
||||
func createDNDStatusExpirationRecurringTask(a *App) {
|
||||
a.ch.srv.dndTaskMut.Lock()
|
||||
a.ch.srv.dndTask = model.CreateRecurringTaskFromNextIntervalTime("Unset DND Statuses", a.UpdateDNDStatusOfUsers, 5*time.Minute)
|
||||
a.ch.srv.dndTaskMut.Unlock()
|
||||
a.ch.dndTaskMut.Lock()
|
||||
a.ch.dndTask = model.CreateRecurringTaskFromNextIntervalTime("Unset DND Statuses", a.UpdateDNDStatusOfUsers, 5*time.Minute)
|
||||
a.ch.dndTaskMut.Unlock()
|
||||
}
|
||||
|
||||
func cancelDNDStatusExpirationRecurringTask(a *App) {
|
||||
a.ch.srv.dndTaskMut.Lock()
|
||||
if a.ch.srv.dndTask != nil {
|
||||
a.ch.srv.dndTask.Cancel()
|
||||
a.ch.srv.dndTask = nil
|
||||
a.ch.dndTaskMut.Lock()
|
||||
if a.ch.dndTask != nil {
|
||||
a.ch.dndTask.Cancel()
|
||||
a.ch.dndTask = nil
|
||||
}
|
||||
a.ch.srv.dndTaskMut.Unlock()
|
||||
a.ch.dndTaskMut.Unlock()
|
||||
}
|
||||
|
||||
func runDNDStatusExpireJob(a *App) {
|
||||
|
||||
Ссылка в новой задаче
Block a user