latest
A go package for channel types that attempt to always use the latest available value.
The fundamental primitive provided by this package is a channel with a special property: sending never blocks. Receiving still has the normal channel blocking semantics. This is achieved by violating the queue-like behavior of normal channels. Instead of data queuing up when sent, data sent later will replace data that is pending delivery. This isn't desired or useful for all applications, but sometimes it's just what you need.
The above is implemented in latest.Chan
.
This package also provides a latest.Worker
that sends and recieves on two latest.Chan
instances and has a goroutine processing data on the other end. This can be useful for building data processing in which the only data whose results matter is the latest request.
License
Dual MIT/Unlicense
Contribute
Send questions, comments, and patches to my public inbox.