Skip to content

feat: instance-scoped "global" configuration#1315

Merged
B4nan merged 2 commits intoapify:masterfrom
barjin:feat/alsConfiguration
Mar 15, 2022
Merged

feat: instance-scoped "global" configuration#1315
B4nan merged 2 commits intoapify:masterfrom
barjin:feat/alsConfiguration

Conversation

@barjin
Copy link
Copy Markdown
Member

@barjin barjin commented Mar 15, 2022

Using asyncLocalStorage, Configuration.getGlobalConfig() now returns instance-scoped configuration (sdk.config).
fixes #1305

…config

Using `asyncLocalStorage`, `Configuration.getGlobalConfig()` now returns instance-scoped configuration (`sdk.config`).
fixes #1305
Comment thread src/configuration.js
@B4nan B4nan merged commit eab4e7f into apify:master Mar 15, 2022
Comment thread src/configuration.js
Comment on lines +312 to +315
return Configuration.storage.getStore() ?? (() => {
Configuration.globalConfig ??= new Configuration();
return Configuration.globalConfig;
})();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be written "normally"? 😄 I mean, it's kinda cool, but going from ?? into an IIFE is a bit hardcore.

Copy link
Copy Markdown
Member

@B4nan B4nan Mar 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its not that hardcore, but that IIFE made me smile too :D

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I paid for the whole JS grammar, I’m using the whole JS grammar!

But understood, I already hate it :) hope it is still legible enough at least

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i gave green light because to me it is readable enough, its actually quite smart way to do this on so few lines. but we can be more readable for sure:

if (Configuration.storage.getStore()) {
  return Configuration.storage.getStore();
}

Configuration.globalConfig ??= new Configuration();
return Configuration.globalConfig;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot disable WAL mode while there are open database connections

3 participants