@@ -479,13 +479,19 @@ RedisClient.prototype.send_offline_queue = function () {
479479var retry_connection = function ( self , error ) {
480480 debug ( 'Retrying connection...' ) ;
481481
482- self . emit ( 'reconnecting' , {
482+ var reconnect_params = {
483483 delay : self . retry_delay ,
484484 attempt : self . attempts ,
485- error : error ,
486- times_connected : self . times_connected ,
487- total_retry_time : self . retry_totaltime
488- } ) ;
485+ error : error
486+ } ;
487+ if ( self . options . camel_case ) {
488+ reconnect_params . totalRetryTime = self . retry_totaltime ;
489+ reconnect_params . timesConnected = self . times_connected ;
490+ } else {
491+ reconnect_params . total_retry_time = self . retry_totaltime ;
492+ reconnect_params . times_connected = self . times_connected ;
493+ }
494+ self . emit ( 'reconnecting' , reconnect_params ) ;
489495
490496 self . retry_totaltime += self . retry_delay ;
491497 self . attempts += 1 ;
@@ -529,12 +535,18 @@ RedisClient.prototype.connection_gone = function (why, error) {
529535 }
530536
531537 if ( typeof this . options . retry_strategy === 'function' ) {
532- this . retry_delay = this . options . retry_strategy ( {
538+ var retry_params = {
533539 attempt : this . attempts ,
534- error : error ,
535- total_retry_time : this . retry_totaltime ,
536- times_connected : this . times_connected
537- } ) ;
540+ error : error
541+ } ;
542+ if ( this . options . camel_case ) {
543+ retry_params . totalRetryTime = this . retry_totaltime ;
544+ retry_params . timesConnected = this . times_connected ;
545+ } else {
546+ retry_params . total_retry_time = this . retry_totaltime ;
547+ retry_params . times_connected = this . times_connected ;
548+ }
549+ this . retry_delay = this . options . retry_strategy ( retry_params ) ;
538550 if ( typeof this . retry_delay !== 'number' ) {
539551 // Pass individual error through
540552 if ( this . retry_delay instanceof Error ) {
@@ -902,6 +914,72 @@ RedisClient.prototype.write = function (data) {
902914 return ;
903915} ;
904916
917+ Object . defineProperty ( exports , 'debugMode' , {
918+ get : function ( ) {
919+ return this . debug_mode ;
920+ } ,
921+ set : function ( val ) {
922+ this . debug_mode = val ;
923+ }
924+ } ) ;
925+
926+ // Don't officially expose the command_queue directly but only the length as read only variable
927+ Object . defineProperty ( RedisClient . prototype , 'command_queue_length' , {
928+ get : function ( ) {
929+ return this . command_queue . length ;
930+ }
931+ } ) ;
932+
933+ Object . defineProperty ( RedisClient . prototype , 'offline_queue_length' , {
934+ get : function ( ) {
935+ return this . offline_queue . length ;
936+ }
937+ } ) ;
938+
939+ // Add support for camelCase by adding read only properties to the client
940+ // All known exposed snack_case variables are added here
941+ Object . defineProperty ( RedisClient . prototype , 'retryDelay' , {
942+ get : function ( ) {
943+ return this . retry_delay ;
944+ }
945+ } ) ;
946+
947+ Object . defineProperty ( RedisClient . prototype , 'retryBackoff' , {
948+ get : function ( ) {
949+ return this . retry_backoff ;
950+ }
951+ } ) ;
952+
953+ Object . defineProperty ( RedisClient . prototype , 'commandQueueLength' , {
954+ get : function ( ) {
955+ return this . command_queue . length ;
956+ }
957+ } ) ;
958+
959+ Object . defineProperty ( RedisClient . prototype , 'offlineQueueLength' , {
960+ get : function ( ) {
961+ return this . offline_queue . length ;
962+ }
963+ } ) ;
964+
965+ Object . defineProperty ( RedisClient . prototype , 'shouldBuffer' , {
966+ get : function ( ) {
967+ return this . should_buffer ;
968+ }
969+ } ) ;
970+
971+ Object . defineProperty ( RedisClient . prototype , 'connectionId' , {
972+ get : function ( ) {
973+ return this . connection_id ;
974+ }
975+ } ) ;
976+
977+ Object . defineProperty ( RedisClient . prototype , 'serverInfo' , {
978+ get : function ( ) {
979+ return this . server_info ;
980+ }
981+ } ) ;
982+
905983exports . createClient = function ( ) {
906984 return new RedisClient ( unifyOptions . apply ( null , arguments ) ) ;
907985} ;
0 commit comments