DEV Community

Bowen for goravel

Posted on

Goravel v1.16.4 has been released

#go

Fix commands cannot be run concurrently

Suppose there are three commands: Test1, Test2, and Test3, they will print:


func (r *Test1) Handle(ctx console.Context) error {
  facades.Log().Info("app:test[*] start")
  facades.Log().Info("app:test[*] end")
  return nil
}
Enter fullscreen mode Exit fullscreen mode

Then register them in the Schedule module and execute once per second:


func (kernel *Kernel) Schedule() []schedule.Event {
  return []schedule.Event{
    facades.Schedule().Command("app:test1").EverySecond(),
    facades.Schedule().Command("app:test2").EverySecond(),
    facades.Schedule().Command("app:test3").EverySecond(),
  }
}
Enter fullscreen mode Exit fullscreen mode

Run the Schedule module:

facades.Schedule().Run()
Enter fullscreen mode Exit fullscreen mode

Previously, the three commands were called randomly, the result is unexpected:

Currently, they can be run expectantly:

Top comments (0)