Skip to content

Commit

Permalink
refactor: always request higher consistency on export
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanharris committed Sep 3, 2024
1 parent 12ba9f5 commit eb16366
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cmd/store/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"math"
"os"

openfga "github.com/openfga/go-sdk"
"github.com/openfga/go-sdk/client"
"github.com/spf13/cobra"
"gopkg.in/yaml.v3"
Expand Down Expand Up @@ -68,7 +69,12 @@ func buildStoreData(config fga.ClientConfig, fgaClient client.SdkClient, maxTupl
// get the tuples
maxPages := int(math.Ceil(float64(maxTupleCount) / float64(tuple.DefaultReadPageSize)))

rawTuples, err := tuple.Read(fgaClient, &client.ClientReadRequest{}, maxPages, nil)
rawTuples, err := tuple.Read(
fgaClient,
&client.ClientReadRequest{},
maxPages,
openfga.CONSISTENCYPREFERENCE_HIGHER_CONSISTENCY.Ptr(),
)
if err != nil {
return nil, fmt.Errorf("unable to read tuples: %w", err)
}
Expand Down
1 change: 1 addition & 0 deletions cmd/store/export_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func TestExportSuccess(t *testing.T) {
readOptions := client.ClientReadOptions{
PageSize: openfga.PtrInt32(tuple.DefaultReadPageSize),
ContinuationToken: openfga.PtrString(""),
Consistency: openfga.CONSISTENCYPREFERENCE_HIGHER_CONSISTENCY.Ptr(),
}

mockReadRequest := mock_client.NewMockSdkClientReadRequestInterface(mockCtrl)
Expand Down

0 comments on commit eb16366

Please sign in to comment.