mirror of
https://github.com/mattermost/mattermost.git
synced 2026-02-03 20:40:00 -05:00
26 lines
421 B
Go
26 lines
421 B
Go
|
|
package cluster
|
||
|
|
|
||
|
|
import (
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"github.com/mattermost/mattermost/server/public/plugin"
|
||
|
|
)
|
||
|
|
|
||
|
|
func ExampleSchedule() {
|
||
|
|
// Use p.API from your plugin instead.
|
||
|
|
pluginAPI := plugin.API(nil)
|
||
|
|
|
||
|
|
callback := func() {
|
||
|
|
// periodic work to do
|
||
|
|
}
|
||
|
|
|
||
|
|
job, err := Schedule(pluginAPI, "key", MakeWaitForInterval(5*time.Minute), callback)
|
||
|
|
if err != nil {
|
||
|
|
panic("failed to schedule job")
|
||
|
|
}
|
||
|
|
|
||
|
|
// main thread
|
||
|
|
|
||
|
|
defer job.Close()
|
||
|
|
}
|