pigato icon indicating copy to clipboard operation
pigato copied to clipboard

Workers communication strategy

Open TCMiranda opened this issue 9 years ago • 2 comments

Hello guys,

I am using Pigato in some projects for now, but sometimes I still get confusing about allowing workers to communicate or even to use each others services.

In some scenarios, I prefer to not allow sub levels of workers, but in other scenarios, this gives me much duplicate code, which I solve creating shared modules.

To illustrate a little better: captura de tela de 2016-02-13 21 19 52

So, what are your thoughts about it? Does anyone knows some good reference on this subject?

TCMiranda avatar Feb 13 '16 23:02 TCMiranda

@TCMiranda in my opinion the right solution is the first. Workers can communicate between them via a Pigato client as well, so no need of direct interaction.

Sometimes you may want to reuse code between multiple workers. There you have two solutions:

  1. use a shared library via a separate github/npm project: suggested when you want to share simple solutions
  2. create dedicated workers: suggested for the rest of usecases.

prdn avatar Feb 15 '16 13:02 prdn

@prdn thanks for your answer!

So, if workers are connected to the "handlers broker" as clients, you would agree to allow them to "communicate" by messages without a separate layer like the second case?

Like this: screenshot from 2016-02-15 15-53-56

The second solution you mentioned would be that case when a worker posts another message as a client to finish its request, right?

TCMiranda avatar Feb 15 '16 18:02 TCMiranda