Skip to content

Commit 35639ab

Browse files
authored
add warm up trigger (#183)
* add warm up trigger * add back name field
1 parent c45de69 commit 35639ab

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
package com.microsoft.azure.functions.annotation;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
9+
/**
10+
* <p> The warmup trigger lets you define a function that's run when a new instance of your function app is started.
11+
* You can use a warmup trigger to pre-load custom dependencies during the pre-warming process so your functions are
12+
* ready to start processing requests immediately. Some actions for a warmup trigger might include opening connections,
13+
* loading dependencies, or running any other custom logic before your app begins receiving traffic.
14+
* The parameter type should be set as {@link java.lang.Object}</p>
15+
*
16+
*
17+
* <p>The following example shows a Java function that logs the message body of the event hub trigger:</p>
18+
*
19+
* <pre>{@literal @}FunctionName("Warmup")
20+
* public void warmup(
21+
* {@literal @}WarmupTrigger Object warmupContext,
22+
* final ExecutionContext context
23+
* ) {
24+
* context.getLogger().info("Function App instance is warm up");
25+
* }</pre>
26+
*
27+
* @since 2.0.2
28+
*/
29+
@Retention(RetentionPolicy.RUNTIME)
30+
@Target(ElementType.PARAMETER)
31+
@CustomBinding(direction = "in", name = "warmupContext", type = "warmupTrigger")
32+
public @interface WarmupTrigger {
33+
/**
34+
* The variable name used in function code for the request or request body.
35+
*
36+
* @return The variable name used in function code for the request or request body.
37+
*/
38+
String name() default "warmupContext";
39+
40+
/**
41+
* <p>Defines how Functions runtime should treat the parameter value. Possible values are:</p>
42+
* <ul>
43+
* <li>"": get the value as a string, and try to deserialize to actual parameter type like POJO</li>
44+
* <li>string: always get the value as a string</li>
45+
* <li>binary: get the value as a binary data, and try to deserialize to actual parameter type byte[]</li>
46+
* </ul>
47+
* @return The dataType which will be used by the Functions runtime.
48+
*/
49+
String dataType() default "";
50+
}

0 commit comments

Comments
 (0)