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.
我是Sidekiq的新手,目前正在使用工作人员异步发送推送通知。当用户将消息发送给另一个消息时,将发送推送通知。
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 ?
由于Sidekiq最佳实践是使工作者参数小而简单,在params中直接传递消息文本(<140个字符)是否可以?
perform(message_text, user_id)
Or is it better to fetch it with the message_id?
或者使用message_id获取它是否更好?
1 个解决方案
#1
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.
是的,如果你需要的话,这完全没问题。更好的方法可能是将message_id包含为另一个参数,以便将来可以查找消息,即
perform(message_text, user_id, message_id)
#1
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.
是的,如果你需要的话,这完全没问题。更好的方法可能是将message_id包含为另一个参数,以便将来可以查找消息,即
perform(message_text, user_id, message_id)