TrustyGorillaDocs
SDK

SDK Reference

Configuration, evaluation methods, and targeting for the TrustyGorilla SDKs.

Configuration

Every SDK exposes a TrustyGorillaConfig with the same three settings:

OptionRequiredDefaultDescription
apiKeyYesEnvironment API key (JWT) from the dashboard. Must not be empty.
apiUrlNohttps://edge.trustygorilla.comBase URL of the TrustyGorilla API.
pollIntervalSecondsNo30How 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 = 60
TrustyGorillaConfig 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 typeOpenFeature client method (typical)Returns
BooleangetBooleanValue(key, default, ctx)bool
StringgetStringValue(key, default, ctx)string
IntegergetIntegerValue(key, default, ctx)integer
Double / FloatgetDoubleValue(key, default, ctx)floating-point
Object / JSONgetObjectValue(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 (percentage strategy): 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 / value strategy): 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):

  1. The SDK decides on/off from enabled and the strategy (percentage bucketing for gradual rollouts).
  2. It picks value when on, fallback_value when off.
  3. 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:

ReasonMeaning
STATICThe flag is enabled with a non-percentage strategy.
SPLITThe value came from percentage-rollout bucketing.
DISABLEDThe flag is disabled; the fallback/default was served.
ERRORThe 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 / SetProviderAsync form (or initialize() in Swift) so the first fetch completes before you evaluate.
  • Refresh — the poller re-fetches every pollIntervalSeconds. Requests use an ETag, 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.

On this page