Class: Rubino::CLI::JobsCommand
- Inherits:
-
Thor
- Object
- Thor
- Rubino::CLI::JobsCommand
- Defined in:
- lib/rubino/cli/jobs_command.rb
Overview
Subcommands for managing the job queue
Class Method Summary collapse
- .exit_on_failure? ⇒ Boolean
-
.render_list(jobs, ui:) ⇒ Object
ONE jobs-table rendering for both surfaces (#187): this CLI verb and the in-chat /jobs list (Commands::Executor).
Instance Method Summary collapse
Class Method Details
.exit_on_failure? ⇒ Boolean
12 13 14 |
# File 'lib/rubino/cli/jobs_command.rb', line 12 def self.exit_on_failure? true end |
.render_list(jobs, ui:) ⇒ Object
ONE jobs-table rendering for both surfaces (#187): this CLI verb and the in-chat /jobs list (Commands::Executor).
49 50 51 52 53 54 55 |
# File 'lib/rubino/cli/jobs_command.rb', line 49 def self.render_list(jobs, ui:) rows = jobs.map do |j| [j[:id][0..7], j[:type], j[:status], j[:attempts].to_s, j[:run_at]] end ui.table(headers: %w[ID Type Status Attempts RunAt], rows: rows) end |
Instance Method Details
#list ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rubino/cli/jobs_command.rb', line 23 def list ensure_jobs_database! queue = Jobs::Queue.new jobs = queue.list(status: [:status], limit: [:limit]) if jobs.empty? # Don't dead-end an empty queue (#559): say how jobs get here (enqueued # automatically during a chat) instead of a bare "No jobs found.", # matching the actionable empty state `sessions list` gives. A `--status` # filter may just be hiding rows, so name that case. msg = if [:status] "No #{[:status]} jobs (drop --status to see every job)." else "No jobs yet — rubino queues background work (e.g. memory polishing) " \ "as you chat. Run `rubino chat`, and jobs will appear here." end Rubino.ui.info(msg) return end self.class.render_list(jobs, ui: Rubino.ui) end |
#process ⇒ Object
59 60 61 62 63 64 |
# File 'lib/rubino/cli/jobs_command.rb', line 59 def process ensure_jobs_database! runner = Jobs::Runner.new processed = runner.run_pending(limit: [:limit]) Rubino.ui.success("Processed #{processed} job(s)") end |
#worker ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/rubino/cli/jobs_command.rb', line 67 def worker ensure_jobs_database! Rubino.ui.info("Starting job worker (poll every #{Rubino.configuration.dig("jobs", "poll_interval")}s)...") Rubino.ui.info("Press Ctrl+C to stop.") worker = Jobs::Worker.new worker.start end |