New
Latency strategy
This strategy selects a node which has the lowest latency, measured by periodic PING
. Notice that the strategy only ping one of nodes from a single host. Due to the node list can be very long, it gets samples and selects the host with the lowest latency from only samples instead of the whole node list.
Usage
let broker = new ServiceBroker({
registry: {
strategy: "Latency"
}
});
Strategy options
Name | Type | Default | Description |
---|---|---|---|
sampleCount
| Number
| 5
| the number of samples. If you have a lot of hosts/nodes, it's recommended to increase the value. |
lowLatency
| Number
| 10
| the low latency (ms). The node which has lower latency than this value is selected immediately. |
collectCount
| Number
| 5
| the number of measured latency per host to keep in order to calculate the average latency. |
pingInterval
| Number
| 10
| ping interval (s). If you have a lot of host/nodes, it's recommended to increase the value. |
Usage with custom options
let broker = new ServiceBroker({
registry: {
strategy: "Latency",
strategyOptions: {
sampleCount: 15,
lowLatency: 20,
collectCount: 10,
pingInterval: 15
}
}
});
Thanks for @zllovesuki!
Filemask for Moleculer Runner
There is a new Moleculer Runner option --mask
to define filemask when load all services from folders.
Example
$ moleculer-runner.js -r --mask **/user*.service.js examples
Example to load Typescript services
$ node -r ts-node/register node_modules/moleculer/bin/moleculer-runner --hot --repl --mask **/*.service.ts services
Changes
- fix
d.ts
issues - fix event
group
handling in mixins (#217) - move
mergeSchemas
fromutils
toService
static method. It can be overwritten in a custom ServiceFactory - improve
d.ts
- fix
prefix
option in Redis Cacher (223) - remove
nanomatch
dependency, use own implementation - fix ContextFactory issue (235)
- expose utility functions as
require("moleculer").Utils
- overwritable
mergeSchemas
static method inService
class. - Moleculer Runner precedence order is changed. The
SERVICES
&SERVICEDIR
env vars overwrites the paths in CLI arguments.