Skip to content

Commit

Permalink
Merge pull request #244 from stgraber/main
Browse files Browse the repository at this point in the history
incusd/auth/openfga: Use chunking
  • Loading branch information
brauner authored Nov 28, 2023
2 parents 9e9ff11 + 28123a2 commit 4bf57b1
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion internal/server/auth/driver_openfga.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,14 +779,27 @@ func (f *fga) updateTuples(ctx context.Context, writes []client.ClientTupleKey,
ctx, cancel := context.WithTimeout(ctx, 5*time.Second)
defer cancel()

opts := client.ClientWriteOptions{AuthorizationModelId: openfga.PtrString(f.authModelID)}
opts := client.ClientWriteOptions{
AuthorizationModelId: openfga.PtrString(f.authModelID),
Transaction: &client.TransactionOptions{
Disable: true,
MaxParallelRequests: 5,
MaxPerChunk: 50,
},
}

body := client.ClientWriteRequest{}

if writes != nil {
body.Writes = &writes
} else {
body.Writes = &[]client.ClientTupleKey{}
}

if deletions != nil {
body.Deletes = &deletions
} else {
body.Deletes = &[]client.ClientTupleKey{}
}

clientWriteResponse, err := f.client.Write(ctx).Options(opts).Body(body).Execute()
Expand Down

0 comments on commit 4bf57b1

Please sign in to comment.