action_worker_mock_que.go 570 B

1234567891011121314151617181920212223242526
  1. package example_basics
  2. import (
  3. "github.com/qor5/admin/presets"
  4. "github.com/qor5/admin/presets/gorm2op"
  5. "github.com/qor5/admin/worker"
  6. )
  7. func ActionWorkerExampleMock(b *presets.Builder) {
  8. if err := DB.AutoMigrate(&ExampleResource{}); err != nil {
  9. panic(err)
  10. }
  11. b.URIPrefix(ActionWorkerExamplePath).
  12. DataOperator(gorm2op.DataOperator(DB))
  13. mb := b.Model(&ExampleResource{})
  14. mb.Listing().ActionsAsMenu(true)
  15. wb := worker.NewWithQueue(DB, Que)
  16. wb.Configure(b)
  17. addActionJobs(mb, wb)
  18. wb.Listen()
  19. }
  20. const ActionWorkerExamplePath = "/samples/action_worker"