* Transforms the ROLE reply into a structured object * * @param reply - The raw reply from Redis * @returns Structured object representing role information
(reply: UnwrapReply<Role>)
| 47 | * @returns Structured object representing role information |
| 48 | */ |
| 49 | transformReply(reply: UnwrapReply<Role>) { |
| 50 | switch (reply[0] as unknown as UnwrapReply<typeof reply[0]>) { |
| 51 | case 'master': { |
| 52 | const [role, replicationOffest, replicas] = reply as MasterRole; |
| 53 | return { |
| 54 | role, |
| 55 | replicationOffest, |
| 56 | replicas: (replicas as unknown as UnwrapReply<typeof replicas>).map(replica => { |
| 57 | const [host, port, replicationOffest] = replica as unknown as UnwrapReply<typeof replica>; |
| 58 | return { |
| 59 | host, |
| 60 | port: Number(port), |
| 61 | replicationOffest: Number(replicationOffest) |
| 62 | }; |
| 63 | }) |
| 64 | }; |
| 65 | } |
| 66 | |
| 67 | case 'slave': { |
| 68 | const [role, masterHost, masterPort, state, dataReceived] = reply as SlaveRole; |
| 69 | return { |
| 70 | role, |
| 71 | master: { |
| 72 | host: masterHost, |
| 73 | port: masterPort |
| 74 | }, |
| 75 | state, |
| 76 | dataReceived, |
| 77 | }; |
| 78 | } |
| 79 | |
| 80 | case 'sentinel': { |
| 81 | const [role, masterNames] = reply as SentinelRole; |
| 82 | return { |
| 83 | role, |
| 84 | masterNames |
| 85 | }; |
| 86 | } |
| 87 | } |
| 88 | } |
| 89 | } as const satisfies Command; |
no outgoing calls
no test coverage detected