Skip to content

Migrate HTTP layer from http4s to zio-http - #2

Draft
lavrov wants to merge 3 commits into
masterfrom
vibe/migrate-zio-http-1d3e4f
Draft

lavrov wants to merge 3 commits into
masterfrom
vibe/migrate-zio-http-1d3e4f

Conversation

@lavrov

@lavrov lavrov commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Replace http4s (ember server/client, DSL, WebSocketBuilder) with zio-http 3.11.2 for the entire HTTP layer
  • Keep the cats-effect IO core (torrent registry, piece store, streams) unchanged; convert at the HTTP boundary via zio-interop-catz (fromEffect/toEffect, fs2 Stream#translate + toZStream)
  • Rewrite routes in zio-http Routes, byte-range handling with Header.Range/Body.fromStream, and the WebSocket session with Handler.webSocket + ChannelEvent
  • Remove the unused org.http4s.Uri import from ServerTorrent.scala

Verification

  • ./mill __.compile passes
  • Runtime smoke test: GET / → 200, torrent metadata/data routes → 404 for unknown torrents and invalid infohashes, negative file index rejected, WebSocket handshake → 101 and Ping → Pong round-trip verified

mistral-vibe and others added 3 commits October 10, 2026 15:57
Serve routes, range requests, and the WebSocket session with zio-http
3.11.2, converting at the HTTP boundary via zio-interop-catz while
keeping the cats-effect core unchanged.

Co-authored-by: lavrov <lavrov@users.noreply.github.com>
Replace IOApp with ZIOAppDefault. Main.run is a ZIO for-comprehension
that acquires a cats-effect Dispatcher via ZIO scope, serves zio-http
routes directly, and converts to the cats-effect core only through
fromEffect at the boundary.

Co-authored-by: lavrov <lavrov@users.noreply.github.com>
TorrentRegistry, ServerTorrent, SocketSession, MetadataRegistry,
Multiplexer, PieceStore, and TorrentIndex are now ZIO-native; cats
effect remains only at the bittorrent library boundary via the new
Interop helper. A new --no-dht argument skips DHT bootstrap with an
empty PeerDiscovery so the HTTP and WebSocket layer can be smoke
tested without network access.

Co-authored-by: lavrov <lavrov@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants