Limit concurrent downloads & uploads (#2313)

This commit is contained in:
Alex
2022-09-23 12:35:55 -05:00
committed by GitHub
parent c4c6d48abf
commit d1511c5eb0
20 changed files with 412 additions and 20 deletions

View File

@@ -254,3 +254,21 @@ func getPrometheusJobID() string {
func getPrometheusExtraLabels() string {
return env.Get(PrometheusExtraLabels, "")
}
func getMaxConcurrentUploadsLimit() int64 {
cu, err := strconv.ParseInt(env.Get(ConsoleMaxConcurrentUploads, "10"), 10, 64)
if err != nil {
return 10
}
return cu
}
func getMaxConcurrentDownloadsLimit() int64 {
cu, err := strconv.ParseInt(env.Get(ConsoleMaxConcurrentDownloads, "20"), 10, 64)
if err != nil {
return 20
}
return cu
}

View File

@@ -51,6 +51,8 @@ const (
PrometheusExtraLabels = "CONSOLE_PROMETHEUS_EXTRA_LABELS"
ConsoleLogQueryURL = "CONSOLE_LOG_QUERY_URL"
ConsoleLogQueryAuthToken = "CONSOLE_LOG_QUERY_AUTH_TOKEN"
ConsoleMaxConcurrentUploads = "CONSOLE_MAX_CONCURRENT_UPLOADS"
ConsoleMaxConcurrentDownloads = "CONSOLE_MAX_CONCURRENT_DOWNLOADS"
LogSearchQueryAuthToken = "LOGSEARCH_QUERY_AUTH_TOKEN"
SlashSeparator = "/"
)

View File

@@ -5570,6 +5570,17 @@ func init() {
}
}
},
"environmentConstants": {
"type": "object",
"properties": {
"maxConcurrentDownloads": {
"type": "integer"
},
"maxConcurrentUploads": {
"type": "integer"
}
}
},
"error": {
"type": "object",
"required": [
@@ -5978,6 +5989,9 @@ func init() {
"type": "string"
}
},
"isDirectPV": {
"type": "boolean"
},
"loginStrategy": {
"type": "string",
"enum": [
@@ -6888,6 +6902,9 @@ func init() {
"distributedMode": {
"type": "boolean"
},
"envConstants": {
"$ref": "#/definitions/environmentConstants"
},
"features": {
"type": "array",
"items": {
@@ -13440,6 +13457,17 @@ func init() {
}
}
},
"environmentConstants": {
"type": "object",
"properties": {
"maxConcurrentDownloads": {
"type": "integer"
},
"maxConcurrentUploads": {
"type": "integer"
}
}
},
"error": {
"type": "object",
"required": [
@@ -13848,6 +13876,9 @@ func init() {
"type": "string"
}
},
"isDirectPV": {
"type": "boolean"
},
"loginStrategy": {
"type": "string",
"enum": [
@@ -14758,6 +14789,9 @@ func init() {
"distributedMode": {
"type": "boolean"
},
"envConstants": {
"$ref": "#/definitions/environmentConstants"
},
"features": {
"type": "array",
"items": {

View File

@@ -238,6 +238,13 @@ func getSessionResponse(ctx context.Context, session *models.Principal) (*models
if err != nil {
return nil, ErrorWithContext(ctx, err)
}
// environment constants
var envConstants models.EnvironmentConstants
envConstants.MaxConcurrentUploads = getMaxConcurrentUploadsLimit()
envConstants.MaxConcurrentDownloads = getMaxConcurrentDownloadsLimit()
sessionResp := &models.SessionResponse{
Features: getListOfEnabledFeatures(session),
Status: models.SessionResponseStatusOk,
@@ -246,6 +253,7 @@ func getSessionResponse(ctx context.Context, session *models.Principal) (*models
Permissions: resourcePermissions,
AllowResources: allowResources,
CustomStyles: customStyles,
EnvConstants: &envConstants,
}
return sessionResp, nil
}