Home Reference Source Repository
import ServiceClient from 'servingjs/src/ServiceClient.js'
public class | source

ServiceClient

Example:

import ServiceClient from "node_modules/servingjs/build/ServiceClient.js";
const service_provider = new ServiceClient("http://localhost:8000");
const result = await service_client.proxy.example_function(3, 39);
// client.close(); // (Node.js only)

Constructor Summary

Public Constructor
public

constructor(url: string, options: object)

Constructs the ServiceClient.

Member Summary

Public Members
public

Provides a proxy to adress service functions like object properties.

Protected Members
protected

Specifies the service provider's location.

protected

Specifies the service provider's location.

Method Summary

Public Methods
public

async close(): boolean

This method closes the http2 client on Node.js.

Protected Methods
protected

_makeRequest(service_function_name: string): *

This method replaces itself a the first invocation with either the _makeRequestFetch or the _makeRequestNode method according to the context.

protected

_makeRequestFetch(service_function_name: string): *

This method make the network request when fetch is available.

protected

_makeRequestNode(service_function_name: string): *

This method make the network request when http2 is available (on Node.js).

Public Constructors

public constructor(url: string, options: object) source

Constructs the ServiceClient.

Params:

NameTypeAttributeDescription
url string

service provider location

options object

passed to http2.connect|fetch

Public Members

public proxy: Proxy source

Provides a proxy to adress service functions like object properties.

Protected Members

protected options: object source

Specifies the service provider's location.

protected url: string source

Specifies the service provider's location.

Public Methods

public async close(): boolean source

This method closes the http2 client on Node.js. In a browser context this method does nothing.

Return:

boolean

true - on Node.js

Protected Methods

protected _makeRequest(service_function_name: string): * source

This method replaces itself a the first invocation with either the _makeRequestFetch or the _makeRequestNode method according to the context. Subsequently calls the replacing method.

Params:

NameTypeAttributeDescription
service_function_name string

name of the requested service function

Return:

*

response_value - response from the requested service function

protected _makeRequestFetch(service_function_name: string): * source

This method make the network request when fetch is available.

Params:

NameTypeAttributeDescription
service_function_name string

name of the requested service function

Return:

*

response_value - response from the requested service function

protected _makeRequestNode(service_function_name: string): * source

This method make the network request when http2 is available (on Node.js).

Params:

NameTypeAttributeDescription
service_function_name string

name of the requested service function

Return:

*

response_value - response from the requested service function