http icon indicating copy to clipboard operation
http copied to clipboard

Fixed signature HttpWorkerInterface

Open root-aza opened this issue 3 months ago • 1 comments

Q A
Bugfix? ✔️
Breaks BC?
New feature?

Fixed signature HttpWorkerInterface

Summary by CodeRabbit

  • New Features
    • Added an optional flag to response handling that explicitly marks the end of streaming responses. This enables finer control over when streams terminate and supports more robust streaming scenarios. Existing behavior remains unchanged if the flag isn’t provided, ensuring backward compatibility and a seamless upgrade path for current integrations.

root-aza avatar Oct 12 '25 16:10 root-aza

Walkthrough

The HttpWorkerInterface’s respond method signature now includes an optional bool parameter endOfStream (default true), expanding from three to four parameters. This modifies the public interface and call pattern for streaming responses while preserving prior behavior when the new parameter is omitted.

Changes

Cohort / File(s) Summary
HTTP Worker interface API update
src/HttpWorkerInterface.php
Added optional bool $endOfStream = true to `respond(int $status, string

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant C as Client
    participant S as Server/App
    participant W as HttpWorkerInterface

    C->>S: HTTP Request
    S->>W: respond(status, body, headers, endOfStream)

    alt endOfStream = true
        Note right of W: Final chunk sent<br/>Connection closed
        W-->>C: Send body and terminate stream
    else endOfStream = false
        Note right of W: Chunked/streaming<br/>More data expected
        W-->>C: Send body chunk, keep stream open
        S->>W: respond(..., endOfStream=true) for final chunk
        W-->>C: Send final chunk and close
    end

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I twitch an ear at streams that flow,
A gentle flag to end—or no?
One nibble more, then close the seam,
Or keep the carrots in the stream.
With one small bool, I hop with glee—
The final byte is up to me! 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title directly reflects the core change of the PR, which is updating the signature of the HttpWorkerInterface’s respond method, and concisely communicates that the interface contract was fixed.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • [ ] 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a44a5f7d54d4ee8a14fe99cd22dcd128db270c88 and c6484a41ab53c82d8114528e1415d39f444abc80.

📒 Files selected for processing (1)
  • src/HttpWorkerInterface.php (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/HttpWorkerInterface.php (2)
src/PSR7Worker.php (1)
  • respond (87-96)
src/HttpWorker.php (1)
  • respond (87-100)
🔇 Additional comments (1)
src/HttpWorkerInterface.php (1)

32-32: All respond implementations conform to the updated interface. HttpWorker’s signature now includes the new endOfStream parameter, and PSR7Worker passes status, body and headers—relying on the default endOfStream value.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Oct 12 '25 16:10 coderabbitai[bot]