Open wang007 opened 3 years ago
The Vert.x model is to design independent units of processing as verticles and exchange messages over the eventbus to avoid multithread programming issues.
If you need three components to be invoked on the same Vert.x context, why not deploying a single verticle and creating the components inside?
As the title says, we want a group of Verticle to run on the same context. This is useful when you have a large number of Verticle. I've already discussed this feature with Vietj on Discord, and VietJ says it is an interesting approach.
For solving this issue, VerticleGroup is useful https://github.com/vert-x3/vertx-web/issues/1909
I think it would be simpler to allow a verticle to inherit the context of its parent when it is deployed, e.g new DeploymentOptions().setInheritParentContext(true)
This would be rejected when the number of instances is > 1
@vietj I think they are different, and they can exist together. InheritParentContext has some restrictions, such as whether it is the same Work Pool and the configuration associated with the Work Pool. But the verticleGroup doesn't need to be concerned because these options must be the same.
VerticleGroup is just a functional class; it doesn't change anything. The user can choose to use it or not, but it works well
when you haved a list of verticle that hope to run on the same context to avoid data race, you can used VerticleGroup
Use cases
VerticleA, VerticleB, VerticleC and CompositeVerticleGroup will run on the same context.
Contribution
yes, I haved create an pr