V8 Javascript API

Architecture

[V8 API]

Description

Unlike many popular JavaScript server implementations the V8 API generally uses a multi-threaded, synchronous architecture. This is due to the fact that individual commands are atomic in nature and typically only execute for a short amount of time. Commands running in separate threads are isolated from each other and not able to share data. Running multiple isolated, synchronous code paths in parallel allows for a more robust architecture, especially when running RealityServer in a clustered environment where a shared environment would require replicating JavaScript globals over multiple hosts. The synchronous nature of the API means there are no callbacks or Promises used within the system.

RealityServer 6.0 introduced asynchronous behaviour into the V8 API via asynchronous variants of the File System and Http Requests modules in addition to Promise based WebAssembly functionality.

All code is implemented within CommonJS modules. Commands are implemented as a special type of module and their execute functions provide the sole entry points to the API. All execution begins with a call to a Command.execute function and ends when that function exits and returns it's result to the client. The execute function can call any other RealityServer command, including JavaScript ones which will execute in the same environment as the current command.

Modules

 
Commands are executed within sandboxed environments which prevent data sharing between individual commands. More...
 
The V8 execution environment provides a number of global objects and functions available to all modules. More...
 
The V8 API is an entirely module based system. More...