Skip to content

Go-matcher is a game matcher implement in Go, which supports add game mode and match strategy easily.

License

Notifications You must be signed in to change notification settings

hedon954/go-matcher

Repository files navigation

go-matcher

Go Report Card codecov CI GitHub release (latest SemVer)

Go-matcher is a game matcher implement in Go, which supports add game mode and match strategy easily.

  • GameMode: The identifier of each different game, used to define as enum.
  • MatchStrategy: The strategy to match players, used to define as interface.

Features

  • API
    • HTTP
    • TCP
    • UDP
    • KCP
    • WebSocket
    • gRPC
  • Service
    • match service
    • push service
    • settle service
  • Swagger Doc
  • timer
    • native timer
    • asynq timer
    • redis timer
  • GameMode
    • GoatGame
  • MatchStrategy
    • Glicko2
    • Gather
    • ELO
  • Config
    • File Loader
    • Nacos Dynamic Loader
  • AI Generator

Architecture

go-matcher architecture

Smoke flow

smoke flow

State Machine

state machine

Entry Design

entry design

Todo

  • network
    • UDP
    • KCP
    • WebSocket
    • gRPC
  • static config
    • yaml
  • dynamic config
    • nacos
    • etcd
    • apollo
    • consul
  • tracer
  • open telemetry
  • repository stats
  • match queue stats
  • graceful restart
  • repository by redis
  • hot upgrade
  • horizontal expansion
  • AI Generator

Schedule

  • HandleMatchSuccess(8.9)
  • HandleGameResult(8.9)
  • Ready & Unready(8.9)
  • Push Service by gRPC(8.12)
  • Static Config(8.13)
  • Dynamic Config by nacos(8.13)
  • repository by redis(8.14)
  • entry encode & decode(8.14)
  • zerolog logger & tracer & open telemetry(8.15-8.16)
  • repository stats & match queue stats(8.19)
  • zinx(8.20-8.23)
  • TCP api(8.26)
  • WebSocket api(8.27)
  • AI Generator

Help

Before writing code

bash ./setup_pre_commit.sh

Start asynq web UI Asynqmon

# clone repo
git clone [email protected]:hibiken/asynqmon.git
# enter repo
cd asynqmon
# check node version
node -v
# if higher 16, should degrade it
# install nvm if not
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
# install node 16
nvm install 16
# use node 16
nvm use 16
# install yarn if not
brew install yarn
# build asynqmon
make build
# start asynqmon
./asynqmon

How to use Open Telemetry

Open Telemetry

Start jaeger

docker run -d --name jaeger \
  -e COLLECTOR_OTLP_ENABLED=true \
  -p 16686:16686 \
  -p 4317:4317 \
  -p 4318:4318 \
  jaegertracing/all-in-one:latest

Start Nacos

run by docker compose:

git clone https://github.com/nacos-group/nacos-docker.git \
cd nacos-docker \
docker-compose -f example/standalone-mysql-8.yaml up

open nacos website:

open http://localhost:8848/nacos/index.html