plugin

package
v2.0.22 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 16, 2021 License: CC-BY-4.0, MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrAlreadyEnabledOrDisabled = errors.New("config is already enabled/disabled")

ErrAlreadyEnabledOrDisabled is returned on SetPluginEnabled call when a plugin is already enabled or disabled.

Functions

This section is empty.

Types

type Database

type Database interface {
	GetUsers() ([]*model.User, error)
	GetPluginConfByUserAndPath(userid uint, path string) (*model.PluginConf, error)
	CreatePluginConf(p *model.PluginConf) error
	GetPluginConfByApplicationID(appid uint) (*model.PluginConf, error)
	UpdatePluginConf(p *model.PluginConf) error
	CreateMessage(message *model.Message) error
	GetPluginConfByID(id uint) (*model.PluginConf, error)
	GetPluginConfByToken(token string) (*model.PluginConf, error)
	GetUserByID(id uint) (*model.User, error)
	CreateApplication(application *model.Application) error
	UpdateApplication(app *model.Application) error
	GetApplicationsByUser(userID uint) ([]*model.Application, error)
	GetApplicationByToken(token string) (*model.Application, error)
}

The Database interface for encapsulating database access.

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager is an encapsulating layer for plugins and manages all plugins and its instances.

func NewManager

func NewManager(db Database, directory string, mux *gin.RouterGroup, notifier Notifier) (*Manager, error)

NewManager created a Manager from configurations.

func (*Manager) HasInstance

func (m *Manager) HasInstance(pluginID uint) bool

HasInstance returns whether the given plugin ID has a corresponding instance.

func (*Manager) InitializeForUserID

func (m *Manager) InitializeForUserID(userID uint) error

InitializeForUserID initializes all plugin instances for a given user.

func (*Manager) Instance

func (m *Manager) Instance(pluginID uint) (compat.PluginInstance, error)

Instance returns an instance with the given ID.

func (*Manager) LoadPlugin

func (m *Manager) LoadPlugin(compatPlugin compat.Plugin) error

LoadPlugin loads a compat plugin, exported to sideload plugins for testing purposes.

func (*Manager) PluginInfo

func (m *Manager) PluginInfo(modulePath string) compat.Info

PluginInfo returns plugin info.

func (*Manager) RemoveUser

func (m *Manager) RemoveUser(userID uint) error

RemoveUser disabled all plugins of a user when the user is disabled.

func (*Manager) SetPluginEnabled

func (m *Manager) SetPluginEnabled(pluginID uint, enabled bool) error

SetPluginEnabled sets the plugins enabled state.

type MessageWithUserID

type MessageWithUserID struct {
	Message model.MessageExternal
	UserID  uint
}

MessageWithUserID encapsulates a message with a given user ID.

type Notifier

type Notifier interface {
	Notify(userID uint, message *model.MessageExternal)
}

Notifier notifies when a new message was created.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL