File tree Expand file tree Collapse file tree 4 files changed +8
-39
lines changed Expand file tree Collapse file tree 4 files changed +8
-39
lines changed Original file line number Diff line number Diff line change @@ -302,18 +302,8 @@ RedisClient.prototype.init_parser = function () {
302
302
this . reply_parser = new this . parser_module . Parser ( {
303
303
return_buffers : self . options . return_buffers || self . options . detect_buffers || false
304
304
} ) ;
305
-
306
- // "reply error" is an error sent back by Redis
307
- this . reply_parser . on ( "reply error" , function ( reply ) {
308
- self . return_error ( reply ) ;
309
- } ) ;
310
- this . reply_parser . on ( "reply" , function ( reply ) {
311
- self . return_reply ( reply ) ;
312
- } ) ;
313
- // "error" is bad. Somehow the parser got confused. It'll try to reset and continue.
314
- this . reply_parser . on ( "error" , function ( err ) {
315
- self . emit ( "error" , new Error ( "Redis reply parser error: " + err . stack ) ) ;
316
- } ) ;
305
+ this . reply_parser . send_error = this . return_error . bind ( self ) ;
306
+ this . reply_parser . send_reply = this . return_reply . bind ( self ) ;
317
307
} ;
318
308
319
309
RedisClient . prototype . on_ready = function ( ) {
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- var events = require ( "events" ) ,
4
- util = require ( "util" ) ,
5
- hiredis = require ( "hiredis" ) ;
3
+ var hiredis = require ( "hiredis" ) ;
6
4
7
5
exports . name = "hiredis" ;
8
6
9
7
function HiredisReplyParser ( options ) {
10
8
this . name = exports . name ;
11
9
this . options = options || { } ;
12
10
this . reset ( ) ;
13
- events . EventEmitter . call ( this ) ;
14
11
}
15
12
16
- util . inherits ( HiredisReplyParser , events . EventEmitter ) ;
17
-
18
13
exports . Parser = HiredisReplyParser ;
19
14
20
15
HiredisReplyParser . prototype . reset = function ( ) {
@@ -27,21 +22,16 @@ HiredisReplyParser.prototype.execute = function (data) {
27
22
var reply ;
28
23
this . reader . feed ( data ) ;
29
24
while ( true ) {
30
- try {
31
- reply = this . reader . get ( ) ;
32
- } catch ( err ) {
33
- this . emit ( "error" , err ) ;
34
- break ;
35
- }
25
+ reply = this . reader . get ( ) ;
36
26
37
27
if ( reply === undefined ) {
38
28
break ;
39
29
}
40
30
41
31
if ( reply && reply . constructor === Error ) {
42
- this . emit ( "reply error" , reply ) ;
32
+ this . send_error ( reply ) ;
43
33
} else {
44
- this . emit ( "reply" , reply ) ;
34
+ this . send_reply ( reply ) ;
45
35
}
46
36
}
47
37
} ;
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- var events = require ( "events" ) ,
4
- util = require ( "util" ) ;
3
+ var util = require ( "util" ) ;
5
4
6
5
function Packet ( type , size ) {
7
6
this . type = type ;
@@ -20,8 +19,6 @@ function ReplyParser(options) {
20
19
this . _reply_type = null ;
21
20
}
22
21
23
- util . inherits ( ReplyParser , events . EventEmitter ) ;
24
-
25
22
exports . Parser = ReplyParser ;
26
23
27
24
function IncompleteReadBuffer ( message ) {
@@ -286,11 +283,3 @@ ReplyParser.prototype._packetEndOffset = function () {
286
283
ReplyParser . prototype . _bytesRemaining = function ( ) {
287
284
return ( this . _buffer . length - this . _offset ) < 0 ? 0 : ( this . _buffer . length - this . _offset ) ;
288
285
} ;
289
-
290
- ReplyParser . prototype . send_error = function ( reply ) {
291
- this . emit ( "reply error" , reply ) ;
292
- } ;
293
-
294
- ReplyParser . prototype . send_reply = function ( reply ) {
295
- this . emit ( "reply" , reply ) ;
296
- } ;
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ describe('javascript parser', function () {
11
11
assert . deepEqual ( reply , [ [ 'a' ] ] , "Expecting multi-bulk reply of [['a']]" ) ;
12
12
reply_count ++ ;
13
13
}
14
- parser . on ( "reply" , check_reply ) ;
14
+ parser . send_reply = check_reply ;
15
15
16
16
parser . execute ( new Buffer ( '*1\r\n*1\r\n$1\r\na\r\n' ) ) ;
17
17
You can’t perform that action at this time.
0 commit comments