-
Notifications
You must be signed in to change notification settings - Fork 598
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
061bf39
commit 3ba6411
Showing
20 changed files
with
1,579 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<h3>Search Overview</h3> | ||
<p> | ||
The object returned from <code>gcloud.search</code> gives you complete access to store and search your indexes and documents. | ||
</p> | ||
<p> | ||
To learn more about Search, see <a href="https://cloud.google.com/search">What is Google Cloud Search?</a> | ||
</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/*! | ||
* Copyright 2015 Google Inc. All Rights Reserved. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
/*! | ||
* @module common/StreamRouter | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var streamEvents = require('stream-events'); | ||
var through = require('through2'); | ||
|
||
/** | ||
* @type {module:common/util} | ||
* @private | ||
*/ | ||
var util = require('../common/util.js'); | ||
|
||
var StreamRouter = {}; | ||
|
||
StreamRouter.extend = function(Class, methodNames) { | ||
methodNames = util.arrayize(methodNames); | ||
|
||
methodNames.forEach(function(methodName) { | ||
var originalMethod = Class.prototype[methodName]; | ||
|
||
Class.prototype[methodName] = function() { | ||
return StreamRouter.router_(arguments, originalMethod.bind(this)); | ||
}; | ||
}); | ||
}; | ||
|
||
StreamRouter.router_ = function(args, originalMethod) { | ||
args = util.toArray(args); | ||
var callback = args[args.length - 1]; | ||
var isStreamMode = !util.is(callback, 'function'); | ||
|
||
if (isStreamMode) { | ||
var stream = streamEvents(through.obj()); | ||
|
||
var onResultSet = function(err, results, nextQuery) { | ||
if (err) { | ||
stream.emit('error', err); | ||
stream.end(); | ||
return; | ||
} | ||
|
||
results.forEach(function(result) { | ||
stream.push(result); | ||
}); | ||
|
||
if (nextQuery) { | ||
originalMethod(nextQuery, onResultSet); | ||
} else { | ||
stream.end(); | ||
} | ||
}; | ||
|
||
stream.once('reading', function() { | ||
originalMethod.apply(null, args.concat(onResultSet)); | ||
}); | ||
|
||
return stream; | ||
} else { | ||
originalMethod.apply(null, args); | ||
} | ||
}; | ||
|
||
module.exports = StreamRouter; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.