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

Error: undefined method 'serialize_uuid' for SomeJob #61

Closed jwoertink closed 3 years ago

jwoertink commented 3 years ago

Please include some details:

Using UUID in params seems to fail.

class SomeJob < Mosquito::QueuedJob
  params user_id : UUID

  def perform
  end
end
web          |  > 71 |               task.config["user_id"] = serialize_uuid(user_id)
web          |                                                ^-------------
web          | Error: undefined method 'serialize_uuid' for SomeJob

Crystal version: 0.36.1 Mosquito Shard version: 0.9.0+git.commit.5f28c5ee997ac40e0177743161db09ec8bd2e477

robacarp commented 3 years ago

@jwoertink the quick and easy fix for this is to use strings.

The right fix is to declare a method called (de)serialize_uuid either in your Job class or in the primitives class.

While I'm not super keen on hundreds of serializers hanging around, uuid seems like a reasonable one to add since it's a crystal core lib.