Some utilities for interacting with channels that I use in my code.
Get - receive from a channel in a blocking manner, but return if a context expires.
Put - the same, for sending to a channel.
Currently, it's so small, that it probably makes no sense to use it. Feel free
to just steal the code you want, no need to introduce unnecessary dependency
on this lib. It's MIT.
Get tries to read a message from a channel, blocking until it succeeds or the
context gets cancelled or expires.
Returns a pointer to the message if it was received successfuly (nil
otherwise), a bool equal to true if the channel isn't closed, and ctx.Err()
if the context expired/got cancelled.
Put tries to put a message in a channel, blocking until it succeeds or the
context gets cancelled or expires. Returns ctx.Err() if the message was not
sent successfuly.