Revert of "feat: Throttle calls to Bitbucket Server API #27850"
Revert "chore: adding reports" This reverts commit3f34ea918d. Revert "Adding throttling" This reverts commit8f7a06bcbf. Revert "Add throttling to bitbucket server client" This reverts commitb3ff40c269. Signed-off-by: Nowacki, Kacper <kacper.nowacki@dynatrace.com>
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend-module-bitbucket-server': minor
|
||||
'@backstage/backend-defaults': minor
|
||||
---
|
||||
|
||||
Remove Throttle of Bitbucket Server API calls
|
||||
@@ -173,7 +173,6 @@
|
||||
"node-fetch": "^2.7.0",
|
||||
"node-forge": "^1.3.1",
|
||||
"p-limit": "^3.1.0",
|
||||
"p-throttle": "^4.1.1",
|
||||
"path-to-regexp": "^8.0.0",
|
||||
"pg": "^8.11.3",
|
||||
"pg-connection-string": "^2.3.0",
|
||||
|
||||
+3
-17
@@ -41,20 +41,6 @@ import { Minimatch } from 'minimatch';
|
||||
import { ReaderFactory, ReadTreeResponseFactory } from './types';
|
||||
import { ReadUrlResponseFactory } from './ReadUrlResponseFactory';
|
||||
|
||||
import pThrottle from 'p-throttle';
|
||||
|
||||
// 1 per second
|
||||
const throttle = pThrottle({
|
||||
limit: 1,
|
||||
interval: 1000,
|
||||
});
|
||||
|
||||
const throttledFetch = throttle(
|
||||
async (url: RequestInfo, options?: RequestInit) => {
|
||||
return await fetch(url, options);
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* Implements a {@link @backstage/backend-plugin-api#UrlReaderService} for files from Bitbucket Server APIs.
|
||||
*
|
||||
@@ -97,7 +83,7 @@ export class BitbucketServerUrlReader implements UrlReaderService {
|
||||
|
||||
let response: Response;
|
||||
try {
|
||||
response = await throttledFetch(bitbucketUrl.toString(), {
|
||||
response = await fetch(bitbucketUrl.toString(), {
|
||||
headers: {
|
||||
...requestOptions.headers,
|
||||
...(etag && { 'If-None-Match': etag }),
|
||||
@@ -147,7 +133,7 @@ export class BitbucketServerUrlReader implements UrlReaderService {
|
||||
url,
|
||||
this.integration.config,
|
||||
);
|
||||
const archiveResponse = await throttledFetch(
|
||||
const archiveResponse = await fetch(
|
||||
downloadUrl,
|
||||
getBitbucketServerRequestOptions(this.integration.config),
|
||||
);
|
||||
@@ -244,7 +230,7 @@ export class BitbucketServerUrlReader implements UrlReaderService {
|
||||
// https://docs.atlassian.com/bitbucket-server/rest/7.9.0/bitbucket-rest.html#idp211 (branches docs)
|
||||
const branchListUrl = `${this.integration.config.apiBaseUrl}/projects/${project}/repos/${repoName}/branches${branchParameter}`;
|
||||
|
||||
const branchListResponse = await throttledFetch(
|
||||
const branchListResponse = await fetch(
|
||||
branchListUrl,
|
||||
getBitbucketServerRequestOptions(this.integration.config),
|
||||
);
|
||||
|
||||
@@ -55,7 +55,6 @@
|
||||
"@backstage/plugin-catalog-common": "workspace:^",
|
||||
"@backstage/plugin-catalog-node": "workspace:^",
|
||||
"@backstage/plugin-events-node": "workspace:^",
|
||||
"p-throttle": "^4.1.1",
|
||||
"uuid": "^11.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
||||
@@ -18,7 +18,6 @@ import {
|
||||
BitbucketServerIntegrationConfig,
|
||||
getBitbucketServerRequestOptions,
|
||||
} from '@backstage/integration';
|
||||
import pThrottle from 'p-throttle';
|
||||
import {
|
||||
BitbucketServerDefaultBranch,
|
||||
BitbucketServerRepository,
|
||||
@@ -27,18 +26,6 @@ import { BitbucketServerProject } from './types';
|
||||
import { NotFoundError } from '@backstage/errors';
|
||||
import { ResponseError } from '@backstage/errors';
|
||||
|
||||
// 1 per second
|
||||
const throttle = pThrottle({
|
||||
limit: 1,
|
||||
interval: 1000,
|
||||
});
|
||||
|
||||
const throttledFetch = throttle(
|
||||
async (url: RequestInfo, options?: RequestInit) => {
|
||||
return await fetch(url, options);
|
||||
},
|
||||
);
|
||||
|
||||
/**
|
||||
* A client for interacting with a Bitbucket Server instance
|
||||
*
|
||||
@@ -83,8 +70,9 @@ export class BitbucketServerClient {
|
||||
repo: string;
|
||||
path: string;
|
||||
}): Promise<Response> {
|
||||
return throttledFetch(
|
||||
`${this.config.apiBaseUrl}/projects/${options.projectKey}/repos/${options.repo}/raw/${options.path}`,
|
||||
const base = new URL(this.config.apiBaseUrl);
|
||||
return fetch(
|
||||
`${base.protocol}//${base.host}/projects/${options.projectKey}/repos/${options.repo}/raw/${options.path}`,
|
||||
getBitbucketServerRequestOptions(this.config),
|
||||
);
|
||||
}
|
||||
@@ -94,7 +82,7 @@ export class BitbucketServerClient {
|
||||
repo: string;
|
||||
}): Promise<BitbucketServerRepository> {
|
||||
const request = `${this.config.apiBaseUrl}/projects/${options.projectKey}/repos/${options.repo}`;
|
||||
const response = await throttledFetch(
|
||||
const response = await fetch(
|
||||
request,
|
||||
getBitbucketServerRequestOptions(this.config),
|
||||
);
|
||||
@@ -163,17 +151,16 @@ export class BitbucketServerClient {
|
||||
}
|
||||
|
||||
private async request(req: Request): Promise<Response> {
|
||||
return throttledFetch(
|
||||
req,
|
||||
getBitbucketServerRequestOptions(this.config),
|
||||
).then((response: Response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`Unexpected response for ${req.method} ${req.url}. Expected 200 but got ${response.status} - ${response.statusText}`,
|
||||
);
|
||||
}
|
||||
return response;
|
||||
});
|
||||
return fetch(req, getBitbucketServerRequestOptions(this.config)).then(
|
||||
(response: Response) => {
|
||||
if (!response.ok) {
|
||||
throw new Error(
|
||||
`Unexpected response for ${req.method} ${req.url}. Expected 200 but got ${response.status} - ${response.statusText}`,
|
||||
);
|
||||
}
|
||||
return response;
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3617,7 +3617,6 @@ __metadata:
|
||||
node-forge: "npm:^1.3.1"
|
||||
node-mocks-http: "npm:^1.0.0"
|
||||
p-limit: "npm:^3.1.0"
|
||||
p-throttle: "npm:^4.1.1"
|
||||
path-to-regexp: "npm:^8.0.0"
|
||||
pg: "npm:^8.11.3"
|
||||
pg-connection-string: "npm:^2.3.0"
|
||||
@@ -5814,7 +5813,6 @@ __metadata:
|
||||
"@backstage/plugin-events-node": "workspace:^"
|
||||
luxon: "npm:^3.0.0"
|
||||
msw: "npm:^1.0.0"
|
||||
p-throttle: "npm:^4.1.1"
|
||||
uuid: "npm:^11.0.0"
|
||||
languageName: unknown
|
||||
linkType: soft
|
||||
|
||||
Reference in New Issue
Block a user