flexmatch

module
v0.0.0-...-237b7d6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2023 License: MIT

README

亚马逊FlexMatch 服务的go语言实现

TODO

  • 迁移服务注册/发现、rpc日志

  • kafka 事件的接口封装 客户端

  • redis 的匹配事件订阅和消费

  • pyroscope

  • metrics

  • pprof

  • admin

  • 对局服务样例

安装

cd $GOPATH/src
mkdir github.com/Languege
cd github.com/Languege
git clone github.com/Languege/flexmatch

运行

cd flexmatch/service/match
bash start.sh

使用

1. 对局服务器实现open.FlexMatchGame服务

用于向对局服务创建唯一游戏对局信息

2. 创建对局配置

对局配置用于团队、匹配规则、事件通知等设置,具体参见open.MatchmakingConfiguration协议说明。 样例位于中台项目match应用TestCreateMatchmakingConfiguration测试用例下

3. 快速开始

3.1. 启动对局demo battle服务

启动脚本service/battle/start.sh

3.2 启动匹配服务

启动脚本service/match/start.sh

3.3 测试对局并消费匹配事件

测试用例TestMatchEventConsume位于service/match/api/test下

3.4 游戏对各个事件进行处理

考虑到实际使用过程中,部分信息匹配服务无法获知,游戏的推送交于游戏自定义。测试用例TestMatchEventConsume中RegisterEventHandler的处理函数交由业务自定义

考虑到消息推送可能存在丢失的情景,客户端应设置保底时长,超过阈值时对票据状态进行轮询, 对应的匹配服务接口DescribeMatchmaking

性能

在未对接游戏对局创建、kafka事件写入时,采用单一分值距离匹配、自动接受匹配规则,5v5单人匹配mac m1性能如下

对局数 平均对局完成耗时ns
50 20695223
200 5586288
2000 1338885

测试用例TestMatchmaking_TicketInput位于service/match/entities/matchmaking_test.go中, 参数N设置对局数

metrics

指标名 类型 说明
flex_match_ticket_queued Counter 票据入队列计数
flex_match_ticket_backfill Counter 票据回填计数
flex_match_ticket_canceled Counter 票据取消计数
flex_match_ticket_timeout Counter 票据超时计数
flex_match_ticket_in_queued Gather 处于队列中的票据数
flex_match_ticket_in_searching Gather 处于搜索中的票据数
flex_match_ticket_in_requires_acceptance Gather 处于请求接收状态中的票据数
flex_match_ticket_in_placing Gather 处于安排游戏状态的票据数
flex_match_match_potential Counter 潜在对局计数
flex_match_match_completed Counter 接收完成对局计数 (超时、部分接收、任意拒绝), 对局配置AcceptanceRequired为true时生效
flex_match_match_succeed Counter 成功对局计数
flex_match_match_accept_timeout Counter 接收超时对局计数
flex_match_match_rejected Counter 拒绝对局计数

其他

本服务为亚马逊匹配服务的实现,变动如下

  1. 取消最小最大团队玩家人数规则、采用固定人数对局;

产品特性可参考亚马逊匹配文档

Directories

Path Synopsis
common
bootstraps
bootstraps @author LanguageY++2013 2023/5/8 23:38 @company soulgame
bootstraps @author LanguageY++2013 2023/5/8 23:38 @company soulgame
constants
constants @author LanguageY++2013 2023/5/9 16:26 @company soulgame
constants @author LanguageY++2013 2023/5/9 16:26 @company soulgame
grpc_middleware
grpc_middleware @author LanguageY++2013 2023/5/9 18:17 @company soulgame
grpc_middleware @author LanguageY++2013 2023/5/9 18:17 @company soulgame
grpc_middleware/resolver/etcd
etcd @author LanguageY++2013 2023/5/8 18:31 @company soulgame
etcd @author LanguageY++2013 2023/5/8 18:31 @company soulgame
grpc_middleware/timeout
timeout @author LanguageY++2013 2023/5/19 18:27 @company soulgame
timeout @author LanguageY++2013 2023/5/19 18:27 @company soulgame
logger
dateformat @author LanguageY++2013 2023/5/10 11:00 @company soulgame
dateformat @author LanguageY++2013 2023/5/10 11:00 @company soulgame
logger/dateformat
dateformat @author LanguageY++2013 2023/5/10 16:33 @company soulgame
dateformat @author LanguageY++2013 2023/5/10 16:33 @company soulgame
singletons/etcd
singletons @author LanguageY++2013 2023/5/8 23:30 @company soulgame
singletons @author LanguageY++2013 2023/5/8 23:30 @company soulgame
utils/network
network @author LanguageY++2013 2023/5/9 15:58 @company soulgame
network @author LanguageY++2013 2023/5/9 15:58 @company soulgame
wrappers/etcd
etcd @author LanguageY++2013 2023/5/8 21:10 @company soulgame
etcd @author LanguageY++2013 2023/5/8 21:10 @company soulgame
wrappers/kafka
kafka @author LanguageY++2013 2023/5/11 10:53 @company soulgame
kafka @author LanguageY++2013 2023/5/11 10:53 @company soulgame
wrappers/pyroscope
pyroscope @author LanguageY++2013 2023/5/18 09:25 @company soulgame
pyroscope @author LanguageY++2013 2023/5/18 09:25 @company soulgame
wrappers/redis
app @author LanguageY++2013 2021/8/6 6:24 PM @company soulgame
app @author LanguageY++2013 2021/8/6 6:24 PM @company soulgame
service
battle/service
service @author LanguageY++2013 2023/5/19 15:03 @company soulgame
service @author LanguageY++2013 2023/5/19 15:03 @company soulgame
match/api
api @author LanguageY++2013 2022/11/23 15:20 @company soulgame
api @author LanguageY++2013 2022/11/23 15:20 @company soulgame
match/api/game
api @author LanguageY++2013 2022/11/23 15:20 @company soulgame
api @author LanguageY++2013 2022/11/23 15:20 @company soulgame
match/entities
entities @author LanguageY++2013 2022/11/8 18:28 @company soulgame
entities @author LanguageY++2013 2022/11/8 18:28 @company soulgame
match/parser
parser @author LanguageY++2013 2023/4/3 18:00 @company soulgame
parser @author LanguageY++2013 2023/4/3 18:00 @company soulgame
match/parser/chain
parser @author LanguageY++2013 2023/4/3 20:44 @company soulgame
parser @author LanguageY++2013 2023/4/3 20:44 @company soulgame
match/pubsub
pubsub @author LanguageY++2013 2023/5/11 09:26 @company soulgame
pubsub @author LanguageY++2013 2023/5/11 09:26 @company soulgame
match/pubsub/kafka
kafka @author LanguageY++2013 2023/5/11 09:33 @company soulgame
kafka @author LanguageY++2013 2023/5/11 09:33 @company soulgame
match/pubsub/logging
logging @author LanguageY++2013 2023/5/11 17:17 @company soulgame
logging @author LanguageY++2013 2023/5/11 17:17 @company soulgame
match/pubsub/prometheus
entities @author LanguageY++2013 2023/5/18 23:16 @company soulgame
entities @author LanguageY++2013 2023/5/18 23:16 @company soulgame
match/pubsub/redis
redis @author LanguageY++2013 2023/5/16 17:00 @company soulgame
redis @author LanguageY++2013 2023/5/16 17:00 @company soulgame
match/repositories/elo_rep
repositories @author LanguageY++2013 2022/11/1 10:19 @company soulgame
repositories @author LanguageY++2013 2022/11/1 10:19 @company soulgame
match/repositories/matchmaking_rep
repositories @author LanguageY++2013 2022/11/7 18:59 @company soulgame
repositories @author LanguageY++2013 2022/11/7 18:59 @company soulgame

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL