AnyEvent-MP

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN


    seed IDs - "host:port"
        Seed IDs are transport endpoint(s) (usually a hostname/IP address
        and a TCP port) of nodes that should be used as seed nodes.

    global nodes
        An AEMP network needs a discovery service - nodes need to know how
        to connect to other nodes they only know by name. In addition, AEMP
        offers a distributed "group database", which maps group names to a
        list of strings - for example, to register worker ports.

        A network needs at least one global node to work, and allows every
        node to be a global node.

        Any node that loads the AnyEvent::MP::Global module becomes a global
        node and tries to keep connections to all other nodes. So while it
        can make sense to make every node "global" in small networks, it
        usually makes sense to only make seed nodes into global nodes in
        large networks (nodes keep connections to seed nodes and global
        nodes, so making them the same reduces overhead).

VARIABLES/FUNCTIONS
    $thisnode = NODE / $NODE
        The "NODE" function returns, and the $NODE variable contains, the
        node ID of the node running in the current process. This value is
        initialised by a call to "configure".

    $nodeid = node_of $port
        Extracts and returns the node ID from a port ID or a node ID.

    $is_local = port_is_local $port
        Returns true iff the port is a local port.

    configure $profile, key => value...
    configure key => value...
        Before a node can talk to other nodes on the network (i.e. enter
        "distributed mode") it has to configure itself - the minimum a node
        needs to know is its own name, and optionally it should know the
        addresses of some other nodes in the network to discover other
        nodes.

        This function configures a node - it must be called exactly once (or
        never) before calling other AnyEvent::MP functions.

        The key/value pairs are basically the same ones as documented for
        the aemp command line utility (sans the set/del prefix), with these
        additions:

        norc => $boolean (default false)
            If true, then the rc file (e.g. ~/.perl-anyevent-mp) will *not*
            be consulted - all configuration options must be specified in
            the "configure" call.

        force => $boolean (default false)
            IF true, then the values specified in the "configure" will take
            precedence over any values configured via the rc file. The
            default is for the rc file to override any options specified in
            the program.

        step 1, gathering configuration from profiles
            The function first looks up a profile in the aemp configuration
            (see the aemp commandline utility). The profile name can be
            specified via the named "profile" parameter or can simply be the
            first parameter). If it is missing, then the nodename (uname -n)
            will be used as profile name.

            The profile data is then gathered as follows:

            First, all remaining key => value pairs (all of which are
            conveniently undocumented at the moment) will be interpreted as
            configuration data. Then they will be overwritten by any values
            specified in the global default configuration (see the aemp
            utility), then the chain of profiles chosen by the profile name
            (and any "parent" attributes).

            That means that the values specified in the profile have highest
            priority and the values specified directly via "configure" have
            lowest priority, and can only be used to specify defaults.

            If the profile specifies a node ID, then this will become the
            node ID of this process. If not, then the profile name will be
            used as node ID, with a unique randoms tring ("/%u") appended.

            The node ID can contain some "%" sequences that are expanded: %n
            is expanded to the local nodename, %u is replaced by a random
            strign to make the node unique. For example, the aemp
            commandline utility uses "aemp/%n/%u" as nodename, which might
            expand to "aemp/cerebro/ZQDGSIkRhEZQDGSIkRhE".

        step 2, bind listener sockets
            The next step is to look up the binds in the profile, followed
            by binding aemp protocol listeners on all binds specified (it is
            possible and valid to have no binds, meaning that the node
            cannot be contacted from the outside. This means the node cannot
            talk to other nodes that also have no binds, but it can still
            talk to all "normal" nodes).

            If the profile does not specify a binds list, then a default of
            "*" is used, meaning the node will bind on a
            dynamically-assigned port on every local IP address it finds.

        step 3, connect to seed nodes
            As the last step, the seed ID list from the profile is passed to
            the AnyEvent::MP::Global module, which will then use it to keep
            connectivity with at least one node at any point in time.

        Example: become a distributed node using the local node name as
        profile. This should be the most common form of invocation for
        "daemon"-type nodes.

           configure

        Example: become a semi-anonymous node. This form is often used for
        commandline clients.

           configure nodeid => "myscript/%n/%u";

        Example: configure a node using a profile called seed, which is
        suitable for a seed node as it binds on all local addresses on a
        fixed port (4040, customary for aemp).



( run in 1.995 second using v1.01-cache-2.11-cpan-39bf76dae61 )