Documentation ¶
Index ¶
- Constants
- func HasSupport(p PluginInstance, toCheck Capability) bool
- type Capabilities
- type Capability
- type Info
- type Message
- type MessageHandler
- type Plugin
- type PluginInstance
- type PluginV1
- type PluginV1Instance
- func (c *PluginV1Instance) DefaultConfig() interface{}
- func (c *PluginV1Instance) Disable() error
- func (c *PluginV1Instance) Enable() error
- func (c *PluginV1Instance) GetDisplay(location *url.URL) string
- func (c *PluginV1Instance) RegisterWebhook(basePath string, mux *gin.RouterGroup)
- func (c *PluginV1Instance) SetMessageHandler(h MessageHandler)
- func (c *PluginV1Instance) SetStorageHandler(handler StorageHandler)
- func (c *PluginV1Instance) Supports() Capabilities
- func (c *PluginV1Instance) ValidateAndSetConfig(config interface{}) error
- type PluginV1MessageHandler
- type PluginV1StorageHandler
- type StorageHandler
- type UserContext
Constants ¶
const ( // Messenger sends notifications. Messenger = Capability("messenger") // Configurer are consigurables. Configurer = Capability("configurer") // Storager stores data. Storager = Capability("storager") // Webhooker registers webhooks. Webhooker = Capability("webhooker") // Displayer displays instructions. Displayer = Capability("displayer") )
Variables ¶
This section is empty.
Functions ¶
func HasSupport ¶
func HasSupport(p PluginInstance, toCheck Capability) bool
HasSupport tests a PluginInstance for a capability.
Types ¶
type Capabilities ¶
type Capabilities []Capability
Capabilities is a slice of module.
func (Capabilities) Strings ¶
func (m Capabilities) Strings() []string
Strings converts []Module to []string.
type Info ¶
type Info struct { Version string Author string Name string Website string Description string License string ModulePath string }
Info is the plugin info.
type MessageHandler ¶
type MessageHandler interface { // SendMessage see plugin.MessageHandler SendMessage(msg Message) error }
MessageHandler see plugin.MessageHandler.
type Plugin ¶
type Plugin interface { PluginInfo() Info NewPluginInstance(ctx UserContext) PluginInstance APIVersion() string }
Plugin is an abstraction of plugin handler.
type PluginInstance ¶
type PluginInstance interface { Enable() error Disable() error // GetDisplay see Displayer GetDisplay(location *url.URL) string // DefaultConfig see Configurer DefaultConfig() interface{} // ValidateAndSetConfig see Configurer ValidateAndSetConfig(c interface{}) error // SetMessageHandler see Messenger#SetMessageHandler SetMessageHandler(h MessageHandler) // RegisterWebhook see Webhooker#RegisterWebhook RegisterWebhook(basePath string, mux *gin.RouterGroup) // SetStorageHandler see Storager#SetStorageHandler. SetStorageHandler(handler StorageHandler) // Returns the supported modules, f.ex. storager Supports() Capabilities }
PluginInstance is an encapsulation layer of plugin instances of different backends.
type PluginV1 ¶
PluginV1 is an abstraction of a plugin written in the v1 plugin API. Exported for testing purposes only.
func (PluginV1) APIVersion ¶
APIVersion returns the API version.
func (PluginV1) NewPluginInstance ¶
func (c PluginV1) NewPluginInstance(ctx UserContext) PluginInstance
NewPluginInstance implements compat/Plugin.
func (PluginV1) PluginInfo ¶
PluginInfo implements compat/Plugin.
type PluginV1Instance ¶
type PluginV1Instance struct {
// contains filtered or unexported fields
}
PluginV1Instance is an adapter for plugin using v1 API.
func (*PluginV1Instance) DefaultConfig ¶
func (c *PluginV1Instance) DefaultConfig() interface{}
DefaultConfig see papiv1.Configurer.
func (*PluginV1Instance) Disable ¶
func (c *PluginV1Instance) Disable() error
Disable implements wrapper.Plugin.
func (*PluginV1Instance) Enable ¶
func (c *PluginV1Instance) Enable() error
Enable implements wrapper.Plugin.
func (*PluginV1Instance) GetDisplay ¶
func (c *PluginV1Instance) GetDisplay(location *url.URL) string
GetDisplay see papiv1.Displayer.
func (*PluginV1Instance) RegisterWebhook ¶
func (c *PluginV1Instance) RegisterWebhook(basePath string, mux *gin.RouterGroup)
RegisterWebhook see papiv1.Webhooker.
func (*PluginV1Instance) SetMessageHandler ¶
func (c *PluginV1Instance) SetMessageHandler(h MessageHandler)
SetMessageHandler see papiv1.Messenger.
func (*PluginV1Instance) SetStorageHandler ¶
func (c *PluginV1Instance) SetStorageHandler(handler StorageHandler)
SetStorageHandler see papiv1.Storager.
func (*PluginV1Instance) Supports ¶
func (c *PluginV1Instance) Supports() Capabilities
Supports returns a slice of capabilities the plugin instance provides.
func (*PluginV1Instance) ValidateAndSetConfig ¶
func (c *PluginV1Instance) ValidateAndSetConfig(config interface{}) error
ValidateAndSetConfig see papiv1.Configurer.
type PluginV1MessageHandler ¶
type PluginV1MessageHandler struct {
WrapperHandler MessageHandler
}
PluginV1MessageHandler is an adapter for messenger plugin handler using v1 API.
func (*PluginV1MessageHandler) SendMessage ¶
func (c *PluginV1MessageHandler) SendMessage(msg papiv1.Message) error
SendMessage implements papiv1.MessageHandler.
type PluginV1StorageHandler ¶
type PluginV1StorageHandler struct {
WrapperHandler StorageHandler
}
PluginV1StorageHandler is a wrapper for v1 storage handler.
func (*PluginV1StorageHandler) Load ¶
func (c *PluginV1StorageHandler) Load() ([]byte, error)
Load implements wrapper.Storager.
func (*PluginV1StorageHandler) Save ¶
func (c *PluginV1StorageHandler) Save(b []byte) error
Save implements wrapper.Storager.
type StorageHandler ¶
StorageHandler see plugin.StorageHandler.
type UserContext ¶
UserContext is the user context used to create plugin instance.