-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* Copyright (c) 2022 Gitpod GmbH. All rights reserved. | ||
* Licensed under the GNU Affero General Public License (AGPL). | ||
* See License-AGPL.txt in the project root for license information. | ||
*/ | ||
|
||
export type PrebuildRateLimiters = { [cloneURL: string]: PrebuildRateLimiterConfig } & { | ||
"*": PrebuildRateLimiterConfig; | ||
}; | ||
|
||
export type PrebuildRateLimiterConfig = { | ||
// maximum number of requests per period | ||
limit: number; | ||
|
||
// time period which the limit is enforce against in seconds | ||
period: number; | ||
}; | ||
|
||
export namespace PrebuildRateLimiterConfig { | ||
const DEFAULT_CONFIG: PrebuildRateLimiterConfig = { | ||
limit: 50, | ||
period: 50, | ||
}; | ||
|
||
export function getConfigForCloneURL( | ||
rateLimiters: PrebuildRateLimiters, | ||
cloneURL: string, | ||
): PrebuildRateLimiterConfig { | ||
// First we use any explicit overrides for a given cloneURL | ||
let config = rateLimiters[cloneURL]; | ||
if (config) { | ||
return config; | ||
} | ||
|
||
// Find if there is a default value set under the '*' key | ||
config = rateLimiters["*"]; | ||
if (config) { | ||
return config; | ||
} | ||
|
||
// Last resort default | ||
return DEFAULT_CONFIG; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.