Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

little more pointless refactoring...

  • Loading branch information...
commit 5ff04f712454f64c50584d12d0623030e7acbb8e 1 parent ceb2f5c
@Jae Jae authored
Showing with 22 additions and 25 deletions.
  1. +22 −25 node-hive.js
View
47 node-hive.js
@@ -11,46 +11,43 @@ var hiveClient = function(config) {
var connection = thrift.createConnection(server, port, options);
var client = thrift.createClient(ThriftHive, connection);
+
+ var propagate = function(func, arguments) {
+ var args = [];
+ for (var i=2; i < arguments.length; i++) {
+ args.push(arguments[i]);
+ };
+ func.apply(null, args);
+ }
+
+ var continueOnSuccess = function(err, onSuccess) {
+ if (err) {
+ connection.end();
+ onError(true, err);
+ } else {
+ propagate(onSuccess, arguments)
+ }
+ };
connected({
execute: function(query, onSuccess) {
client.execute(query, function(err) {
- if (err) {
- connection.end();
- onError(true, err);
- } else {
- onSuccess();
- }
+ continueOnSuccess(err, onSuccess);
});
},
getSchema: function(onSuccess) {
client.getSchema(function(err, schema) {
- if (err) {
- connection.end();
- onError(true, err);
- } else {
- onSuccess(schema);
- }
+ continueOnSuccess(err, onSuccess, schema);
});
},
fetchAll: function(onSuccess) {
client.fetchAll(function(err, data) {
- if (err) {
- connection.end();
- onError(true, err);
- } else {
- onSuccess(data);
- }
+ continueOnSuccess(err, onSuccess, data);
});
},
fetchN: function(batchSize, onSuccess) {
client.fetchN(batchSize, function(err, data) {
- if (err) {
- connection.end();
- onError(true, err);
- } else {
- onSuccess(data);
- }
+ continueOnSuccess(err, onSuccess, data);
});
},
closeConnection: function() {
@@ -106,4 +103,4 @@ var hiveClient = function(config) {
exports.for = function(config) {
return hiveClient(config);
-};
+};
Please sign in to comment.
Something went wrong with that request. Please try again.