关于laravel:在-Golang-中进行任务调度像用-Laravel-一样丝滑

Laravel 中的「任务调度」

class Kernel extends ConsoleKernel
{
    protected function schedule(Schedule $schedule)
    {
        $schedule->call(function () {
            DB::table('recent_users')->delete();
        )}->daily();

        $schedule->command('emails:send name')->daily();
    }
}

Goravel 中的「任务调度」

type Kernel struct {
}

func (kernel Kernel) Schedule() []*support.Event {
    return []*support.Event{
        facades.Schedule.Call(func() {
            facades.DB.Where("1 = 1").Delete(&models.User{})
        }).Daily(),

        facades.Schedule.Command("emails:send name").Daily(),
    }
}

func (kernel Kernel) Commands() []console.Command {
    return []console.Command{
        &commands.SendEmails{},
    }
}

实现了 Laravel 中大部分的实用办法,继续更新中, 欢送 star 与 issues。

对于 Goravel

Goravel 是一个性能齐备、具备良好扩大能力的 Web 应用程序框架。 作为一个起始脚手架帮忙 Golang 开发者疾速构建本人的利用。

我的项目地址:https://github.com/goravel/goravel

文档地址:https://www.goravel.dev

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理