408da3f201
New public ingress and the first network edge. Framework + a vertical slice of operations end-to-end; remaining ops reuse the same transcode pattern in Stage 7. Contracts (new module scrabble/pkg): - push.proto (backend->gateway gRPC server-stream) + scrabble.fbs (FlatBuffers edge payloads), committed generated Go; buf/flatc Makefiles (dev-time codegen). Backend: - REST handlers on the /api/v1 groups: internal session endpoints (telegram/guest/email login -> mint, resolve, revoke) and the user slice (profile, submit_play, state, lobby enqueue/poll, chat). - internal/notify in-process Publisher hub + internal/pushgrpc gRPC server (BACKEND_GRPC_ADDR) streaming your_turn/opponent_moved/chat/nudge/match_found; emission in game.commit, social, matchmaker. - migration 00005 accounts.is_guest; guests are durable rows excluded from stats; ProvisionGuest; email-as-login (RequestLoginCode/LoginWithCode). Gateway (new module scrabble/gateway): - Connect Gateway service over h2c (Execute + Subscribe), FlatBuffers<->JSON transcode registry, Telegram initData HMAC validator (seam), session cache, token-bucket rate limiter (3 classes), push fan-out hub, backend REST + push gRPC client, admin Basic-Auth reverse proxy. go.work: use ./pkg, ./gateway + replace scrabble/pkg. CI: gateway/**, pkg/** path filters; unit build/vet/test span all three modules. Docs (PLAN, ARCHITECTURE, FUNCTIONAL+ru, TESTING, READMEs) updated; gateway/pkg unit tests + guest/email-login integration tests.
51 lines
1.9 KiB
Protocol Buffer
51 lines
1.9 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
// Package scrabble.edge.v1 is the client <-> gateway Connect-RPC contract. It is
|
|
// deliberately minimal (ARCHITECTURE.md §2): a single unary Execute that routes
|
|
// by message_type, and a server-streaming Subscribe for the in-app live channel.
|
|
// The actual request/response and event bodies travel as FlatBuffers bytes in the
|
|
// payload fields (pkg/fbs). The session token rides in the Authorization header,
|
|
// not the envelope (no per-request signing — ARCHITECTURE.md §3).
|
|
package scrabble.edge.v1;
|
|
|
|
option go_package = "scrabble/gateway/proto/edge/v1;edgev1";
|
|
|
|
// Gateway is the public edge service.
|
|
service Gateway {
|
|
// Execute runs one unary operation identified by message_type. Auth operations
|
|
// (auth.*) are unauthenticated and return a minted session; all others require
|
|
// a valid session token in the Authorization header.
|
|
rpc Execute(ExecuteRequest) returns (ExecuteResponse);
|
|
// Subscribe opens the in-app live-event stream for the authenticated session.
|
|
rpc Subscribe(SubscribeRequest) returns (stream Event);
|
|
}
|
|
|
|
// ExecuteRequest is the unary envelope. message_type selects the operation;
|
|
// payload is its FlatBuffers-encoded request body; request_id is an optional
|
|
// client correlation id echoed back.
|
|
message ExecuteRequest {
|
|
string message_type = 1;
|
|
bytes payload = 2;
|
|
string request_id = 3;
|
|
}
|
|
|
|
// ExecuteResponse is the unary reply. result_code is "ok" on success or a stable
|
|
// error code; payload is the FlatBuffers-encoded response body (empty on error).
|
|
message ExecuteResponse {
|
|
string request_id = 1;
|
|
string result_code = 2;
|
|
bytes payload = 3;
|
|
}
|
|
|
|
// SubscribeRequest opens the live stream. It is empty: the session is taken from
|
|
// the Authorization header.
|
|
message SubscribeRequest {}
|
|
|
|
// Event is one live event. kind is the notification catalog kind; payload is its
|
|
// FlatBuffers-encoded body; event_id is a correlation id.
|
|
message Event {
|
|
string kind = 1;
|
|
bytes payload = 2;
|
|
string event_id = 3;
|
|
}
|