Skip to content

chore(packages): remove loadedConfig option #3478

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Mar 25, 2022

Conversation

trivikr
Copy link
Member

@trivikr trivikr commented Mar 24, 2022

Issue

Refs: #3285

Description

Caching of configuration happens at slurpFile level in #3285
The function loadSharedConfigFiles can be called multiple times, and doesn't have to be called at top level.

Testing

Unit testing

Manual testing to ensure two readFile calls

// packages/shared-ini-file-loader/src/slurpFile.ts

let readFileCallTotal = 0;

export const slurpFile = (path: string) =>
  new Promise<string>((resolve, reject) => {
    if (!fileStatusHash[path]) {
      // File not read yet, set file isReading to true and read file.
      fileStatusHash[path] = { isReading: true, contents: "", requestQueue: [] };
      fileStatusHash[path].requestQueue.push({ resolve, reject });
      const readFileCallMsg = `readFile call #${++readFileCallTotal} for: ${path}`;
      console.log(`start: ${readFileCallMsg}`);
      readFile(path, "utf8")
        .then((data) => {
          console.log(`end: ${readFileCallMsg}`);
Single client
import { S3 } from "../aws-sdk-js-v3/clients/client-s3/dist-cjs/index.js";

console.log("Before client instantiation");
const client = new S3({});
console.log("After client instantiation");
Before client instantiation
After client instantiation
start: readFile call #1 for: /home/trivikr/.aws/config
start: readFile call #2 for: /home/trivikr/.aws/credentials
end: readFile call #1 for: /home/trivikr/.aws/config
end: readFile call #2 for: /home/trivikr/.aws/credentials
Two clients
import { S3 } from "../aws-sdk-js-v3/clients/client-s3/dist-cjs/index.js";

console.log("Before client1 instantiation");
const client1 = new S3({});
console.log("After client1 instantiation");

console.log("Before client2 instantiation");
const client2 = new S3({});
console.log("After client2 instantiation");
Before client1 instantiation
After client1 instantiation
Before client2 instantiation
After client2 instantiation
start: readFile call #1 for: /home/trivikr/.aws/config
start: readFile call #2 for: /home/trivikr/.aws/credentials
end: readFile call #1 for: /home/trivikr/.aws/config
end: readFile call #2 for: /home/trivikr/.aws/credentials
Client with an operation
import { S3 } from "../aws-sdk-js-v3/clients/client-s3/dist-cjs/index.js";

console.log("Before client instantiation");
const client = new S3({});
console.log("After client instantiation");

console.log("Before calling operation");
await client.listBuckets({});
console.log("After calling operation");
Before client instantiation
After client instantiation
Before calling operation
start: readFile call #1 for: /home/trivikr/.aws/config
start: readFile call #2 for: /home/trivikr/.aws/credentials
end: readFile call #1 for: /home/trivikr/.aws/config
end: readFile call #2 for: /home/trivikr/.aws/credentials
After calling operation

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@trivikr trivikr requested a review from a team as a code owner March 24, 2022 23:34
@trivikr trivikr marked this pull request as draft March 24, 2022 23:34
@trivikr trivikr changed the title chore(packages): remove loadedConfig calls chore(packages): remove loadedConfig option Mar 24, 2022
@trivikr trivikr marked this pull request as draft March 25, 2022 16:38
@trivikr trivikr marked this pull request as ready for review March 25, 2022 22:25
@trivikr trivikr merged commit b76b537 into aws:main Mar 25, 2022
@trivikr trivikr deleted the remove-loaded-config branch March 25, 2022 22:25
@github-actions
Copy link

github-actions bot commented Apr 9, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants