Author image SAY MEDIA
and 1 contributors


Data::YUID::Client - Client for distributed YUID generation


    use Data::YUID::Client;
    my $client = Data::YUID::Client->new(
            servers => [
            connect_timeout => 1.0, # seconds
            select_timeout  => 1.0, # seconds
    my $id = $client->get_id;


Data::YUID::Client is a client for the client/server protocol used to generate distributed unique IDs. bin/yuidd implements the server portion of the protocol.



Creates a new client object, initialized with %param, and returns the new object.

%param can contain:

  • servers

    A reference to a list of server addresses, in host:port notation. These should point to the locations of servers running the yuidd server using the client/server protocol for ID generation.

    New Behavior: the original version of this would create a connection to every server at new() and cache them all. This version creates only one connection, when the first YUID is requested, and caches that connection. If the connection goes bad, it'll try other servers it its list until one works or until it has worked through the list.

  • connect_timeout

    Number of seconds (can be fractional) to wait for a valid connection to the server. It defaults to 1.0 if the option is left out. If the value is undef then it basically waits forever (one of the previous behaviour of this library.

  • select_timeout

    Number of seconds (can be fractional) for the select() on the server socket. It defaults to 1.0 if the option is left out. If the value is undef then it waits forever (not really advised).

$client->get_id([ $namespace ])

Obtains a unique ID from one of the servers, in the optional namespace $namespace.

Returns undef if it can't get an ID from any server.


Please see the Data::YUID manpage for author, copyright, and license information.