tidb: github.com/pingcap/tidb/plugin Index | Files | Directories

package plugin

import "github.com/pingcap/tidb/plugin"

Index

Package Files

audit.go const.go errors.go helper.go plugin.go spi.go

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

var ExecStartTimeCtxKey = execStartTimeCtxKeyType{}

ExecStartTimeCtxKey indicates stmt start execution time.

func ChangeDisableFlagAndFlush Uses

func ChangeDisableFlagAndFlush(dom *domain.Domain, pluginName string, disable bool) error

ChangeDisableFlagAndFlush changes plugin disable flag and notify other nodes to do same change.

func ForeachPlugin Uses

func ForeachPlugin(kind Kind, fn func(plugin *Plugin) error) error

ForeachPlugin loops all ready plugins.

func GetAll Uses

func GetAll() map[Kind][]Plugin

GetAll finds and returns all plugins.

func Init Uses

func Init(ctx context.Context, cfg Config) (err error)

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 IsEnable Uses

func IsEnable(kind Kind) bool

IsEnable checks plugin's enable state.

func Load Uses

func Load(ctx context.Context, cfg Config) (err error)

Load load plugin by config param. This method need be called before domain init to inject global variable info during bootstrap.

func NotifyFlush Uses

func NotifyFlush(dom *domain.Domain, pluginName string) error

NotifyFlush notify plugins to do flush logic.

func Shutdown Uses

func Shutdown(ctx context.Context)

Shutdown cleanups all plugin resources. Notice: it just cleanups the resource of plugin, but cannot unload plugins(limited by go plugin).

type AuditManifest Uses

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, 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 Uses

func DeclareAuditManifest(m *Manifest) *AuditManifest

DeclareAuditManifest declares manifest as AuditManifest.

type AuthenticationManifest Uses

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 Uses

func DeclareAuthenticationManifest(m *Manifest) *AuthenticationManifest

DeclareAuthenticationManifest declares manifest as AuthenticationManifest.

type Config Uses

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 Uses

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 Uses

func (c ConnectionEvent) String() string

type DaemonManifest Uses

type DaemonManifest struct {
    Manifest
}

DaemonManifest presents a sub-manifest that every DaemonManifest plugins must provide.

func DeclareDaemonManifest Uses

func DeclareDaemonManifest(m *Manifest) *DaemonManifest

DeclareDaemonManifest declares manifest as DaemonManifest.

type GeneralEvent Uses

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 ID Uses

type ID string

ID present plugin identity.

func (ID) Decode Uses

func (n ID) Decode() (name string, version string, err error)

Decode decodes a plugin id into name, version parts.

type Kind Uses

type Kind uint8

Kind presents the kind of plugin.

const (
    // Audit indicates it is a Audit plugin.
    Audit Kind = 1 + iota
    // Authentication indicate it is a Authentication plugin.
    Authentication
    // Schema indicate a plugin that can change TiDB schema.
    Schema
    // Daemon indicate a plugin that can run as daemon task.
    Daemon
)

func (Kind) String Uses

func (k Kind) String() (str string)

type Manifest Uses

type Manifest struct {
    Name           string
    Description    string
    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

    Version uint16
    Kind    Kind
    // contains filtered or unexported fields
}

Manifest describes plugin info and how it can do by plugin itself.

func ExportManifest Uses

func ExportManifest(m interface{}) *Manifest

ExportManifest exports a manifest to TiDB as a known format. it just casts sub-manifest to manifest.

type ParseEvent Uses

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 Plugin Uses

type Plugin struct {
    *Manifest

    Path     string
    Disabled uint32
    State    State
    // contains filtered or unexported fields
}

Plugin presents a TiDB plugin.

func Get Uses

func Get(kind Kind, name string) *Plugin

Get finds and returns plugin by kind and name parameters.

func (*Plugin) DisableFlag Uses

func (p *Plugin) DisableFlag(disable bool)

DisableFlag changes the disable flag of plugin.

func (*Plugin) StateValue Uses

func (p *Plugin) StateValue() string

StateValue returns readable state string.

type SchemaManifest Uses

type SchemaManifest struct {
    Manifest
}

SchemaManifest presents a sub-manifest that every schema plugins must provide.

func DeclareSchemaManifest Uses

func DeclareSchemaManifest(m *Manifest) *SchemaManifest

DeclareSchemaManifest declares manifest as SchemaManifest.

type State Uses

type State uint8

State present the state of plugin.

const (
    // Uninitialized indicates plugin is uninitialized.
    Uninitialized State = iota
    // Ready indicates plugin is ready to work.
    Ready
    // Dying indicates plugin will be close soon.
    Dying
    // Disable indicate plugin is disabled.
    Disable
)

func (State) String Uses

func (s State) String() (str string)

Directories

PathSynopsis
conn_ip_example

Package plugin imports 17 packages (graph) and is imported by 10 packages. Updated 2019-08-20. Refresh now. Tools for package owners.