Skip to content

add Environment variable: LOWCODER_DEFAULT_QUERY_TIMEOUT_MILLIS #1187

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
Sep 26, 2024
Merged
Show file tree
Hide file tree
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
Expand Up @@ -13,10 +13,18 @@
import org.lowcoder.sdk.exception.PluginException;

import com.google.common.annotations.VisibleForTesting;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public final class QueryTimeoutUtils {

private static final int DEFAULT_QUERY_TIMEOUT_MILLIS = 10000;
private static int defaultQueryTimeout = 10;

@Value("${default.query-timeout}")
public void setDefaultQueryTimeoutMillis(int defaultQueryTimeout) {
QueryTimeoutUtils.defaultQueryTimeout = defaultQueryTimeout;
}

public static int parseQueryTimeoutMs(String timeoutStr, Map<String, Object> paramMap, int maxQueryTimeout) {
return parseQueryTimeoutMs(renderMustacheString(timeoutStr, paramMap), maxQueryTimeout);
Expand All @@ -25,7 +33,7 @@ public static int parseQueryTimeoutMs(String timeoutStr, Map<String, Object> par
@VisibleForTesting
public static int parseQueryTimeoutMs(String timeoutStr, int maxQueryTimeout) {
if (StringUtils.isBlank(timeoutStr)) {
return DEFAULT_QUERY_TIMEOUT_MILLIS;
return Math.min(defaultQueryTimeout * 1000, (int)Duration.ofSeconds(maxQueryTimeout).toMillis());
}

Pair<String, Integer> unitInfo = getUnitInfo(timeoutStr);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ logging:
level:
root: debug
org.lowcoder: debug

default:
query-timeout: ${LOWCODER_DEFAULT_QUERY_TIMEOUT:10s}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ default:
org-app-count: ${LOWCODER_MAX_APPS_PER_ORG:1000}
developer-count: ${LOWCODER_MAX_DEVELOPERS:50}
api-rate-limit: ${LOWCODER_API_RATE_LIMIT:50}
query-timeout: ${LOWCODER_DEFAULT_QUERY_TIMEOUT:10}

common:
cookie-name: LOWCODER_CE_SELFHOST_TOKEN
Expand Down
Loading