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

Support crl-0.27.0 undefined epoch_ms #23

Closed duraki closed 5 years ago

duraki commented 6 years ago

When we try to enqueue a job to task store, we get an issue:

in lib/mosquito/src/mosquito/queued_job.cr:108: instantiating 'Mosquito::Task#store()'

      task.store
           ^~~~~

in lib/mosquito/src/mosquito/task.cr:46: undefined method 'epoch_ms' for Time

      epoch = time.epoch_ms.to_s
                   ^~~~~~~~

Rerun with --error-trace to show a complete error trace.

epoch_ms is removed in favour to Times to_unix_ms.

duraki commented 6 years ago

For a quick and dirty fix:

struct Time
  def epoch_ms
    self.to_unix_ms
  end

  def epoch
    self.to_unix
  end

  def self.epoch(ms : Int)
    Time.new.to_unix
  end
end
Blacksmoke16 commented 6 years ago

Making a PR for this now.

duraki commented 6 years ago

Thanks for #25 @Blacksmoke16 :)! Testing WIP.

Blacksmoke16 commented 5 years ago

@duraki This is now fixed in mosquito 0.3.0.

@robacarp Can probably close this now.