Construct UC4 client¶
This operation runs once per UC4Client instance. It checks that the two settings the client needs exist in the Environment API, reads their values, and derives the caller-identity header value — before the instance can be used to schedule any job.
| Field | Value |
|---|---|
| Operation ID | OP-UC4-01 |
| Trigger | DI container resolves IUC4Client, or a caller runs new UC4Client(env, httpJsonClient) |
| Inputs | IEnvironmentClient env, IHttpJsonClient httpJsonClient |
| Outputs | An instance with ServiceUrl, ScheduleJobEndpoint, and ClientName populated, and IsConfigured = false |
| Primary components | UC4Client..ctor, UC4Client.EnsureSettingExists |
| Entry point | src/SAIF.NetCore.Clients.UC4/SAIF.NetCore.Clients.UC4/SAIF.NetCore.Clients.UC4/Services/UC4Client.cs |
Steps¶
- Check that setting
uc4coreapi:urlexists (BR-UC4-01). - Delegates to
SAIF.NetCore.EnvironmentClient'sBaseEnvironmentClient.HasSetting(configKey, section): start a taggedActivitySourcespan, build the cache key from key and section, lazily load the section from the Environment API if not already cached, check the cache, and return a bool. - On failure (
false): throwNotSupportedException("UC4 Client cannot be ran in an environment where the environment key uc4coreapi.url does not exist."). Construction aborts. - Check that setting
uc4coreapi:schedulejobrouteexists (BR-UC4-01). - Same callee as step 1.
- On failure: same exception, naming
uc4coreapi.schedulejobroute.
Origin: Steps 1–2 are implemented in
HasSetting(SAIF.NetCore.EnvironmentClient) and executed on behalf of this operation. 3. Read theuc4coreapi:urlvalue intoServiceUrl(BR-UC4-02). - Delegates toBaseEnvironmentClient.GetSettingValue(configKey, section), which returnsConfigValue?.Value ?? ""— a null value becomes an empty string with no error. - If empty: accepted silently here; fails later in Schedule a UC4 job step 2. 4. Read theuc4coreapi:schedulejobroutevalue intoScheduleJobEndpoint(BR-UC4-02). - Same callee as step 3. - If empty: accepted silently; the later POST targets""+jobnamerelative to the base URL.Origin: Steps 3–4 are implemented in
GetSettingValue(SAIF.NetCore.EnvironmentClient) and executed on behalf of this operation. 5. SetClientNameto the assembly simple name,"SAIF.NetCore.Clients.UC4"(BR-UC4-04). 6. Store the injectedIHttpJsonClient. - No null-guard exists on either constructor argument. A nullenvcauses aNullReferenceExceptionin step 1. A nullhttpJsonClientfails later, in Schedule a UC4 job.
Process flow¶
flowchart TD
Start([DI resolves IUC4Client / new UC4Client]) --> S1["Check uc4coreapi:url exists"]
S1 --> D1{Exists?}
D1 -->|No| Err1(["NotSupportedException: uc4coreapi.url"])
D1 -->|Yes| S2["Check uc4coreapi:schedulejobroute exists"]
S2 --> D2{Exists?}
D2 -->|No| Err2(["NotSupportedException: uc4coreapi.schedulejobroute"])
D2 -->|Yes| S3["Read ServiceUrl, ScheduleJobEndpoint"]
S3 --> S4[Set ClientName from assembly name]
S4 --> Ok(["Instance ready, IsConfigured=false"])
Failure and edge-case behavior¶
- Missing
uc4coreapi:urloruc4coreapi:schedulejobroute:NotSupportedException, construction aborts entirely. - Present but empty values: construction succeeds; failures surface later in
ScheduleJob. - Null
IEnvironmentClientargument:NullReferenceExceptionduring step 1*.
Related documentation¶
Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified.
Sources¶
src/SAIF.NetCore.Clients.UC4/SAIF.NetCore.Clients.UC4/SAIF.NetCore.Clients.UC4/Services/UC4Client.cssrc/SAIF.NetCore.EnvironmentClient/SAIF.NetCore.EnvironmentClient/SAIF.NetCore.EnvironmentClient/BaseEnvironmentClient.cs— declaresHasSetting/GetSettingValue, the delegated behavior described in steps 1–4.