dimanche 30 juin 2019

Sequentially execute webhooks received in node application

I have a node application using koa. It receiving webhooks from external application on specific resources.

To illustrate let say the webhook send me with POST request an object of this type :

{
  'resource_id':'<SomeID>',
  'resource_origin':'<SomeResourceOrigin>',
  'value' : '<SomeValue>'
}

I would like to execute sequentially any resources coming from the same origin to avoid desynchronization of resources related to my execution.

I was thinking to use database as lock and use cron to sequentially executing my process for each resources of same origin.

But I'm not sure it's the most efficient method.

So my question is here :

Do you know some method/package/service allowing me to use global queues that I could implement for each origin insuring resources from same origin will be executed synchronously without making all webhooks processed sequentially ? If it do not use database it's better.

Aucun commentaire:

Enregistrer un commentaire