-
Notifications
You must be signed in to change notification settings - Fork 726
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
[State] Add missing Go examples #4127
Conversation
Signed-off-by: Hannah Hunter <[email protected]>
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.
ok, I've checked the code and made a few suggestions.
.../content/en/developing-applications/building-blocks/state-management/howto-get-save-state.md
Outdated
Show resolved
Hide resolved
.../content/en/developing-applications/building-blocks/state-management/howto-get-save-state.md
Outdated
Show resolved
Hide resolved
.../content/en/developing-applications/building-blocks/state-management/howto-get-save-state.md
Show resolved
Hide resolved
.../content/en/developing-applications/building-blocks/state-management/howto-get-save-state.md
Outdated
Show resolved
Hide resolved
keys := []string{"key1", "key2", "key3"} | ||
items, err := client.GetBulkState(ctx, store, keys, nil, 100) | ||
|
||
log.Println("Result after get:", string(result.Value)) |
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 will not work, as this is an array of BulkStateItems, what's the objective of this println? show all the Items in the array? We might need to loop here.
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.
@salaboy I'm least familiar with Go, so I'm not sure about the printIn
haha I may have grabbed it when piecing together examples
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.
@salaboy
Yes, @hhunter-ms is asking the the equivalent of this below, but for bulkstate, which means iterating over each item and showing it's value. This is just for a simple example to show how the API works
result, err := client.GetState(ctx, STATE_STORE_NAME, "order_1", nil)
if err != nil {
panic(err)
}
log.Println("Result after get:", string(result.Value))
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.
Ok, then @hhunter-ms something like this would work
items, err := client.GetBulkState(ctx, STATE_STORE_NAME, keys, nil, 100)
if err != nil {
panic(err)
}
for _, item := range items {
log.Println("Item from GetBulkState:", string(item.Value))
}
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.
Thanks @salaboy! I've pushed that update
Signed-off-by: Hannah Hunter <[email protected]>
Signed-off-by: Hannah Hunter <[email protected]>
Stale PR, paging all reviewers |
Signed-off-by: Hannah Hunter <[email protected]>
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.
LGTM
Description
Add examples for Bulk State and StateStore transactions for Go
Issue reference
PR will close: #4059