Skip to content

Commit

Permalink
fix(db): fix connection limitation
Browse files Browse the repository at this point in the history
  • Loading branch information
DEgITx committed Jun 30, 2018
1 parent 6d8c04e commit 4a0b04d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/background/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let config = {
sphinx: {
host : '127.0.0.1',
port : 9306,
connectionLimit: 30
connectionLimit: 12
},

spider: {
Expand Down
13 changes: 13 additions & 0 deletions tests/sphinx.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { expect } from "chai";

const mysql = require('mysql')
const config = require('../src/background/config')
const {pool} = require('../src/background/mysql')

describe("sphinx", () => {
let sphinx;
Expand Down Expand Up @@ -58,4 +59,16 @@ describe("sphinx", () => {
done()
})
})

it("query limit", function(done) {
const sphinx = pool()
let promises = []
sphinx.query(`delete from feed where id >= 0`, () => {
for(let i = 0; i < 500; i++)
promises.push(sphinx.query(`insert into feed(id, data) values(${i}, 'a')`))
Promise.all(promises).then(() => {
sphinx.query(`delete from feed where id >= 0`, () => done())
})
})
})
});

0 comments on commit 4a0b04d

Please sign in to comment.