onBuildData -> buildData event

This commit is contained in:
oleg 2015-05-12 22:53:04 +03:00
parent 4438f998f4
commit 79003d2885
2 changed files with 20 additions and 22 deletions

View File

@ -19,9 +19,6 @@ function Distributor(params) {
self.saveBuild = params.saveBuild || function(build, callback) { self.saveBuild = params.saveBuild || function(build, callback) {
callback(null, build); callback(null, build);
}; };
self.onBuildData = params.onBuildData || function(build, data) {
};
} }
inherits(Distributor, EventEmitter); inherits(Distributor, EventEmitter);
@ -85,7 +82,7 @@ Distributor.prototype._runNext = function(callback) {
}); });
executor.on('data', function(data) { executor.on('data', function(data) {
self.onBuildData(build, data); self.emit('buildData', build, data);
}); });
executor.once('scmData', function(scmData) { executor.once('scmData', function(scmData) {

View File

@ -20,25 +20,22 @@ project.loadAll('projects', function(err, loadedProjects) {
); );
}); });
module.exports = function(app) { var distributor = new Distributor({
nodes: [{type: 'local', maxExecutorsCount: 1}],
saveBuild: function(build, callback) {
Steppy(
function() {
db.builds.put(build, this.slot());
},
function() {
this.pass(build);
},
callback
);
}
});
var distributor = new Distributor({ module.exports = function(app) {
nodes: [{type: 'local', maxExecutorsCount: 1}],
saveBuild: function(build, callback) {
Steppy(
function() {
db.builds.put(build, this.slot());
},
function() {
this.pass(build);
},
callback
);
},
onBuildData: function(build, data) {
app.dataio.resource('build' + build.id).clientEmitSync('data', data);
}
});
distributor.on('buildUpdate', function(build, changes) { distributor.on('buildUpdate', function(build, changes) {
var buildsResource = app.dataio.resource('builds'); var buildsResource = app.dataio.resource('builds');
@ -56,6 +53,10 @@ module.exports = function(app) {
}); });
}); });
distributor.on('buildData', function(build, data) {
app.dataio.resource('build' + build.id).clientEmitSync('data', data);
});
var resource = app.dataio.resource('projects'); var resource = app.dataio.resource('projects');
resource.use('read', function(req, res) { resource.use('read', function(req, res) {