public class HandlerInstrumentor extends Object
instrument or instrumentChecked| Modifier and Type | Method and Description |
|---|---|
static <I,O> O |
instrument(I input,
com.amazonaws.services.lambda.runtime.Context context,
Class<?> handlerClass,
Handler<O> handlerFunction)
Instruments the code execution specified by the handlerFunction.
|
static <I> void |
instrument(I input,
com.amazonaws.services.lambda.runtime.Context context,
Class<?> handlerClass,
Procedure handlerFunction)
Similar to
instrument(Object, Context, Class, Handler) except that the handler function returns nothing |
static <I,O,E extends Throwable> |
instrumentChecked(I input,
com.amazonaws.services.lambda.runtime.Context context,
Class<?> handlerClass,
CheckedHandler<O,E> handlerFunction)
Similar to
instrument(Object, Context, Class, Handler). |
static <I,E extends Throwable> |
instrumentChecked(I input,
com.amazonaws.services.lambda.runtime.Context context,
Class<?> handlerClass,
CheckedProcedure<E> handlerFunction)
Similar to
instrumentChecked(Object, Context, Class, CheckedHandler) except that the handler function returns nothing |
public static <I,O> O instrument(I input,
com.amazonaws.services.lambda.runtime.Context context,
Class<?> handlerClass,
Handler<O> handlerFunction)
public String handle(String input, Context context) {
//code logic
}
Then wrap the function by changing it to:
public String handle(String input, Context context) {
return HandlerInstrumentor.instrument(input, context, getClass(), () -> {
//original code logic
});
}
I - Input type of the original handlingO - Output type of the original handlinginput - The input for the handler, null if not availablecontext - The `com.amazonaws.services.lambda.runtime.Context` for this handling, null if not availablehandlerClass - The handler class, usually is this.getClass(), this is optionalhandlerFunction - Original code logic wrapped with `com.appoptics.awslambda.handler.Handler`public static <I> void instrument(I input,
com.amazonaws.services.lambda.runtime.Context context,
Class<?> handlerClass,
Procedure handlerFunction)
instrument(Object, Context, Class, Handler) except that the handler function returns nothingI - Input type of the original handlinginput - The input for the handler, null if not availablecontext - The `com.amazonaws.services.lambda.runtime.Context` for this handling, null if not availablehandlerClass - The handler class, usually is this.getClass(), this is optionalhandlerFunction - Original code logic wrapped with `com.appoptics.awslambda.handler.Procedure`public static <I,O,E extends Throwable> O instrumentChecked(I input, com.amazonaws.services.lambda.runtime.Context context, Class<?> handlerClass, CheckedHandler<O,E> handlerFunction) throws E extends Throwable
instrument(Object, Context, Class, Handler). Except that this can be used to
wrap handling code that throws checked exceptionI - Input type of the original handlingO - Output type of the original handlingE - Exception type thrown of the original handlinginput - The input for the handler, null if not availablecontext - The `com.amazonaws.services.lambda.runtime.Context` for this handling, null if not availablehandlerClass - The handler class, usually is this.getClass(), this is optionalhandlerFunction - Original code logic wrapped with `com.appoptics.awslambda.handler.CheckedHandler`E - Exception to be thrown by the original handlerFunctionE extends Throwablepublic static <I,E extends Throwable> void instrumentChecked(I input, com.amazonaws.services.lambda.runtime.Context context, Class<?> handlerClass, CheckedProcedure<E> handlerFunction) throws E extends Throwable
instrumentChecked(Object, Context, Class, CheckedHandler) except that the handler function returns nothingI - Input type of the original handlingE - Exception type thrown of the original handlinginput - The input for the handler, null if not availablecontext - The `com.amazonaws.services.lambda.runtime.Context` for this handling, null if not availablehandlerClass - The handler class, usually is this.getClass(), this is optionalhandlerFunction - Original code logic wrapped with `com.appoptics.awslambda.handler.CheckedProcedure`E - Exception to be thrown by the original handlerFunctionE extends ThrowableCopyright © 2020. All rights reserved.