# @cfware/queue_log-mysql

> CFWare queue_log mysql writer

Latest version **0.2.0** (published 2017-12-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @cfware/queue_log-mysql
pnpm add @cfware/queue_log-mysql
yarn add @cfware/queue_log-mysql
bun add @cfware/queue_log-mysql
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.0 |
| Published | 2017-12-02 |
| First published | 2017-11-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Corey Farrell |
| Maintainers | coreyfarrell |
| Keywords | asterisk, queue_log, queuemetrics, mysql |

## Links

- npm: https://www.npmjs.com/package/@cfware/queue_log-mysql
- Repository: https://github.com/cfware/queue_log-mysql
- Homepage: https://github.com/cfware/queue_log-mysql#readme
- Issues: https://github.com/cfware/queue_log-mysql/issues
- npm.io page: https://npm.io/package/@cfware/queue_log-mysql

## Dependencies (3)

- [mysql](https://npm.io/package/mysql.md) ^2.15.0
- [p-event](https://npm.io/package/p-event.md) ^1.3.0
- [@cfware/p-mutex](https://npm.io/package/@cfware/p-mutex.md) ^0.1.0

## Alternatives

- [cron](https://npm.io/package/cron.md) — 4.9M weekly downloads
- [@vercel/queue](https://npm.io/package/@vercel/queue.md) — 731.6K weekly downloads
- [create-sonicjs](https://npm.io/package/create-sonicjs.md) — 1.6K weekly downloads
- [@exellix/jobs-api](https://npm.io/package/@exellix/jobs-api.md) — 941 weekly downloads
- [@forwardimpact/libskill](https://npm.io/package/@forwardimpact/libskill.md) — 575 weekly downloads

## Recent versions

- 0.2.0 (latest) — 2017-12-02
- 0.1.0 — 2017-11-26

## README

# @cfware/queue_log-mysql

[![Travis CI][travis-image]][travis-url]
[![Coverage Status][coverage-image]][coverage-url]
[![Greenkeeper badge](https://badges.greenkeeper.io/cfware/queue_log-mysql.svg)](https://greenkeeper.io/)
[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![MIT][license-image]](LICENSE)

CFWare queue_log mysql writer

### Install @cfware/queue_log-mysql

This module requires node.js 8 or above.

```sh
npm i --save @cfware/queue_log-mysql
```

## Usage

```js
const queue_log = require('@cfware/queue_log-mysql');

class QueueManager {
	constructor() {
		this.queue_log = new queue_log({
			/* 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. */
			table_name: 'queue_log',
			/* Override default settings used by require('mysql').createPool.
			 * The default database is queuemetrics.
			 */
			mysql: {},
		});

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

	async writeQueueLog(time_id, call_id, 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.queue_log.writeEntry(time_id, call_id, 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:
```sh
npm config set @cfware/queue_log-mysql:dbhost 'localhost'
npm config set @cfware/queue_log-mysql:dbprivuser 'root'
npm config set @cfware/queue_log-mysql: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:
```sh
npm install
npm test
```

[npm-image]: https://img.shields.io/npm/v/@cfware/queue_log-mysql.svg
[npm-url]: https://npmjs.org/package/@cfware/queue_log-mysql
[travis-image]: https://travis-ci.org/cfware/queue_log-mysql.svg?branch=master
[travis-url]: https://travis-ci.org/cfware/queue_log-mysql
[coverage-image]: https://coveralls.io/repos/github/cfware/queue_log-mysql/badge.svg
[coverage-url]: https://coveralls.io/github/cfware/queue_log-mysql
[downloads-image]: https://img.shields.io/npm/dm/@cfware/queue_log-mysql.svg
[downloads-url]: https://npmjs.org/package/@cfware/queue_log-mysql
[license-image]: https://img.shields.io/github/license/cfware/queue_log-mysql.svg

---
_Source: https://npm.io/package/@cfware/queue_log-mysql · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
