There’s a lot more uses for UUIDs than reliable messaging, so I figured it would be best to spin the UUID generator into its own Gem. I just made a Gem you can install from RubyForge:
UUIDs (Universally Unique Identifiers) are primarily used in distributed applications to generate identifiers that do not conflict.
This UUID generator is based on RFC 4122, and uses the time-based format, allowing for up to 10 million unique identifiers per machine per second.
A 48-bit node identifier prevents identifier conflicts between machines. The setup script automatically discovers a node identifier from one of the network cards MAC address on your machine.
As I was double checking the Gem, I found out another developer interested in UUIDs. So now you have to UUID gems to choose from. How about that for building distributed applications in Ruby?
And if you’re still not sure what UUIDs are good for, go read this article by Paul Dix:
Some of the key concerns when designing this solution are how to select primary keys that will avoid collision and how to keep relational data in tact when syncing data from one database to another. The method I follow for this is to use a UUID or GUID as the primary key for every table, just like Active Directory. When I initially looked at Rails for this project this was a major concern. ActiveRecord ties an auto-incrementing integer as the primary key for all tables/models and I was worried about my ability to override that. Well with a little searching, reading and a tiny amount of effort I was able to get Rails to do exactly what was needed.