コード例 #1
0
 function comTransacao(callback){
     me.conexao.beginTransaction(dominio.intercept(function() {
         return callback(me.conexao, function(success,error) {
             me.commit(success);
         });
     }));
 }
コード例 #2
0
ファイル: app.js プロジェクト: Aakak/expressjsguide
app.use(function (error, req, res, next) {
  if (domain.active) {
    console.info('caught with domain', domain.active);
    domain.active.emit('error', error);
  } else {
    console.info('no domain');
    defaultHandler(error, req, res, next);
  }
});
コード例 #3
0
issues.log = function log (message) {
  var issue = this;

  this.failed = true;
  this.messages.push(message || 'No message specified');

  if (this.retries > 0) {
    var retryTimer = setTimeout(issue.attemptRetry.bind(issue), this.retry);
    if (domain.active) {
      domain.active.remove(retryTimer);
    }
    return this.emit('issue', this.details);
  }

  if (this.remove) {
    this.emit('remove', this.details);
  }

  var reconnectTimer = setTimeout(issue.attemptReconnect.bind(issue), this.reconnect);
  if (domain.active) {
    domain.active.remove(reconnectTimer);
  }
};
コード例 #4
0
		.then(domain.bind(function(next){
			
			_this._estimationStatus = {
				state: 'calculating',
				message: 'Calculating: Fetching meta data',
			}
	
			cachedRequest(
				_this._metaCacheUrl,
				Domain.active.intercept(function( response, body ){
					
					//Parse the result and pull out the t_bounds
					var result = JSON.parse( body );
					var lower = new Date(_this._dataSource.t_bounds.first());
					var upper = new Date(_this._dataSource.t_bounds.last());
					
					var timeDimension = null;
					for( var i in result.Dimensions ){
						if( result.Dimensions[i].Name == 'time' )
							var timeDimension = result.Dimensions[i];
					}
					
					if( timeDimension == null )
						throw new Error('No time dimension in meta data');
					
					//Get the dates that are in a valid range from the users request.
					// Also sort them.
					data.timeSlicesInRange = timeDimension.Value
						//Get the times in an array
						.split(',')
						// Convert the str times to Date objects
						.map(function( strTime ){
							return new Date( strTime )
						})
						// Filter out the Dates out of the needed range
						.filter(function( date ){
							if( date == null ) return false;
							
							if( lower < date && date < upper )
								return true;
							else
								return false;
						}).sort(function( a , b ){
							return a > b ? 1 : -1
						});
					
					next();
				})
			);
		}))
コード例 #5
0
    commit:function(callback){
        if(!this.conexao) return;

        var me = this;

        var dominio = require('domain').active;

        me.conexao.commit(dominio.intercept(function(result,err) {
            if (err) {
                me.conexao.rollback(function() {
                    if(callback) callback(false);
                });
            } else  if(callback) callback(true);

        }));
    },
コード例 #6
0
ファイル: client.js プロジェクト: getsentry/raven-node
 self.context({req: req}, function() {
   domain.active.add(req);
   domain.active.add(res);
   next();
 });