Using Go's auto-reconnecting MySQL client librariesThu, Nov 1, 2012 in Databases
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!
I'm Baron Schwartz, the founder and CEO of VividCortex. I am the author of High Performance MySQL and many open-source tools for performance analysis, monitoring, and system administration. I contribute to various database communities such as Oracle, PostgreSQL, Redis and MongoDB.