A proxy object, being a bridge between Communicator and Controller, making RFC (Remote Function Call) possible.
The Driver class would be an object who makes to call remote functions, defined in the Controller and provided by Provider in the remote system, possible. In other words, calling a functions in the Driver<Controller>, it would mean to call a matched function in the remote system's Provider object.
Controller: Definition only
Driver: Remote Function Call
Definition
To make RFC (Remote Function Call) possible, the Driver class must extend the Proxy class implementing Controller functions and delivering the function calls to the Communicator class.
namespace tgrid.components
{
export class Driver<Controller extends object>
extends Proxy<Promisify<Controller>>
{
public constructor(communicator: CommunicatorBase);
}
// Functions must be converted to return Promise<T> value.
// sum(x: number, y: number): number -->> sum(x: number, y: number): Promise<number>
type Promisify<Controller extends object>;
}
Also, calling functions in the remote system would be processed not in synchronous level. They would be processed in the asynchronous level. Thus, the Driver class should convert functions in the Controller to be return Promise typed value.
// Can be a "Controller"
interface ICalculator
{
plus(x: number, y: number): number;
minus(x: number, y: number): number;
multiplies(x: number, y: number): number;
divides(x: number, y: number): number;
}
// Return type T must be converted to the Promise<T>
type Promisify<ICalculator> =
{
plus(x: number, y: number): Promise<number>;
minus(x: number, y: number): Promise<number>;
multiplies(x: number, y: number): Promise<number>;
divides(x: number, y: number): Promise<number>;
};
Outline
A proxy object, being a bridge between
Communicator
andController
, making RFC (Remote Function Call) possible.The
Driver
class would be an object who makes to call remote functions, defined in theController
and provided byProvider
in the remote system, possible. In other words, calling a functions in theDriver<Controller>
, it would mean to call a matched function in the remote system'sProvider
object.Controller
: Definition onlyDriver
: Remote Function CallDefinition
To make RFC (Remote Function Call) possible, the
Driver
class must extend theProxy
class implementingController
functions and delivering the function calls to theCommunicator
class.Also, calling functions in the remote system would be processed not in synchronous level. They would be processed in the asynchronous level. Thus, the
Driver
class should convert functions in theController
to be return Promise typed value.