But I digress. I’m writing Go applications that talk to MySQL. Some of them talk to the database in read-only ways, and I just wanted to share this neat little nugget about the MyMySQL client libraries (pure-Go implementation; not a wrapper around a C library). One of its features, which you can enable optionally, is autorc. This stands for auto-reconnect to the server. It’s done very smartly. In fact, you don’t even have to connect at all; you just query the server, and the connection either opens or reopens. I’ve tested it and it’s really working well.
This has removed a large pile of smelly code from my application. It’s awesome. That’s all, folks!