Skip to content

Scheduled events

Korrent supports plugins to customize scheduled tasks and supports calling in an event-driven manner.

Define plugin schedule event

@KorrentScheduleEvent is used to define scheduled tasks, using cron expressions, and will be got from the configuration file. If the configuration file field is not specified, it will fall back to the default value.

java
@KorrentScheduleEvent("*/5 * * * * *", "example.text")
public class RefreshEvent extends ScheduleEvent {
    
}
kotlin
@KorrentScheduleEvent("*/5 * * * * *", "example.text")
class RefreshEvent: ScheduleEvent()

Schedule events

java
import com.google.common.eventbus.Subscribe;
import moe.shizuki.korrent.plugin.annotation.KorrentEvent;

@KorrentEvent
public class OnEvent {
    @Subscribe
    public void onRefresh(RefreshEvent event) {
        System.out.println("Schedule event");
    }
}
kotlin
import com.google.common.eventbus.Subscribe
import moe.shizuki.korrent.plugin.annotation.KorrentEvent

@KorrentEvent
class OnEvent {
    @Subscribe
    fun onRefresh(event: RefreshEvent) {
        println("Schedule event")
    }
}