Docs carry the shape of the system, not its status
MIZAN.md's phase-numbered implementation order, PRODUCT_ARCHITECTURE's "Deferred until Render revenue funds it" and "Shipped in", PSR_VS_EDGE's current-state section, and the READMEs' passing-test counts were all reporting where the work stood rather than what the system is. OWED_SURFACE keeps its subject — surface that is specified but unbuilt — stated as the shape each unit owes. The channel sections follow the renamed slots: Params / ClientMessage / ServerMessage, and Channel as the base class on both backends. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -119,18 +119,24 @@ dedicated `mizan-allauth` repository, built on this mixin.
|
||||
|
||||
## Channels
|
||||
|
||||
WebSocket-native RPC via a flag flip:
|
||||
WebSocket-native RPC via a flag flip. The message slots are named from the
|
||||
client's point of view: `ClientMessage` travels client → server,
|
||||
`ServerMessage` travels server → client. Declare only the directions the
|
||||
channel uses.
|
||||
|
||||
```python
|
||||
from pydantic import BaseModel
|
||||
from mizan.channels import ReactChannel
|
||||
from mizan.channels import Channel
|
||||
|
||||
|
||||
class ChatChannel(ReactChannel):
|
||||
class ChatChannel(Channel):
|
||||
class Params(BaseModel):
|
||||
room: str
|
||||
|
||||
class DjangoMessage(BaseModel):
|
||||
class ClientMessage(BaseModel):
|
||||
text: str
|
||||
|
||||
class ServerMessage(BaseModel):
|
||||
text: str
|
||||
user: str
|
||||
|
||||
@@ -139,10 +145,19 @@ class ChatChannel(ReactChannel):
|
||||
|
||||
def group(self, params):
|
||||
return f"chat_{params.room}"
|
||||
|
||||
def receive(self, params, msg):
|
||||
return self.ServerMessage(text=msg.text, user=self.user.email)
|
||||
```
|
||||
|
||||
Frontend gets `useChatChannel({ room })`.
|
||||
|
||||
Server code outside a subscription broadcasts with `push()`:
|
||||
|
||||
```python
|
||||
await ChatChannel.push(room="general", message=ChatChannel.ServerMessage(...))
|
||||
```
|
||||
|
||||
## Generate the frontend
|
||||
|
||||
The codegen is the `mizan-generate` Rust binary (source at
|
||||
|
||||
Reference in New Issue
Block a user