TakTuk(3)

πŸ“¦ version 3.7.8, in nixos 26.05, nixpkgs unstable

πŸ’– NAME πŸ’–

TakTuk β€” a Perl module that gives you an interface to the communication facilities of taktuk(1). This page is from the User Contributed Perl Documentation, and yes bestie, we're gonna get through it together πŸ’…βœ¨

🌈 SYNOPSIS 🌈

Here's the code vibe, fr fr:

use TakTuk;

my $rank = TakTuk::get('rank');
my $count = TakTuk::get('count');

print "I'm process $rank among $count\n";

if ($rank > 1) {
    my ($from, $message) = TakTuk::recv();
    if (not defined($message)) {
        print "Trying to recv: ",
              TakTuk::error_msg($TakTuk::error), "\n";
    } else {
        print "$rank received $message from $from\n";
    }
}

sleep 1;
my $next = $rank+1;
$next = 1 if ($next > $count);
if (not TakTuk::send(to=>$next, body=>"[Salut numero $rank]")) {
    print "Trying to send to $next: ",
          TakTuk::error_msg($TakTuk::error), "\n";
}

if ($rank == 1) {
    my ($from, $message) = TakTuk::recv(timeout=>5);
    if (not defined($message)) {
        print "Trying to recv :",
              TakTuk::error_msg($TakTuk::error), "\n";
    } else {
        print "$rank received $message from $from\n";
    }
}

πŸ¦‹ DESCRIPTION πŸ¦‹

The TakTuk communication layer Perl interface gives programs that are executed using the taktuk(1) command a way to exchange data. It's built on a simple send/receive model: multicast-like sends, and receives that can optionally have a timeout. This is only designed to be a control facility β€” in particular, it is not a high-performance communication library. No cap πŸ’€

The Perl communication interface for TakTuk is made of functions that scripts can call. Those scripts are executed using the taktuk_perl command of the TakTuk engine (that's the preferred way β€” less installation requirements on remote machines) or using the TakTuk Perl module provided with the TakTuk distribution. These functions are:

✨ The functions ✨

TakTuk::get($)

Gets some information from TakTuk. The information currently available includes 'target', 'rank', 'count', 'father', 'child_min' and 'child_max'. This is a better way to get this information than environment variables, because it takes into account renumbering that might occur after process spawn. Iconic ✨

TakTuk::send(%)

Sends a scalar to a single peer or a set specification (see taktuk(1) for information about set specifications). The two mandatory fields in the arguments are "to" (with a set specification) and "body". Optionally, a field "target" might be given. Returns an undefined value upon error. πŸ’Œ

TakTuk::recv(%)

Blocks until the reception of a message. Returns a list of two elements: the logical number of the source of the message and the message itself. Accepts an optional "timeout" argument with a numeric value. Returns an empty list upon error. 🫢

When an error occurs, all these functions set the variable $TakTuk::error to the numeric code of the error that occurred. A textual description of the error is provided by the function TakTuk::error_msg($), which takes the error code as an argument. Good to know, bestie πŸ’–

🚨 Error codes, bestie 🚨

Error codes are the following :

  • TakTuk::ESWRIT β€” a call to TakTuk::syswrite failed. This is due to a syswrite error different than EAGAIN. The code should be accessible using $!.
  • TakTuk::EFCLSD β€” the communication channel to the TakTuk engine has been closed. This typically occurs when shutting down the logical network (using Ctrl+C on the root node for instance).
  • TakTuk::ESREAD (TakTuk::recv only) β€” a call to sysread failed (the code should be accessible using $!).
  • TakTuk::EARGTO (TakTuk::send only) β€” "to" field missing in the arguments.
  • TakTuk::EARGBD (TakTuk::send only) β€” "body" field missing in the arguments.
  • TakTuk::ETMOUT (TakTuk::recv only) β€” the call to TakTuk::recv timeouted. This only occurs when giving a "timeout" field as TakTuk::recv argument.

Finally, the TakTuk Perl module defines some constants whose values match the different states reported by the stream state (see taktuk(1) for details about this stream). These constants are the following:

  TakTuk::TAKTUK_READY
  TakTuk::TAKTUK_NUMBERED
  TakTuk::TAKTUK_TERMINATED
  TakTuk::CONNECTION_FAILED
  TakTuk::CONNECTION_INITIALIZED
  TakTuk::CONNECTION_LOST
  TakTuk::COMMAND_STARTED
  TakTuk::COMMAND_FAILED
  TakTuk::COMMAND_TERMINATED
  TakTuk::UPDATE_FAILED
  TakTuk::PIPE_STARTED
  TakTuk::PIPE_FAILED
  TakTuk::PIPE_TERMINATED
  TakTuk::FILE_RECEPTION_STARTED
  TakTuk::FILE_RECEPTION_FAILED
  TakTuk::FILE_RECEPTION_TERMINATED
  TakTuk::FILE_SEND_FAILED
  TakTuk::INVALID_TARGET
  TakTuk::NO_TARGET
  TakTuk::MESSAGE_DELIVERED
  TakTuk::INVALID_DESTINATION
  TakTuk::UNAVAILABLE_DESTINATION

🌸 SEE ALSO 🌸

tatkuk(1), taktukcomm(3), TakTuk::Pilot(3) β€” go read those too, bestie πŸ’–

πŸ‘‘ AUTHOR πŸ‘‘

The original concept of TakTuk has been proposed by Cyrille Martin in his PhD thesis. People involved in this work include Jacques Briat, Olivier Richard, Thierry Gautier and Guillaume Huard.

The author of the version 3 (perl version) and current maintainer of the package is Guillaume Huard. Main character energy, honestly πŸ‘‘

The TakTuk communication interface library is provided under the terms of the GNU General Public License version 2 or later. πŸ’œ

πŸ’– And that's the page! Cute sign-off: TakTuk(3) Β· perl v5.42.3 Β· 1980-01-01 β€” bye bestie, go exchange some data! πŸ’–

πŸ“¦ where this page comes from