AnyEvent-MP
view release on metacpan or search on metacpan
aemp setbinds "*"
Example: bind on a random port on all local interfaces.
aemp setbinds "*:*"
Example: resolve "doomed.mydomain" and try to bind on port C<4040> of all
IP addressess returned.
aep setbinds doomed.mydomain:4040
=item delbinds
Removes the bind list again, which means it is inherited again from it's
parent profile, or stays unset.
=item addbind <host:port>
Adds a single bind address.
=item delbind <host:port>
Deletes the given bind address, if it exists.
=back
=head2 CONFIGURATION/SERVICES
Services are modules (or functions) that are automatically loaded (or
executed) when a node starts. They are especially useful when used in
conjunction with F<aemp run>, to configure which services a node should
run.
Despite the daunting name, services really I<are> nothing more than a
module name or a function name with arguments. The "service" aspect comes
only from the behaviour of the module or function, which is supposed to
implement, well, some kind of service for the node, network etc.
Instead of writing a standalone program for each different node type in
your network, you can simply put your code into a module, and then let the
configuration decide which node runs which "services". This also makes it
easy to combine multiple different services within the same node.
=over 4
=item setservices <initfunc>...
Sets or replaces the list of services, which must be specified as a
comma-separated list or a JSON array.
Each string entry in the list is interpreted as either a module name to
load (when it ends with C<::>) or a function to call (all other cases).
Each entry which is an array itself (you need to use JSON format to
specify those) is interpreted as a function name and the arguments to
pass.
The algorithm to find the function is the same as used for C<<
L<AnyEvent::MP>::spawn >>.
Example: run the global service.
aemp setservices AnyEvent::MP::Global::
Example: call the mymod::myfun function with arguments 1, 2 and 3.
aemp setservices '[["mymod::myfun", 1,2,3]]'
=item delservices
Removes the service list again, which means it is inherited again from
it's parent profile, or stays unset.
=item addservice <initfunc>
Adds a single service.
=item delservice <initfunc>
Deletes the given service, if it exists.
=item seteval <string>
Sometimes, all you need is to evaluate a small perl snippet to bring a
node up. This sets a perl string that is eval'ed after the node has been
configured.
=item deleval
Delete any eval string set with seteval.
=back
=head2 CONFIGURATION/PROFILE MANAGEMENT
All the above configuration functions by default affect the I<global
default configuration>, which is basically used to augment every profile
and node configuration.
=over 4
=item profile <name> ...
This subcommand makes the following subcommands act only on a specific
named profile, instead of on the global default. The profile is created if
necessary.
Example: create a C<server> profile, give it a random node name, some seed
nodes and bind it on an unspecified port on all local interfaces. You
should add some services then and run the node...
aemp profile server nodeid anon/ seeds doomed,10.0.0.2:5000 binds "*:*"
=item delprofile <name>
Deletes the profile of the given name.
=item setparent <name>
Sets the parent profile to use - values not specified in a profile will be
taken from the parent profile (even recursively, with the global default
config being the default parent). This is useful to configure profile
I<classes> and then to inherit from them for individual nodes.
Note that you can specify circular parent chains and even a parent for the
global configuration. Neither will do you any good, however.
Example: inherit all values not specified in the C<doomed> profile from
the C<server> profile.
aemp profile doomed setparent server
=item delparent
Removes the parent again from the profile, if any was set, so the profile
inherits directly from the global default config again.
=item showprofile <name>
Shows the values of the given profile, and only those, no inherited
values.
=item showconfig <name> <key value...>
Shows the I<effective> config, i.e. the values as used by a node started
with the given profile name. Any additional key-value pairs specified
augment the configuration, just as with C<configure>.
If all arguments are omitted, show the global default config.
=back
=head2 LOW-LEVEL TRANSPORT PROTOCOL
The low-level transport protocol betwene two nodes also has a number of
configurable options, most of which should not be touched unless you know
what you are doing.
=over 4
=item [set|del]secure <boolean>
Normally, nodes allow anything to be done to them by remote nodes,
including remotely-triggered execution of code.
Sometimes a more secure mode is desired - this can be achieved by setting
the secure option to a true value.
When secure mode is enabled, then the node will not execute code locally,
at least not via the normal node protocol. All other messages are still
allowed. This means remote nodes can monitor, kill or snd to local ports
(port names can also be easily guessed).
At the moment, this setting ignores C<snd_on>, C<eval_on> and C<spawn>
requests.
=item [set|del]monitor_timeout <seconds>
Sets the default monitor timeout, that is, when a connection to a node
cannot be established within this many seconds, the node is declared
unreachable and all monitors will fire.
C<30> seconds are usually a good time span for this.
=item [set|del]connect_interval <seconds>
When a connection cannot be established successfully within this many
seconds, try the next transport address (e.g. the next IP address). If
your nodes have a lot of transports, you might have to set this to a low
value so that they will actually all be tried within the monitor timeout
interval.
C<2> is usually a good value, unless you live in new zealand.
=item [set|del]framing_format [array]
Configures the list of framing formats offered to the other side. This is
simply a list of formatted read/write types used with L<AnyEvent::Handle>,
in order of decreasing preference.
Nodes support C<cbor>, C<json> and C<storable> framing formats for data
packets out of the box, and usually choose C<cbor> because it is first in
the list.
Example: prefer the C<My::Personal::Format> framing format over JSON over
Storable.
aemp setframing_format '["My::Personal::Format", "json", "storable"]'
( run in 0.509 second using v1.01-cache-2.11-cpan-39bf76dae61 )