dev.westyx.nexus.*. The auto-configuration creates the NexusClient bean and starts the SSE stream - for most users, the read methods (getConfig, getFlag, getSecret) are the entire API surface.
Construction
NexusClient.create(NexusConfig config)
Creates a client and runs a blocking initial sync. Used internally by the auto-configuration; rarely called directly.
Configs
Optional<JsonValue> getConfig(String key)
Returns the resolved config value as a JsonValue (the wire-decoded JSON), or Optional.empty() when the key is absent. JsonValue is the SDK’s own immutable tree rather than a Jackson JsonNode, which is what lets one artifact serve Spring Boot 3 and 4.
<T> Optional<T> getConfigAs(String key, Class<T> type)
Returns the config value coerced to the given type, using Jackson’s treeToValue.
Map<String, JsonValue> getAllConfigs()
Snapshot copy of every config key-value pair currently in the cache.
public-key (wxp_) clients receive all configs and flags, the same set a secret key sees; what they do not receive is secrets, which are absent from the sync response entirely.
Feature flags
boolean getFlag(String key) / boolean getFlag(String key, boolean defaultValue)
Returns the is_active state of a flag, or defaultValue (default false) when the key is absent.
Optional<Boolean> findFlag(String key) (v0.12.0)
Returns the is_active state, or an empty Optional when the flag is not defined.
getFlag cannot express the difference between “the flag does not exist” and “it exists and is off” - both are false. It is what the OpenFeature provider uses to report FLAG_NOT_FOUND, and why an unknown key is never sent to evaluateAB: the endpoint answers false for a key it does not know. getFlag is expressed in terms of findFlag, so the two cannot drift apart.
Map<String, Boolean> getAllFlags()
Snapshot copy of every flag key-is_active pair in the cache.
AB Testing (v0.3.0)
Map<String, Boolean> evaluateAB(List<String> keys, String userId, Map<String, String> attributes)
Batch-evaluates feature flags with AB Testing semantics. Posts to POST /v1/flags/evaluate-ab and returns the server’s results map verbatim.
Unlike getFlag, this method always makes a network call. The call is blocking; run it off the request thread if your handler is latency-sensitive.
Object in v0.12.0). The endpoint binds them as a string-to-string map and cohort conditions compare them as strings, so formatting the value at the call site is what lets you control exactly what the rule is matched against. A null value is treated as unset and dropped - sent as "" it could satisfy an eq "" condition.
Requires the AB Testing add-on to be active on the project; otherwise the server returns HTTP 403.
Secrets (secret key only)
String getSecret(String key)
Returns the plaintext value of a secret.
Optional<String> getSecretFilePath(String key) (v0.3.0)
Returns the absolute path to the on-disk file where the SDK has materialised a type="file" secret, or Optional.empty() when the key is unknown or the secret is of type="text".
Write API (v0.5.0)
The write API allows programmatic secret creation and deletion. Available for secret keys only. Using a public key throwsNexusPublicKeyException immediately, before the network call.
void setSecret(String key, String value)
Creates or updates a secret with the given key and plaintext value. The secret defaults to type="text".
void deleteSecret(String key)
Deletes a secret and all its versions.
void deleteSecretVersion(String key, int version)
Deletes a specific version of a secret.
Metadata
Sync / lifecycle
void sync()
Forces a sync now, bypassing the TTL. Atomically replaces the cache. ETag / If-None-Match is used automatically; a 304 resets the TTL without downloading data. Rarely needed.
void connectStream() / void disconnectStream()
Start/stop the SSE thread. The auto-configuration calls connectStream() automatically (unless nexus.stream=false). Idempotent.
void close()
Stops the SSE thread, removes any temp files created for type="file" secrets, and releases the SDK-owned HTTP clients. The auto-configuration registers this as the bean’s destroy method (destroyMethod = "close"), so it fires automatically on Spring context shutdown.
NexusClient implements AutoCloseable, so try-with-resources also works:
Exception hierarchy
NexusException. See Error handling for full semantics.
Logger SPI
dev.westyx.nexus.NexusClient. To override, register your own NexusLogger bean.