Limit concurrent downloads & uploads (#2313)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 = "/"
|
||||
)
|
||||
|
||||
@@ -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": {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user