> ## Documentation Index
> Fetch the complete documentation index at: https://docs.westyx.cloud/llms.txt
> Use this file to discover all available pages before exploring further.

# Go SDK - OpenFeature integration

> Use the Westyx Nexus Go SDK as an OpenFeature provider.

The `openfeature/` sub-module wraps an initialized `*nexus.Client` in an [OpenFeature](https://openfeature.dev) provider. It is published as a separate Go module so you only pull in the OpenFeature SDK dependency if you need it.

## Installation

Install both the core SDK and the provider sub-module:

```sh theme={null}
go get gitlab.com/westyx/nexus/sdk/go@v0.10.1
go get gitlab.com/westyx/nexus/sdk/go/openfeature@v0.8.0
```

## Usage

```go theme={null}
import (
    "context"
    "log"

    nexus "gitlab.com/westyx/nexus/sdk/go"
    nexusof "gitlab.com/westyx/nexus/sdk/go/openfeature"
    "github.com/open-feature/go-sdk/openfeature"
)

func main() {
    ctx, cancel := context.WithCancel(context.Background())
    defer cancel()

    // Initialize the Nexus client (performs a blocking sync on startup)
    client, err := nexus.NewClient(ctx, nexus.Config{
        BaseURL: "https://blue-ocean-a5rx7.westyx.dev",
        APIKey:  "wxs_...",
    })
    if err != nil {
        log.Fatal(err)
    }
    defer client.Close()

    // Register the Nexus provider with OpenFeature globally
    openfeature.SetProvider(nexusof.New(client))

    // Use the standard OpenFeature client
    ofClient := openfeature.NewClient("my-service")

    enabled, _ := ofClient.BooleanValue(ctx, "dark-mode", false, openfeature.EvaluationContext{})
    region, _  := ofClient.StringValue(ctx, "aws.region", "eu-west-1", openfeature.EvaluationContext{})
    limit, _   := ofClient.FloatValue(ctx, "rate.limit", 100.0, openfeature.EvaluationContext{})
    pageSize, _ := ofClient.IntValue(ctx, "page.size", 50, openfeature.EvaluationContext{})
    dbConf, _  := ofClient.ObjectValue(ctx, "db.config", nil, openfeature.EvaluationContext{})
}
```

## Evaluation mapping

| OpenFeature method                   | Nexus call                                | Miss behavior                                              |
| ------------------------------------ | ----------------------------------------- | ---------------------------------------------------------- |
| `BooleanValue` / `BooleanEvaluation` | `client.GetFlag(key, default)`            | returns default with `STATIC` reason                       |
| `StringValue` / `StringEvaluation`   | `client.GetConfig(key)` cast to `string`  | `FLAG_NOT_FOUND` if missing, `TYPE_MISMATCH` if wrong type |
| `FloatValue` / `FloatEvaluation`     | `client.GetConfig(key)` cast to `float64` | `FLAG_NOT_FOUND` if missing, `TYPE_MISMATCH` if wrong type |
| `IntValue` / `IntEvaluation`         | `client.GetConfig(key)` cast to `int64`   | `FLAG_NOT_FOUND` if missing, `TYPE_MISMATCH` if wrong type |
| `ObjectValue` / `ObjectEvaluation`   | `client.GetConfig(key)` returned as-is    | `FLAG_NOT_FOUND` if missing                                |

<Note>
  **EvaluationContext is ignored.** Nexus does not support per-user flag targeting. All successful evaluations return `STATIC` reason. The context parameter is accepted to satisfy the OpenFeature interface but has no effect.
</Note>

## Behavior notes

* **Boolean flags use `GetFlag`.** All other types use `GetConfig`. `GetFlag` always returns a value (default on miss), so boolean evaluations never produce `FLAG_NOT_FOUND`.
* **JSON number types.** Config values decoded from JSON are `float64` by default (`encoding/json` behavior). `IntEvaluation` accepts both `float64` (JSON numbers) and `int64`. `FloatEvaluation` accepts both `float64` and `float32`.
* **No I/O in the provider.** The provider is a thin delegation layer. All network activity (initial sync, background refresh, SSE stream) is handled by the `*nexus.Client`. The OpenFeature evaluation calls never block on network.
* **Provider metadata name** is `"Nexus"`.

## Module path

```
gitlab.com/westyx/nexus/sdk/go/openfeature
```

Latest release: **v0.8.0** *(2026-06-16)*
