Projects / relay
relay
gRPC pub/sub. Publish to a topic, watch a stream, or join a chat room.
Why
Hotwire uses the same three RPC shapes: a bidirectional stream, a server stream, and a unary call. Those are hard to see when they are buried under a scorer. Relay is the streams without the score, so a broken stream is just a broken stream.
Diagrams
A solid outline is the path in the repo. A dashed outline is the alternative that shape is refusing.
Publish is unary. Watch is a server stream. Chat is bidirectional. The server keeps topics in memory. There is no disk.
flowchart TD
cli[CLI]
server["In-memory server"]
once["Publish, unary"]
watch["Watch, server stream"]
chat["Chat, bidirectional"]
cli --> server
server --> once
server --> watch
server --> chat
class cli,server,once,watch,chat chosen
Hotwire uses the same three RPC shapes under a scorer. Relay is those streams on their own. Restarting the server drops the topics. A second node is a different program.
flowchart TD
q{What is being learned}
q -->|"a broken stream is just a broken stream"| relay["gRPC pub sub"]
q -->|"the pattern stays buried under weights"| buried["Only inside hotwire"]
store{Where rooms live}
store -->|"one process"| mem["Memory"]
store -->|"restart keeps the topics"| disk["Disk and a second node"]
class relay,mem chosen
class buried,disk rejected
Why this shape
Topics are names. Watch is a server stream. Chat is bidirectional. The server keeps the rooms in memory. There is no disk and no second node. A CLI is enough, because the thing being learned is the protobuf streaming pattern, not a product.
Where it breaks
Restart the server and the topics are gone. A client whose stream errors has to dial again. Nothing here will fan out across machines. Hotwire’s proxy has the same habit: when its weight stream errors, it keeps the last map and does not redial.