Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@brigade/pooled-thrift-client

Package Overview
Dependencies
Maintainers
5
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@brigade/pooled-thrift-client - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

CHANGELOG.md

83

dist/index.js

@@ -8,2 +8,38 @@ 'use strict';

var _keys = require('babel-runtime/core-js/object/keys');
var _keys2 = _interopRequireDefault(_keys);
var _regenerator = require('babel-runtime/regenerator');
var _regenerator2 = _interopRequireDefault(_regenerator);
var _asyncToGenerator2 = require('babel-runtime/helpers/asyncToGenerator');
var _asyncToGenerator3 = _interopRequireDefault(_asyncToGenerator2);
var _assign = require('babel-runtime/core-js/object/assign');
var _assign2 = _interopRequireDefault(_assign);
var _promise = require('babel-runtime/core-js/promise');
var _promise2 = _interopRequireDefault(_promise);
var _getPrototypeOf = require('babel-runtime/core-js/object/get-prototype-of');
var _getPrototypeOf2 = _interopRequireDefault(_getPrototypeOf);
var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);
var _inherits2 = require('babel-runtime/helpers/inherits');
var _inherits3 = _interopRequireDefault(_inherits2);
exports.default = function (TService, poolOptions, thriftOptions) {

@@ -16,4 +52,4 @@ var _this4 = this;

thriftOptions = Object.assign({}, DEFAULT_THRIFT_OPTIONS, thriftOptions);
poolOptions = Object.assign({}, DEFAULT_POOL_OPTIONS, poolOptions);
thriftOptions = (0, _assign2.default)({}, DEFAULT_THRIFT_OPTIONS, thriftOptions);
poolOptions = (0, _assign2.default)({}, DEFAULT_POOL_OPTIONS, poolOptions);

@@ -25,4 +61,4 @@ var pool = _genericPool2.default.createPool({

validate: function () {
var _ref = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(connection) {
return regeneratorRuntime.wrap(function _callee$(_context) {
var _ref = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee(connection) {
return _regenerator2.default.wrap(function _callee$(_context) {
while (1) {

@@ -48,4 +84,4 @@ switch (_context.prev = _context.next) {

destroy: function () {
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(connection) {
return regeneratorRuntime.wrap(function _callee2$(_context2) {
var _ref2 = (0, _asyncToGenerator3.default)( /*#__PURE__*/_regenerator2.default.mark(function _callee2(connection) {
return _regenerator2.default.wrap(function _callee2$(_context2) {
while (1) {

@@ -72,3 +108,3 @@ switch (_context2.prev = _context2.next) {

return Object.keys(TService.Client.prototype).reduce(function (thriftClient, rpc) {
return (0, _keys2.default)(TService.Client.prototype).reduce(function (thriftClient, rpc) {
thriftClient[rpc] = pooledRpc(TService, rpc, pool);

@@ -89,22 +125,13 @@ return thriftClient;

function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
/* Error types */
var AcquisitionTimeoutError = exports.AcquisitionTimeoutError = function (_Error) {
_inherits(AcquisitionTimeoutError, _Error);
(0, _inherits3.default)(AcquisitionTimeoutError, _Error);
function AcquisitionTimeoutError(message) {
var metadata = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
(0, _classCallCheck3.default)(this, AcquisitionTimeoutError);
_classCallCheck(this, AcquisitionTimeoutError);
var _this = (0, _possibleConstructorReturn3.default)(this, (AcquisitionTimeoutError.__proto__ || (0, _getPrototypeOf2.default)(AcquisitionTimeoutError)).call(this, 'Thrift pool connection acquisition timeout: ' + message, metadata));
var _this = _possibleConstructorReturn(this, (AcquisitionTimeoutError.__proto__ || Object.getPrototypeOf(AcquisitionTimeoutError)).call(this, 'Thrift pool connection acquisition timeout: ' + message, metadata));
_this.name = 'AcquisitionTimeoutError';

@@ -119,8 +146,8 @@ Error.captureStackTrace(_this, AcquisitionTimeoutError);

var ConnectionTimeoutError = exports.ConnectionTimeoutError = function (_Error2) {
_inherits(ConnectionTimeoutError, _Error2);
(0, _inherits3.default)(ConnectionTimeoutError, _Error2);
function ConnectionTimeoutError() {
_classCallCheck(this, ConnectionTimeoutError);
(0, _classCallCheck3.default)(this, ConnectionTimeoutError);
var _this2 = _possibleConstructorReturn(this, (ConnectionTimeoutError.__proto__ || Object.getPrototypeOf(ConnectionTimeoutError)).call(this, 'Thrift connection timeout'));
var _this2 = (0, _possibleConstructorReturn3.default)(this, (ConnectionTimeoutError.__proto__ || (0, _getPrototypeOf2.default)(ConnectionTimeoutError)).call(this, 'Thrift connection timeout'));

@@ -136,8 +163,8 @@ _this2.name = 'ConnectionTimeoutError';

var ConnectionClosedError = exports.ConnectionClosedError = function (_Error3) {
_inherits(ConnectionClosedError, _Error3);
(0, _inherits3.default)(ConnectionClosedError, _Error3);
function ConnectionClosedError() {
_classCallCheck(this, ConnectionClosedError);
(0, _classCallCheck3.default)(this, ConnectionClosedError);
var _this3 = _possibleConstructorReturn(this, (ConnectionClosedError.__proto__ || Object.getPrototypeOf(ConnectionClosedError)).call(this, 'Thrift connection closed'));
var _this3 = (0, _possibleConstructorReturn3.default)(this, (ConnectionClosedError.__proto__ || (0, _getPrototypeOf2.default)(ConnectionClosedError)).call(this, 'Thrift connection closed'));

@@ -164,3 +191,3 @@ _this3.name = 'ConnectionClosedError';

var createThriftConnection = function createThriftConnection(thriftOptions) {
return new Promise(function (resolve, reject) {
return new _promise2.default(function (resolve, reject) {
var host = thriftOptions.host,

@@ -201,5 +228,5 @@ port = thriftOptions.port;

return pool.acquire().catch(function (e) {
return Promise.reject(new AcquisitionTimeoutError(e.message));
return _promise2.default.reject(new AcquisitionTimeoutError(e.message));
}).then(function (connection) {
return new Promise(function (resolve, reject) {
return new _promise2.default(function (resolve, reject) {
var onTimeout = function onTimeout() {

@@ -206,0 +233,0 @@ connection.alive = false;

{
"name": "@brigade/pooled-thrift-client",
"version": "1.0.1",
"version": "1.0.2",
"description": "A Thrift client utilising a pool of service connections and improved error handling/recovery",

@@ -28,2 +28,3 @@ "main": "dist/index.js",

"dependencies": {
"babel-runtime": "^6.26.0",
"generic-pool": "^3.4.0",

@@ -34,3 +35,3 @@ "thrift": "^0.11.0"

"babel-cli": "^6.26.0",
"babel-polyfill": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-env": "^1.6.1",

@@ -37,0 +38,0 @@ "eslint": "^4.13.1",

# pooled-thrift-client
[![npm version](https://badge.fury.io/js/%40brigade%2Fpooled-thrift-client.svg)](https://badge.fury.io/js/%40brigade%2Fpooled-thrift-client)
[![Build Status](https://travis-ci.org/brigade/pooled-thrift-client.svg?branch=master)](https://travis-ci.org/brigade/pooled-thrift-client)

@@ -7,2 +8,13 @@

## Features
- proper Promise support in pool instance con/destruction
- correct behaviour on "Internal Error", aka, socket misalignment on
unhandled server errors
- better/existent timeout support for: connections, pool checkout,
execution
- builtin retry support using upstream Thrift code
- faster detection and pruning of dead connections
- async/await and other niceties
## Example usage

@@ -9,0 +21,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc