Your skill will accomplish what the force of many cannot |
|
PerlMonks |
Module callbacks - to fork or not forkby Bod (Parson) |
on Feb 28, 2023 at 23:10 UTC ( [id://11150655]=perlquestion: print w/replies, xml ) | Need Help?? |
Bod has asked for the wisdom of the Perl Monks concerning the following question: I am writing a module to handle Stripe webhook calls. The module does the necessary checking that the call has come from Stripe and provides the user with a means to give defined callbacks for each webhook. They simply pass in a parameter that matches the Stripe event so it is compatible when Stripe adds new events. The module is instantiated like this: Here we call &paid; when Stripe sends an invoice.paid event. Plus, we call &all; for every event sent. The person using the module could do things that take a significant time in those subs. But the documentation says "your endpoint must quickly return a successful status code (2xx) prior to any complex logic that could cause a timeout.". So should I fork to another process for the callback or should I warn the user of the module in the documentation? Something along the lines of: "If your logic might take some time to complete, fork a new process and perform your logic there. This will allow a timely reply to be sent back to Stripe." Or should I be dealing with this problem in some other way? This is the code that provides the callback:
In my own implementation of handling events from Stripe, I only make a couple of calls to the database and write to a text file. But of course, I have no idea what other people might want to do with the callbacks. They might decide to send an email which is usually not exactly quick...
Back to
Seekers of Perl Wisdom
|
|