Skip to content

Commit

Permalink
Rename: adq.js -> abq.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Bacra committed Jul 25, 2015
1 parent 887d14e commit e0b6678
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 31 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
node-adq [![Build Status](https://travis-ci.org/Bacra/node-adq.svg?branch=master)](https://travis-ci.org/Bacra/node-adq)
node-abq [![Build Status](https://travis-ci.org/Bacra/node-abq.svg?branch=master)](https://travis-ci.org/Bacra/node-abq)
==================

A(ppend) D(ata) (in) Q(uery)
A(ppend) B(uffer) (in) Q(uery)

Append data to a file in query.

## Install

```
npm i adq --save
npm i abq --save
```

## Usage

```javascript
var adq = require('adq')({file:'/var/log/w.log'});
adq('msg1');
adq('msg2');
var abq = require('abq')({file:'/var/log/w.log'});
abq('msg1');
abq(new Buffer('msg2'));
```
30 changes: 15 additions & 15 deletions adq.js → abq.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var path = require('path');
var events = require('events');
var extend = require('extend');
var mkdirp = require('mkdirp');
var debug = require('debug')('adq');
var debug = require('debug')('abq');

var concat = Array.prototype.concat;

Expand Down Expand Up @@ -134,8 +134,8 @@ extend(QPD.prototype, {
this._writing = false;

if (isWriteLog) {
this.writeQuery.unshift(new Buffer('\n\n↓↓↓↓↓↓↓↓↓↓ [adq] process exit write, maybe repeat!!!~ ↓↓↓↓↓↓↓↓↓↓\n\n'));
this.writeQuery.push(new Buffer('\n\n↑↑↑↑↑↑↑↑↑↑ [adq] process exit write, maybe repeat!!!~ ↑↑↑↑↑↑↑↑↑↑\n\n'));
this.writeQuery.unshift(new Buffer('\n\n↓↓↓↓↓↓↓↓↓↓ [abq] process exit write, maybe repeat!!!~ ↓↓↓↓↓↓↓↓↓↓\n\n'));
this.writeQuery.push(new Buffer('\n\n↑↑↑↑↑↑↑↑↑↑ [abq] process exit write, maybe repeat!!!~ ↑↑↑↑↑↑↑↑↑↑\n\n'));
}
}

Expand Down Expand Up @@ -238,21 +238,21 @@ GenFd.prototype = {



var adqs = [];
var abqs = [];
function main(opts) {
var adq = new QPD(opts);
var handler = adq.handler.bind(adq);
handler.adq = adq;
adqs.push(adq);
var abq = new QPD(opts);
var handler = abq.handler.bind(abq);
handler.abq = abq;
abqs.push(abq);

// 销毁的时候从队列中移除
adq.once('destroy', function() {
var index = adqs.indexOf(adq);
abq.once('destroy', function() {
var index = abqs.indexOf(abq);
if (index != -1) {
adqs.splice(adqs.indexOf(adq), 1);
debug('remove adqs %d', index);
abqs.splice(abqs.indexOf(abq), 1);
debug('remove abqs %d', index);
} else {
debug('remove adqs err:-1');
debug('remove abqs err:-1');
}
});

Expand All @@ -264,8 +264,8 @@ function bindProcess() {
bindProcess._inited = true;

process.on('exit', function() {
adqs.forEach(function(adq) {
adq.destroy();
abqs.forEach(function(abq) {
abq.destroy();
});
});
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "adq",
"version": "0.1.3",
"name": "abq",
"version": "0.1.4",
"description": "Append data to a file in query.",
"main": "adq.js",
"main": "abq.js",
"repository": {
"type": "git",
"url": "git@github.com:Bacra/node-adq.git"
"url": "git@github.com:Bacra/node-abq.git"
},
"scripts": {
"test": "node test/index"
Expand All @@ -19,9 +19,9 @@
"author": "Bacra Woo",
"license": "MIT",
"bugs": {
"url": "https://github.com/Bacra/node-adq/issues"
"url": "https://github.com/Bacra/node-abq/issues"
},
"homepage": "https://github.com/Bacra/node-adq",
"homepage": "https://github.com/Bacra/node-abq",
"dependencies": {
"debug": "^2.2.0",
"extend": "^3.0.0",
Expand Down
2 changes: 1 addition & 1 deletion test/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require('debug').enable('adq');
require('debug').enable('abq');

var fork = require('child_process').fork;

Expand Down
4 changes: 2 additions & 2 deletions test/mulit_process.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,10 @@ function fork() {
}
}

log.adq.on('flushEnd', function() {
log.abq.on('flushEnd', function() {
setTimeout(doLog, 2);

if (!log.adq.waitQuery.length && logindex <= 0) {
if (!log.abq.waitQuery.length && logindex <= 0) {
process.send('end');
}
});
Expand Down
2 changes: 1 addition & 1 deletion test/process_exit.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ var logfile = __dirname+'/tmp2.log';
var log = require('../')({file: logfile, flag: 'w+'});

log('some msg');
log.adq.on('open', function() {
log.abq.on('open', function() {
process.exit();
});

0 comments on commit e0b6678

Please sign in to comment.