Added multiple connection support, separated read and write transactions

pull/1/head
Rob Hedgpeth 2020-01-02 12:46:10 -06:00
rodzic deffe91eaa
commit 65f8b95662
3 zmienionych plików z 45 dodań i 17 usunięć

Wyświetl plik

@ -109,9 +109,9 @@ export default class Dashboard extends Component {
<div className="form-main">
<div className={this.state.showConnectionOptions ? '' : 'hidden'}>
<select onChange={this.onChangeConnectionOption}>
<option value="0">Localhost</option>
<option value="1">Standalone - 4x15</option>
<option value="2">Single Node - 16x60 (2)</option>
<option value="0">Connection 1</option>
<option value="1">Connection 2</option>
<option value="2">Connection 3</option>
</select>
</div>
<div className="form-content">

Wyświetl plik

@ -1,23 +1,48 @@
const fs = require("fs");
var mariadb = require('mariadb');
// Place a .pem file within the project root to use this line
//const serverCert = [fs.readFileSync("skysql_chain.pem", "utf8")];
var pools = [
mariadb.createPool({
host: 'localhost',
user:'root',
password: 'password',
host: '<host_address>',
user:'<user>',
password: '<password>',
database: 'orders',
port: 3309,
port: 5001,
multipleStatements: true,
connectionLimit: 5
connectionLimit: 5,
ssl: {
//ca: serverCert
rejectUnauthorized: false
}
}),
mariadb.createPool({
host: 'localhost',
user:'root',
password: 'password',
host: '<host_address>',
user:'<user>',
password: '<password>',
database: 'orders',
port: 3310,
port: 5002,
multipleStatements: true,
connectionLimit: 5
connectionLimit: 5,
ssl: {
//ca: serverCert
rejectUnauthorized: false
}
}),
mariadb.createPool({
host: '<host_address>',
user:'<user>',
password: '<password>',
database: 'orders',
port: 5003,
multipleStatements: true,
connectionLimit: 5,
ssl: {
//ca: serverCert
rejectUnauthorized: false
}
})
];

Wyświetl plik

@ -12,21 +12,24 @@ router.get("/", async (req, res, next) => {
let conn;
try {
conn = await pool.getConnection(connection_id);
let query= "";
let reads = "";
let writes = "";
// reads
for (let i = 0; i < read_count; i++) {
query += "select * from orders limit 1;";
reads += "select * from orders limit 1;";
}
// writes
let transaction_id = Date.now().toString();
for (let i = 0; i < write_count; i++) {
query += "insert into orders (description) values('order - " + transaction_id + "');";
writes += "insert into orders (description) values('order - " + transaction_id + "');";
}
var start = Date.now();
await conn.query(query);
await conn.query(reads);
await conn.query(writes);
var delta = Date.now() - start;
res.send({ execution_time: delta });