Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Move microtime to optionalDependencies.

This way if you have trouble installing/building microtime on Windows, you
can still use helenus (albeit without microsecond precision timestamps).
  • Loading branch information...
commit 21230b7477d60c9da6d18b9fb7c9c52070a465e4 1 parent a4f2942
@muirmanders muirmanders authored
View
4 lib/column.js
@@ -1,6 +1,6 @@
var util = require('util'),
ttypes = require('./cassandra/cassandra_types'),
- microtime = require('microtime');
+ time = require('./time');
/**
* Cassandra Column object representation
@@ -26,7 +26,7 @@ var Column = function(name, value, timestamp, ttl){
* The timestamp in microseconds of the value
* @default {Number} current time in microseconds
*/
- this.timestamp_micro = microtime.now();
+ this.timestamp_micro = time.microtime();
} else if (this.timestamp instanceof Date) {
this.timestamp_micro = timestamp.getTime() * 1000;
} else {
View
4 lib/column_family.js
@@ -4,7 +4,7 @@ var util = require('util'),
CounterColumn = require('./counter_column'),
Row = require('./row'),
ttype = require('./cassandra/cassandra_types'),
- microtime = require('microtime');
+ time = require('./time');
/**
* NO-Operation for deault callbacks
@@ -288,7 +288,7 @@ ColumnFamily.prototype.remove = function() {
var timestamp;
if (args.options.timestamp == null) {
- timestamp = microtime.now();
+ timestamp = time.microtime();
} else if (args.options.timestamp instanceof Date) {
timestamp = args.options.timestamp.getTime() * 1000;
} else {
View
12 lib/time.js
@@ -0,0 +1,12 @@
+var time = {};
+
+try {
+ var microtime = require('microtime');
+ time.microtime = microtime.now;
+} catch (e) {
+ time.microtime = function() {
+ return Date.now() * 1000;
+ };
+}
+
+module.exports = time;
View
4 package.json
@@ -15,7 +15,9 @@
, "dependencies": {
"helenus-thrift": "0.7.3"
, "node-uuid": "1.3.3"
- , "microtime": "0.4.0"
+ }
+ , "optionalDependencies": {
+ "microtime": "0.4.0"
}
, "devDependencies": {
"whiskey": "git://github.com/cloudkick/whiskey.git#b3c5bc23e30c95e46083bc7628c2557c1c15ec95"
View
16 test/thrift.js
@@ -4,6 +4,12 @@ var config = require('./helpers/thrift'),
Helenus, conn, ks, cf_standard, row_standard, cf_composite, cf_counter,
cf_reversed, cf_composite_nested_reversed;
+var has_microtime = false;
+try {
+ require('microtime');
+ has_microtime = true;
+} catch(e) { }
+
module.exports = {
'setUp':function(test, assert){
Helenus = require('helenus');
@@ -207,6 +213,11 @@ module.exports = {
},
'test cf.insert default microsecond timestamp':function(test, assert){
+ if (!has_microtime) {
+ test.finish();
+ return;
+ }
+
//try to tease out same-ms collision with 50 attempts
var finished = 0, ok = true;
var callback = function() {
@@ -700,6 +711,11 @@ module.exports = {
},
'test standard cf remove default microsecond timestamp':function(test, assert) {
+ if (!has_microtime) {
+ test.finish();
+ return;
+ }
+
//try to tease out same-ms collision with 50 attempts
var finished = 0, ok = true;
var callback = function() {
Please sign in to comment.
Something went wrong with that request. Please try again.