@@ -56,13 +56,13 @@ var __spreadArrays = (this && this.__spreadArrays) || function () {
5656} ;
5757Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
5858var util_1 = require ( "util" ) ;
59- var CallableBalancer = /** @class */ ( function ( ) {
59+ var RedisFunctionsBalancer = /** @class */ ( function ( ) {
6060 /**
6161 *
6262 * @param methods not empty array of functions
6363 * @param redisClient
6464 */
65- function CallableBalancer ( methods , redisClient ) {
65+ function RedisFunctionsBalancer ( methods , redisClient ) {
6666 this . _STORE_PREFIX = 'balancer' ;
6767 this . INC_VALUE = 1 ;
6868 this . _redisClient = redisClient ;
@@ -76,24 +76,24 @@ var CallableBalancer = /** @class */ (function () {
7676 zIncRbyAsync : util_1 . promisify ( redisClient . zincrby ) . bind ( this . _redisClient ) ,
7777 } ;
7878 }
79- CallableBalancer . prototype . setMethods = function ( methods ) {
79+ RedisFunctionsBalancer . prototype . setMethods = function ( methods ) {
8080 this . _methods = methods ;
8181 this . _storeKey = this . makeStoreKey ( methods ) ;
8282 } ;
83- CallableBalancer . prototype . increaseMethodRank = function ( method , incValue ) {
83+ RedisFunctionsBalancer . prototype . increaseRank = function ( func , incValue ) {
8484 if ( incValue === void 0 ) { incValue = this . INC_VALUE ; }
8585 return __awaiter ( this , void 0 , void 0 , function ( ) {
8686 return __generator ( this , function ( _a ) {
8787 switch ( _a . label ) {
88- case 0 : return [ 4 /*yield*/ , this . _functions . zIncRbyAsync ( this . _storeKey , incValue , method . name ) ] ;
88+ case 0 : return [ 4 /*yield*/ , this . _functions . zIncRbyAsync ( this . _storeKey , incValue , func . name ) ] ;
8989 case 1 :
9090 _a . sent ( ) ;
9191 return [ 2 /*return*/ ] ;
9292 }
9393 } ) ;
9494 } ) ;
9595 } ;
96- CallableBalancer . prototype . getAsyncIterator = function ( ) {
96+ RedisFunctionsBalancer . prototype . getAsyncIterator = function ( ) {
9797 return __asyncGenerator ( this , arguments , function getAsyncIterator_1 ( ) {
9898 var storedMethodNames , _i , storedMethodNames_1 , methodName , _a , _b , method ;
9999 return __generator ( this , function ( _c ) {
@@ -112,7 +112,7 @@ var CallableBalancer = /** @class */ (function () {
112112 if ( ! ( _a < _b . length ) ) return [ 3 /*break*/ , 8 ] ;
113113 method = _b [ _a ] ;
114114 if ( ! ( method . name === methodName ) ) return [ 3 /*break*/ , 7 ] ;
115- return [ 4 /*yield*/ , __await ( this . increaseMethodRank ( method , this . INC_VALUE ) ) ] ;
115+ return [ 4 /*yield*/ , __await ( this . increaseRank ( method , this . INC_VALUE ) ) ] ;
116116 case 4 :
117117 _c . sent ( ) ;
118118 return [ 4 /*yield*/ , __await ( method ) ] ;
@@ -134,7 +134,7 @@ var CallableBalancer = /** @class */ (function () {
134134 /**
135135 * Clear store
136136 */
137- CallableBalancer . prototype . resetStore = function ( ) {
137+ RedisFunctionsBalancer . prototype . resetStore = function ( ) {
138138 return __awaiter ( this , void 0 , void 0 , function ( ) {
139139 return __generator ( this , function ( _a ) {
140140 switch ( _a . label ) {
@@ -146,15 +146,15 @@ var CallableBalancer = /** @class */ (function () {
146146 } ) ;
147147 } ) ;
148148 } ;
149- CallableBalancer . prototype . getStoreKey = function ( ) {
149+ RedisFunctionsBalancer . prototype . getStoreKey = function ( ) {
150150 return this . _storeKey ;
151151 } ;
152152 /**
153153 * Return redis key to store list of methods with ranks
154154 * @param methods
155155 * @protected
156156 */
157- CallableBalancer . prototype . makeStoreKey = function ( methods ) {
157+ RedisFunctionsBalancer . prototype . makeStoreKey = function ( methods ) {
158158 var storeKeyArray = [ this . _STORE_PREFIX ] ;
159159 methods . forEach ( function ( method ) {
160160 storeKeyArray . push ( method . name ) ;
@@ -165,7 +165,7 @@ var CallableBalancer = /** @class */ (function () {
165165 * Returns an Array stored in Redis in Rank order
166166 * @private
167167 */
168- CallableBalancer . prototype . getRange = function ( ) {
168+ RedisFunctionsBalancer . prototype . getRange = function ( ) {
169169 return __awaiter ( this , void 0 , void 0 , function ( ) {
170170 var storedMethodNames , args_1 , result_1 ;
171171 var _a ;
@@ -190,6 +190,6 @@ var CallableBalancer = /** @class */ (function () {
190190 } ) ;
191191 } ) ;
192192 } ;
193- return CallableBalancer ;
193+ return RedisFunctionsBalancer ;
194194} ( ) ) ;
195- exports . default = CallableBalancer ;
195+ exports . default = RedisFunctionsBalancer ;
0 commit comments