Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Routing operation exposed via Event Bus #13

Open
tomaszmichalak opened this issue Feb 28, 2019 · 4 comments
Open

Routing operation exposed via Event Bus #13

tomaszmichalak opened this issue Feb 28, 2019 · 4 comments
Labels
enhancement New feature or request

Comments

@tomaszmichalak
Copy link
Member

Vert.x API Contract allows to define operations that are consumed by event bus handlers. This functionality comes from https://vertx.io/docs/vertx-web-api-service/java/. This issue is about defining and implementing this new functionality.

@tomaszmichalak
Copy link
Member Author

@tomaszmichalak tomaszmichalak added the enhancement New feature or request label Feb 28, 2019
@tomaszmichalak
Copy link
Member Author

Additional references here: https://vertx.io/blog/vert-x-web-api-service-introduction/

@tomaszmichalak
Copy link
Member Author

Analysis

In a typical Vert.x application, when you receive a request to your router, you would forward it to an event bus endpoint that performs some actions and sends the result back to the operation handler.

This makes the encapsulation of the service logic easy to achieve. The class that implements the interface is exposed via Event Bus, and its methods correspond with operations defined in the Open API spec configuration. This allows you to create an interface in the form of:

@WebApiServiceGen
public interface MyService {
  void get(...);
  void create(...);
  void update();
  void delete();
}

Scalability

Each service implementation is exposed with a dedicated Verticle. This allows us to define more instances of the same service that listen on a specific address (Vert.x provides load balancing ootb).

Use cases

With this approach we need to serialize all request (think about streams) data and send it via Event Bus. It fits well REST API interfaces but make it more complicated when we define more complex endpoints. So the current implementation (with io.knotx.server.api.handler.RoutingHandlerFactory) is valid and allows to define Handlers in the form of chain.

Problems

We need to make sure that we do not register routing handlers when x-vertx-event-bus is defined. Additionally we need to verify how we can define failure handlers for those services.

Example

The example interface should be a part of https://github.com/Knotx/knotx-example-project.

tomaszmichalak added a commit that referenced this issue Mar 11, 2019
…ervices

Routing operation exposed via Event Bus
@marcinus
Copy link
Contributor

@tomaszmichalak should this issue be closed by now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants