Documentation ¶
Index ¶
- Variables
- type EventScheduler
- func (es *EventScheduler) AddEvent(ctx *sql.Context, edb sql.EventDatabase, details sql.EventDefinition)
- func (es *EventScheduler) Close()
- func (es *EventScheduler) RemoveEvent(dbName, eventName string)
- func (es *EventScheduler) RemoveSchemaEvents(dbName string)
- func (es *EventScheduler) TurnOffEventScheduler() error
- func (es *EventScheduler) TurnOnEventScheduler(a *analyzer.Analyzer) error
- func (es *EventScheduler) UpdateEvent(ctx *sql.Context, edb sql.EventDatabase, orgEventName string, ...)
- type SchedulerStatus
Constants ¶
This section is empty.
Variables ¶
var ErrEventSchedulerDisabled = errors.New("The server is running with the --event-scheduler=DISABLED or --skip-grant-tables option and the event scheduler cannot be enabled")
ErrEventSchedulerDisabled is returned when user tries to set `event_scheduler_notifier` global system variable to ON or OFF when the server started with either `--event-scheduler=DISABLED` or `--skip-grant-tables` configuration. Should have ERROR 1290 code.
Functions ¶
This section is empty.
Types ¶
type EventScheduler ¶
type EventScheduler struct {
// contains filtered or unexported fields
}
EventScheduler is responsible for SQL events execution.
func InitEventScheduler ¶
func InitEventScheduler( a *analyzer.Analyzer, bgt *sql.BackgroundThreads, getSqlCtxFunc func() (*sql.Context, func() error, error), status SchedulerStatus, runQueryFunc func(ctx *sql.Context, dbName, query, username, address string) error, period int, ) (*EventScheduler, error)
InitEventScheduler is called at the start of the server. This function returns EventScheduler object creating eventExecutor with empty events list. The enabled events will be loaded into the eventExecutor if the EventScheduler status is 'ON'. The runQueryFunc is used to run an event definition during event execution. If the |period| parameter is 1 or greater, then that value will be used as the period (in seconds) at which the event scheduler will wake up and see if events need to be executed.
func (*EventScheduler) AddEvent ¶
func (es *EventScheduler) AddEvent(ctx *sql.Context, edb sql.EventDatabase, details sql.EventDefinition)
AddEvent implements sql.EventScheduler interface. This function is called when there is an event created at runtime.
func (*EventScheduler) RemoveEvent ¶
func (es *EventScheduler) RemoveEvent(dbName, eventName string)
RemoveEvent implements sql.EventScheduler interface. This function is called when there is an event dropped at runtime. This function removes the given event if it exists in the enabled events list of the EventScheduler.
func (*EventScheduler) RemoveSchemaEvents ¶
func (es *EventScheduler) RemoveSchemaEvents(dbName string)
RemoveSchemaEvents implements sql.EventScheduler interface. This function is called when there is a database dropped at runtime. This function removes all events of given database that exist in the enabled events list of the EventScheduler.
func (*EventScheduler) TurnOffEventScheduler ¶
func (es *EventScheduler) TurnOffEventScheduler() error
TurnOffEventScheduler is called when user sets --event-scheduler system variable to OFF or 0.
func (*EventScheduler) TurnOnEventScheduler ¶
func (es *EventScheduler) TurnOnEventScheduler(a *analyzer.Analyzer) error
TurnOnEventScheduler is called when user sets --event-scheduler system variable to ON or 1. This function requires valid analyzer and sql context to evaluate all events in all databases to load enabled events to the EventScheduler.
func (*EventScheduler) UpdateEvent ¶
func (es *EventScheduler) UpdateEvent(ctx *sql.Context, edb sql.EventDatabase, orgEventName string, details sql.EventDefinition)
UpdateEvent implements sql.EventScheduler interface. This function is called when there is an event altered at runtime.
type SchedulerStatus ¶
type SchedulerStatus string
SchedulerStatus can be one of 'ON', 'OFF' or 'DISABLED' If --event-scheduler configuration variable is set to 'DISABLED' at the start of the server, it cannot be updated during runtime. If not defined, it defaults to 'ON', and it can be updated to 'OFF' during runtime. If --skip-grant-tables configuration flag is used, it defaults to 'DISABLED'.
const ( SchedulerOn SchedulerStatus = "ON" SchedulerOff SchedulerStatus = "OFF" SchedulerDisabled SchedulerStatus = "DISABLED" )