Search code examples
ruby-on-railssidekiq

Rails 4 Pass Arguments To Sidekiq Worker


I am new to Sidekiq and currently using a worker to send push notifications asynchronously. Push notifications are sent when a message is sent by a user to another.

Since Sidekiq best practices are to make worker params small and simple, is it fine to pass the message text (<140 characters) directly in the params ?

perform(message_text, user_id)

Or is it better to fetch it with the message_id?


Solution

  • Yeah, that's totally fine if the text is all you need. Even better might be to include the message_id as another parameter so you can lookup the message if you need to in the future, i.e.

    perform(message_text, user_id, message_id)