Skip to content

Commit

Permalink
chore: Fetch one destination instead of all (#4371)
Browse files Browse the repository at this point in the history
* fix some tests

* fix all tests except caching

* fix last tests

* fix http-client tests

* improve default mocking for 404

* add changelog

* fix mail tests

* fix request builder mocks

* Remove nock from dependencies

* fix integration tests

* remove unused function

* remove unused mock function

* refactor tests and fix tsconfig

* improve changelog message

* rename

* fix typo
  • Loading branch information
marikaner authored Dec 23, 2023
1 parent df144e7 commit c721bbd
Show file tree
Hide file tree
Showing 26 changed files with 990 additions and 1,253 deletions.
6 changes: 6 additions & 0 deletions .changeset/funny-weeks-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@sap-cloud-sdk/connectivity': minor
---

[Compatibility Note] The SAP Cloud SDK used to get all subaccount and instance destinations, that are available with your JWT (without potentially required token retrieval), through two requests to the destination service (`/subaccountDestinations` and `/instanceDestinations`). While this approach can have advantages when caching, it can cause severe performance issues without caching. Therefore, from now on, only one destination is retrieved per requested destination through `/destinations`.
You can no longer rely on the SDK to automatically cache all destinations on the first request. If needed, you can call `getAllDestinationsFromDestinationService()` with cache enabled instead.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-dogs-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sap-cloud-sdk/connectivity': minor
---

[Improvement] Retrieve only one destination per requested destination instead of all subaccount and instance destinations. (See compatibility notes.)
4 changes: 2 additions & 2 deletions packages/connectivity/src/scp-cf/circuit-breaker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from '../../../../test-resources/test/test-util/environment-mocks';
import { privateKey } from '../../../../test-resources/test/test-util/keys';
import { getClientCredentialsToken } from './xsuaa-service';
import { fetchDestination } from './destination';
import { fetchDestinationWithTokenRetrieval } from './destination';

const jwt = jwt123.sign(
JSON.stringify({ user_id: 'user', zid: 'tenant' }),
Expand All @@ -30,7 +30,7 @@ describe('circuit breaker', () => {

it('opens after 50% failed request attempts (with at least 10 recorded requests) for destination service', async () => {
const request = () =>
fetchDestination(destinationServiceUri, jwt, {
fetchDestinationWithTokenRetrieval(destinationServiceUri, jwt, {
destinationName: 'FINAL-DESTINATION'
});

Expand Down
Loading

0 comments on commit c721bbd

Please sign in to comment.