-
Notifications
You must be signed in to change notification settings - Fork 44
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
include go routines #304
include go routines #304
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we should be using more context.WithTimeout
in our code to handle long API call issues.
internal/cluster/query.go
Outdated
@@ -27,18 +28,37 @@ func QueryCluster(ctx context.Context, OrganizationSlug string, ClusterID string | |||
Queues: []Queue{}, | |||
} | |||
|
|||
queueChannel := make(chan Queue, len(q.Organization.Cluster.Queues.Edges)) | |||
errorChannel := make(chan error, len(q.Organization.Cluster.Queues.Edges)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error channel doesn't seem to ever be read from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What would be the best place to send this information?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Used errgroup to handle this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks okay but its all done manually. This page https://gobyexample.com/waitgroups links out to the errgroup package which will make this much simpler: https://pkg.go.dev/golang.org/x/sync/errgroup
If you search the codebase, you'll see an example of it already in use as well I think
9d5072b
to
79fd86d
Compare
Thanks @jradtilbrook as discussed I have made changes to include err group and instead of channel added array of queues and go routines based on the queue index |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sweet 👍
Adding go routines to run queue agent querying in parallel.
With agents:
Without queue: