SDK Reference
Configuration, evaluation methods, and targeting for the TrustyGorilla SDKs.
Configuration
Every SDK exposes a TrustyGorillaConfig with the same three settings:
| Option | Required | Default | Description |
|---|---|---|---|
apiKey | Yes | — | Environment API key (JWT) from the dashboard. Must not be empty. |
apiUrl | No | https://edge.trustygorilla.com | Base URL of the TrustyGorilla API. |
pollIntervalSeconds | No | 30 | How often flags are refreshed in the background. |
Constructing a config is language-idiomatic:
const config = new TrustyGorillaConfig({
apiKey: process.env.TG_API_KEY!,
apiUrl: 'https://edge.trustygorilla.com', // optional
pollIntervalSeconds: 30, // optional
});config = TrustyGorillaConfig(
api_key=os.environ["TG_API_KEY"],
api_url="https://edge.trustygorilla.com", # optional
poll_interval_seconds=30, # optional
)// NewTrustyGorillaConfig applies defaults and returns an error if apiKey is empty.
cfg, err := trustygorilla.NewTrustyGorillaConfig(os.Getenv("TG_API_KEY"))
// Override defaults directly on the struct if needed:
cfg.PollIntervalSeconds = 60TrustyGorillaConfig config = TrustyGorillaConfig.builder()
.apiKey(System.getenv("TG_API_KEY"))
.apiUrl("https://edge.trustygorilla.com") // optional
.pollIntervalSeconds(30) // optional
.build();val config = TrustyGorillaConfig(
apiKey = System.getenv("TG_API_KEY"),
apiUrl = "https://edge.trustygorilla.com", // optional
pollIntervalSeconds = 30, // optional
)var config = new TrustyGorillaConfig(
ApiKey: Environment.GetEnvironmentVariable("TG_API_KEY")!,
ApiUrl: "https://edge.trustygorilla.com", // optional
PollIntervalSeconds: 30); // optional$config = new TrustyGorillaConfig(
apiKey: getenv('TG_API_KEY'),
apiUrl: 'https://edge.trustygorilla.com', // optional
pollIntervalSeconds: 30, // optional
);config = TrustyGorillaSDK::Config.new(
api_key: ENV["TG_API_KEY"],
api_url: "https://edge.trustygorilla.com", # optional
poll_interval_seconds: 30, # optional
)let config = try TrustyGorillaConfig(
apiKey: ProcessInfo.processInfo.environment["TG_API_KEY"]!,
apiUrl: "https://edge.trustygorilla.com", // optional
pollIntervalSeconds: 30 // optional
)An empty apiKey throws (or returns an error in Go) at construction time.
Evaluation methods
Because TrustyGorilla is an OpenFeature provider, you evaluate flags through the standard OpenFeature client. Method names follow each language's OpenFeature SDK; the semantics are identical.
| Value type | OpenFeature client method (typical) | Returns |
|---|---|---|
| Boolean | getBooleanValue(key, default, ctx) | bool |
| String | getStringValue(key, default, ctx) | string |
| Integer | getIntegerValue(key, default, ctx) | integer |
| Double / Float | getDoubleValue(key, default, ctx) | floating-point |
| Object / JSON | getObjectValue(key, default, ctx) | structured value |
Each method takes the flag key, a default value returned when the flag can't be resolved, and an optional evaluation context.
The Swift SDK is the exception — it exposes evaluation on the provider itself
(provider.getBooleanValue(_:defaultValue:targetingKey:)) and returns an
EvaluationDetails whose .value holds the resolved value.
Targeting
Pass a targeting key in the evaluation context — typically a stable user or session identifier. TrustyGorilla uses it to bucket users deterministically:
- Gradual rollout (
percentagestrategy): the SDK hashes"<flagKey>:<targetingKey>"with FNV-1a and enables the flag when the bucket falls under the configured rollout percentage. The same user always lands in the same bucket. - Static flags (
boolean/valuestrategy): the targeting key is not used for bucketing, but you should still pass it for consistent logging.
If no targeting key is provided, all users share the empty-string bucket.
How values resolve
Each flag carries an enabled state, a strategy, a value (served when the
flag is on), and a fallback_value (served when the flag is off):
- The SDK decides on/off from
enabledand the strategy (percentage bucketing for gradual rollouts). - It picks
valuewhen on,fallback_valuewhen off. - It coerces that node to the requested type. If the node is missing or the type doesn't match, the default value you passed is returned instead.
Resolution reasons
Evaluation details include a reason describing how the value was resolved:
| Reason | Meaning |
|---|---|
STATIC | The flag is enabled with a non-percentage strategy. |
SPLIT | The value came from percentage-rollout bucketing. |
DISABLED | The flag is disabled; the fallback/default was served. |
ERROR | The flag was not found or the provider wasn't ready; the default was served. |
Lifecycle
- Startup — registering the provider fetches flags once and starts the
background poller. Use the
setProviderAndWait/SetProviderAsyncform (orinitialize()in Swift) so the first fetch completes before you evaluate. - Refresh — the poller re-fetches every
pollIntervalSeconds. Requests use anETag, so unchanged flags cost almost nothing. - Shutdown — call the provider's shutdown method (or let OpenFeature call it) to stop the poller and release resources.