samchon / tgrid

TypeScript RPC (Remote Procedure Call) for WebSocket and Worker protocols
https://tgrid.com/
MIT License
141 stars 19 forks source link

`Worker` to support both `thread` and `process` mode #51

Closed samchon closed 2 years ago

samchon commented 2 years ago

In the NodeJS, it's possible to constructing worker both by process.fork and worker-thread.

Therefore, give option to specialize the work mode in the NodeJS, by supporting the type parameter in theWorkerConnector.

In the WorkerServer case, it would find the type by itself.

export class WorkerConnector<Header, Provider extends object | null>
    extends ConnectorBase<Header, Provider>
    implements IWorkerSystem
{
    /**
     * Initializer Constructor.
     * 
     * @param header An object containing initialization data like activation.
     * @param provider An object providing features for remote system.
     * @param type You can specify the worker mode when NodeJS. Default is "thread".
     */
    public constructor
        (
            header: Header, 
            provider: Provider, 
            type: "thread" | "process" = "thread"
        )
}