Skip to main content

Net overview

1. What it is#

Net is a core component of CellularJS, it has responsibility to maintain virtual network where services can communicate with each others in protocol-agnostic manner. For example, instead of importing code directly from other cell, virtual network help your services communicate via a message flow, so it keep your code separate.

note

CelluarJS is about programmatic isolation. It can't help you with something like data separation, what it can do is help you enforce logical isolation by yourself.

2. Installation#

If you don't want to use CellularJs starter, you can install and use @cellularjs/net independently, or even integrate it into other framework(Of course that framework must support TypeScript).

yarn add @cellularjs/net

Note: you need to enable typescript decorator to use this package. Adding experimentalDecorators, emitDecoratorMetadata to your tsconfig.json.

{  "compilerOptions": {    ...    "experimentalDecorators": true,    "emitDecoratorMetadata": true,    ...  }}

3. Message flow#

Drawing with excalidraw.com

Explain:

  • 1: This is external message, it can come from any type of client(http, cli, other framework, library, ...).
  • 2.x: $gateway as home entry points will transform external message into internal message and vice versa. Virtual network will help routing internal message to the target service(cell).
You should know

Behind the scenes, internal message transportation with local driver is just a function call, there is no request to internet, so there's no need to worry about speed,...