Skip to content

Dynamic selection of servlet runtime for Micronaut Applications #2413

@wwwsahoo

Description

@wwwsahoo

Feature description

In an attempt to reduce the native image size we opted for the option of selecting servlet runtime to be Apache-http-poja, Netty, Jetty, or Tomcat at build time using classpath based bean discovery. The goal of this meeting is to explore possibilities to allow user to defer the selection to runtime. This has two important benefits:

  1. User can create a single image and decide whether to run it as a (serverless) function or server at runtime depending on usage of the application.
  2. Current solution may not work with layered native image where all the runtimes may be present in classpath.

The runtime selection seems to be done in the following code in Micronaut.start():

EmbeddedApplication<?> embeddedApplication = (EmbeddedApplication)applicationContext.findBean(EmbeddedApplication.class).orElse((Object)null);

Can we annotate ApacheServerlessApplication with @requires(condition = CustomConditition.class) where CustomCondition is defined something like this?

`
public class CustomCondition implements Condition {

public boolean matches(ConditionContext context) {

    return System.inheritedChannel() instanceOf SocketInputChannel || Boolean.valueOf(System.getProperty("HTTP_POJA"));

}

}
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions