How to use the @hapi/boom.serverUnavailable function in @hapi/boom

To help you get started, we’ve selected a few @hapi/boom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hapijs / hapi / lib / request.js View on Github external
internals.timeoutReply = function (request, timeout) {

    const elapsed = Date.now() - request.info.received;
    request._log(['request', 'server', 'timeout', 'error'], { timeout, elapsed });
    request._reply(Boom.serverUnavailable());
};
github hapijs / catbox / lib / policy.js View on Github external
            pending.setTimeout(() => this._send(pending, Boom.serverUnavailable(), null, null, report), this.rule.generateTimeout);
        }
github hapijs / nes / lib / listener.js View on Github external
internals.Sockets.prototype.auth = function (socket) {

    if (!this._listener._settings.auth.index) {
        return;
    }

    if (!socket.auth.credentials.user) {
        return;
    }

    const user = socket.auth.credentials.user;
    if (this._listener._settings.auth.maxConnectionsPerUser &&
        this._byUser[user] &&
        this._byUser[user].length >= this._listener._settings.auth.maxConnectionsPerUser) {

        throw Boom.serverUnavailable('Too many connections for the authenticated user');
    }

    this._byUser[user] = this._byUser[user] || [];
    this._byUser[user].push(socket);
};
github hapijs / heavy / lib / index.js View on Github external
if (this.settings.maxEventLoopDelay &&
        load.eventLoopDelay > this.settings.maxEventLoopDelay) {

        throw Boom.serverUnavailable('Server under heavy load (event loop)', load);
    }

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

        throw Boom.serverUnavailable('Server under heavy load (heap)', load);
    }

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

        throw Boom.serverUnavailable('Server under heavy load (rss)', load);
    }
};
github hapijs / heavy / lib / index.js View on Github external
const load = this.load;

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

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

        throw Boom.serverUnavailable('Server under heavy load (event loop)', load);
    }

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

        throw Boom.serverUnavailable('Server under heavy load (heap)', load);
    }

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

        throw Boom.serverUnavailable('Server under heavy load (rss)', load);
    }
};
github hapijs / heavy / lib / index.js View on Github external
return;
    }

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

    const elapsed = this._loadBench.elapsed();
    const load = this.load;

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

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

        throw Boom.serverUnavailable('Server under heavy load (event loop)', load);
    }

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

        throw Boom.serverUnavailable('Server under heavy load (heap)', load);
    }

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

        throw Boom.serverUnavailable('Server under heavy load (rss)', load);
    }
};