コード例 #1
0
ファイル: index.js プロジェクト: 10fish/datafari
internals.Policy.prototype.check = function () {

    if (!this._process.settings.sampleInterval) {
        return null;
    }

    Hoek.assert(this._process._eventLoopTimer, 'Cannot check load when sampler is not started');

    var elapsed = this._process._loadBench.elapsed();
    var load = this._process.load;

    if (elapsed > this._process.settings.sampleInterval) {
        load.eventLoopDelay = Math.max(load.eventLoopDelay, elapsed - this._process.settings.sampleInterval);
    }

    if (this.settings.maxEventLoopDelay &&
        load.eventLoopDelay > this.settings.maxEventLoopDelay) {

        return Boom.serverTimeout('Server under heavy load (event loop)', load);
    }

    if (this.settings.maxHeapUsedBytes &&
        load.heapUsed > this.settings.maxHeapUsedBytes) {

        return Boom.serverTimeout('Server under heavy load (heap)', load);
    }

    if (this.settings.maxRssBytes &&
        load.rss > this.settings.maxRssBytes) {

        return Boom.serverTimeout('Server under heavy load (rss)', load);
    }

    return null;
};
コード例 #2
0
    return function (req, res) {

        // Create request

        var request = new Request(self, req, res, options);

        // Check load

        if (limits.sampleInterval &&
            ((limits.maxEventLoopDelay && (load.eventLoopDelay > limits.maxEventLoopDelay || self._loadBench.elapsed() > limits.maxEventLoopDelay)) ||
            (limits.maxHeapUsedBytes && load.heapUsed > limits.maxHeapUsedBytes) ||
            (limits.maxRssBytes && load.rss > limits.maxRssBytes))) {

            request._reply(Boom.serverTimeout('Server under heavy load', load));
        }
        else {

            // Execute request lifecycle

            request._protect.domain.run(function () {

                request._execute();
            });
        }
    };
コード例 #3
0
ファイル: handle_es_error.js プロジェクト: BigFunger/kibana
export function handleEsError(error) {
  if (!(error instanceof Error)) {
    throw new Error('Expected an instance of Error');
  }

  const { reason, type } = get(error, 'body.error', {});
  const details = { type };

  if (
    error instanceof ConnectionFault ||
    error instanceof ServiceUnavailable ||
    error instanceof NoConnections ||
    error instanceof RequestTimeout
  ) {
    throw Boom.serverTimeout();
  }

  if (error instanceof Conflict) {
    throw Boom.conflict(reason, details);
  }

  if (error instanceof Forbidden) {
    throw Boom.forbidden(reason, details);
  }

  if (error instanceof NotFound) {
    throw Boom.notFound(reason, details);
  }

  if (error instanceof BadRequest) {
    throw Boom.badRequest(reason, details);
  }

  throw error;
}
コード例 #4
0
	getStations(function (err, stations) {
		if (err) { return reply(boom.internal()); }
		if (!stations[stationId]) { return reply(boom.notFound()); }

		var nowPlaying = state.getNowPlaying(stationId);
		if (!nowPlaying) { return reply(boom.serverTimeout('unavailable')); }

		reply(nowPlaying);
	});
コード例 #5
0
ファイル: teachers.js プロジェクト: medokin/stupid-gso-server
 app.server.methods.getTeachers(function (err, teachers) {
   if (err) {
     reply(Boom.serverTimeout(err));
   }
   reply({
     result: teachers,
     meta: {
       timestamp: moment().format()
     }
   });
 });
コード例 #6
0
ファイル: subjects.js プロジェクト: medokin/stupid-gso-server
 app.server.methods.getSubjects(function (err, subjects) {
   if (err) {
     reply(Boom.serverTimeout(err));
   }
   reply({
     result: subjects,
     meta: {
       timestamp: moment().format()
     }
   });
 });
コード例 #7
0
ファイル: connection.js プロジェクト: captscooby/hapi
    return function (req, res) {

        // Create request

        var request = new Request(self, req, res, options);

        // Check load

        if (!self._load.check()) {
            self.server._log(['load'], self.server.load);
            request._reply(Boom.serverTimeout('Server under heavy load', self.server.load));
        }
        else {

            // Execute request lifecycle

            request._protect.domain.run(function () {

                request._execute();
            });
        }
    };
コード例 #8
0
ファイル: handle_es_error.js プロジェクト: CartoDB/kibana
module.exports = function handleESError(error) {
  if (!(error instanceof Error)) {
    throw new Error('Expected an instance of Error');
  }

  if (error instanceof esErrors.ConnectionFault ||
    error instanceof esErrors.ServiceUnavailable ||
    error instanceof esErrors.NoConnections ||
    error instanceof esErrors.RequestTimeout) {
    return Boom.serverTimeout(error);
  } else if (error instanceof esErrors.Conflict || _.contains(error.message, 'index_template_already_exists')) {
    return Boom.conflict(error);
  } else if (error instanceof esErrors[403]) {
    return Boom.forbidden(error);
  } else if (error instanceof esErrors.NotFound) {
    return Boom.notFound(error);
  } else if (error instanceof esErrors.BadRequest || error instanceof TypeError) {
    return Boom.badRequest(error);
  } else {
    return error;
  }
};
コード例 #9
0
ファイル: holidays.js プロジェクト: medokin/stupid-gso-server
 }, function (err) {
   reply(Boom.serverTimeout(err));
 });
コード例 #10
0
        const timeoutReply = () => {

            this._log(['request', 'server', 'timeout', 'error'], { timeout: serverTimeout, elapsed: this._bench.elapsed() });
            this._reply(Boom.serverTimeout());
        };
コード例 #11
0
ファイル: request.js プロジェクト: Cain1127/IoTMobileDemo
        var timeoutReply = function () {

            self._log(['request', 'server', 'timeout', 'error'], { timeout: serverTimeout, elapsed: self._bench.elapsed() });
            self._reply(Boom.serverTimeout());
        };
コード例 #12
0
ファイル: policy.js プロジェクト: WDI-HK-7/hapi_restful_api
        setTimeout(function () {

            return finalize(id, Boom.serverTimeout(), null, null, report);
        }, this.rule.generateTimeout);
コード例 #13
0
        setTimeout(() => {

            return respond(this, id, Boom.serverTimeout(), null, null, report);
        }, this.rule.generateTimeout);
コード例 #14
0
ファイル: index.js プロジェクト: fritzy/pgboom
 '53': function (err) {
     return Boom.serverTimeout('Database unavailable');
 },
コード例 #15
0
ファイル: policy.js プロジェクト: Binarytales/helloperi
        setTimeout(function () {

            return respond(self, id, Boom.serverTimeout(), null, null, report);
        }, this.rule.generateTimeout);
コード例 #16
0
ファイル: request.js プロジェクト: abpin/hapi
        var timeoutReply = function () {

            self._reply(Boom.serverTimeout());
        };
コード例 #17
0
ファイル: request.js プロジェクト: 4yu/hapi
            var timeoutReply = function () {

                self.log(['hapi', 'server', 'timeout']);
                self._reply(Boom.serverTimeout());
            };