Documentation ¶
Index ¶
- type Configuration
- type Service
- type ServiceImpl
- func (c *ServiceImpl) GetConfiguration() *Configuration
- func (c *ServiceImpl) GetManifest() *model.Manifest
- func (c *ServiceImpl) IsConfiguredForDevelopmentAndTesting() bool
- func (c *ServiceImpl) OnConfigurationChange() error
- func (c *ServiceImpl) RegisterConfigChangeListener(listener func()) string
- func (c *ServiceImpl) UnregisterConfigChangeListener(id string)
- func (c *ServiceImpl) UpdateConfiguration(f func(*Configuration)) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
type Configuration struct { Policy string BotUserID string // AdminLogLevel is "debug", "info", "warn", or "error". AdminLogLevel string // AdminLogVerbose: set to include full context with admin log messages. AdminLogVerbose bool // ** The following are NOT stored on the server // AdminUserIDs contains a list of user IDs that are allowed // to administer plugin functions, even if not Mattermost sysadmins. AllowedUserIDs []string }
Configuration captures the plugin's external Configuration as exposed in the Mattermost server Configuration, as well as values computed from the Configuration. Any public fields will be deserialized from the Mattermost server Configuration in OnConfigurationChange.
As plugins are inherently concurrent (hooks being called asynchronously), and the plugin Configuration can change at any time, access to the Configuration must be synchronized. The strategy used in this plugin is to guard a pointer to the Configuration, and clone the entire struct whenever it changes. You may replace this with whatever strategy you choose.
If you add non-reference types to your Configuration struct, be sure to rewrite Clone as a deep copy appropriate for your types.
func (*Configuration) Clone ¶
func (c *Configuration) Clone() *Configuration
Clone shallow copies the configuration. Your implementation may require a deep copy if your configuration has reference types.
type Service ¶
type Service interface { // GetConfiguration retrieves the active configuration under lock, making it safe to use // concurrently. The active configuration may change underneath the client of this method, but // the struct returned by this API call is considered immutable. GetConfiguration() *Configuration // UpdateConfiguration updates the config. Any parts of the config that are persisted in the plugin's // section in the server's config will be saved to the server. UpdateConfiguration(f func(*Configuration)) error // RegisterConfigChangeListener registers a function that will called when the config might have // been changed. Returns an id which can be used to unregister the listener. RegisterConfigChangeListener(listener func()) string // UnregisterConfigChangeListener unregisters the listener function identified by id. UnregisterConfigChangeListener(id string) // GetManifest gets the plugin manifest. GetManifest() *model.Manifest // IsConfiguredForDevelopmentAndTesting returns true when the server has `EnableDeveloper` and // `EnableTesting` configuration settings enabled. IsConfiguredForDevelopmentAndTesting() bool }
type ServiceImpl ¶
type ServiceImpl struct {
// contains filtered or unexported fields
}
ServiceImpl holds access to the plugin's Configuration.
func NewConfigService ¶
func NewConfigService(api *pluginapi.Client, manifest *model.Manifest) *ServiceImpl
NewConfigService Creates a new ServiceImpl struct.
func (*ServiceImpl) GetConfiguration ¶
func (c *ServiceImpl) GetConfiguration() *Configuration
GetConfiguration retrieves the active configuration under lock, making it safe to use concurrently. The active configuration may change underneath the client of this method, but the struct returned by this API call is considered immutable.
func (*ServiceImpl) GetManifest ¶
func (c *ServiceImpl) GetManifest() *model.Manifest
GetManifest gets the plugin manifest.
func (*ServiceImpl) IsConfiguredForDevelopmentAndTesting ¶
func (c *ServiceImpl) IsConfiguredForDevelopmentAndTesting() bool
IsConfiguredForDevelopmentAndTesting returns true when the server has `EnableDeveloper` and `EnableTesting` configuration settings enabled.
func (*ServiceImpl) OnConfigurationChange ¶
func (c *ServiceImpl) OnConfigurationChange() error
OnConfigurationChange is invoked when configuration changes may have been made. This method satisfies the interface expected by the server. Embed config.Config in the plugin.
func (*ServiceImpl) RegisterConfigChangeListener ¶
func (c *ServiceImpl) RegisterConfigChangeListener(listener func()) string
RegisterConfigChangeListener registers a function that will called when the config might have been changed. Returns an id which can be used to unregister the listener.
func (*ServiceImpl) UnregisterConfigChangeListener ¶
func (c *ServiceImpl) UnregisterConfigChangeListener(id string)
UnregisterConfigChangeListener unregisters the listener function identified by id.
func (*ServiceImpl) UpdateConfiguration ¶
func (c *ServiceImpl) UpdateConfiguration(f func(*Configuration)) error
UpdateConfiguration updates the config. Any parts of the config that are persisted in the plugin's section in the server's config will be saved to the server.