mreinstein / node-gearman

⚙ Gearman client and worker for node
75 stars 13 forks source link

Support running a callback when a job is submitted #27

Closed emlove closed 4 years ago

emlove commented 4 years ago

Description

This PR adds support for running a callback after a job is completely submitted. The callback supported by the nodejs net.socket is exposed here, so that the client can know when the job submission is complete. Since socket.write may buffer in internal memory, the callback is the most reliable way to know that all the data has been transmitted.

This use case here is a one-off script that creates a gearman client, and schedules a job but doesn't need to wait for the job to be completed. In our case we're using an AWS lambda to schedule gearman jobs. We don't want the script running until the job is complete so we use as little billable time as possible, but we do need to guarantee that the packets have been sent.

mreinstein commented 4 years ago

LGTM! 👍

mreinstein commented 4 years ago

Thanks for the PR!

emlove commented 4 years ago

Thanks for the quick merge! :bowing_woman: