MM-25404: Add GetHealthScore metric for the cluster (#14767)

* MM-25404: Add GetHealthScore metric for the cluster

This PR adds the necessary function to the cluster interface
so that they can be called from App code.

* Add mocks

* Remove fakeapp

Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
This commit is contained in:
Agniva De Sarker 2020-06-24 18:46:33 +05:30 committed by GitHub
parent 64d12c08e9
commit 3cf05efdd9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 27 additions and 0 deletions

View file

@ -124,3 +124,4 @@ func (c *ClusterMock) GetPluginStatuses() (model.PluginStatuses, *model.AppError
func (c *ClusterMock) ConfigChanged(previousConfig *model.Config, newConfig *model.Config, sendToOtherServer bool) *model.AppError {
return nil
}
func (c *ClusterMock) HealthScore() int { return 0 }

View file

@ -1242,6 +1242,10 @@ func (s *Server) TotalWebsocketConnections() int {
return int(count)
}
func (s *Server) ClusterHealthScore() int {
return s.Cluster.HealthScore()
}
func (s *Server) ensureDiagnosticId() {
if s.diagnosticId != "" {
return

View file

@ -15,6 +15,10 @@ type ClusterInterface interface {
RegisterClusterMessageHandler(event string, crm ClusterMessageHandler)
GetClusterId() string
IsLeader() bool
// HealthScore returns a number which is indicative of how well an instance is meeting
// the soft real-time requirements of the protocol. Lower numbers are better,
// and zero means "totally healthy".
HealthScore() int
GetMyClusterInfo() *model.ClusterInfo
GetClusterInfos() []*model.ClusterInfo
SendClusterMessage(cluster *model.ClusterMessage)

View file

@ -153,6 +153,20 @@ func (_m *ClusterInterface) GetPluginStatuses() (model.PluginStatuses, *model.Ap
return r0, r1
}
// HealthScore provides a mock function with given fields:
func (_m *ClusterInterface) HealthScore() int {
ret := _m.Called()
var r0 int
if rf, ok := ret.Get(0).(func() int); ok {
r0 = rf()
} else {
r0 = ret.Get(0).(int)
}
return r0
}
// IsLeader provides a mock function with given fields:
func (_m *ClusterInterface) IsLeader() bool {
ret := _m.Called()

View file

@ -21,6 +21,10 @@ func (c *FakeClusterInterface) RegisterClusterMessageHandler(event string, crm e
c.clusterMessageHandler = crm
}
func (c *FakeClusterInterface) HealthScore() int {
return 0
}
func (c *FakeClusterInterface) GetClusterId() string { return "" }
func (c *FakeClusterInterface) IsLeader() bool { return false }