Enable redis client to be paused and resumed using underlying stream's pause and resume

Đang mở
#1,500 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
42/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
nodejs, redis, typescript
Lĩnh vực
api, backend

Hướng nghiên cứu

Đọc hướng dẫn backpressure được liên kết của Node.js, sau đó bắt đầu từ API của client Redis và stream nền tảng được đề cập trong issue. Xác định pause và resume sẽ ảnh hưởng như thế nào đến dữ liệu pubsub đến và kết nối TCP, đồng thời xác minh rằng việc sử dụng client.pause() và client.resume() trong client ví dụ hoạt động như yêu cầu.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Issue

node-redis doesn't support the ability to pause and resume the data coming into it. That means if a node process is taking data off redis (for example pubsub) and storing it in another location that has less operations per second the requests from redis will pile up inside nodejs or worse the requests will exceed the limits of the upstream location and requests will begin to fail and drop at that location. Nodejs applications need the ability to manage their own resource consumption. Currently with redis calling callbacks for pubsub events there is no way to backpressure on the redis client and back to the tcp connection. See node guide to backpressure

I am thinking a simple function mirroring the underlying function would be good

const redis = require("redis");
const client = redis.createClient();
client.pause();
client.resume();

I would like to build a nodejs stream on top of redis pubsub and/or redis stream. I think the best way to do this would be to support pause and resume on the client.

The stream would wrap around the client something like

const redis = require("redis");
const redisStream = require("redis-stream");
const { pipeline } = require('stream');
const subscriber = redis.createClient();
subscriber.subscribe("a channel");
const subscriberStream  = redisStream.createReadStream(subscriber, {include_connect: true});

pipeline(subscriberStream, process.stdout)

Environment
  • Node.js Version: 12.16.1
  • Redis Version: 5.0.3
  • Platform: 10.14.6
Ngôn ngữ chính
TypeScript
Star
17.6k
Fork
2k
Merge trung bình
1 ngày 22 giờ
Pull request đã merge (30 ngày)
62

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của redis/node-redis

Tất cả issue của redis/node-redis

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.