Go and Postgres Listen/Notify or: How I Learned to Stop Worrying and Love PubSub

Go and Postgres Listen/Notify or: How I Learned to Stop Worrying and Love PubSub
I was reading HackerNews a few months ago and came across this post. It demystified something I’d long wondered about but hadn’t investigated myself: PubSub with PostgreSQL. Most PubSub implementations I’ve seen rely on some sort of message broker like Redis. To be fair, the Redis PubSub interface is pretty easy to work with (I think I have a post or two showing just how easy), and if you were purely working in memory, it would be totally fine. However, most applications rely on some sort of SQL database. In that case, in order to “publish”, you have to write to the database and then notify listeners over your message broker. You end up having to maintain two systems and it’s kind of annoying.
Read more →

Channel Merging for (Periodic) Func

Channel Merging for (Periodic) Func
Continuing on this hot streak of posts, I figured I’d write up something I’ve wanted to do a post on for quite a while. The idea here is to have a sort of “arterial channel” where we merge some arbitrary number of channels into one singular channel. There’s actually a couple “Just for Func” episodes on this topic that were extremely helpful: justforfunc #26: why are there nil channels in Go? and justforfunc #27: two ways of merging N channels.
Read more →

Pumping Messages with Websocket

Pumping Messages with Websocket
Howdy folks. I was refactoring some of my Go code from another project this past weekend and I realized this would be a great opportunity for a post about working with WebSockets in Go, so here we are.
Read more →

Channel Smuggling for Fun and Profit

Channel Smuggling for Fun and Profit
Neat snippet for y’all today. I’m calling this snippet “channel smuggling”; I googled this and all that came up was weird stuff. Anyway, the idea here is that suppose you want to pass a piece of data into a channel and have something do some work on it. However, what if you want to block until after all the work on that data is completed? Here’s an example on Go Playground, and here it is replicated below:
Read more →

Getting Starting with go-redis

Getting Starting with go-redis
Hi. It’s been a while. This post is covering go-redis, which is a popular Redis client for Go. There’s other Redis clients as well as other key-value store backends that you could opt for, but this post is about go-redis. Importantly, this post is not a primer on Redis itself (maybe I’ll have one of those in the future, but this ain’t it). I have a couple use cases in mind that will be the focus of this post:
Read more →

Minimal Go HTTP Servers

Minimal Go HTTP Servers
Hi there. In this post, I’m going to go over a couple snippets of minimal HTTP servers that I use from time to time when I’m tinkering with Go.
Read more →