-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sqewer::SimpleJob doesn't help adding new attributes to a Job class #66
Comments
I'm in favour, spawning new jobs every time is a pain! |
While I do see changes like this as pretty cumbersome, I don't think they outweigh safety and the overall reliability of the library. Runtime issues caused by wrong arguments passed are more frequently to occur than the need to alter a job's interface. Therefore, I do see the reasoning for why it has been designed like this. I believe we could improve this, though I am not sure your proposed solution should be the way. For simplicity, I would either keep the contract strict, or would remove the need for it and rely on developer's common sense (in the Sidekiq way). Mixing the two would only cause confusion when using the library, imho. |
My idea is not to change the standard as it is today, because even if it is not a compatibility break, it would change a behavior that some developers are used to. Therefore, I'd prefer to make the opt-in explicit. |
I understand @linkyndy 's concern, but if we clearly document the intended use case I think this could be a good approach. For example, the README could include a section like this: Adding job attributesBy default, Sqewer raises For this, Sqewer provides |
To me, this sounds more confusing (I am a fan of simplicity and of having a single, clear way of doing things). And if one anyway would have to add something only to remove it later, it doesn't improve the process by much. But if you feel this would really have a positive impact, don't get blocked by me 🙂 |
Imagine one worker (let's call it "Worker O") has |
@julik could you tell me pls where I can find this code in Sqewer? I mean the part which detects a failure and enqueue the job to the dead-letter queue. I couldn't find it. |
That would be SQS' job. Received messages by clients need to be deleted from the queue. If they are not, and the message is received more times than it is allowed, it goes to the dead-letter queue. |
From what I understand, the job wouldn't be deleted from the queue and it would still with the same attributes (having the bit_depth set), isn't it? And I can't see a problem with this, but I might be wrong 🤔 |
If we don't agree on changing this, it's also possible to improve the README giving more details about this process of adding a new attribute. For example, we can suggest creating another worker and also reviewing the PR using the |
Sometimes, we want to add a new attribute to a Job class, which includes
Sqewer::SimpleJob
, but it's not possible becauseSqewer::SimpleJob.new
raises an error when it detects that there are missing attributes.Example:
Assuming that exists the following job:
And we want to add the attribute
height
:By doing this, when the new version is deployed, if there are old jobs enqueued, it will raise
MissingAttribute
because of this piece of code:So, the only option to add a new attribute is to add a new job, duplicating the previous one, for example:
This has the advantage of being safer when changing the job's payload, but it complicates the analysis if the PR because a whole new file has been added.
My suggestion is adding a method to allow changing this behaviour, such as:
By doing this we can use the new attribute assuming that it may not exist, for example:
wdyt?
cc @julik @linkyndy @nitika080289 @martijnvermaat @lorenzograndi4
The text was updated successfully, but these errors were encountered: