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

NAME

Argon::Message - Encodable message structure used for cross-system coordination

VERSION

version 0.17

SYNOPSIS

  use Argon::Message;
  use Argon ':commands', ':priorities';

  my $msg = Argon::Message->new(
    cmd  => $PING,
    pri  => $NORMAL,
    info => {thing => ['with', 'data', 'in', 'it']},
  );

  my $reply = $msg->reply(info => '...');
  my $error = $msg->error("some error message");

DESCRIPTION

Argon protocol messages.

ATTRIBUTES

id

Unique identifier for the conversation. Used to track the course of a task from the client to the manager to the worker and back.

cmd

The command verb. See ":commands" in Argon::Constants.

pri

The message priority. See ":priorities" in Argon::Constants.

info

The data payload of the message. May be a string, reference, et al.

token

Used internally by Argon::SecureChannel to identify message senders.

METHODS

failed

Returns true if the cmd is $ERROR.

denied

Returns true if the cmd is $DENY.

copy

Returns a shallow copy of the message with a new id and token.

reply

Returns a copy of the message. Any additional parameters passed are passed transparently to new.

error

Returns a new message with the same id, cmd set to $ERROR, and info set to the supplied error message.

result

Returns the decoded data playload. If the message is an $ERROR or $DENY, croaks with info as the error message. If the message is an $ACK, returns true.

explain

Returns a formatted string describing the message. Useful for debugging and logging.

AUTHOR

Jeff Ober <sysread@fastmail.fm>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Jeff Ober.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.