Documentation
¶
Index ¶
- Constants
- func ForeachPlugin(kind Kind, fn func(plugin *Plugin) error) error
- func GetAll() map[Kind][]Plugin
- func Init(ctx context.Context, cfg Config) (err error)
- func IsEnable(kind Kind) bool
- func Load(ctx context.Context, cfg Config) (err error)
- func NotifyFlush(dom *domain.Domain, pluginName string) error
- func Shutdown(ctx context.Context)
- type AuditManifest
- type AuthenticationManifest
- type Config
- type ConnectionEvent
- type DaemonManifest
- type GeneralEvent
- type ID
- type Kind
- type Manifest
- type ParseEvent
- type Plugin
- type SchemaManifest
- type State
Constants ¶
const ( // LibrarySuffix defines TiDB plugin's file suffix. LibrarySuffix = ".so" // ManifestSymbol defines TiDB plugin's entrance symbol. // Plugin take manifest info from this symbol. ManifestSymbol = "PluginManifest" )
Variables ¶
This section is empty.
Functions ¶
func ForeachPlugin ¶
ForeachPlugin loops all ready plugins.
func Init ¶
Init initializes the loaded plugin by config param. This method must be called after `Load` but before any other plugin method call, so it call got TiDB domain info.
func Load ¶
Load load plugin by config param. This method need be called before domain init to inject global variable info during bootstrap.
func NotifyFlush ¶
NotifyFlush notify plugins to do flush logic.
Types ¶
type AuditManifest ¶
type AuditManifest struct {
Manifest
// OnConnectionEvent will be called when TiDB receive or disconnect from client.
// return error will ignore and close current connection.
OnConnectionEvent func(ctx context.Context, identity *auth.UserIdentity, event ConnectionEvent, info *variable.ConnectionInfo) error
// OnGeneralEvent will be called during TiDB execution.
OnGeneralEvent func(ctx context.Context, sctx *variable.SessionVars, event GeneralEvent, cmd string)
// OnGlobalVariableEvent will be called when Change GlobalVariable.
OnGlobalVariableEvent func(ctx context.Context, sctx *variable.SessionVars, varName, varValue string)
// OnParseEvent will be called around parse logic.
OnParseEvent func(ctx context.Context, sctx *variable.SessionVars, event ParseEvent) error
}
AuditManifest presents a sub-manifest that every audit plugin must provide.
func DeclareAuditManifest ¶
func DeclareAuditManifest(m *Manifest) *AuditManifest
DeclareAuditManifest declares manifest as AuditManifest.
type AuthenticationManifest ¶
type AuthenticationManifest struct {
Manifest
AuthenticateUser func()
GenerateAuthenticationString func()
ValidateAuthenticationString func()
SetSalt func()
}
AuthenticationManifest presents a sub-manifest that every audit plugin must provide.
func DeclareAuthenticationManifest ¶
func DeclareAuthenticationManifest(m *Manifest) *AuthenticationManifest
DeclareAuthenticationManifest declares manifest as AuthenticationManifest.
type Config ¶
type Config struct {
Plugins []string
PluginDir string
GlobalSysVar *map[string]*variable.SysVar
PluginVarNames *[]string
SkipWhenFail bool
EnvVersion map[string]uint16
EtcdClient *clientv3.Client
}
Config presents the init configuration for plugin framework.
type ConnectionEvent ¶
type ConnectionEvent byte
ConnectionEvent presents TiDB connection event.
const ( // Connected presents new connection establish event(finish auth). Connected ConnectionEvent = iota // Disconnect presents disconnect event. Disconnect // ChangeUser presents change user. ChangeUser // PreAuth presents event before start auth. PreAuth )
func (ConnectionEvent) String ¶
func (c ConnectionEvent) String() string
type DaemonManifest ¶
type DaemonManifest struct {
Manifest
}
DaemonManifest presents a sub-manifest that every DaemonManifest plugins must provide.
func DeclareDaemonManifest ¶
func DeclareDaemonManifest(m *Manifest) *DaemonManifest
DeclareDaemonManifest declares manifest as DaemonManifest.
type GeneralEvent ¶
type GeneralEvent byte
GeneralEvent presents TiDB generate event.
const ( // Log presents log event. Log GeneralEvent = iota // Error presents error event. Error // Result presents result event. Result // Status presents status event. Status )
type Manifest ¶
type Manifest struct {
Kind Kind
Name string
Description string
Version uint16
RequireVersion map[string]uint16
License string
BuildTime string
SysVars map[string]*variable.SysVar
// Validate defines the validate logic for plugin.
// returns error will stop load plugin process and TiDB startup.
Validate func(ctx context.Context, manifest *Manifest) error
// OnInit defines the plugin init logic.
// it will be called after domain init.
// return error will stop load plugin process and TiDB startup.
OnInit func(ctx context.Context, manifest *Manifest) error
// OnShutDown defines the plugin cleanup logic.
// return error will write log and continue shutdown.
OnShutdown func(ctx context.Context, manifest *Manifest) error
// OnFlush defines flush logic after executed `flush tidb plugins`.
// it will be called after OnInit.
// return error will write log and continue watch following flush.
OnFlush func(ctx context.Context, manifest *Manifest) error
// contains filtered or unexported fields
}
Manifest describes plugin info and how it can do by plugin itself.
func ExportManifest ¶
func ExportManifest(m interface{}) *Manifest
ExportManifest exports a manifest to TiDB as a known format. it just casts sub-manifest to manifest.
type ParseEvent ¶
type ParseEvent byte
ParseEvent presents events happen around parser.
const ( // PreParse presents event before parse. PreParse ParseEvent = 1 + iota // PostParse presents event after parse. PostParse )
type SchemaManifest ¶
type SchemaManifest struct {
Manifest
}
SchemaManifest presents a sub-manifest that every schema plugins must provide.
func DeclareSchemaManifest ¶
func DeclareSchemaManifest(m *Manifest) *SchemaManifest
DeclareSchemaManifest declares manifest as SchemaManifest.