worker.go 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package basics
  2. import (
  3. "fmt"
  4. "path"
  5. "github.com/qor5/docs/docsrc/examples/example_basics"
  6. "github.com/qor5/docs/docsrc/generated"
  7. "github.com/qor5/docs/docsrc/utils"
  8. . "github.com/theplant/docgo"
  9. "github.com/theplant/docgo/ch"
  10. )
  11. var Worker = Doc(
  12. Markdown(fmt.Sprintf(`
  13. Worker runs a single Job in the background, it can do so immediately or at a scheduled time.
  14. Once registered with QOR Admin, Worker will provide a Workers section in the navigation tree, containing pages for listing and managing the following aspects of Workers:
  15. - All Jobs.
  16. - Running: Jobs that are currently running.
  17. - Scheduled: Jobs which have been scheduled to run at a time in the future.
  18. - Done: finished Jobs.
  19. - Errors: any errors output from any Workers that have been run.
  20. ## Note
  21. - The default que GoQueQueue(https://github.com/tnclong/go-que) only supports postgres for now.
  22. - To make a job abortable, you need to check %s channel in job handler and stop the handler func.
  23. `, "`ctx.Done()`")),
  24. Markdown(`
  25. ## Example
  26. `),
  27. ch.Code(generated.WorkerExample).Language("go"),
  28. utils.Demo(
  29. "Worker",
  30. path.Join(example_basics.WorkerExamplePath, "/workers"),
  31. "example_basics/worker.go",
  32. ),
  33. Markdown(`
  34. ## Action Worker
  35. Action Worker is used to visualize the progress of long-running actions.
  36. `),
  37. ch.Code(generated.ActionWorkerExample).Language("go"),
  38. utils.Demo(
  39. "Action Worker",
  40. path.Join(example_basics.ActionWorkerExamplePath, "/example-resources"),
  41. "example_basics/action_worker.go",
  42. ),
  43. ).Slug("basics/worker").Title("Worker")