Add additional logging to CustomRuntimeEventLoop

This commit is contained in:
Oleg Zhurakousky
2021-12-06 12:55:42 +01:00
parent 0475ae5671
commit 5f7313ff31

View File

@@ -174,25 +174,33 @@ public final class CustomRuntimeEventLoop implements SmartLifecycle {
private FunctionInvocationWrapper locateFunction(Environment environment, FunctionCatalog functionCatalog, MediaType contentType) {
String handlerName = environment.getProperty("DEFAULT_HANDLER");
if (logger.isDebugEnabled()) {
logger.debug("Value of DEFAULT_HANDLER env: " + handlerName);
}
FunctionInvocationWrapper function = functionCatalog.lookup(handlerName, contentType.toString());
if (function == null) {
logger.debug("Could not locate function under DEFAULT_HANDLER");
handlerName = environment.getProperty("_HANDLER");
if (logger.isDebugEnabled()) {
logger.debug("Value of _HANDLER env: " + handlerName);
}
function = functionCatalog.lookup(handlerName, contentType.toString());
}
if (function == null) {
function = functionCatalog.lookup(null, contentType.toString());
logger.debug("Could not locate function under _HANDLER");
function = functionCatalog.lookup((String) null, contentType.toString());
}
if (function == null) {
logger.info("Could not determine default function");
handlerName = environment.getProperty("spring.cloud.function.definition");
if (logger.isDebugEnabled()) {
logger.debug("Value of 'spring.cloud.function.definition' env: " + handlerName);
}
function = functionCatalog.lookup(handlerName, contentType.toString());
}
if (function == null) {
function = functionCatalog.lookup(null, contentType.toString());
}
Assert.notNull(function, "Failed to locate function. Tried locating default function, "
+ "function by 'DEFAULT_HANDLER', '_HANDLER' env variable as well as'spring.cloud.function.definition'. "
+ "Functions available in catalog are: " + functionCatalog.getNames(null));