Sidekiq returning job id

3.1k views Asked by At

I'm have a check_delivery method which uses Sidekiq to call the EasyPost api gem.

  def check_delivery
    if tracking_number.present?
      EasypostWorker.perform_async(tracking_number)
    end
  end

class EasypostWorker
  include Sidekiq::Worker

  def perform(tracking_number)
    EasyPost.api_key = Rails.application.secrets.easypost_api_key
    tracker = EasyPost::Tracker.create(tracking_code: tracking_number)
    tracker.status
  end
end

However this returns the 24 random char Sidekiq job id instead of the tracker status (ie, "out_for_delivery", "delivered", etc.)

What am I doing wrong?

1

There are 1 answers

0
zapatos On

The check_delivery method was calling the EasypostWorker, which returned the job id.

Apparently Sidekiq Workers don't return results like regular ruby classes and methods.

So I added a status attribute to my model and updated the attribute inside the Worker.