From 90cfb4cc71fa6b2666d301c287a21ff2f6cf69e0 Mon Sep 17 00:00:00 2001 From: kaibocai <89094811+kaibocai@users.noreply.github.com> Date: Wed, 10 Aug 2022 15:04:30 -0500 Subject: [PATCH 1/2] add warm up trigger --- .../functions/annotation/WarmupTrigger.java | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 src/main/java/com/microsoft/azure/functions/annotation/WarmupTrigger.java diff --git a/src/main/java/com/microsoft/azure/functions/annotation/WarmupTrigger.java b/src/main/java/com/microsoft/azure/functions/annotation/WarmupTrigger.java new file mode 100644 index 0000000..03d9833 --- /dev/null +++ b/src/main/java/com/microsoft/azure/functions/annotation/WarmupTrigger.java @@ -0,0 +1,43 @@ +package com.microsoft.azure.functions.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +/** + *
The warmup trigger lets you define a function that's run when a new instance of your function app is started. + * You can use a warmup trigger to pre-load custom dependencies during the pre-warming process so your functions are + * ready to start processing requests immediately. Some actions for a warmup trigger might include opening connections, + * loading dependencies, or running any other custom logic before your app begins receiving traffic. + * The parameter type should be set as {@link java.lang.Object}
+ * + * + *The following example shows a Java function that logs the message body of the event hub trigger:
+ * + *{@literal @}FunctionName("Warmup") + * public void warmup( + * {@literal @}WarmupTrigger Object warmupContext, + * final ExecutionContext context + * ) { + * context.getLogger().info("Function App instance is warm up"); + * }+ * + * @since 2.0.2 + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.PARAMETER) +@CustomBinding(direction = "in", name = "warmupContext", type = "warmupTrigger") +public @interface WarmupTrigger { + /** + *
Defines how Functions runtime should treat the parameter value. Possible values are:
+ *Defines how Functions runtime should treat the parameter value. Possible values are:
*