Skip to content
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

Add batching functionality #120

Merged
merged 1 commit into from
May 13, 2022
Merged

Add batching functionality #120

merged 1 commit into from
May 13, 2022

Conversation

bryanhuhta
Copy link
Contributor

@bryanhuhta bryanhuhta commented May 11, 2022

supersedes #95
closes #94

This PR implements a more testable variant of batching than the one presented in #95. The default batch size is 1000 records with 1 worker. A single worker renders the import synchronous, making parallel processing opt-in.

internal/grpcutil/batch.go Outdated Show resolved Hide resolved
internal/grpcutil/batch.go Show resolved Hide resolved
if _, err := client.WriteRelationships(context.Background(), request); err != nil {
return err
}
err := grpcutil.ConcurrentBatch(context.Background(), len(relationshipUpdates), batchSize, workers, func(ctx context.Context, no int, start int, end int) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory we could use a cancel context here and have another cli flag to dictate how long a timeout should be. I think that should be a follow up feature though.

Copy link
Member

@jzelinskie jzelinskie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, this has nothing to do with grpc, so grpcutil probably isn't the best package for it, but it's fine for now.

LGTM

@jzelinskie jzelinskie merged commit 3c0bf27 into authzed:main May 13, 2022
@github-actions github-actions bot locked and limited conversation to collaborators May 13, 2022
@bryanhuhta bryanhuhta deleted the batch-import branch May 16, 2022 15:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support large, batch importing of relationships
2 participants