Improve API4 initialization (#18680)
* Improve API4 initialization - Refactored openGraphDataCache to be inside app layer. - Moved the cache instance from global variable to be inside server. - Moved out the app instantiation from the global commands package to be instantiated on every call. Only the server instance is passed. - Moved InitLocal to be called from inside Init. ```release-note NONE ``` * Remove commented line ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
43a99a5783
Коммит
c27814393d
@@ -137,6 +137,7 @@ type Server struct {
|
||||
htmlTemplateWatcher *templates.Container
|
||||
seenPendingPostIdsCache cache.Cache
|
||||
statusCache cache.Cache
|
||||
openGraphDataCache cache.Cache
|
||||
configListenerId string
|
||||
licenseListenerId string
|
||||
clusterLeaderListenerId string
|
||||
@@ -349,6 +350,11 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
}); err != nil {
|
||||
return nil, errors.Wrap(err, "Unable to create status cache")
|
||||
}
|
||||
if s.openGraphDataCache, err = s.CacheProvider.NewCache(&cache.CacheOptions{
|
||||
Size: openGraphMetadataCacheSize,
|
||||
}); err != nil {
|
||||
return nil, errors.Wrap(err, "Unable to create opengraphdata cache")
|
||||
}
|
||||
|
||||
s.createPushNotificationsHub()
|
||||
|
||||
@@ -708,6 +714,16 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
}
|
||||
})
|
||||
|
||||
// Dump the image cache if the proxy settings have changed. (need switch URLs to the correct proxy)
|
||||
s.AddConfigListener(func(oldCfg, newCfg *model.Config) {
|
||||
if (oldCfg.ImageProxySettings.Enable != newCfg.ImageProxySettings.Enable) ||
|
||||
(oldCfg.ImageProxySettings.ImageProxyType != newCfg.ImageProxySettings.ImageProxyType) ||
|
||||
(oldCfg.ImageProxySettings.RemoteImageProxyURL != newCfg.ImageProxySettings.RemoteImageProxyURL) ||
|
||||
(oldCfg.ImageProxySettings.RemoteImageProxyOptions != newCfg.ImageProxySettings.RemoteImageProxyOptions) {
|
||||
s.openGraphDataCache.Purge()
|
||||
}
|
||||
})
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user