How to use the nats.publish function in nats

To help you get started, we’ve selected a few nats examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JarvusInnovations / lapidus / src / plugins / nats.js View on Github external
eventEmitter.on('event', function(event) {
            var subject,
                action,
                cachePrefix = config.cachePrefix;

            if (event.schema && event.table) {
                subject = event.schema + '.' + event.table + (event.pk ? ('.' + event.pk) : '');
            } else if (event.ns && event.pk) {
                subject = event.ns + '.' + event.pk;
            }

            nats.publish(subject, config.publishEventData ? JSON.stringify(event) : null);

            if (cachePrefix) {
                action = event.type === 'update' ? 'invalidate.' : event.action === 'delete' ? 'purge.' : 'populate.';
                nats.publish(cachePrefix + action + subject);
            }
        });
    },
github JarvusInnovations / lapidus / src / plugins / nats.js View on Github external
eventEmitter.on('event', function(event) {
            var subject,
                action,
                cachePrefix = config.cachePrefix;

            if (event.schema && event.table) {
                subject = event.schema + '.' + event.table + (event.pk ? ('.' + event.pk) : '');
            } else if (event.ns && event.pk) {
                subject = event.ns + '.' + event.pk;
            }

            nats.publish(subject, config.publishEventData ? JSON.stringify(event) : null);

            if (cachePrefix) {
                action = event.type === 'update' ? 'invalidate.' : event.action === 'delete' ? 'purge.' : 'populate.';
                nats.publish(cachePrefix + action + subject);
            }
        });
    },

nats

Node.js client for NATS, a lightweight, high-performance cloud native messaging system

Apache-2.0
Latest version published 4 months ago

Package Health Score

86 / 100
Full package analysis