Permalink
Browse files

Merge pull request #541 from prabhakhar/master

Timeout support for update.
  • Loading branch information...
2 parents 76f55fe + 1e04403 commit 69d50dfbcdb93752d0bf2ab6e8406a561369a0b8 @prabhakhar prabhakhar committed Aug 13, 2012
View
5 CHANGES.md
@@ -1,3 +1,8 @@
+## August 09, 2012
+
+* Node 0.8.x and other dependecy upgrades.
+* Timeout support for update.
+
## JULY 23, 2012
* Upgrade code-mirror to 2.32 to avoid space issue
View
6 modules/app/package.json
@@ -1,7 +1,7 @@
{
"author": "ql.io",
"name": "ql.io-app",
- "version": "0.8.0",
+ "version": "0.8.1",
"repository": {
"type": "git",
"url": "https://github.com/ql-io/ql.io"
@@ -15,8 +15,8 @@
},
"dependencies": {
"commander": "1.0.0",
- "ql.io-console": "0.8.0",
- "ql.io-compiler": "0.8.0",
+ "ql.io-console": "0.8.1",
+ "ql.io-compiler": "0.8.1",
"winston": "0.6.2",
"express": "2.5.11",
"underscore": "1.3.3",
View
8 modules/compiler/lib/compiler.js
@@ -14,12 +14,12 @@
* limitations under the License.
*/
+'use strict';
+
var ql = require('./peg/ql.js'),
assert = require('assert'),
- strParser = require('ql.io-str-template')
- _ = require('underscore')
-
-'use strict'
+ strParser = require('ql.io-str-template'),
+ _ = require('underscore');
exports.version = require('../package.json').version;
View
61 modules/compiler/lib/peg/ql.js
@@ -3410,7 +3410,7 @@ module.exports = (function(){
}
function parse_UpdateStatement() {
- var result0, result1, result2, result3, result4, result5, result6;
+ var result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12;
var pos0, pos1;
pos0 = clone(pos);
@@ -3445,7 +3445,46 @@ module.exports = (function(){
if (result5 !== null) {
result6 = parse_QuotedWord();
if (result6 !== null) {
- result0 = [result0, result1, result2, result3, result4, result5, result6];
+ result7 = parse_insig();
+ if (result7 !== null) {
+ result8 = parse_Timeout();
+ result8 = result8 !== null ? result8 : "";
+ if (result8 !== null) {
+ result9 = parse_insig();
+ if (result9 !== null) {
+ result10 = parse_MinDelay();
+ result10 = result10 !== null ? result10 : "";
+ if (result10 !== null) {
+ result11 = parse_insig();
+ if (result11 !== null) {
+ result12 = parse_MaxDelay();
+ result12 = result12 !== null ? result12 : "";
+ if (result12 !== null) {
+ result0 = [result0, result1, result2, result3, result4, result5, result6, result7, result8, result9, result10, result11, result12];
+ } else {
+ result0 = null;
+ pos = clone(pos1);
+ }
+ } else {
+ result0 = null;
+ pos = clone(pos1);
+ }
+ } else {
+ result0 = null;
+ pos = clone(pos1);
+ }
+ } else {
+ result0 = null;
+ pos = clone(pos1);
+ }
+ } else {
+ result0 = null;
+ pos = clone(pos1);
+ }
+ } else {
+ result0 = null;
+ pos = clone(pos1);
+ }
} else {
result0 = null;
pos = clone(pos1);
@@ -3475,14 +3514,26 @@ module.exports = (function(){
pos = clone(pos1);
}
if (result0 !== null) {
- result0 = (function(offset, line, column, s, w) {
- return {
+ result0 = (function(offset, line, column, s, w, timeout, minDelay, maxDelay) {
+
+ var u = {
type: 'update',
source : s,
withClause: w,
line: line
+ };
+
+ if(timeout) {
+ u.timeout = timeout;
+ }
+ if(minDelay) {
+ u.minDelay = minDelay;
}
- })(pos0.offset, pos0.line, pos0.column, result0[2], result0[6]);
+ if(maxDelay) {
+ u.maxDelay = maxDelay;
+ }
+ return u;
+ })(pos0.offset, pos0.line, pos0.column, result0[2], result0[6], result0[8], result0[10], result0[12]);
}
if (result0 === null) {
pos = clone(pos0);
View
2 modules/compiler/package.json
@@ -1,7 +1,7 @@
{
"author": "ql.io",
"name": "ql.io-compiler",
- "version": "0.8.0",
+ "version": "0.8.1",
"repository": {
"type": "git",
"url": "https://github.com/ql-io/ql.io"
View
17 modules/compiler/pegs/ql.peg
@@ -800,13 +800,26 @@ DeleteStatement = 'delete' insig 'from' insig s:Source insig wc:WhereClause* ins
return s;
}
-UpdateStatement = 'update' insig s:Source insig 'with' insig w:QuotedWord {
- return {
+UpdateStatement = 'update' insig s:Source insig 'with' insig w:QuotedWord insig
+ timeout:Timeout? insig minDelay:MinDelay? insig maxDelay:MaxDelay? {
+
+ var u = {
type: 'update',
source : s,
withClause: w,
line: line
+ };
+
+ if(timeout) {
+ u.timeout = timeout;
}
+ if(minDelay) {
+ u.minDelay = minDelay;
+ }
+ if(maxDelay) {
+ u.maxDelay = maxDelay;
+ }
+ return u;
}
// Various clauses
View
15 modules/compiler/test/update-test.js
@@ -35,5 +35,18 @@ module.exports = {
test.ok(statement.rhs.dependsOn.length === 1);
test.ok(statement.rhs.dependsOn[0].type === "select");
test.done();
+ },
+
+ 'update-timeout': function (test) {
+ var q = 'a = select * from tab; update tab with "{a}" timeout 100 minDelay 50 maxDelay 5000';
+ var statement = compiler.compile(q);
+ test.ok(statement.rhs.type === 'update');
+ test.ok(statement.rhs.dependsOn.length === 1);
+ test.ok(statement.rhs.dependsOn[0].type === "select");
+ test.ok(statement.rhs.timeout === 100);
+ test.ok(statement.rhs.minDelay === 50);
+ test.ok(statement.rhs.maxDelay === 5000);
+ test.done();
}
-};
+
+};
View
6 modules/console/package.json
@@ -1,7 +1,7 @@
{
"author": "ql.io",
"name": "ql.io-console",
- "version": "0.8.0",
+ "version": "0.8.1",
"repository": {
"type": "git",
"url": "https://github.com/ql-io/ql.io"
@@ -15,9 +15,9 @@
"express": "2.5.11",
"ejs": "0.8.0",
"underscore": "1.3.3",
- "ql.io-engine": "0.8.0",
+ "ql.io-engine": "0.8.1",
"ql.io-mutable-uri": "0.8.0",
- "ql.io-compiler": "0.8.0",
+ "ql.io-compiler": "0.8.1",
"winston": "0.6.2",
"browserify": "1.14.2",
"uglify-js": "1.3.3",
View
4 modules/engine/package.json
@@ -1,7 +1,7 @@
{
"author": "ql.io",
"name": "ql.io-engine",
- "version": "0.8.0",
+ "version": "0.8.1",
"repository": {
"type": "git",
"url": "https://github.com/ql-io/ql.io"
@@ -14,7 +14,7 @@
"winston": "0.6.2",
"underscore": "1.3.3",
"xml2json": "https://github.com/ql-io/node-xml2json/tarball/master",
- "ql.io-compiler": "0.8.0",
+ "ql.io-compiler": "0.8.1",
"ql.io-mutable-uri": "0.8.0",
"ql.io-uri-template": "0.8.0",
"ql.io-str-template": "0.8.0",
View
35 modules/engine/test/timeout-test.js
@@ -280,5 +280,40 @@ module.exports = {
}, 550);
})
});
+ },
+ 'update-timeout-test': function (test) {
+ var server = http.createServer(function (req, res) {
+ setTimeout(function () {
+ res.writeHead(200, {
+ 'Content-Type': 'application/json'
+ });
+ res.end(JSON.stringify({
+ 'message': 'ok'
+ }));
+ }, 30); // No 'retry' on timeout for update
+ });
+
+ server.listen(3000, function () {
+ // Do the test here.
+ var engine = new Engine({
+ tables: __dirname + '/update'
+ });
+ var script = 'upd = {"id":1, "team":[{"name":"Joe"},{"name":"Mike"},{"name":"Haker"}]}; update test.update with "{upd}" timeout 10 minDelay 50 maxDelay 5000';
+ engine.execute(
+ script,
+ function (emitter) {
+ emitter.on('end', function (err, results) {
+ if(err) {
+ // Timeout as expected
+ test.ok(true);
+ }
+ else {
+ test.ok(false, "Did not fail");
+ }
+ server.close();
+ test.done();
+ });
+ });
+ });
}
};

0 comments on commit 69d50df

Please sign in to comment.