mirror of
https://github.com/mattermost/mattermost.git
synced 2026-05-28 04:35:04 -04:00
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:
parent
64d12c08e9
commit
3cf05efdd9
5 changed files with 27 additions and 0 deletions
|
|
@ -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 }
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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 }
|
||||
|
|
|
|||
Loading…
Reference in a new issue