Broker options
These options can be used in ServiceBroker
constructor or in moleculer.config.js
file.
List of all available broker options:
namespace
:String
- Namespace of nodes to segment your nodes on the same network (e.g.: “development”, “staging”, “production”). Default:""
nodeID
:String
- Unique node identifier. Must be unique in a namespace. If not the broker will throw a fatal error and stop the process. Default: hostname + PIDlogger
:Boolean | String | Object | Array<Object>
) - Logger class. By default, it prints message to theconsole
. Read more. _Default:"Console"
logLevel
:String | Object
- Log level for loggers (trace, debug, info, warn, error, fatal). Read more. Default:info
transporter
:String | Object | Transporter
- Transporter configuration. Read more. Default:null
requestTimeout
:Number
- Number of milliseconds to wait before reject a request with aRequestTimeout
error. Disabled:0
Default:0
retryPolicy
:Object
- Retry policy configuration. Read more.contextParamsCloning
:Boolean
- Cloning theparams
of context if enabled. High performance impact. Use it with caution! Default:false
dependencyInterval
: Configurable interval (defined inms
) that’s used by the services while waiting for dependency services. Default:1000
maxCallLevel
:Number
- Limit of calling level. If it reaches the limit, broker will throw anMaxCallLevelError
error. (Infinite loop protection) Default:0
heartbeatInterval
:Number
- Number of seconds to send heartbeat packet to other nodes. Default:5
heartbeatTimeout
:Number
- Number of seconds to wait before setting remote nodes to unavailable status in Registry. Default:15
tracking
:Object
- Tracking requests and waiting for running requests before shutdowning. (Graceful shutdown) Read more.disableBalancer
: Boolean - Disable built-in request & emit balancer. Transporter must support it, as well. Read more. Default:false
registry
:Object
- Settings of Service Registry.circuitBreaker
:Object
- Settings of Circuit Breaker.bulkhead
:Object
- Settings of bulkhead.transit.maxQueueSize
:Number
- A protection against inordinate memory usages when there are too many outgoing requests. If there are more than stated outgoing live requests, the new requests will be rejected withQueueIsFullError
error. Default:50000
transit.maxChunkSize
Number
- Maximum chunk size while streaming. Default:256KB
transit.disableReconnect
:Boolean
- Disables the reconnection logic while starting a broker. Default:false
transit.disableVersionCheck
:Boolean
- Disable protocol version checking logic in Transit. Default:false
transit.packetLogFilter
:Array
- Filters out the packets in debug log messages. It can be useful to filter out theHEARTBEAT
packets while debugging. Default:[]
uidGenerator
:Function
- Custom UID generator function for Context ID.errorHandler
:Function
- Global error handler function.cacher
:String | Object | Cacher
- Cacher settings. Read more. Default:null
serializer
:String | Serializer
- Instance of serializer. Read more. Default:JSONSerializer
validator
:Boolean | Validator
- Enable the default or create custom parameters validation. Default:true
errorRegenerator
:Regenerator
- Instance of error regenerator. Read more. Default:null
metrics
:Boolean | Object
- Enable & configure metrics feature. Default:false
tracing
:Boolean | Object
- Enable & configure tracing feature. Default:false
internalServices
:Boolean | Object
- Register internal services at start. Default:true
internalServices.$node
-Object
- Extend internal services with custom actions. Default:null
internalMiddlewares
:Boolean
- Register internal middlewares. Default:true
hotReload
:Boolean
- Watch the loaded services and hot reload if they changed. Read more. Default:false
middlewares
:Array<Object>
- Register custom middlewares. Default:null
replOptions
:Object
- Custom REPL options. Default:null
replOptions.delimiter
:String
- REPL delimiter. Default:null
replOptions.customCommands
:String
- REPL custom commands. Default:null
metadata
:Object
- Store custom values. Default:null
skipProcessEventRegistration
: Boolean - Skip the default graceful shutdown event handlers. In this case, you have to register them manually. Default:false
maxSafeObjectSize
:Number
- Maximum size of objects that can be serialized. On serialization process, check each object property size (based onlength
orsize
property value) and trim it, if object size bigger thanmaxSafeObjectSize
value. Default:null
created
:Function
- Fired when the broker created. Default:null
started
:Function
- Fired when the broker started (all local services loaded & transporter is connected). Default:null
stopped
:Function
- Fired when the broker stopped (all local services stopped & transporter is disconnected). Default:null
ServiceFactory
:ServiceClass
- CustomService
class. If notnull
, broker will use it when creating services by service schema. Default:null
ContextFactory
:ContextClass
- CustomContext
class. If notnull
, broker will use it when creating contexts for requests & events. Default:null
Full options object
{ |