@@ -56,13 +56,13 @@ var __spreadArrays = (this && this.__spreadArrays) || function () {
56
56
} ;
57
57
Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
58
58
var util_1 = require ( "util" ) ;
59
- var CallableBalancer = /** @class */ ( function ( ) {
59
+ var RedisFunctionsBalancer = /** @class */ ( function ( ) {
60
60
/**
61
61
*
62
62
* @param methods not empty array of functions
63
63
* @param redisClient
64
64
*/
65
- function CallableBalancer ( methods , redisClient ) {
65
+ function RedisFunctionsBalancer ( methods , redisClient ) {
66
66
this . _STORE_PREFIX = 'balancer' ;
67
67
this . INC_VALUE = 1 ;
68
68
this . _redisClient = redisClient ;
@@ -76,24 +76,24 @@ var CallableBalancer = /** @class */ (function () {
76
76
zIncRbyAsync : util_1 . promisify ( redisClient . zincrby ) . bind ( this . _redisClient ) ,
77
77
} ;
78
78
}
79
- CallableBalancer . prototype . setMethods = function ( methods ) {
79
+ RedisFunctionsBalancer . prototype . setMethods = function ( methods ) {
80
80
this . _methods = methods ;
81
81
this . _storeKey = this . makeStoreKey ( methods ) ;
82
82
} ;
83
- CallableBalancer . prototype . increaseMethodRank = function ( method , incValue ) {
83
+ RedisFunctionsBalancer . prototype . increaseRank = function ( func , incValue ) {
84
84
if ( incValue === void 0 ) { incValue = this . INC_VALUE ; }
85
85
return __awaiter ( this , void 0 , void 0 , function ( ) {
86
86
return __generator ( this , function ( _a ) {
87
87
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 ) ] ;
89
89
case 1 :
90
90
_a . sent ( ) ;
91
91
return [ 2 /*return*/ ] ;
92
92
}
93
93
} ) ;
94
94
} ) ;
95
95
} ;
96
- CallableBalancer . prototype . getAsyncIterator = function ( ) {
96
+ RedisFunctionsBalancer . prototype . getAsyncIterator = function ( ) {
97
97
return __asyncGenerator ( this , arguments , function getAsyncIterator_1 ( ) {
98
98
var storedMethodNames , _i , storedMethodNames_1 , methodName , _a , _b , method ;
99
99
return __generator ( this , function ( _c ) {
@@ -112,7 +112,7 @@ var CallableBalancer = /** @class */ (function () {
112
112
if ( ! ( _a < _b . length ) ) return [ 3 /*break*/ , 8 ] ;
113
113
method = _b [ _a ] ;
114
114
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 ) ) ] ;
116
116
case 4 :
117
117
_c . sent ( ) ;
118
118
return [ 4 /*yield*/ , __await ( method ) ] ;
@@ -134,7 +134,7 @@ var CallableBalancer = /** @class */ (function () {
134
134
/**
135
135
* Clear store
136
136
*/
137
- CallableBalancer . prototype . resetStore = function ( ) {
137
+ RedisFunctionsBalancer . prototype . resetStore = function ( ) {
138
138
return __awaiter ( this , void 0 , void 0 , function ( ) {
139
139
return __generator ( this , function ( _a ) {
140
140
switch ( _a . label ) {
@@ -146,15 +146,15 @@ var CallableBalancer = /** @class */ (function () {
146
146
} ) ;
147
147
} ) ;
148
148
} ;
149
- CallableBalancer . prototype . getStoreKey = function ( ) {
149
+ RedisFunctionsBalancer . prototype . getStoreKey = function ( ) {
150
150
return this . _storeKey ;
151
151
} ;
152
152
/**
153
153
* Return redis key to store list of methods with ranks
154
154
* @param methods
155
155
* @protected
156
156
*/
157
- CallableBalancer . prototype . makeStoreKey = function ( methods ) {
157
+ RedisFunctionsBalancer . prototype . makeStoreKey = function ( methods ) {
158
158
var storeKeyArray = [ this . _STORE_PREFIX ] ;
159
159
methods . forEach ( function ( method ) {
160
160
storeKeyArray . push ( method . name ) ;
@@ -165,7 +165,7 @@ var CallableBalancer = /** @class */ (function () {
165
165
* Returns an Array stored in Redis in Rank order
166
166
* @private
167
167
*/
168
- CallableBalancer . prototype . getRange = function ( ) {
168
+ RedisFunctionsBalancer . prototype . getRange = function ( ) {
169
169
return __awaiter ( this , void 0 , void 0 , function ( ) {
170
170
var storedMethodNames , args_1 , result_1 ;
171
171
var _a ;
@@ -190,6 +190,6 @@ var CallableBalancer = /** @class */ (function () {
190
190
} ) ;
191
191
} ) ;
192
192
} ;
193
- return CallableBalancer ;
193
+ return RedisFunctionsBalancer ;
194
194
} ( ) ) ;
195
- exports . default = CallableBalancer ;
195
+ exports . default = RedisFunctionsBalancer ;
0 commit comments