Перейти к содержанию

session-service (C4 Level 3)

Ответственность

  • CRUD сессий, invite codes
  • Participants, roles, kick
  • Session lifecycle FSM
  • Presence (web/telegram)
  • Старт игры (делегирует game-runtime)

Компоненты

flowchart TB
    subgraph session_service [session-service]
        API[Session API]
        CodeGen[Invite Code Generator]
        Lifecycle[Session Lifecycle]
        ParticipantMgr[Participant Manager]
        Presence[Presence Tracker]
        GameStarter[Game Start Coordinator]
    end
    API --> CodeGen
    API --> Lifecycle
    API --> ParticipantMgr
    ParticipantMgr --> Presence
    GameStarter --> GameRT[game-runtime HTTP]
    Lifecycle --> PG[(PostgreSQL)]
    Presence --> Redis[(Redis)]
Компонент Описание
Invite Code Generator 6–8 chars, unique, exclude ambiguous
Session Lifecycle Lobby → GameSelection → InGame → Closed
Participant Manager CRUD, role assignment
Presence Tracker Redis keys presence:{session}:{participant}
Game Start Coordinator POST game-runtime create instance

Данные

  • sessions, participants — PostgreSQL
  • Presence TTL — Redis 60s heartbeat

События

Publish: session.created, session.closed, participant.joined, participant.left

FR

FR-001, FR-002, FR-010, FR-018–FR-020