(private redis: DataHandledable, parserOptions: ParserOptions)
| 42 | |
| 43 | export default class DataHandler { |
| 44 | constructor(private redis: DataHandledable, parserOptions: ParserOptions) { |
| 45 | const parser = new RedisParser({ |
| 46 | stringNumbers: parserOptions.stringNumbers, |
| 47 | returnBuffers: true, |
| 48 | returnError: (err: Error) => { |
| 49 | this.returnError(err); |
| 50 | }, |
| 51 | returnFatalError: (err: Error) => { |
| 52 | this.returnFatalError(err); |
| 53 | }, |
| 54 | returnReply: (reply: any) => { |
| 55 | this.returnReply(reply); |
| 56 | }, |
| 57 | }); |
| 58 | |
| 59 | // prependListener ensures the parser receives and processes data before socket timeout checks are performed |
| 60 | redis.stream.prependListener("data", (data) => { |
| 61 | parser.execute(data); |
| 62 | }); |
| 63 | // prependListener() doesn't enable flowing mode automatically - we need to resume the stream manually |
| 64 | redis.stream.resume(); |
| 65 | } |
| 66 | |
| 67 | private returnFatalError(err: Error) { |
| 68 | err.message += ". Please report this."; |
nothing calls this directly
no test coverage detected