Interface INopeRpcManager<T>

The rpcManager is essentially a service registry.

Service Registry

A service registry is a tool used to store and manage information about available services in a distributed system. It is an important component of microservices architectures, where applications are divided into smaller, independent services that communicate over the network.

A service registry serves as a central repository for metadata about each service, including its address, port number, protocol, and API version. When a service is started, it registers with the service registry, and when it is stopped, it is removed from it.

Other services in the architecture can then query the Service Registry to find out which services are available and how they can communicate. This reduces the complexity of managing distributed systems and improves scalability and flexibility

Service Broker

A broker in the services world refers to a software tool or mechanism that acts as an intermediary between different services or applications. A broker is typically used in a service-oriented architecture (SOA) to facilitate and manage interaction and communication between different services.

A broker provides various functions, such as message routing and transformation, monitoring, and security management. The broker can also perform tasks such as caching messages and routing requests to the most appropriate service.

In an SOA environment, applications or services may communicate using different protocols and transports, and the broker acts as an intermediary to ensure that messages are exchanged correctly and reliably between the different systems. The broker can also help improve the scalability and flexibility of services by providing centralized control and management of service interactions.

Implementation of a service registry and broker in NoPE by the rpcManager.

A service in NoPE is defined by an id. This usually corresponds to a name with which the service is to be addressed.

In order to implement the required functionalities of a service registry, the rpcManager has the following methods and attributes:

  • registerService: This can be used to register services. These are then made available to all participants of the NoPE network.
  • unregisterService: This can be used to remove services from the network.
  • The services property provides an overview of which services are available (including frequency and their parameters and description).
  • The serviceExists method can be used to test whether the service is available.
  • performCall execute a service. All relevant communications are mapped by the rpcManager. The user does not know which runtime provides the service.
    • The execution leads to a so called task which can be aborted by cancelTask. This leads to an exception at the calling unit.
    • If several service providers (NoPE-Runtime) are able to execute the service, the provider can be selected via a callback. For this purpose there are predefined selectors
      • master (see connectivityManager) the master must execute the process
      • first: any provider executes the serives (the first in the list)
      • dispatcher: a specific dispatcher must run the service (defined by its id)
      • host: a dispatcher on the defined host.
      • cpu-usage: the dispatcher with the least CPU usage
      • free-ram: The dispatcher with the lowest RAM usage
  • services with callbacks can also be hosted via a plugin

Author

M.Karkowski

Export

INopeRpcManager

Type Parameters

Hierarchy

  • INopeRpcManager

Implemented by

Properties

methodInterface: {
    [index: string]: (<T>(...args) => INopePromise<T>);
}

A Proxy to the provided Methods (without the Options)

Author

M.Karkowski

Memberof

INopeRpcManager

Type declaration

methodInterfaceWithOptions: {
    [index: string]: (<T>(options, ...args) => INopePromise<T>);
}

A Proxy to the provided Methods (including the Options)

Author

M.Karkowski

Memberof

INopeRpcManager

Type declaration

Event, which is fired, if a task has been canceled. this is called after a the method.

Author

M.Karkowski

Memberof

INopeRpcManager

ready: INopeObservable<boolean, boolean, boolean, IEventAdditionalData>

Flag, to show, that the System is ready

Author

M.Karkowski

Memberof

INopeRpcManager

services: IMapBasedMergeData<string, IAvailableServicesMsg, string, T>

Element showing the available services.

  • OriginalKey = Dispatcher ID (string);
  • OriginalValue = Original Message (IAvailableServicesMsg);
  • ExtractedKey = Function ID (string);
  • ExtractedValue = FunctionOptions (T);

Author

M.Karkowski

Memberof

INopeRpcManager

Methods

  • cancel all Tasks of the given dispatcher. If the Dispatcher isnt present, an error is raised

    Author

    M.Karkowski

    Memberof

    INopeRpcManager

    Parameters

    • dispatcher: string
    • reason: Error

    Returns void

  • Function to cancel the given Task

    Author

    M.Karkowski

    Memberof

    INopeRpcManager

    Parameters

    • taskId: string

      The ID of the Task

    • reason: Error

      The Reason to Cancel the Task

    • Optional quiet: boolean

      Disables Log or not.

    Returns Promise<boolean>

  • Simple checker, to test, if this rpc-mananger is providing a service with the given id.

    Returns

    The result

    Parameters

    • id: string

      The id of the service, which is used during registration

    Returns boolean

  • performCall execute a service. All relevant communications are mapped by the rpcManager. The user does not know which runtime provides the service.

    • The execution leads to a so called task which can be aborted by cancelTask. This leads to an exception at the calling unit.
    • If several service providers (NoPE-Runtime) are able to execute the service, the provider can be selected via a callback. For this purpose there are predefined selectors
      • master (see connectivityManager) the master must execute the process
      • first: any provider executes the serives (the first in the list)
      • dispatcher: a specific dispatcher must run the service (defined by its id)
      • host: a dispatcher on the defined host.
      • cpu-usage: the dispatcher with the least CPU usage
      • free-ram: The dispatcher with the lowest RAM usage

    Author

    M.Karkowski

    Returns

    Memberof

    INopeRpcManager

    Type Parameters

    • T

    Parameters

    • serviceName: string | string[]

      The name of the service. If a list is provided, all services will be called at the same time using the same parameters

    • params: unknown[]

      Parameters

    • Optional options: ValidCallOptions | ValidCallOptions[]

    Returns INopePromise<T, any>

  • Registers a function

    Author

    M.Karkowski

    Returns

    Memberof

    INopeRpcManager

    Type Parameters

    • T

    Parameters

    • func: ((...args) => Promise<T>)

      The Function

        • (...args): Promise<T>
        • Parameters

          • Rest ...args: any[]

          Returns Promise<T>

    • options: {
          addNopeServiceIdPrefix?: boolean;
      } & IServiceOptions<any>

      used during the service call.

    Returns Promise<((...args) => Promise<T>)>

  • Function, that must be called if a dispatcher is is gone. This might be the case on slow connections or an a triggered disconnect.

    Author

    M.Karkowski

    Memberof

    INopeRpcManager

    Parameters

    • dispatcher: string

    Returns void

  • Simple helper to find the existing Services

    Author

    M.Karkowski

    Returns

    The result

    Memberof

    INopeRpcManager

    Parameters

    • id: string

      The id of the service, which is used during registration

    Returns boolean

  • Description of a RPC-Manager

    Returns {
        services: {
            all: T[];
            internal: {
                func: ((...args) => Promise<any>);
                options: T;
            }[];
        };
        task: {
            executing: string[];
            requested: {
                id: string;
                service: string;
                target: string;
                timeout: any;
            }[];
        };
    }

    • services: {
          all: T[];
          internal: {
              func: ((...args) => Promise<any>);
              options: T;
          }[];
      }
      • all: T[]
      • internal: {
            func: ((...args) => Promise<any>);
            options: T;
        }[]
    • task: {
          executing: string[];
          requested: {
              id: string;
              service: string;
              target: string;
              timeout: any;
          }[];
      }
      • executing: string[]
      • requested: {
            id: string;
            service: string;
            target: string;
            timeout: any;
        }[]
  • Helper to unregister an callback.

    Author

    M.Karkowski

    Returns

    Success of the Operation

    Memberof

    INopeRpcManager

    Parameters

    • func: string | ((...args) => any)

    Returns Promise<boolean>

Generated using TypeDoc