The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Data::STUID - Yet Another Unique ID Generator

SYNOPSIS

    # see Data::STUID::Server
    #     Data::STUID::Client
    #     Data::STUID::Generator

DESCRIPTION

Minimalistic unique ID generator. Main logic ported from STF (http://github.com/stf-storage/stf).

The generated IDs are always in 64bit range, and can be ordered sequentially, so it's easy to use for sort operations.

SAMPLE SERVER SETUP

For programmatic usage, see Data::STUID::Server

Install dependencies

You can do the regular

    perl Build.PL
    ./Build
    ./Build install

and then execute stuid-server directly, but you could also use carton.

install carton >= 0.9.10, and cpanm >= 1.60002.

    cd /path/to/Data-STUID
    carton install
    # optionally, skip tests: 'PERL_CPANM_OPT=-n carton install'
Execute It!

Plain usage would be:

    stuid-server --host_id=1

With carton:

    carton exec -I/path/to/Data-STUID/lib -- \
        /path/to/Data-STUID/script/stuid-server \
        --host_id=1

It might be easier if you wrap the above in a shell script, say server.sh:

    #!/bin/sh
    STUID_HOME=/path/to/Data-STUID
    exec \
        carton exec -I$STUID_HOME/lib -- \
        $STUID_HOME/script/stuid-server $@

Then execute it as:

    ./server.sh --host_id=1

Note that you need pass a unique host_id parameter to each distinct STUID server instance

Tweaks

Data::STUID::Server is a subclass of Net::Server::PreFork. You should be able to pass parameters that the parent class accepts. If the script doesn't, send me a pullreq!

SAMPLE CLIENT SETUP

For programmatic usage, see Data::STUID::Client

Install dependencies

See "SAMPLE SERVER SETUP"

Execute it!

Plain usage would be:

    stuid-client --server=127.0.0.1:9001 --server=127.0.0.1:9002 ...

    carton exec -I/path/to/Data-STUID/lib -- \
        /path/to/Data-STUID/script/stuid-client \
             --server=127.0.0.1:9001 --server=127.0.0.1:9002 ...

AUTHOR

Daisuke Maki <daisuke@endeworks.jp>