Moleculer v0.14.9 Release Notes

Release Date: 2020-08-06 // over 3 years ago
  • Register method in module resolver

    If you create a custom module (e.g. serializer), you can register it into the built-in modules with the register method. This method is also available in all other built-in module resolvers.

    Example

    // SafeJsonSerializer.js
    const { Serializers } = require("moleculer");
    
    class SafeJsonSerializer {}
    
    Serializers.register("SafeJSON", SafeJSON);
    
    module.exports = SafeJsonSerializer;
    
    // moleculer.config.js
    require("./SafeJsonSerializer");
    
    module.exports = {
        nodeID: "node-100",
        serializer: "SafeJSON"
        // ...
    });
    

    ๐Ÿ”„ Changeable validation property name

    You can change the params property name in validator options. It can be useful if you have a custom Validator implementation.

    const broker = new ServiceBroker({
        validator: {
            type: "Fastest",
            options: {
                paramName: "myParams" // using `myParams` instead of `params`
            }
        }
    });
    
    broker.createService({
        name: "posts",
        actions: {
            create: {
                myParams: {
                    title: "string"
                }
            },
            handler(ctx) { /* ... */ }
        }
    });
    

    Global tracing span tags for actions & events

    ๐Ÿ”ง Thanks for @kthompson23, you can configure the action & events tracing span tags globally. These tags will be used for all actions & events where tracing is enabled. Of course, you can overwrite them locally in the action & event schema.

    Example

    // moleculer.config.js
    module.exports = {
        tracing: {
            enabled: true,
            exporter: 'Zipkin',
            tags: {
                action: {
                    meta: ['app.id', 'user.email', 'workspace.name'],
                    params: false,  // overrides default behavior of all params being adding as tags
                    response: true,
                },
                event: (ctx) {
                    return {
                        caller: ctx.caller,
                    }
                }  
            }
        }
    }
    

    Other changes

    • ๐Ÿ›  fix multiple trace spans with same ID issue in case of retries.
    • โšก๏ธ update dependencies
    • โž• add lastValue property to histogram metric type.
    • โšก๏ธ update return type of context's copy method.
    • โž• add configuration hotReloadModules #779
    • โœ‚ Remove Zipkin v1 annotations and change kind to SERVER