Socket
Socket
Sign inDemoInstall

@aqm/queuelogger

Package Overview
Dependencies
16
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @aqm/queuelogger

CFWare AQM queue_log mysql writer


Version published
Weekly downloads
5
increased by25%
Maintainers
1
Install size
1.07 MB
Created
Weekly downloads
 

Changelog

Source

2.0.0 (2019-06-15)

Features

  • Require node.js 12 (6bc8ffc)

BREAKING CHANGES

  • The mysql pool is no longer exposed.
  • The implementation is now an ES module.
  • Named export QueueLogger is provided instead of default export.

Readme

Source

@aqm/queuelogger

Travis CI Greenkeeper badge NPM Version NPM Downloads MIT

CFWare AQM queue_log mysql writer

Install @aqm/queuelogger

This module requires node.js 12 or above.

npm i --save @aqm/queuelogger

Usage

import {QueueLogger} from '@aqm/queuelogger';

class QueueManager {
	constructor() {
		this.logger = new QueueLogger({
			/* Default is 'P001', used as value of partition column. */
			partition: 'P001',
			/* Default is least significant part of hostname, used as value of serverid column. */
			serverID: 'serverid',
			/* Default: 'queue_log', the table we insert to. */
			tableName: 'queue_log',
			/* Override default settings used by require('mysql').createPool.
			 * The default database is queuemetrics.
			 */
			mysql: {},
		});

		process.on('SIGTERM', () => this.logger.end().catch(() => {}));
	}

	async writeQueueLog(timeID, callID, queue, agent, verb, data1, data2, data3, data4, data5) {
		/* This is a pointless example.  In real life a queue manager would retrieve some
		 * data from a channel or other object. */
		try {
			await this.logger.writeEntry(timeID, callID, queue, agent, verb, data1, data2, data3, data4, data5);
		} catch (err) {
			/* mysql write failed, record to a file. */
		}
	}
}

Running tests

Tests are provided by eslint and mocha. Tests require access to a test mysql or mariadb daemon. The test database server must have a queuemetrics database and a queuelogd user as defined by sampledb/qm.sql.

Default test configuration:

npm config set @aqm/queuelogger:dbhost 'localhost'
npm config set @aqm/queuelogger:dbprivuser 'root'
npm config set @aqm/queuelogger:dbprivpassword ''

These settings can be changed to use a different server or to use an account less privileged than root. The priv account must have SELECT and DELETE access to the queuemetrics.queue_log table.

Once the database is created and a privileged account configured the tests can be run:

npm install
npm test

Keywords

FAQs

Last updated on 15 Jun 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc