[erlang-questions] Use of uuidgen with a mnesia application
Frank Mueller
frank@REDACTED
Fri Jun 6 21:07:50 CEST 2008
Hi Alexander,
in http://code.google.com/p/tideland-cel/source/browse/trunk/src/celutl.erl
you'll find my process and functions for the generation of guids.
Regards
mue
Am 06.06.2008 um 16:43 schrieb Alexander Lamb:
> Hello,
>
> I need to generate ids to be used as mnesia keys which will be unique
> not only withing a cluster of Erlang nodes but also globally (e.g. may
> be read from a Java program).
>
> I initially thought of writing my own uuidgen function, but it seems
> like reading the mac address of network interfaces can be rather
> cumbersom depending on systems.
>
> So I decided to use uuidgen from the system and convert it to binary
> (for efficiency).
>
> Is this the correct way of doing things:
>
> verify_guuid(Value) ->
> A = lists:nth(9,Value),
> B = lists:nth(14,Value),
> C = lists:nth(19,Value),
> case [A,B,C] of
> "---" -> true;
> _ -> false
> end.
>
> make_guuid() ->
> First = os:cmd("uuidgen -t"),
> case verify_guuid(First) of
> true -> Result = First;
> false -> Second = os:cmd("uuidgen"),
> case verify_guuid(Second) of
> true -> Result = Second;
> false -> Result = "error",
> throw({uuidgen_error,Second})
> end
> end,
> erlang:list_to_binary(Result).
>
> Now, the reason I have this cascade of case is because on Linux (our
> Ubuntu servers) it recognizes the -t option to generate the uuid and
> on MacOSX (our dev machines) it does not.
> Call me crazy, but I never feel confortable about using a totally
> random uuid to identity medical records that might be copied from
> system to system, exported, etc... even if the probability of
> collision is lower than that of a large asteroid hitting earth!
>
> What is your strategy for this (maybe this is a question to ask the
> couchdb developers, since they use guuids to identify the documents)?
>
> Thanks,
>
> Alex
> --
> Alexander Lamb
> Founding Associate
> RODANOTECH Sàrl
>
> 4 ch. de la Tour de Champel
> 1206 Geneva
> Switzerland
>
> Tel: 022 347 77 37
> Fax: 022 347 77 38
>
> http://www.rodanotech.ch
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
--
**
** Frank Mueller / Oldenburg / Germany
**
** http://frank.mweb.de and http://mue.tideland.biz
**
More information about the erlang-questions
mailing list