- Multiprocessing, Process Pool with IPC.
Warning:
Module currently not working, Pull Requests welcome.
Types
Cluster = ref object of JsRoot isMaster*, isPrimary*, isWorker*: bool schedulingPolicy*: cstring settings*, worker*, workers*: JsObject
- https://nodejs.org/api/cluster.html#cluster_cluster
Worker = ref object of JsRoot exitedAfterDisconnect*: bool id*: int
- https://nodejs.org/api/cluster.html#cluster_class_worker
Procs
func disconnect(self: Cluster) {.importjs: "#.$1()", ...raises: [], tags: [].}
- https://nodejs.org/api/cluster.html#cluster_cluster_disconnect_callback
func disconnect(self: Worker): auto {.importjs: "#.$1()", discardable, ...raises: [], tags: [].}
- https://nodejs.org/api/cluster.html#cluster_worker_disconnect
func disconnect[T](self: Cluster; callback: T) {.importjs: "#.$1(#)", ...raises: [], tags: [].}
- https://nodejs.org/api/cluster.html#cluster_cluster_disconnect_callback
func fork(): Worker {.importjs: "cluster.$1()", discardable, ...raises: [], tags: [].}
- https://nodejs.org/api/cluster.html#cluster_cluster_fork_env
func importCluster() {.importjs: "import * as cluster from \'cluster\'@", ...raises: [], tags: [].}
- Alias for import * as module_name from 'module_name';. Must be called once before using the module
func isConnected(self: Worker): bool {.importjs: "#.$1()", ...raises: [], tags: [].}
- https://nodejs.org/api/cluster.html#cluster_worker_isconnected
func isDead(self: Worker): bool {.importjs: "#.$1()", ...raises: [], tags: [].}
- https://nodejs.org/api/cluster.html#cluster_worker_isdead
func isMaster(): bool {.importjs: "(cluster.isPrimary)@", ...raises: [], tags: [].}
func isPrimary(): bool {.importjs: "(cluster.isPrimary)@", ...raises: [], tags: [].}
func isWorker(): bool {.importjs: "(cluster.isWorker)@", ...raises: [], tags: [].}
func kill(self: Worker; signal = "SIGTERM".cstring) {.importjs: "#.$1(#)", discardable, ...raises: [], tags: [].}
- https://nodejs.org/api/cluster.html#cluster_worker_kill_signal
func requireCluster() {.importjs: "const cluster = require(\'cluster\')@", ...raises: [], tags: [].}
- Alias for const module_name = require('module_name');. Must be called once before using the module
func send(self: Worker; message: JsObject): bool {.importjs: "#.$1(#)", ...raises: [], tags: [].}
- https://nodejs.org/api/cluster.html#cluster_worker_send_message_sendhandle_options_callback
func send[T](self: Worker; message: JsObject; callback: T): bool {. importjs: "#.$1(#, #)", ...raises: [], tags: [].}
- https://nodejs.org/api/cluster.html#cluster_worker_send_message_sendhandle_options_callback
func setupMaster(self: Cluster) {.importjs: "#.$1()", ...raises: [], tags: [].}
- https://nodejs.org/api/cluster.html#cluster_cluster_fork_env
func setupMaster(self: Cluster; settings: JsObject) {.importjs: "#.$1(#)", ...raises: [], tags: [].}
- https://nodejs.org/api/cluster.html#cluster_cluster_fork_env
func setupPrimary(self: Cluster) {.importjs: "#.$1()", ...raises: [], tags: [].}
- https://nodejs.org/api/cluster.html#cluster_cluster_fork_env
func setupPrimary(self: Cluster; settings: JsObject) {.importjs: "#.$1(#)", ...raises: [], tags: [].}
- https://nodejs.org/api/cluster.html#cluster_cluster_fork_env
Iterators
iterator clusterWorkers(): Worker {....raises: [], tags: [].}
Templates
template onDisconnect(self: Worker; callback)
- Alias for httpServer.on(event = cstring("disconnect"), callback).
template onListening(self: Worker; callback)
- Alias for httpServer.on(event = cstring("listening"), callback).