-
Notifications
You must be signed in to change notification settings - Fork 279
docs: add TS to envconfig #3996
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
base: main
Are you sure you want to change the base?
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📖 Docs PR preview links
|
| // The 'staging' profile in config.toml has an incorrect address (localhost:9999) | ||
| // We'll programmatically override it to the correct address | ||
|
|
||
| // Load the 'staging' profile. | ||
| const config = loadClientConnectConfig({ | ||
| profile: profileName, | ||
| configSource: { path: configFile }, | ||
| }); | ||
|
|
||
| // Override the target host to the correct address. | ||
| // This is the recommended way to override configuration values. | ||
| config.connectionOptions.address = 'localhost:7233'; | ||
|
|
||
| console.log(`\nLoaded '${profileName}' profile from ${configFile} with overrides.`); | ||
| console.log(` Address: ${config.connectionOptions.address} (overridden from localhost:9999)`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to do this override bit, I would follow the simpler sample here, imo.
| console.log("--- Loading 'staging' profile with programmatic overrides ---"); | ||
|
|
||
| const configFile = resolve(__dirname, '../config.toml'); | ||
| const profileName = 'staging'; | ||
|
|
||
| // The 'staging' profile in config.toml has an incorrect address (localhost:9999) | ||
| // We'll programmatically override it to the correct address | ||
|
|
||
| // Load the 'staging' profile. | ||
| const config = loadClientConnectConfig({ | ||
| profile: profileName, | ||
| configSource: { path: configFile }, | ||
| }); | ||
|
|
||
| // Override the target host to the correct address. | ||
| // This is the recommended way to override configuration values. | ||
| config.connectionOptions.address = 'localhost:7233'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here - unless we explicitly want to document this and have precedent
That being said - I still think we don't need to demonstrate this twice, I think we typically have one simpler sample than a more complex one with the override?
| async function main() { | ||
| console.log('--- Loading default profile from config.toml ---'); | ||
|
|
||
| // For this sample to be self-contained, we explicitly provide the path to | ||
| // the config.toml file included in this directory. | ||
| // By default though, the config.toml file will be loaded from | ||
| // ~/.config/temporalio/temporal.toml (or the equivalent standard config directory on your OS). | ||
| const configFile = resolve(__dirname, '../config.toml'); | ||
|
|
||
| // loadClientConnectConfig is a helper that loads a profile and prepares | ||
| // the configuration for Connection.connect and Client. By default, it loads the | ||
| // "default" profile. | ||
| const config = loadClientConnectConfig({ | ||
| configSource: { path: configFile }, | ||
| }); | ||
|
|
||
| console.log(`Loaded 'default' profile from ${configFile}.`); | ||
| console.log(` Address: ${config.connectionOptions.address}`); | ||
| console.log(` Namespace: ${config.namespace}`); | ||
| console.log(` gRPC Metadata: ${JSON.stringify(config.connectionOptions.metadata)}`); | ||
|
|
||
| console.log('\nAttempting to connect to client...'); | ||
| try { | ||
| const connection = await Connection.connect(config.connectionOptions); | ||
| const client = new Client({ connection, namespace: config.namespace }); | ||
| console.log('✅ Client connected successfully!'); | ||
| await connection.close(); | ||
| } catch (err) { | ||
| console.log(`❌ Failed to connect: ${err}`); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is what I would use as a simpler sample, for my previous comment
What does this PR do?
Notes to reviewers