Pass Object to Sidekiq
Best way to approach the problem you are trying to solve is to save the object data in a database and then pass the id of @mixpanel
to your MixpanelWorker
job like so:
@mixpanel = Mixpanel.create [your parameters]
MixpanelWorker.perform_async @mixpanel.id, 'person', mixpanel_distinct_id, cleaned_params
Then your MixpanelWorker
would handle the job like this:
def perform(mixpanel_id, type_of_send, distinct_id, event)
mixpanel_object = Mixpanel.find mixpanel_id
case type_of_send
when 'person'
mixpanel_object.people.set(distinct_id, event)
when 'event'
mixpanel_object.track(distinct_id, event)
end
end
Also read the link that Mike Perham posted, I think he may know a little about Sidekiq ;).