suborbital / grav

Embedded decentralized message bus
Apache License 2.0
103 stars 8 forks source link

When to use blocking vs non-blocking message receive #78

Closed lePereT closed 2 years ago

lePereT commented 2 years ago

Still an enthusiastic Go semi-novice but I was surprised that Grav offers both a non-blocking and a blocking message receive. I would have thought that the paradigm in Go would have been to offer only the blocking receive and to run that in a goroutine and then sync over a channel to avoid callbacks :)

Would love to know why both are offered and where you've used the async receive...

cohix commented 2 years ago

The async version is simply a convenience so that you don't need to spawn your own goroutine (it does so internally) 🙂

lePereT commented 2 years ago

Ah gotcha :)