mirror of
https://github.com/mattermost/mattermost.git
synced 2026-02-03 20:40:00 -05:00
* Move State property from activePlugin to PluginHealthStatus. env.activePlugins is now reserved for healthy running plugins. * Add comments for function declarations * Combine activePlugins and pluginHealthStatuses into a common structure, registeredPlugins * Add check to see if plugin is active before deactivating it * Make `Deactivate` set plugin status * Add comment explaining the `registeredPlugins` map * Give responsibility to set plugin disabled status upon deactivation back to `env.Deactivate` * check if plugin needs to be deactivated before setting status
42 lines
1 KiB
Go
42 lines
1 KiB
Go
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
|
// See LICENSE.txt for license information.
|
|
|
|
package model
|
|
|
|
import (
|
|
"encoding/json"
|
|
"io"
|
|
)
|
|
|
|
const (
|
|
PluginStateNotRunning = 0
|
|
PluginStateStarting = 1 // unused by server
|
|
PluginStateRunning = 2
|
|
PluginStateFailedToStart = 3
|
|
PluginStateFailedToStayRunning = 4
|
|
PluginStateStopping = 5 // unused by server
|
|
)
|
|
|
|
// PluginStatus provides a cluster-aware view of installed plugins.
|
|
type PluginStatus struct {
|
|
PluginId string `json:"plugin_id"`
|
|
ClusterId string `json:"cluster_id"`
|
|
PluginPath string `json:"plugin_path"`
|
|
State int `json:"state"`
|
|
Name string `json:"name"`
|
|
Description string `json:"description"`
|
|
Version string `json:"version"`
|
|
}
|
|
|
|
type PluginStatuses []*PluginStatus
|
|
|
|
func (m *PluginStatuses) ToJson() string {
|
|
b, _ := json.Marshal(m)
|
|
return string(b)
|
|
}
|
|
|
|
func PluginStatusesFromJson(data io.Reader) PluginStatuses {
|
|
var m PluginStatuses
|
|
json.NewDecoder(data).Decode(&m)
|
|
return m
|
|
}
|