While it’s convenient, the Decoder isn’t recommended for those use cases precisely because of the edge cases around readers that don’t contain at most one JSON document with no suffixes.
The standard library maintainers recognized this as a problem that there was no “better,” more convenient way to do it and in encoding/json/v2 they have UnmarshalRead for that use case: https://pkg.go.dev/encoding/json/v2#UnmarshalRead
In gRPC, the statuses it returns in trailers can include arbitrary details, and Google has a well-known proto for common ones in `google/rpc/error_details.proto`. One such detail is RetryInfo [1].
When we implement retries where I work, the general rule is that if a request is suitable for retry, it should include the RetryInfo in the error status and use it as the base delay for the exponential backoff. The absence of that detail means don’t retry, and we have a client interceptor that parses the response status and retries according to that logic.
I’d like to mention it since Uber has a really cool load shedder [1], also implemented similarly by Netflix [2] and failsafe-go [3]. It basically looks for points where more requests per second suddenly cause a significant increase in latency and calls that the concurrency limit.
The point isn’t that the HEPA filter won’t work under those conditions, it’s that if you can get away with not separating the clean and dirty air, you can achieve better filtration overall with a higher flow, lower resistance filter at a lower noise level. HEPA filters shine in use cases where you need single-pass filtration, like vacuum cleaner output filters or clean room air filters. If you don’t separate clean and dirty air, the filter will still work, but you aren’t taking advantage of its main distinguishing quality, which is its single-pass filtration performance.
If you get to recycle the air through the filter several times, MERV-13 offers much better performance tradeoffs for a residential air purifier because you can recycle the air through it much faster at acceptable noise levels. My home air purifier recycles the volume of my home every 15 minutes or so, vs HEPA filters which produce totally clean air, but since it just mixes with the dirty air that doesn’t matter as much as the rate at which it cleans air.
And guess what 98% of consumer air filtering systems utilize a hepa filter. You’re really over optimizing a non problem. Unless you are constantly producing more contaminants than the system can keep up with it’s totally a fine solution.
Someone in the thread about the Ruff update ingenuously said they wished Go had something like Ruff, being unaware of this framework. In that thread, someone seemed to take it as a sign that many people who might care to know about this don't yet, so they made a dedicated post for it.
It’s also a fairly traumatic thing to people through and I can imagine it does a lot of damage to people’s faith in law enforcement. Personal anecdote: when I was a teenager some cops gave me a list of fabricated evidence that I’d committed a crime, not intending to ever show a court; just trying to get me to confess. They said they’d go easy on me if I confessed but if I held out then they would petition the court to have me tried as an adult and sent to “big boy” prison. They also told me my parents were cooperating in the investigation and didn’t tell me. The whole ordeal basically made sure no one in my previously quite pro-cop family would ever trust an LEO again.
My first experience with the police was just as bad. A friend and I were waiting on the porch of another friend (all like 14 years old). We were waiting for him to come home. He knew we were there waiting for him.
His neighbors yelled something to us out of their window. We went to see what they wanted, but they didn't say anything when we got near.
We went back to the porch and waited for maybe 10-15 minutes, but decided to leave as we felt really weird about those neighbors. As we started walking, a police officer pulled up screaming at us, telling us we were under arrest for throwing rocks at the windows of those neighbors. The police officer took us to the police station, put handcuffs on us, as well as shackled our feet to the floor, where we remained for like 2 hours. He made us write a statement, and then told our parents to come get us.
It was truly the most confusing thing I ever experienced. Angers me a bit today thinking about it.
Personally I love it for cache invalidation. I used it on an older especially on project originally built without caching in mind that then added caching for immutable data without caching for mutable data in mind. It fell to me to add caching of mutable data. I found it rather convenient to put NOTIFY triggers on cached tables and have a LISTENer that will delete the corresponding rows from memcached when it gets a notification. It’s basically impossible to out-scale it in that use case because the scale is intrinsically linked to number of writes the leader in your database processes.
The standard library maintainers recognized this as a problem that there was no “better,” more convenient way to do it and in encoding/json/v2 they have UnmarshalRead for that use case: https://pkg.go.dev/encoding/json/v2#UnmarshalRead
reply