Annotation Interface Function


@Retention(SOURCE) @Target(METHOD) public @interface Function
Marks a method as a deployable cloud function.

The annotated method is discovered during annotation processing, which generates the provider-specific CloudRequestHandler and the deployment artifacts for it — you no longer implement that interface yourself. Combine @Function with a trigger such as HttpTrigger or ScheduledTrigger, and bind the method parameters with RequestBody, PathParam, QueryParam or HeaderParam.

Example:


 @Function(name = "hello")
 @HttpTrigger(method = "GET", path = "/hello/{name}")
 public String hello(@PathParam("name") String name) {
     return "Hello, " + name;
 }
 
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Constants representing the attribute names of Function.
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The unique name of the function in the deployment target.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Register extension attributes, for example vendor specific extensions or unsupported attributes you need for your generator.
    int
    The maximum memory allocated to the function (in megabytes).
    int
    The minimum number of instances to keep warm.
    int
    The function timeout in seconds.
  • Element Details

    • name

      String name
      The unique name of the function in the deployment target.
      Returns:
      the function name
    • memory

      int memory
      The maximum memory allocated to the function (in megabytes). Default is 128 MB.
      Returns:
      the memory limit in MB
      Default:
      128
    • timeout

      int timeout
      The function timeout in seconds. Defines how long the function may run before being terminated. Default is 30 seconds.
      Returns:
      timeout in seconds
      Default:
      30
    • minInstances

      int minInstances
      The minimum number of instances to keep warm. This enables pre-warming for reduced cold starts on some platforms. Default is 0.
      Returns:
      minimum instance count
      Default:
      0
    • extensions

      Extension[] extensions
      Register extension attributes, for example vendor specific extensions or unsupported attributes you need for your generator.
      Returns:
      the extension attributes, or an empty array if none
      Default:
      {}