-
Notifications
You must be signed in to change notification settings - Fork 78
feat: add env var config layer for EurekaClient intervals — GH#4774 #4794
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
Open
balhar-jakub
wants to merge
5
commits into
v3.x.x
Choose a base branch
from
hermes/gh4774
base: v3.x.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+119
−2
Open
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
6507f7e
feat: add env var config layer for EurekaClient intervals (#4774)
balhar-jakub c378d20
fix: line length lint fixes in envConfig.js
balhar-jakub f310627
fix: lint indentation in index.js
balhar-jakub f513ea7
Update envConfig.js
balhar-jakub a31ca0b
Update index.js
balhar-jakub File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| /* | ||
| * This program and the accompanying materials are made available under the terms of the | ||
| * Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
| * https://www.eclipse.org/legal/epl-v20.html | ||
| * | ||
| * SPDX-License-Identifier: EPL-2.0 | ||
| * | ||
| * Copyright Contributors to the Zowe Project. | ||
| */ | ||
|
|
||
| // envConfig.js — maps EUREKA_CLIENT_* env vars to eureka config properties | ||
| import Logger from './Logger.js'; | ||
|
|
||
| const logger = new Logger(); | ||
|
|
||
| const ENV_MAP = [ | ||
| { | ||
| env: 'EUREKA_CLIENT_REGISTRYFETCHINTERVALSECONDS', | ||
| key: 'registryFetchInterval', | ||
| unit: 'seconds', | ||
| }, | ||
| { | ||
| env: 'EUREKA_CLIENT_INSTANCEINFOREPLICATIONINTERVALSECONDS', | ||
| key: 'heartbeatInterval', | ||
| unit: 'seconds', | ||
| }, | ||
| // Future: add entries here for circuit breaker properties (#4775) | ||
| // { env: 'EUREKA_CLIENT_MAXFAILURES', key: 'maxFailures', unit: 'milliseconds' }, | ||
| // { env: 'EUREKA_CLIENT_COOLDOWNTIME', key: 'cooldownTime', unit: 'seconds' }, | ||
| // { env: 'EUREKA_CLIENT_BACKOFFMAX', key: 'backoffMax', unit: 'seconds' }, | ||
| ]; | ||
|
|
||
| function parsePositiveInt(envName) { | ||
| const raw = process.env[envName]; | ||
| if (raw === undefined || raw === '') return undefined; | ||
| const parsed = parseInt(raw, 10); | ||
| if (isNaN(parsed) || parsed <= 0) { | ||
| const msg = `Invalid value for ${envName}: "${raw}". ` | ||
| + 'Expected a positive integer. Using default.'; | ||
| logger.warn(msg); | ||
| return undefined; | ||
| } | ||
| return parsed; | ||
| } | ||
|
|
||
| export default function envConfig() { | ||
| const result = { eureka: {} }; | ||
| for (const { env, key, unit } of ENV_MAP) { | ||
| const value = parsePositiveInt(env); | ||
| if (value !== undefined) { | ||
| result.eureka[key] = unit === 'seconds' ? value * 1000 : value; | ||
| } | ||
| } | ||
| return result; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.