From 59d971dc751b0414c5b38c9df4b552e45f5641be Mon Sep 17 00:00:00 2001 From: Corey Hulen Date: Thu, 4 Aug 2016 09:25:37 -0800 Subject: PLT-2899 adding clustering of app servers (#3682) * PLT-2899 adding clustering of app servers * PLT-2899 base framework * PLT-2899 HA backend * PLT-2899 Fixing config file * PLT-2899 adding config syncing * PLT-2899 set System console to readonly when clustering enabled. * PLT-2899 Fixing publish API * PLT-2899 fixing strings --- api/status.go | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'api/status.go') diff --git a/api/status.go b/api/status.go index 2a5a73c4a..d19105e3b 100644 --- a/api/status.go +++ b/api/status.go @@ -7,11 +7,23 @@ import ( "net/http" l4g "github.com/alecthomas/log4go" + + "github.com/mattermost/platform/einterfaces" "github.com/mattermost/platform/model" "github.com/mattermost/platform/store" "github.com/mattermost/platform/utils" ) +var statusCache *utils.Cache = utils.NewLru(model.STATUS_CACHE_SIZE) + +func AddStatusCache(status *model.Status) { + statusCache.Add(status.UserId, status) + + if einterfaces.GetClusterInterface() != nil { + einterfaces.GetClusterInterface().UpdateStatus(status) + } +} + func InitStatus() { l4g.Debug(utils.T("api.status.init.debug")) @@ -69,7 +81,7 @@ func SetStatusOnline(userId string, sessionId string) { status.LastActivityAt = model.GetMillis() } - statusCache.Add(status.UserId, status) + AddStatusCache(status) achan := Srv.Store.Session().UpdateLastActivityAt(sessionId, model.GetMillis()) @@ -98,7 +110,7 @@ func SetStatusOnline(userId string, sessionId string) { func SetStatusOffline(userId string) { status := &model.Status{userId, model.STATUS_OFFLINE, model.GetMillis()} - statusCache.Add(status.UserId, status) + AddStatusCache(status) if result := <-Srv.Store.Status().SaveOrUpdate(status); result.Err != nil { l4g.Error(utils.T("api.status.save_status.error"), userId, result.Err) @@ -125,7 +137,7 @@ func SetStatusAwayIfNeeded(userId string) { status.Status = model.STATUS_AWAY - statusCache.Add(status.UserId, status) + AddStatusCache(status) if result := <-Srv.Store.Status().SaveOrUpdate(status); result.Err != nil { l4g.Error(utils.T("api.status.save_status.error"), userId, result.Err) -- cgit v1.2.3-1-g7c22