A safe execution environment for NOMAD code execution.
get isBooting(): boolean
Getter used to determine if the VM is in the “booting” state.
boolean
get isCreated(): boolean
Getter used to determine if the VM is in the “created” state.
boolean
get isRunning(): boolean
Getter used to determine if the VM is in the “running” state.
boolean
get isStopped(): boolean
Getter used to determine if the VM is in the “stopped” state.
boolean
get isStopping(): boolean
Getter used to determine if the VM is in the “stopping” state.
boolean
get name(): string
Getter used to retrieve the VM’s name.
string
createEnclosure(enclosure: string): Promise<Enclosure>
Create a new enclosure with the given name.
• enclosure: string
Enclosure to create.
A Promise that resolves with a Enclosure wrapper if enclosure creation completed successfully, and rejects with an Error in case errors occur.
deleteEnclosure(enclosure: string): Promise<string[]>
Delete the enclosure with the given name.
This method will reject all tunnels awaiting responses on the given enclosure.
• enclosure: string
Enclosure to delete.
Promise
<string
[]>
A Promise that resolves with a list of deleted enclosures (the one given and any sub enclosures of it) if enclosure deletion completed successfully, and rejects with an Error in case errors occur.
emit(
enclosure: string,
event: string, ...
args: AnyArgs): this
Emit an event towards the VMWorker.
• enclosure: string
Enclosure to use.
• event: string
Event name to emit.
• …args: AnyArgs
Associated arguments to emit alongside the event.
this
this
, for chaining.
execute(
enclosure: string,
dependency: Dependency,
args?: ArgumentsMap): Promise<unknown>
Execute the given Dependency with the given arguments map in the VMWorker.
• enclosure: string
The enclosure to use.
• dependency: Dependency
The Dependency to execute.
• args?: ArgumentsMap
The arguments map to execute with.
Promise
<unknown
>
A Promise that resolves with the Dependency’s execution result, and rejects with an Error in case errors occurred.
getSubEnclosures(enclosure: string, depth?: number): Promise<string[]>
List the given enclosure’s sub enclosures.
• enclosure: string
Enclosure to list the sub enclosures of.
• depth?: number
Maximum enclosure depth to retrieve results for, defaults to retrieving all.
Promise
<string
[]>
A Promise that resolves with a list of sub enclosures enclosures if successful, and rejects with an Error in case errors occur.
install(enclosure: string, dependency: Dependency): Promise<void>
Install the given Dependency on the VMWorker.
• enclosure: string
Enclosure to use.
• dependency: Dependency
The Dependency to install.
Promise
<void
>
A Promise that resolves with void
if the Dependency was correctly installed, and rejects with an Error in case errors occurred.
installAll(enclosure: string, dependencies: Iterable<Dependency>): Promise<void>
Install the given Dependency iterable, by sorting them topologically and installing each one in turn.
• enclosure: string
Enclosure to use.
• dependencies: Iterable
<Dependency
>
Dependencies to install.
Promise
<void
>
A Promise that resolves with void
if every Dependency in the iterable was correctly installed, and rejects with an Error in case errors occurred.
isMuted(enclosure: string): Promise<boolean>
Determine whether the given enclosure is muted.
• enclosure: string
Enclosure to determine mute status of.
Promise
<boolean
>
A Promise that resolves with a boolean value indicating whether the enclosure is muted if successful, and rejects with an Error in case errors occur.
linkEnclosures(enclosure: string, target: string): Promise<boolean>
Link one enclosure to another, so that events cast on the first are also handled in the second.
• enclosure: string
“Source” enclosure to use.
• target: string
“Destination” enclosure to use.
Promise
<boolean
>
A Promise that resolves with a boolean value if enclosure linking completed successfully (the value itself determining if a new link was added), and rejects with an Error in case errors occur.
listInstalled(enclosure: string): Promise<string[]>
List the dependencies (user-level and predefined) installed on the given enclosure or its prefixes.
• enclosure: string
Enclosure to list installed dependencies of.
Promise
<string
[]>
A Promise that resolves with a list of installed dependency names if successful, and rejects with an Error in case errors occur.
listLinkedFrom(enclosure: string): Promise<string[]>
List the enclosures that link to the given one.
• enclosure: string
Enclosure to list linked-from enclosures of.
Promise
<string
[]>
A Promise that resolves with a list of linked-from enclosures if successful, and rejects with an Error in case errors occur.
listLinksTo(enclosure: string): Promise<string[]>
List the enclosures the given one is linked to.
• enclosure: string
Enclosure to list linked-to enclosures of.
Promise
<string
[]>
A Promise that resolves with a list of linked-to enclosures if successful, and rejects with an Error in case errors occur.
listRootEnclosures(): Promise<string[]>
List the root enclosures created.
Promise
<string
[]>
A Promise that resolves with a list of root enclosures created if successful, and rejects with an Error in case errors occur.
mergeEnclosure(enclosure: string): Promise<void>
Merge the given enclosure to its parent.
• enclosure: string
Enclosure to merge.
Promise
<void
>
A Promise that resolves with void
if enclosure merging completed successfully, and rejects with an Error in case errors occur.
muteEnclosure(enclosure: string): Promise<boolean>
Mute the given enclosure, so that events cast on it are no longer propagated to this VM.
• enclosure: string
Enclosure to mute.
Promise
<boolean
>
A Promise that resolves with the previous muting status if enclosure muting completed successfully, and rejects with an Error in case errors occur.
off(callback: EventCallback): this
Remove the given callback from the listeners set.
• callback: EventCallback
The callback to remove.
this
this
, for chaining.
on(filter: string, callback: EventCallback): this
Attach the given callback to the EventCaster, triggered on events matching the given filter.
• filter: string
Event name filter to assign the listener to.
• callback: EventCallback
Callback to call on a matching event being cast.
this
this
, for chaining.
once(filter: string, callback: EventCallback): this
Attach the given callback to the EventCaster, triggered on events matching the given filter, and removed upon being called once.
• filter: string
Event name filter to assign the listener to.
• callback: EventCallback
Callback to call on a matching event being cast.
this
this
, for chaining.
predefine(
enclosure: string,
name: string,
callback: AnyFunction): Promise<void>
Add a predefined function to the VM’s list under the given enclosure.
• enclosure: string
Enclosure to use.
• name: string
Function name to add.
• callback: AnyFunction
Function callback to use.
Promise
<void
>
A Promise that resolves with void
if the Function was correctly predefined, and rejects with an Error in case errors occurred.
shutdown(timeout?: number): Promise<void>
Shut the VMWorker down.
Shutting a VM instance consists of the following:
• timeout?: number
Milliseconds to wait for the VMWorker to shut down.
Promise
<void
>
A Promise that resolves with void
if the VMWorker was successfully shut down, and rejects with an Error in case errors are found.
start(
workerCtor?: WorkerConstructor,
timeout?: number,
rootEnclosure?: string): Promise<Enclosure>
Start the VMWorker and wait for its boot-up sequence to complete.
Starting a VM instance consists of the following:
message
, error
, and messageerror
.• workerCtor?: WorkerConstructor
The Worker constructor to use in order to build the worker instance (will default to the Worker one if not given).
• timeout?: number
Milliseconds to wait for the VMWorker to complete its boot-up sequence.
• rootEnclosure?: string
Name of the root Enclosure to create.
A Promise that resolves with a Enclosure wrapper for the default enclosure if the VMWorker was successfully booted up, and rejects with an Error in case errors occur.
startPinger(pingInterval?: number, pongLimit?: number): this
Start (or re-start) the pinger interval.
• pingInterval?: number
Number of milliseconds to wait between pings to the worker.
• pongLimit?: number
Maximum number of milliseconds between pong responses from the worker before declaring it unresponsive.
this
this
, for chaining.
stop(): Promise<void>
Stop the VMWorker immediately and reject all pending tunnels.
Stopping a Vm instance entails:
Promise
<void
>
A Promise that resolves with void
if the stopping procedure completed successfully, and rejects with an Error in case errors occur.
stopPinger(): this
Stop the pinger interval.
this
this
, for chaining.
unlinkEnclosures(enclosure: string, target: string): Promise<boolean>
Unlink one enclosure from another, so that events cast on the first are no longer handled in the second.
• enclosure: string
“Source” enclosure to use.
• target: string
“Destination” enclosure to use.
Promise
<boolean
>
A Promise that resolves with a boolean indicating whether the target enclosure was previously linked if enclosure unlinking completed successfully, and rejects with an Error in case errors occur.
unmuteEnclosure(enclosure: string): Promise<boolean>
Unmute the given enclosure, so that events cast on it are propagated to this VM.
• enclosure: string
Enclosure to unmute.
Promise
<boolean
>
A Promise that resolves with he previous muting status if enclosure un-muting completed successfully, and rejects with an Error in case errors occur.