-
-
Notifications
You must be signed in to change notification settings - Fork 31
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
Feature/pushb #272
Feature/pushb #272
Conversation
added encoding array to json utility method
This is according to the feature highlighted in faktory.
Fixed linting issue.
@jbielick Hey Josh, Thanks |
Hi @ankitAtVauld . Thanks for the work and following the new server features. At a high level, I think I would prefer to see this library generate JIDs for the payloads. That would align pretty well with the rest of the library and the push_bulk functionality in Sidekiq. Is there some reasoning for avoiding creating JIDs that I'm not seeing? Additionally, how would you feel about naming the client method Do you think the I'd be happy to add on some of these changes, but thought I would get your feedback first. If you'd like me to take this a bit further before releasing I can merge as-is and then add some of the behavior or changes I'm describing and then release after adding tests. |
@@ -4,6 +4,10 @@ export function encode(object: Record<string, unknown>): string { | |||
return JSON.stringify(object); | |||
} | |||
|
|||
export function encodeArray(object: Array<Record<string, unknown>>): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should be able to use encode
instead of making a new function. The type signature for encode
would need to be updated to something like Record<string, unknown> | Array
I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh if that works, it would be great. As both of these do exactly same thing. I just figured below works as you mentioned:
export function encode(
object: Record<string, unknown> | Array<Record<string, unknown>>
): string {
return JSON.stringify(object);
}
Lack of experience on Typescript :)
Appreciate your response Josh. Below are my comments on your suggestions. At a high level, I think I would prefer to see this library generate JIDs for the payloads. That would align pretty well with the rest of the library and the push_bulk functionality in Sidekiq. Is there some reasoning for avoiding creating JIDs that I'm not seeing? -- My thought process was to let the submitter match the submitted JIDs with failed JIDs in response. Never used sidekiq, so I would go with your way to align it pretty well with existing framework. Additionally, how would you feel about naming the client method pushBulk to match the order of the command PUSHB (push-bulk). -- I agree. Do you think the Job class or a new class could help here at all? That is, would a nicer developer experience be an API where you can successively add jobs to a local list and then push the whole list? JIDs would be automatically created and perhaps we can model the server response somehow to make it easier to identify which jobs (and their args) that failed? I think the JID mapping from client to server can be handled within the library, what's important to the developer is probably what jobtype and job args failed to submit. -- I think that would be the way to do it if we would like to let library handle the JIDs. I'd be happy to add on some of these changes, but thought I would get your feedback first. If you'd like me to take this a bit further before releasing I can merge as-is and then add some of the behavior or changes I'm describing and then release after adding tests. -- Would be great to see the changes the way you mentioned. Let me know if I can be of any help. |
@ankitAtVauld Great. Thanks for the feedback. I'm going to merge this and take it a bit further. I'll post here when I've got something to show. |
@jbielick Thanks Josh. Would you like to release it with a newer version soon, so that we can upgrade our dependency to use it. |
@ankitAtVauld Could you try out v4.3.0? It's published now with {
'123': {
reason: "Reason from server",
payload: {
jid: '123',
jobtype: 'XyzJob',
args: [...]
}
}
} |
@jbielick Appreciate your valuable time. Thanks a ton. Yeah this works well. I already integrated with our code and will soon test out this. |
Bulk Push feature as supported by latest version of faktory.
https://github.com/contribsys/faktory/blob/main/Changes.md#160