Skip to content

add warm up trigger #183

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
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;


/**
* <p> 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}</p>
*
*
* <p>The following example shows a Java function that logs the message body of the event hub trigger:</p>
*
* <pre>{@literal @}FunctionName("Warmup")
* public void warmup(
* {@literal @}WarmupTrigger Object warmupContext,
* final ExecutionContext context
* ) {
* context.getLogger().info("Function App instance is warm up");
* }</pre>
*
* @since 2.0.2
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.PARAMETER)
@CustomBinding(direction = "in", name = "warmupContext", type = "warmupTrigger")
public @interface WarmupTrigger {
/**
* The variable name used in function code for the request or request body.
*
* @return The variable name used in function code for the request or request body.
*/
String name() default "warmupContext";

/**
* <p>Defines how Functions runtime should treat the parameter value. Possible values are:</p>
* <ul>
* <li>"": get the value as a string, and try to deserialize to actual parameter type like POJO</li>
* <li>string: always get the value as a string</li>
* <li>binary: get the value as a binary data, and try to deserialize to actual parameter type byte[]</li>
* </ul>
* @return The dataType which will be used by the Functions runtime.
*/
String dataType() default "";
}