plugin/product: improve product hooks API (#20556)
* plugin/product: improve product hooks API * elaborate HookService.RegisterHooks method documentation * remove unnecessary re-assigns
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
fe23501d40
Коммит
90c687b728
@@ -10,7 +10,6 @@ import (
|
||||
|
||||
"github.com/mattermost/mattermost-server/v6/app/request"
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/plugin"
|
||||
"github.com/mattermost/mattermost-server/v6/shared/filestore"
|
||||
)
|
||||
|
||||
@@ -108,19 +107,25 @@ type ConfigService interface {
|
||||
SaveConfig(newCfg *model.Config, sendConfigChangeClusterMessage bool) (*model.Config, *model.Config, *model.AppError)
|
||||
}
|
||||
|
||||
// Hooks is an interim solution for enabling plugin hooks on the multi-product architecture. After the
|
||||
// focalboard migration is completed, this API should replaced with something else that would enable a
|
||||
// product to register any hook. Currently this is added to unblock the migration.
|
||||
type Hooks interface {
|
||||
plugin.ProductHooks
|
||||
}
|
||||
|
||||
// HooksService is the API for adding exiting plugin hooks to the server so that they can be called as
|
||||
// they were. This Service is required to be used after the products start. Otherwise it will return an error.
|
||||
//
|
||||
// The service shall be registered via app.HooksKey service key.
|
||||
type HooksService interface {
|
||||
RegisterHooks(productID string, hooks Hooks) error
|
||||
// RegisterHook checks whether if the 'hooks' implements any method of plugin.Hooks methods. Rather than
|
||||
// using the whole plugin.Hooks interface with its 20+ methods, a product can implement any exiting method
|
||||
// of plugin.Hooks w/o requiring to declare which method they implemented or not. This is going to be
|
||||
// checked on runtime. We have individual interfaces for each method declared in plugin.Hooks interface.
|
||||
// Hence, while registering a product, the service will check if the product implements any of these individual
|
||||
// interfaces. If so, a map of hook IDs that are implemented will be used to call the hooks. The method will
|
||||
// return an error in case if there is an incorrect implementation of the any of the individual interface in runtime.
|
||||
// Consider checking plugin.Hooks for the reference.
|
||||
// Following methods are not allowed to be implemented in the product:
|
||||
// - plugin.Hooks.OnActivate
|
||||
// - plugin.Hooks.OnDeactivate
|
||||
// - plugin.Hooks.Implemented
|
||||
// - plugin.Hooks.ServeHTTP
|
||||
RegisterHooks(productID string, hooks any) error
|
||||
}
|
||||
|
||||
// FilestoreService is the API for accessing the file store.
|
||||
|
||||
Ссылка в новой задаче
Block a user