Skip to content

Commit

Permalink
Implement "dataset" option to Connection#emitMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Oct 11, 2013
1 parent ad9db08 commit 36765e2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion application.js
Expand Up @@ -8,7 +8,7 @@ var application = express();
var server = http.createServer(application);
application.droonga({
prefix: '',
dataset: 'example',
defaultDataset: 'example',
server: server
});

Expand Down
6 changes: 3 additions & 3 deletions lib/droonga-protocol/connection.js
@@ -1,6 +1,6 @@
/**
* var connection = new Connection({ tag: 'droonga',
* dataset: 'example',
* defaultDataset: 'example',
* hostName: 'localhost',
* port: 24224,
* receiveHostName: 'localhost',
Expand Down Expand Up @@ -46,7 +46,7 @@ Connection.prototype._init = function() {
this._callbacks = {};
this._id = Date.now();
this.tag = this._params.tag || DEFAULT_FLUENT_TAG;
this.dataset = this._params.dataset || '';
this.defaultDataset = this._params.defaultDataset || '';
this._initSender();
this._initReceiver();
};
Expand Down Expand Up @@ -132,7 +132,7 @@ Connection.prototype.emitMessage = function(type, body, callback, options) {
date: getCurrentTime(),
replyTo: replyTo,
statusCode: 200,
dataset: this.dataset,
dataset: options.dataset || this.defaultDataset,
type: type,
body: body
};
Expand Down
2 changes: 1 addition & 1 deletion test/droonga-protocol/connection.test.js
Expand Up @@ -64,7 +64,7 @@ suite('Connection', function() {
backend = newBackend;
connection = new Connection({
tag: 'test',
dataset: 'test-dataset',
defaultDataset: 'test-dataset',
hostName: 'localhost',
port: utils.testSendPort,
receivePort: utils.testReceivePort,
Expand Down
7 changes: 4 additions & 3 deletions test/test-utils.js
Expand Up @@ -194,7 +194,7 @@ function setupApplication() {
backend = newBackend;
var connection = new Connection({
tag: testTag,
dataset: 'test-dataset',
defaultDataset: 'test-dataset',
hostName: 'localhost',
port: testSendPort,
receivePort: testReceivePort,
Expand Down Expand Up @@ -297,14 +297,15 @@ exports.createBackend = createBackend;
Deferred.register('createBackend', createBackend);


function createEnvelope(type, body) {
function createEnvelope(type, body, options) {
options = options || {};
var now = new Date();
var envelope = {
id: now.getTime(),
date: now.toISOString(),
replyTo: 'localhost:' + testReceivePort + '/' + testTag,
statusCode: 200,
dataset: 'test-dataset',
dataset: options.dataset || 'test-dataset',
type: type,
body: body
};
Expand Down

0 comments on commit 36765e2

Please sign in to comment.