1. Nov 23rd, 2005

    UUID generator, actually two of them

    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.

    More information here.

    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.

    1. Nov 30th, 2005

      Bob Aman

      The main difference between my implementation and most of the others is that a) I provide generators for all 4 major UUID versions (I’d like to provide a generator/parser for the uncommon version 2 UUIDs, but I’ve seen no documentation for how to generate them correctly), and b) I also provided parsing methods for extracting information from any UUID. For example, given any version 1 UUID, I can extract a timestamp and return a Time object for it. It pretty cool stuff, and also almost entirely useless for about 99.9% of the projects that might use my code. :-)

    Your comment, here ⇓

    Or using OpenID