Module ao
The AO module provides functionality for managing the AO environment and handling messages.
Returns the ao table.
Functions
| clone (obj, seen) | Clones a table recursively. |
| normalize (msg) | Normalizes a message by extracting tags. |
| sanitize (msg) | Sanitizes a message by removing non-forwardable tags. |
| init (env) | Initializes the AO environment, including ID, module, authorities, outbox, and environment. |
| log (txt) | Logs a message to the output. |
| clearOutbox () | Clears the outbox. |
| send (msg) | Sends a message. |
| spawn (module, msg) | Spawns a process. |
| assign (assignment) | Assigns a message to a process. |
| isTrusted (msg) | Checks if a message is trusted. |
| result (result) | Returns the result of the process. |
| addAssignable (nameOrMatchSpec, matchSpec) | Add the MatchSpec to the ao.assignables table. |
| removeAssignable (name) | Remove the MatchSpec, either by name or by index If the name is not found, or if the index does not exist, then do nothing. |
| isAssignment (msg) | Return whether the msg is an assignment or not. |
| isAssignable (msg) | Check whether the msg matches any assignable MatchSpec. |
Tables
| ao | The AO module |
Functions
- clone (obj, seen)
-
Clones a table recursively.
Parameters:
- obj {any} The object to clone
- seen {table} The table of seen objects (default is nil)
Returns:
-
{any}
The cloned object
- normalize (msg)
-
Normalizes a message by extracting tags.
Parameters:
- msg {table} The message to normalize
Returns:
-
{table}
The normalized message
- sanitize (msg)
-
Sanitizes a message by removing non-forwardable tags.
Parameters:
- msg {table} The message to sanitize
Returns:
-
{table}
The sanitized message
- init (env)
-
Initializes the AO environment, including ID, module, authorities, outbox, and environment.
Parameters:
- env {table} The environment object
- log (txt)
-
Logs a message to the output.
Parameters:
- txt {string} The message to log
- clearOutbox ()
- Clears the outbox.
- send (msg)
-
Sends a message.
Parameters:
- msg {table} The message to send
- spawn (module, msg)
-
Spawns a process.
Parameters:
- assign (assignment)
-
Assigns a message to a process.
Parameters:
- assignment {table} The assignment to assign
- isTrusted (msg)
-
Checks if a message is trusted.
The default security model of AOS processes: Trust all and *only* those on the ao.authorities list.
Parameters:
- msg {table} The message to check
Returns:
-
{boolean}
True if the message is trusted, false otherwise
- result (result)
-
Returns the result of the process.
Parameters:
- result {table} The result of the process
Returns:
-
{table}
The result of the process, including Output, Messages, Spawns, and Assignments
- addAssignable (nameOrMatchSpec, matchSpec)
-
Add the MatchSpec to the ao.assignables table. An optional name may be provided.
This implies that ao.assignables may have both number and string indices.
Added in the assignment module.
Parameters:
- nameOrMatchSpec string, number or any The name of the MatchSpec to be added to ao.assignables. if a MatchSpec is provided, then no name is included
- matchSpec optional any The MatchSpec to be added to ao.assignables. Only provided if its name is passed as the first parameter
Returns:
-
string or number
name The name of the MatchSpec, either as provided
as an argument or as incremented
See also:
- removeAssignable (name)
-
Remove the MatchSpec, either by name or by index
If the name is not found, or if the index does not exist, then do nothing.
Added in the assignment module.
Parameters:
- name {string or number} The name or index of the MatchSpec to be removed
See also:
- isAssignment (msg)
-
Return whether the msg is an assignment or not. This can be determined by simply check whether the msg's Target is this process' id
Added in the assignment module.
Parameters:
- msg The msg to be checked
Returns:
-
boolean
isAssignment
See also:
- isAssignable (msg)
-
Check whether the msg matches any assignable MatchSpec.
If no assignables are configured, the msg is deemed not assignable, by default.
Added in the assignment module.
Parameters:
- msg The msg to be checked
Returns:
-
boolean
isAssignable
See also:
Tables
- ao
-
The AO module
Fields:
- _version The version number of the ao module
- _module The module id of the process
- id The id of the process
- authorities A table of authorities of the process
- reference The reference number of the process
- outbox The outbox of the process
- nonExtractableTags The non-extractable tags
- nonForwardableTags The non-forwardable tags
- clone The clone function
- normalize The normalize function
- sanitize The sanitize function
- init The init function
- log The log function
- clearOutbox The clearOutbox function
- send The send function
- spawn The spawn function
- assign The assign function
- isTrusted The isTrusted function
- result The result function