I have a worker that handles form submissions. One of the things that it does is using 3rd party service to send email notifications.
I’d like to make this part more resilience and handle it in an asynchronous manner. I.e. the worker will write an email-job to a durable-object (or maybe k/v is enough?), and then trigger another worker to handle that job.
This will allow me to (a) finish the first worker faster, and (b) handle retries by using a cron-job worker that will pick all the jobs that filed to send (e.g. due to downtime with the 3rd party service)
- Does this high level plan sounds right? Any other suggestions?
- I know that a worker cannot trigger another worker in the same zone. If my 2nd worker will be on workers.dev subdomain, will I be able to trigger it from the first worker?
- In case of downtime with the 3rd party service, the cron-job might take a while to run in order to resend all jobs that have failed. Is there a limit on the runtime of a cron-job worker?
- The blogpost about durable-objects mentioned pub/sub use-case. Is this how it was intended to be used? I.e. using cron-job worker that will read jobs from it? Is there a sample code that does something like that?