From 869c5cb2e75e750dfa2e6da315be43f418c4a928 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Rold=C3=A1n=20Betancort?= Date: Fri, 20 Sep 2024 17:34:13 +0100 Subject: [PATCH] make bulk export service functions use read-only datastore --- internal/services/v1/experimental.go | 4 ++-- pkg/services/v1/services.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/services/v1/experimental.go b/internal/services/v1/experimental.go index ae2ce67336..6561626dde 100644 --- a/internal/services/v1/experimental.go +++ b/internal/services/v1/experimental.go @@ -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)) } @@ -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 diff --git a/pkg/services/v1/services.go b/pkg/services/v1/services.go index 5d123a4ace..d9543dad17 100644 --- a/pkg/services/v1/services.go +++ b/pkg/services/v1/services.go @@ -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) }