openfaas / templates

OpenFaaS Classic templates
https://www.openfaas.com
MIT License
281 stars 227 forks source link

Update vert.x template to 4.x #285

Open pmlopes opened 2 years ago

pmlopes commented 2 years ago

Signed-off-by: Paulo Lopes pmlopes@gmail.com

Fixes #282

Description

This PR will update the template to:

Motivation and Context

The original template has several limitations and is using a almost unsupported release of Vert.x. The current template allows simple functions but lacks ways to configure features like, safe body parsing, CORS, JWTs...

This new template tries to address the issues as described in the linked issue.

How Has This Been Tested?

A basic unit test is added to the project and docker images built and tested.

Types of changes

Impact to existing users

For existing users, the main function entry signature is changed, so it requires a small change to existing functions.

Old:

public class Handler implements io.vertx.core.Handler<RoutingContext> {

  public void handle(RoutingContext routingContext) {
    // user function body
  }
}

New:

public class OpenFaasFunction implements Function<RoutingContext, Future<JsonObject>> {

    public Future<JsonObject> apply(RoutingContext routingContext) {
      // user function body
    }
}

Checklist:

pmlopes commented 2 years ago

@alexellis please have a look at the PR and the discussion about upgrading the template. I believe this PR would make it easier to support all features of vert.x and user customization with a small breaking change.

If you wish to avoid the breaking change, I can adapt the function code itself to be closer to the original.

pmlopes commented 2 years ago

PR is updated to be fully backwards compatible and docs updated.

pmlopes commented 2 years ago

Fixes #256