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

[IMPROVED] Test for concurrently adding service endpoints #1521

Merged
merged 1 commit into from
Jan 12, 2024

Conversation

piotrpio
Copy link
Collaborator

Signed-off-by: Piotr Piotrowski piotr@synadia.com

@piotrpio piotrpio requested a review from Jarema January 12, 2024 10:26
Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

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

Small potential improvement suggestion.

// and there is no race
for i := 0; i < 10; i++ {
go func(i int) {
res <- srv.AddEndpoint(fmt.Sprintf("test%d", i), micro.ContextHandler(ctx, handler))
Copy link
Member

Choose a reason for hiding this comment

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

It could be me being picky, but I find it better in catching race conditions if you start adding endpoint exactly at the same time in goroutines. For example by having a wait group or channel that releases all goroutines when all gorutines have started?

Signed-off-by: Piotr Piotrowski <piotr@synadia.com>
@piotrpio piotrpio force-pushed the modify-service-test branch from 0c7c3ad to 6e55237 Compare January 12, 2024 10:54
Copy link
Member

@Jarema Jarema left a comment

Choose a reason for hiding this comment

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

LGTM!

@piotrpio piotrpio merged commit 990323d into main Jan 12, 2024
1 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants