1. Logic
DATA SPORT
  • DATABASE-SPORT
    • Tổng quan
    • Logic
      • Logic tổng thể
    • Projects
      • Yêu cầu hệ thống
      • Architecture
        • Database
    • Public APi
      • Tổng quan
    • Cron Make File
      • Tổng quan
  • GOLANG-THESPORT
    • Tổng quan
    • Architecture
      • System
      • Database
      • Source Code
    • Development
      • Local
      • Production
  • GOLANG-KSPORT
    • Tổng quan
    • Architecture
      • System
      • Database
      • Source Code
    • Development
      • Production
  • CRONJOB-LARAVEL
    • Tổng quan
    • Logic
      • Logic tổng thể
    • Projects
      • Yêu cầu hệ thống
      • Architecture
        • System
        • Source code
        • Database
      • Development
        • Dev
        • Production
      • Public API
        • Common API
          • League & Cup Profile (Basic)
          • Schedule & Results (Basic)
          • Match Modify Record
          • List of Countries
          • List of Bookmakers
          • Configuration instructions
        • Live animation
          • Configuration instructions
          • Schedule & Results
        • Live Data
          • Livescores for Today
          • Livescores Changes
          • Schedule & Results
          • Schedule Changes
          • Events
          • Stats
          • Corner
          • Lineups
          • Injury
          • Match List of Live Text
          • Live Text
          • Transfer
        • Profile
          • League & Cup Profile
          • Subleague Profile
          • Cup Stage Profile
          • Team Profile
          • Team Profile Copy
          • Team Profile for Search
          • Player Profile
          • Player Profile for Search
          • Referee Profile
          • Teamlist with Player Profile
        • Stats
          • Matches Analysis
          • List of Player Stats (Match)
          • Player Stats (Match)
          • List of Player Stats (League & Cup)
          • Player Stats (League & Cup)
          • League Standing (Get Subleague)
          • League Standing
          • Cup Standing
          • Top Scorer
          • FIFA Ranking
        • Odds (18 bookmakers)
          • Pre-match and In-play Odds (Main)
          • Live Odds Changes (Main)
          • Historical Odds (Main)
          • Future Odds (Main)
          • Pre-match and In-play Odds (All)
          • Live Odds Changes (All)
          • Historical Odds (All)
          • Future Odds (All)
          • European Odds (Halftime)
          • In-play Odds
          • In-play Odds (Halftime)
          • Odd Modify Record
        • European Odds (200+ Bookmakers)
          • European Odds (200+ Bookmakers)
        • Other Odds
          • Outrights
          • First/Last Team To Score (pre-match)
          • Goals Odd/Even (pre-match)
          • Goals Odd/Even (In-play)
          • Number of Goals in Match (pre-match)
          • Number of Goals in Match (In-play)
          • Half Time/Full Time (pre-match)
          • Half Time/Full Time (In-play)
          • Correct Score (pre-match)
          • Correct Score (In-play)
          • Half Time Correct Score (pre-match)
          • Half Time Correct Score (In-play)
          • Handicap Corners (pre-match)
          • Handicap Corners (In-play)
          • Total Corners (pre-match) - Tổng phạt góc trước trận đấu: First Odds
          • Total Corners (In-play) - Tổng số quả phạt góc (Trong trận) - Run Odds
          • Double Chance(pre-match)
          • EuroHandicap(pre-match)
  • GOLANG-WEBSOCKET
    • Tổng Quan
    • Logic
      • Logic tổng thể
    • Projects
      • Yêu cầu hệ thống
      • Architecture
        • System
        • Source code
      • Development
        • Dev
        • Production
      • Public API
        • API
  • ADMIN-BANNER
    • Tổng quan
    • Logic
      • Logic tổng thể
    • Projects
      • Architecture
        • System
        • Source Code
      • Development
        • Develop
        • Production
      • Public API
        • API
      • Database
        • Cấu trúc Database
      • Admin FE
        • HƯỚNG DẪN CÀI ĐẶT MÔI TRƯỜNG DỰ ÁN SPORT ADMIN
        • Hướng dẫn Đăng nhập
        • QUẢN LÝ SITE (SITE MANAGEMENT)
        • QUẢN LÝ GIẢI ĐẤU (LEAGUE MANAGEMENT)
        • QUẢN LÝ NHÀ CUNG CẤP (SUPPLIER MANAGEMENT)
        • TIP & CHUYÊN GIA - TAB QUẢN LÝ TIPS (TIPS MANAGEMENT)
        • WHITELIST
        • QUẢN LÝ MINIGAME (MINIGAME MANAGEMENT)
        • TRAFFIC REPORT
        • TOOLS - RAPID DATA
        • TOOLS - LIVE SITES
        • TOOLS - SUPPLIERS
        • THEME / PLUGIN
        • NGƯỜI DÙNG - PHÂN QUYỀN VÀ HIỂN THỊ (PERMISSION & DISPLAY MANAGEMENT)
        • QUẢN LÝ NGƯỜI DÙNG (USER MANAGEMENT)
        • NGƯỜI DÙNG - QUẢN LÝ NHÓM QUYỀN (ROLE GROUP MANAGEMENT)
  1. Logic

Logic tổng thể

ChatGPT Image Mar 26, 2026, 03_10_43 PM.png
Luồng tổng thể

1. Hệ thống#

Hệ thống WebSocket được thiết kế để xử lý real-time data streaming, sử dụng mô hình:
WebSocket (client communication)
Redis Pub/Sub (message broker)
Goroutine (concurrency)

2. Cấu trúc hệ thống#

config/: Config hệ thống
server/: Core logic WebSocket
nginx.conf: Reverse proxy
docker-compose.yml: Deploy services
ssl/: SSL certificate

3. Logic chi tiết#

Entry Point (main.go)#

Start → Load config → Connect Redis → Init HubManager → Listen WebSocket

Hub Manager#

Quản lý nhiều Hub theo channel
map[string]*Hub

Hub#

Register / Unregister client
Broadcast message

Client#

Read Pump (receive)
Write Pump (send)

Redis + Pub/Sub#

Redis → PubSub → Hub → Client

Stream Worker#

Fetch data → Process → Publish Redis

Replay#

Gửi lại data cũ cho client mới

Health Check#

Check server & Redis

4. Luồng hoạt động#

Client connect#

Client → /ws → Upgrade → Register Hub

Subscribe#

Client gửi channel → Join Hub

Data flow#

Worker → Redis → Hub → Client

Disconnect#

Remove client → Cleanup

5. Deployment#

Docker + Docker Compose
Nginx reverse proxy
SSL (HTTPS/WSS)

6. Ưu điểm#

Real-time mạnh
Scale tốt với Redis
Tách biệt rõ ràng các layer
Modified at 2026-03-26 08:18:49
Previous
Tổng Quan
Next
Yêu cầu hệ thống
Built with