Skip to main content
Version: Next

Process

Constructors

Constructor

new Process(): Process;

Returns

Process

Methods

connect()

static connect(): Promise<void>;

Static method that manually triggers a connection attempt to the server to go ONLINE. If you have called () before, it will cancel the OFFLINE mode, next time the app will be opened, it will try to go ONLINE on its own.

Returns a promise that resolves when the server connection is established. If it fails, the promise is rejected.

Returns

Promise<void>


disconnect()

static disconnect(): Promise<void>;

Static method that manually close the connection to the server to go OFFLINE. Persists the offline status so the app restart offline after being closed. The only way to clean that status is to call ().

Returns a promise that resolves when the server connection is indeed disconnected and the state is OFFLINE. If the flag offline.enabled is not set to true, the promise is rejected.

Returns

Promise<void>


isOnline()

static isOnline(context): Observable<boolean>;

Static method that returns an observable on the connection state: the observable send TRUE if the process is considered as ONLINE and false if not.

Parameters

ParameterTypeDescription
contextContextthe context of the brick to garbage collect the observable when not needed anymore.

Returns

Observable<boolean>


onHealthCheck()

static onHealthCheck(callback, options?): () => void;

Static method to register a callback that is used to check the health status of the process. This is typically used by kubernetes environment to maintain backend healthy

The callback must return a Promise which returns a string as valid message. The process is considered by the runtime as unhealthy if the promise is rejected.

The options parameter can be used to specify the type of probe to register:

  • LIVENESS: used to check if the process is alive
  • READINESS: used to check if the process is ready to operate
  • ALL: used to check both liveness and readiness

Parameters

ParameterTypeDescription
callback() => Promise<string>the callback executed each time the runtime check the health of the process.
options?{ type: ProbeType; }options to specify the type of probe to register
options.type?ProbeType-

Returns

(): void;
Returns

void


onShutdown()

static onShutdown(callback, shutdownId?): () => void;

Static method to register a callback called by the runtime when it receives the signal to be terminated. This is typically used to graceful shutdown some connections or drivers to external processes.

The callback must return a Promise which is resolved when the shutdown process is done.

Parameters

ParameterTypeDescription
callback() => Promise<void>the callback executed when the runtime terminates.
shutdownId?stringoptional id to name the shutdown hook, mainly for debug purpose

Returns

(): void;
Returns

void