Has setting¶
| Field | Value |
|---|---|
| Owner | HasSetting |
| Trigger | Consumer call; also step 4 of Get secure setting |
| Inputs | configKey, optional section (default "") |
| Outputs | true/false |
Steps¶
- Build the dictionary key via
BuildDictionaryKey(configKey, section)using the literalsectionargument as passed — unlike Get setting value/GetConfigSetting,HasSettingdoes not substituteTrackNamewhensectionis blank. CallingHasSetting(configKey)with no section therefore checks the bareconfigKey.ToLower()key, whileGetSettingValue(configKey)with no section resolves against"{TrackName}.{configKey}"— the two "no section" defaults are not equivalent (BR-EC-12). - Call
LoadSectionfor the same literalsectionvalue. - 2.1. This always runs the refresh check first: an empty global cache (or any call once the server's
lastRefreshedtimestamp has advanced, probed at most every 60 seconds) clears and reloads the whole cache —LastRefreshedis set before that reload runs, not after it completes, so a failure partway through is not guaranteed to be retried on the very next call. - 2.2. If the (lowercased) section key is already recorded in the
Sectionscache,LoadSectionreturns immediately with no network call; otherwise it acquiresSectionsSemaphore, re-checksSectionsunder the lock (so a concurrent caller that just finished loading the same section is not re-fetched), and only then calls the Environment API. A successful fetch with 1+ settings adds the section toSections; a successful fetch with zero settings is treated as not-loaded and is removed fromSectionsif present, so it is retried on the very next call rather than being stuck; a non-success HTTP result or a malformed response throwsEnvironmentClientExceptionout of this call (and out ofHasSettingitself) instead of returningfalse. Only a nonemptysectionis ever marked loaded this way; if the caller omittedsection(so it is the literal empty-string root), this guard never short-circuits and the root is fetched again on every call that reaches it (BR-EC-13). -
Origin: Steps 2.1–2.2 are implemented in Load section and Refresh check and cache reload, and executed on behalf of this operation.
- Return
CheckForSetting(settingKey):trueif the globalSettingsdictionary is non-empty and contains the composed key,falseotherwise (BR-EC-28). - This check never consults the developer override file (see Developer override lookup) or the secure-setting API; it only reflects the non-secure settings most recently loaded from the Environment API.
Process flow¶
flowchart TD
A["HasSetting configKey, section=''"] --> B["BuildDictionaryKey(configKey, section)<br>— literal section, no TrackName substitution"]
B --> C[Load section for literal section value]
C --> D{"Settings non-empty and<br>contains composed key?"}
D -- Yes --> E[Return true]
D -- No --> F[Return false]
Sources¶
src/SAIF.NetCore.EnvironmentClient/SAIF.NetCore.EnvironmentClient/SAIF.NetCore.EnvironmentClient/BaseEnvironmentClient.cs