Skip to content

Commit

Permalink
docs: mention ID property of sdk.Options and its benefits (#5876)
Browse files Browse the repository at this point in the history
Fixes #5875

Signed-off-by: Anders Eknert <anders@styra.com>
  • Loading branch information
anderseknert committed Apr 27, 2023
1 parent b65c68e commit f2c8474
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
5 changes: 5 additions & 0 deletions docs/content/integration.md
Expand Up @@ -236,6 +236,7 @@ func main() {

// create an instance of the OPA object
opa, err := sdk.New(ctx, sdk.Options{
ID: "opa-test-1",
Config: bytes.NewReader(config),
})
if err != nil {
Expand All @@ -256,6 +257,10 @@ func main() {
If you executed this code, the output (i.e. [Decision Log](https://www.openpolicyagent.org/docs/latest/management-decision-logs/) event)
would be logged to the console by default.

Setting an `ID` in `sdk.Options` is optional, but recommended. If you do not set an `ID`, a random one will be created
for the system. While this is fine for testing, it makes it difficult to monitor the system over time, as a new ID will
be created each time the SDK is initialized, such as when the process is restarted.

### Integrating with the Go API

Use the low-level
Expand Down
4 changes: 3 additions & 1 deletion sdk/options.go
Expand Up @@ -39,7 +39,9 @@ type Options struct {
// registered with the OPA SDK instance.
Plugins map[string]plugins.Factory

// When calling the sdk the user can specify an opa id so that repeat calls to the sdk don't have a unique opa id
// ID provides an option to set a static ID for the OPA system, avoiding
// the need to generate a random one at initialization. Setting a static ID
// is recommended, as it makes it easier to track the system over time.
ID string

config []byte
Expand Down

0 comments on commit f2c8474

Please sign in to comment.