spicedb icon indicating copy to clipboard operation
spicedb copied to clipboard

Refactor the graph package to use errgroup

Open jakedt opened this issue 3 years ago • 3 comments

Right now the graph package uses something that looks very similar to errgroups for running a bunch of checks in parallel, and was written naive of the existence of errgroups. I think we could make it cleaner and get rid of quite a bit of code by moving it over to using errgroups.

jakedt avatar Dec 20 '21 15:12 jakedt

Hello,

I'm new to Golang and want to try it out by fixing an issue.

Authzed and SpiceDB (or Zanzibar) is a mind-blown way to solve the authorization problems, which bugs me for a long time.

May I proceed on solving this issue?

Can I confirm the scope of this is code in file internal/graph/check.go ?

tiev avatar Apr 12 '22 12:04 tiev

Hi @tiev ,

There would be changes in check.go, lookup.go, and expand.go. Roughly the idea is to stop using a wrapped type that contains both results and errors on the results channel, but instead use Errgroup to have two different control streams, one for the error case and one for the valid response case.

Hope this helps!

jakedt avatar Apr 13 '22 14:04 jakedt

Reachable resources uses errgroup now, and lookup uses reachable resources.

This is still an opportunity for moving to errgroup in check and expand

josephschorr avatar Sep 01 '22 20:09 josephschorr

We'd likely want to use https://github.com/authzed/spicedb/blob/main/internal/graph/taskrunner.go now

josephschorr avatar Jan 11 '23 19:01 josephschorr

Hi team! Is this something we still want to do? If yes, I would love to work on it. Also, if possible, it would be great if you could help with some starting guidance. Thanks!

Devanshu24 avatar Feb 22 '23 09:02 Devanshu24

Hi @Devanshu24, it will be a fairly involved change, but if you're interested in trying to do this, take a look in https://github.com/authzed/spicedb/blob/main/internal/graph/check.go and see how we changed it from using resolver functions into direct calls. The first step is applying the same work to https://github.com/authzed/spicedb/blob/main/internal/graph/expand.go

josephschorr avatar Feb 22 '23 18:02 josephschorr