Make used of typed atomic.Pointer (#23550)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
2ac375b3fe
Коммит
7a9a098ce4
@@ -198,10 +198,7 @@ func (ps *PlatformService) regenerateClientConfig() {
|
|||||||
|
|
||||||
// AsymmetricSigningKey will return a private key that can be used for asymmetric signing.
|
// AsymmetricSigningKey will return a private key that can be used for asymmetric signing.
|
||||||
func (ps *PlatformService) AsymmetricSigningKey() *ecdsa.PrivateKey {
|
func (ps *PlatformService) AsymmetricSigningKey() *ecdsa.PrivateKey {
|
||||||
if key := ps.asymmetricSigningKey.Load(); key != nil {
|
return ps.asymmetricSigningKey.Load()
|
||||||
return key.(*ecdsa.PrivateKey)
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// EnsureAsymmetricSigningKey ensures that an asymmetric signing key exists and future calls to
|
// EnsureAsymmetricSigningKey ensures that an asymmetric signing key exists and future calls to
|
||||||
|
|||||||
@@ -43,8 +43,7 @@ func (ps *PlatformService) SetLicenseManager(impl einterfaces.LicenseInterface)
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ps *PlatformService) License() *model.License {
|
func (ps *PlatformService) License() *model.License {
|
||||||
license, _ := ps.licenseValue.Load().(*model.License)
|
return ps.licenseValue.Load()
|
||||||
return license
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ps *PlatformService) LoadLicense() {
|
func (ps *PlatformService) LoadLicense() {
|
||||||
@@ -208,7 +207,7 @@ func (ps *PlatformService) SetLicense(license *model.License) bool {
|
|||||||
if oldLicense == nil {
|
if oldLicense == nil {
|
||||||
listener(nil, license)
|
listener(nil, license)
|
||||||
} else {
|
} else {
|
||||||
listener(oldLicense.(*model.License), license)
|
listener(oldLicense, license)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
@@ -255,7 +254,7 @@ func (ps *PlatformService) ClientLicense() map[string]string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ps *PlatformService) RemoveLicense() *model.AppError {
|
func (ps *PlatformService) RemoveLicense() *model.AppError {
|
||||||
if license, _ := ps.licenseValue.Load().(*model.License); license == nil {
|
if license := ps.licenseValue.Load(); license == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
package platform
|
package platform
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"crypto/ecdsa"
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash/maphash"
|
"hash/maphash"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -49,7 +50,7 @@ type PlatformService struct {
|
|||||||
sessionCache cache.Cache
|
sessionCache cache.Cache
|
||||||
sessionPool sync.Pool
|
sessionPool sync.Pool
|
||||||
|
|
||||||
asymmetricSigningKey atomic.Value
|
asymmetricSigningKey atomic.Pointer[ecdsa.PrivateKey]
|
||||||
clientConfig atomic.Value
|
clientConfig atomic.Value
|
||||||
clientConfigHash atomic.Value
|
clientConfigHash atomic.Value
|
||||||
limitedClientConfig atomic.Value
|
limitedClientConfig atomic.Value
|
||||||
@@ -67,7 +68,7 @@ type PlatformService struct {
|
|||||||
featureFlagStop chan struct{}
|
featureFlagStop chan struct{}
|
||||||
featureFlagStopped chan struct{}
|
featureFlagStopped chan struct{}
|
||||||
|
|
||||||
licenseValue atomic.Value
|
licenseValue atomic.Pointer[model.License]
|
||||||
clientLicenseValue atomic.Value
|
clientLicenseValue atomic.Value
|
||||||
licenseListeners map[string]func(*model.License, *model.License)
|
licenseListeners map[string]func(*model.License, *model.License)
|
||||||
licenseManager einterfaces.LicenseInterface
|
licenseManager einterfaces.LicenseInterface
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ type WebConn struct {
|
|||||||
// leave that as an edge-case.
|
// leave that as an edge-case.
|
||||||
reuseCount int
|
reuseCount int
|
||||||
sessionToken atomic.Value
|
sessionToken atomic.Value
|
||||||
session atomic.Value
|
session atomic.Pointer[model.Session]
|
||||||
connectionID atomic.Value
|
connectionID atomic.Value
|
||||||
endWritePump chan struct{}
|
endWritePump chan struct{}
|
||||||
pumpFinished chan struct{}
|
pumpFinished chan struct{}
|
||||||
@@ -304,7 +304,7 @@ func areAllInactive(conns []*WebConn) bool {
|
|||||||
|
|
||||||
// GetSession returns the session of the connection.
|
// GetSession returns the session of the connection.
|
||||||
func (wc *WebConn) GetSession() *model.Session {
|
func (wc *WebConn) GetSession() *model.Session {
|
||||||
return wc.session.Load().(*model.Session)
|
return wc.session.Load()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetSession sets the session of the connection.
|
// SetSession sets the session of the connection.
|
||||||
|
|||||||
@@ -484,9 +484,9 @@ func TestHubIsRegistered(t *testing.T) {
|
|||||||
defer wc2.Close()
|
defer wc2.Close()
|
||||||
defer wc3.Close()
|
defer wc3.Close()
|
||||||
|
|
||||||
assert.True(t, th.Service.SessionIsRegistered(*wc1.session.Load().(*model.Session)))
|
assert.True(t, th.Service.SessionIsRegistered(*wc1.session.Load()))
|
||||||
assert.True(t, th.Service.SessionIsRegistered(*wc2.session.Load().(*model.Session)))
|
assert.True(t, th.Service.SessionIsRegistered(*wc2.session.Load()))
|
||||||
assert.True(t, th.Service.SessionIsRegistered(*wc3.session.Load().(*model.Session)))
|
assert.True(t, th.Service.SessionIsRegistered(*wc3.session.Load()))
|
||||||
|
|
||||||
session4, err := th.Service.CreateSession(&model.Session{
|
session4, err := th.Service.CreateSession(&model.Session{
|
||||||
UserId: th.BasicUser2.Id,
|
UserId: th.BasicUser2.Id,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ type SearchStore struct {
|
|||||||
channel *SearchChannelStore
|
channel *SearchChannelStore
|
||||||
post *SearchPostStore
|
post *SearchPostStore
|
||||||
fileInfo *SearchFileInfoStore
|
fileInfo *SearchFileInfoStore
|
||||||
configValue atomic.Value
|
configValue atomic.Pointer[model.Config]
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewSearchLayer(baseStore store.Store, searchEngine *searchengine.Broker, cfg *model.Config) *SearchStore {
|
func NewSearchLayer(baseStore store.Store, searchEngine *searchengine.Broker, cfg *model.Config) *SearchStore {
|
||||||
@@ -44,7 +44,7 @@ func (s *SearchStore) UpdateConfig(cfg *model.Config) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SearchStore) getConfig() *model.Config {
|
func (s *SearchStore) getConfig() *model.Config {
|
||||||
return s.configValue.Load().(*model.Config)
|
return s.configValue.Load()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *SearchStore) Channel() store.ChannelStore {
|
func (s *SearchStore) Channel() store.ChannelStore {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user