Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
43f6e17
bigtable: v2 support
callmehiphop Aug 8, 2016
377c39a
added support for grpc operations
callmehiphop Aug 17, 2016
adda9e0
added system tests for new apis
callmehiphop Aug 17, 2016
d77b73c
documented all the things!
callmehiphop Aug 17, 2016
50c7403
linted + streaming tests
callmehiphop Aug 17, 2016
7b9b764
updated docs for grpc operations
callmehiphop Aug 18, 2016
ed1f7cc
fixed broken unit tests
callmehiphop Aug 19, 2016
ef548c8
added Instance tests
callmehiphop Aug 19, 2016
13b0417
added Cluster tests
callmehiphop Aug 19, 2016
87de5e9
added GrpcOperation tests
callmehiphop Aug 19, 2016
c7e41b9
linting all the things
callmehiphop Aug 19, 2016
363d4d4
updated proto files
callmehiphop Aug 19, 2016
1b9e002
fixed documentation typos
callmehiphop Aug 21, 2016
0973ca9
updated several assertions
callmehiphop Aug 21, 2016
17e5362
created getLocation method for clusters
callmehiphop Aug 21, 2016
c5a58cc
adding tests for new/updated methods
callmehiphop Aug 21, 2016
3516c59
fix lint issue
callmehiphop Aug 21, 2016
fc47d5d
additional unit tests
callmehiphop Aug 22, 2016
502c2e8
small documentation changes
callmehiphop Aug 22, 2016
f34b47c
lint round 2
callmehiphop Aug 25, 2016
51c8d3e
update mutations to not re-encode buffers
callmehiphop Aug 25, 2016
4f63a08
add encode/decode options
callmehiphop Aug 25, 2016
878e1a2
fix linting errors
callmehiphop Aug 25, 2016
e0bbc4d
reverted jscs rules
callmehiphop Aug 25, 2016
fc1e9fb
bumping common version
callmehiphop Aug 29, 2016
a0e461a
removed encode option
callmehiphop Aug 29, 2016
718b7d2
refactored Table#mutate to only return failed statuses
callmehiphop Aug 29, 2016
952dcdc
mutate tweaks + doc updates
callmehiphop Aug 29, 2016
4125d3f
updated mutate to return an event emitter
callmehiphop Aug 29, 2016
9fcba7d
renamed entries param to mutationErrors
callmehiphop Aug 29, 2016
36458f4
updated emitter docs + changed finish event to complete
callmehiphop Aug 29, 2016
fc34f2f
updating system-tests
callmehiphop Aug 29, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions packages/bigtable/src/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
var arrify = require('arrify');
var common = require('@google-cloud/common');
var concat = require('concat-stream');
var events = require('events');
var flatten = require('lodash.flatten');
var is = require('is');
var propAssign = require('prop-assign');
Expand Down Expand Up @@ -685,8 +686,8 @@ Table.prototype.getRows = function(options, callback) {
* table.insert(entries, callback);
*
* //-
* // A stream mode is also provided, this is useful when making a large number
* // of inserts.
* // An event emitter mode is also provided, this is useful when making a large
* // number of inserts.
* //
* // The error event can be either an API error or an insert error.
* //-
Expand Down Expand Up @@ -807,8 +808,8 @@ Table.prototype.insert = function(entries, callback) {
* table.mutate(entries, callback);
*
* //-
* // A stream mode is also provided, this is useful when making a large number
* // of mutations.
* // An event emitter mode is also provided, this is useful when making a large
* // number of mutations.

This comment was marked as spam.

This comment was marked as spam.

* //
* // The error event can be either an API error or a mutation error.
* //-
Expand All @@ -832,7 +833,12 @@ Table.prototype.mutate = function(entries, callback) {
entries: entries.map(Mutation.parse)
};

var isStreamMode = !is.function(callback);
var isCallbackMode = is.function(callback);
var emitter = null;

if (!isCallbackMode) {
emitter = new events.EventEmitter();
}

var stream = pumpify.obj([
this.requestStream(grpcOpts, reqOpts),
Expand All @@ -849,8 +855,8 @@ Table.prototype.mutate = function(entries, callback) {
status.entry = entries[entry.index];


if (isStreamMode) {
stream.emit('error', status);
if (!isCallbackMode) {
emitter.emit('error', status);
return;
}

Expand All @@ -861,8 +867,11 @@ Table.prototype.mutate = function(entries, callback) {
})
]);

if (isStreamMode) {
return stream;
if (!isCallbackMode) {
['error', 'finish'].forEach(function(event) {

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

This comment was marked as spam.

stream.on(event, emitter.emit.bind(emitter, event));
});
return emitter;
}

stream
Expand Down
13 changes: 10 additions & 3 deletions packages/bigtable/test/table.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
'use strict';

var assert = require('assert');
var events = require('events');
var nodeutil = require('util');
var proxyquire = require('proxyquire');
var pumpify = require('pumpify');
Expand Down Expand Up @@ -924,8 +925,11 @@ describe('Bigtable/Table', function() {

it('should emit a mutation error as an error event', function(done) {
var mutationErrors = [];
var emitter = table.mutate(entries)

table.mutate(entries)
assert(emitter instanceof events.EventEmitter);

emitter
.on('error', function(err) {
mutationErrors.push(err);
})
Expand Down Expand Up @@ -980,9 +984,12 @@ describe('Bigtable/Table', function() {
});

it('should emit the appropriate stream events', function(done) {
table.mutate(entries)
var emitter = table.mutate(entries);

assert(emitter instanceof events.EventEmitter);

emitter
.on('error', done) // should not be emitted
.on('data', done) // should not be emitted
.on('finish', function() {
done();
});
Expand Down