-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
niko/go-sdk-docs #553
base: main
Are you sure you want to change the base?
niko/go-sdk-docs #553
Conversation
On branch niko/go-to-new-template Changes to be committed: new file: docs/sdks/server-sdks/go/_category_.json new file: docs/sdks/server-sdks/go/assignments.mdx new file: docs/sdks/server-sdks/go/bandits.mdx new file: docs/sdks/server-sdks/go/initialization.mdx new file: docs/sdks/server-sdks/go/intro.mdx new file: docs/sdks/server-sdks/go/quickstart.mdx
✅ Deploy Preview for eppo-data-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
import ( | ||
"github.com/eppo-exp/eppo-go-sdk/eppo" | ||
) | ||
|
||
config := eppo.NewConfig("<SDK-KEY>") | ||
client, err := eppo.Init(config) | ||
if err != nil { | ||
log.Fatal("Failed to initialize Eppo client:", err) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 This example is off. The one in initialization section is correct
type MyLogger struct{} | ||
|
||
func (l *MyLogger) LogAssignment(assignment *eppo.Assignment) error { | ||
// Replace with your logging logic | ||
log.Printf("Logging assignment: %+v", assignment) | ||
return nil | ||
} | ||
|
||
config := eppo.NewConfig( | ||
"<SDK-KEY>", | ||
eppo.WithAssignmentLogger(&MyLogger{}), | ||
) | ||
client, err := eppo.Init(config) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🐛 same here. Go SDK doesn't have NewConfig
. See examples in initialization section
|
||
### Action Contexts | ||
|
||
Next, supply a map with actions and their attributes: `actions: map[string]Attributes`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Next, supply a map with actions and their attributes: `actions: map[string]Attributes`. | |
Next, supply a map with actions and their attributes: `actions: map[string]ContextAttributes`. |
All actions supplied are considered to be valid; if an action should not be shown to a user, do not include it in this map. | ||
|
||
The action attributes are similar to the `subject_attributes` but hold action-specific information. | ||
You can use `Attributes{}` to create an empty attribute context. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use `Attributes{}` to create an empty attribute context. | |
You can use `ContextAttributes{}` to create an empty attribute context. |
|
||
The `result` is an instance of `BanditResult`, which has two fields: | ||
- `Variation` (string): The variation that was assigned to the subject | ||
- `Action` (string): The action that was assigned to the subject (empty string if no action was assigned) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- `Action` (string): The action that was assigned to the subject (empty string if no action was assigned) | |
- `Action` (`*string`): The action that was assigned to the subject (`nil` if no action was assigned) |
|
||
The variation returns the feature flag variation, this can be the bandit itself, or the "status quo" variation if the user is not assigned to the bandit. | ||
If we are unable to generate a variation, for example when the flag is turned off, then the `default` variation is returned. | ||
In both of those cases, the `Action` is an empty string, and you should use the status-quo algorithm to select an action. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In both of those cases, the `Action` is an empty string, and you should use the status-quo algorithm to select an action. | |
In both of those cases, the `Action` is nil, and you should use the status-quo algorithm to select an action. |
## Debugging | ||
|
||
You may encounter a situation where a bandit assignment produces a value that you did not expect. The SDK provides detailed evaluation information through the `GetBanditActionDetails` method: | ||
|
||
```go | ||
evaluation, err := client.GetBanditActionDetails( | ||
"shoe-bandit", | ||
"test-subject", | ||
attributes, | ||
actions, | ||
"control", | ||
) | ||
if err != nil { | ||
log.Printf("Error getting bandit details: %v", err) | ||
return | ||
} | ||
|
||
log.Printf("Assignment: %s", evaluation.Variation) | ||
log.Printf("Action: %s", evaluation.Action) | ||
log.Printf("Details: %+v", evaluation.EvaluationDetails) | ||
``` | ||
|
||
For more information on debugging assignments, see [Debugging Flag Assignment](/sdks/sdk-features/debugging-flag-assignment/). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not supported
## Debugging | |
You may encounter a situation where a bandit assignment produces a value that you did not expect. The SDK provides detailed evaluation information through the `GetBanditActionDetails` method: | |
```go | |
evaluation, err := client.GetBanditActionDetails( | |
"shoe-bandit", | |
"test-subject", | |
attributes, | |
actions, | |
"control", | |
) | |
if err != nil { | |
log.Printf("Error getting bandit details: %v", err) | |
return | |
} | |
log.Printf("Assignment: %s", evaluation.Variation) | |
log.Printf("Action: %s", evaluation.Action) | |
log.Printf("Details: %+v", evaluation.EvaluationDetails) | |
``` | |
For more information on debugging assignments, see [Debugging Flag Assignment](/sdks/sdk-features/debugging-flag-assignment/). |
Updating to most recent version for the install instructions. Co-authored-by: Oleksii Shmalko <[email protected]>
Updating typed assignment list to correct names. Co-authored-by: Oleksii Shmalko <[email protected]>
Co-authored-by: Oleksii Shmalko <[email protected]>
What?
Moving the Go docs into the format similar to what we have for node.
Why?
Review instructions
Todo before merge