Skip to content

Commit

Permalink
Merge pull request #2072 from authzed/readonly-bulk-export
Browse files Browse the repository at this point in the history
make bulk export service functions use read-only datastore
  • Loading branch information
josephschorr authored Sep 20, 2024
2 parents f813abe + 869c5cb commit 66ee7e2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions internal/services/v1/experimental.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func (es *experimentalServer) BulkExportRelationships(
// BulkExport implements the BulkExportRelationships API functionality. Given a datastore.Datastore, it will
// export stream via the sender all relationships matched by the incoming request.
// If no cursor is provided, it will fallback to the provided revision.
func BulkExport(ctx context.Context, ds datastore.Datastore, batchSize uint64, req *v1.BulkExportRelationshipsRequest, fallbackRevision datastore.Revision, sender func(response *v1.BulkExportRelationshipsResponse) error) error {
func BulkExport(ctx context.Context, ds datastore.ReadOnlyDatastore, batchSize uint64, req *v1.BulkExportRelationshipsRequest, fallbackRevision datastore.Revision, sender func(response *v1.BulkExportRelationshipsResponse) error) error {
if req.OptionalLimit > 0 && uint64(req.OptionalLimit) > batchSize {
return shared.RewriteErrorWithoutConfig(ctx, NewExceedsMaximumLimitErr(uint64(req.OptionalLimit), batchSize))
}
Expand Down Expand Up @@ -752,7 +752,7 @@ func queryForEach(
return cur, nil
}

func decodeCursor(ds datastore.Datastore, encoded *v1.Cursor) (datastore.Revision, string, *core.RelationTuple, error) {
func decodeCursor(ds datastore.ReadOnlyDatastore, encoded *v1.Cursor) (datastore.Revision, string, *core.RelationTuple, error) {
decoded, err := cursor.Decode(encoded)
if err != nil {
return datastore.NoRevision, "", nil, err
Expand Down
2 changes: 1 addition & 1 deletion pkg/services/v1/services.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ import (
// BulkExport implements the BulkExportRelationships API functionality. Given a datastore.Datastore, it will
// export stream via the sender all relationships matched by the incoming request.
// If no cursor is provided, it will fallback to the provided revision.
func BulkExport(ctx context.Context, ds datastore.Datastore, batchSize uint64, req *v1.BulkExportRelationshipsRequest, fallbackRevision datastore.Revision, sender func(response *v1.BulkExportRelationshipsResponse) error) error {
func BulkExport(ctx context.Context, ds datastore.ReadOnlyDatastore, batchSize uint64, req *v1.BulkExportRelationshipsRequest, fallbackRevision datastore.Revision, sender func(response *v1.BulkExportRelationshipsResponse) error) error {
return servicesv1.BulkExport(ctx, ds, batchSize, req, fallbackRevision, sender)
}

0 comments on commit 66ee7e2

Please sign in to comment.