MCPcopy
hub / github.com/tinode/chat / NodeRestarted

Method NodeRestarted

server/sessionstore.go:247–262  ·  view source on GitHub ↗

NodeRestarted removes stale sessions from a restarted cluster node. - nodeName is the name of affected node - fingerprint is the new fingerprint of the node.

(nodeName string, fingerprint int64)

Source from the content-addressed store, hash-verified

245// - nodeName is the name of affected node
246// - fingerprint is the new fingerprint of the node.
247func (ss *SessionStore) NodeRestarted(nodeName string, fingerprint int64) {
248 ss.lock.Lock()
249 defer ss.lock.Unlock()
250
251 for _, s := range ss.sessCache {
252 if !s.isMultiplex() || s.clnode.name != nodeName {
253 continue
254 }
255 if s.clnode.fingerprint != fingerprint {
256 s.stopSession(nil)
257 delete(ss.sessCache, s.sid)
258 }
259 }
260
261 statsSet("LiveSessions", int64(len(ss.sessCache)))
262}
263
264// NewSessionStore initializes a session store.
265func NewSessionStore(lifetime time.Duration) *SessionStore {

Callers

nothing calls this directly

Calls 5

statsSetFunction · 0.85
LockMethod · 0.80
UnlockMethod · 0.80
isMultiplexMethod · 0.80
stopSessionMethod · 0.80

Tested by

no test coverage detected