Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

impossible to combine streaming and non-streaming in same lambda

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

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
45/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
aws, go
Lĩnh vực
api, backend, cloud

Hướng nghiên cứu

Bắt đầu bằng cách lần theo phần triển khai của LambdaFunctionURLStreamingResponse và cách xử lý phần mở đầu cùng các mã trạng thái của nó. Tái hiện cả phản hồi streaming và phản hồi JSON thuần, sau đó xác định cách hành vi này có thể tránh làm hỏng một trong hai chế độ phản hồi trong khi vẫn giữ lại các mã trạng thái lỗi có ý nghĩa; được xem là hoàn thành khi cả các client hiện có không sử dụng streaming và các consumer streaming đều có thể hoạt động chính xác.

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

Mô tả

Imagine you have a lambda that returns JSON:

{"result":"this is the result"}

only imagine the JSON is much more complicated, with sub-objects, and it takes a long time to generate.

Because it takes a long time to generate, you'd like to implement a mode where a certain header or payload indicates to stream status updates, according to some message scheme.

The LambdaFunctionURLStreamingResponse seems to offer it!

But alas, it has this gnarly code:

if r.prelude == nil {
    ...
}
if r.prelude.Len() > 0 {
    return r.prelude.Read()
}

Now, whether you want it or not, the lambda outputs this prelude. The prelude doesn't match your original output! And as it is JSON, it breaks message decoding and prevents sending a single, sane JSON message output.

And on the streaming side, it messes with your streaming output - the receiver always has to skip this prelude.

Foiled! it's not possible to both implement streaming, and let it fall back to a simple JSON response. Therefore It's not backwards compatible - there is no way to roll out the change and keep existing plain-json-only clients working.

Furthermore, your error codes will break. The lambda always returns status code 200! Even if you return an error from the handler with no LambdaFunctionURLStreamResponse!

Could we please remove this gnarly prelude??

Ngôn ngữ chính
Go
Star
3.8k
Fork
581
Merge trung bình
2 ngày 2 giờ
Pull request đã merge (30 ngày)
2

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 aws/aws-lambda-go

Tất cả issue của aws/aws-lambda-go

Issue tương tự

Thêm issue về Go

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.