mosquito-cr / mosquito

A background task runner for crystal applications supporting periodic (CRON) and manually queued jobs
MIT License
227 stars 24 forks source link

Unable to write a job with no params #66

Closed jwoertink closed 2 years ago

jwoertink commented 3 years ago

Making a job worker with no params like this

class SyncStatusWorker < Mosquito::QueuedJob
  def perform
    # code
  end
end

SyncStatusWorker.new.enqueue

will throw this compile error

❯ crystal src/start_server.cr
Showing last frame. Use --error-trace for full trace.

In lib/mosquito/src/mosquito/queued_job.cr:107:14

 107 | task = build_task
              ^---------
Error: undefined local variable or method 'build_task' for SyncStatusWorker

To get around it, you can just call params in the head of the class.

Crystal version: 1.1.1 Mosquito Shard version: 0.11.0