赣州网站建设培训网店营销推广

当前位置: 首页 > news >正文

赣州网站建设培训,网店营销推广,建设可以聊天的网站,外贸流程基本知识背景介绍 open-match是Google和unity联合开源的支持实时多人匹配的框架#xff0c;已有多家游戏厂商在生产环境使用#xff0c;官网 https://open-match.dev/site/ 。原本我们使用的是UOS上提供的匹配能力#xff0c;但是UOS目前不支持自建的Dedicated servers 集群#x… 背景介绍 open-match是Google和unity联合开源的支持实时多人匹配的框架已有多家游戏厂商在生产环境使用官网 https://open-match.dev/site/ 。原本我们使用的是UOS上提供的匹配能力但是UOS目前不支持自建的Dedicated servers 集群只能上传镜像UOS会自动完成分配以及创建灵活性就不是那么高了按照open-match的官方教程需要有k8s的环境。但是小公司就是不想要k8s我就想单机部署可以使用docker-compose。open-match本身的镜像build 提供了dockerfile文件。把项目clone到本地然后在 tm中以此使用以下命令构建对用的image tip:该方案只是启动了 core 部分要求的组件即 搭建步骤 Install with YAML | Open Match 后面的部分需要自行探索了现在也在学习中欢迎交流讨论 先构建一个中间镜像base builder然后一次构建对应的component即可需要修改Dockerfile.cmd中的 FROM open-match-base-build as builder 为目的是指定使用本地的version版本否则会远程拉取镜像网络问题会导致不成功需要开梯子 FROM open-match-base-build:latest as builder docker build -f .\Dockerfile.base-build -t open-match-base-build .
docker build –build-arg IMAGE_TITLEsynchronizer -f .\Dockerfile.cmd -t open-match-synchronizer . 接着使用docker-compose.yaml 来控制启动过程内如如下 version: 3 services:open-match-backend:image: open-match-backend:latestcontainer_name: open-match-backendvolumes:- ./matchmaker_config_default.yaml:/app/matchmaker_config_default.yaml- ./matchmaker_config_override.yaml:/app/matchmaker_config_override.yamlports:- 50505:50505 # gRPC- 51505:51505 # HTTPenvironment:API_BACKEND_HOSTNAME: open-match-backendAPI_BACKEND_GRPC_PORT: 50505API_BACKEND_HTTP_PORT: 51505REDIS_HOSTNAME: open-match-redisREDIS_PORT: 6379depends_on:- redisopen-match-frontend:image: open-match-frontend:latestcontainer_name: open-match-frontendports:- 50504:50504 # gRPC- 51504:51504 # HTTPvolumes:- ./matchmaker_config_default.yaml:/app/matchmaker_config_default.yaml- ./matchmaker_config_override.yaml:/app/matchmaker_config_override.yamlenvironment:API_FRONTEND_HOSTNAME: open-match-frontendAPI_FRONTEND_GRPC_PORT: 50504API_FRONTEND_HTTP_PORT: 51504REDIS_HOSTNAME: open-match-redisREDIS_PORT: 6379depends_on:- redisopen-match-query:image: open-match-query:latestcontainer_name: open-match-queryports:- 50503:50503 # gRPC- 51503:51503 # HTTPenvironment:API_QUERY_HOSTNAME: open-match-queryAPI_QUERY_GRPC_PORT: 50503API_QUERY_HTTP_PORT: 51503REDIS_HOSTNAME: open-match-redisREDIS_PORT: 6379volumes:- ./matchmaker_config_default.yaml:/app/matchmaker_config_default.yaml- ./matchmaker_config_override.yaml:/app/matchmaker_config_override.yamldepends_on:- redisopen-match-synchronizer:image: open-match-synchronizer:latestcontainer_name: open-match-synchronizervolumes:- ./matchmaker_config_default.yaml:/app/matchmaker_config_default.yaml- ./matchmaker_config_override.yaml:/app/matchmaker_config_override.yamlports:- 50506:50506 # gRPC- 51506:51506 # HTTPenvironment:API_SYNCHRONIZER_HOSTNAME: open-match-synchronizerAPI_SYNCHRONIZER_GRPC_PORT: 50506API_SYNCHRONIZER_HTTP_PORT: 51506REDIS_HOSTNAME: open-match-redisREDIS_PORT: 6379depends_on:- redisopen-match-swaggerui:image: open-match-swaggerui:latestcontainer_name: open-match-swaggeruiports:- 51500:51500 # HTTP for Swagger UIvolumes:- ./matchmaker_config_default.yaml:/app/matchmaker_config_default.yaml- ./matchmaker_config_override.yaml:/app/matchmaker_config_override.yamlenvironment:API_SWAGGERUI_HOSTNAME: open-match-swaggeruiAPI_SWAGGERUI_HTTP_PORT: 51500depends_on:- open-match-backend- open-match-frontend- open-match-query- open-match-synchronizerredis:image: redis:alpinecontainer_name: open-match-redisports:- 6379:6379volumes:- redis-data:/datavolumes:redis-data:matchmaker_config_default.yaml 的内容和 matchmaker_config_override.yaml的内容是一致的目的就是override可以覆盖default中的值猜的这部分内容从k8s的yaml文件中copy过来内容如下   logging:level: debugformat: textrpc: false

Open Match applies the exponential backoff strategy for its retryable gRPC calls.

The settings below are the default backoff configuration used in Open Match.

See https://github.com/cenkalti/backoff/blob/v3/exponential.go for detailed explanations

backoff:# The initial retry interval (in milliseconds)initialInterval: 100ms# maxInterval caps the maximum time elapsed for a retry intervalmaxInterval: 500ms# The next retry interval is multiplied by this multipliermultiplier: 1.5# Randomize the retry intervalrandFactor: 0.5# maxElapsedTime caps the retry time (in milliseconds)maxElapsedTime: 3000msapi:backend:hostname: open-match-backendgrpcport: 50505httpport: 51505frontend:hostname: open-match-frontendgrpcport: 50504httpport: 51504query:hostname: open-match-querygrpcport: 50503httpport: 51503synchronizer:hostname: open-match-synchronizergrpcport: 50506httpport: 51506swaggerui:hostname: open-match-swaggeruihttpport: 51500# Configurations for api.test and api.scale are used for testing.test:hostname: open-match-testgrpcport: 50509httpport: 51509scale:httpport: 51509redis:# Open Matchs default Redis setupshostname: open-match-redis# source value: open-match-core.redis.port 6379port: 6379usePassword: falsepasswordPath: /redis-passwordpool:maxIdle: 200maxActive: 0idleTimeout: 0healthCheckTimeout: 300mstelemetry:reportingPeriod: 1mtraceSamplingFraction: 0.01zpages:enable: trueprometheus:enable: falseendpoint: /metricsserviceDiscovery: truestackdriverMetrics:enable: falsegcpProjectId: replace_with_your_project_idprefix: open_match 然后就可以启动了 运行demo 如果要运行open-match的 demo-first-match还要一个组件 evaluator 该组件的目的是对所有的matches进行评估并返回得分open-match会保留评分最高的组合比如我们以 战力相差的相近为评估规则假定 abc三个玩家的战力分值分配时 10 20 25则abc三人同时匹配在1v1的条件选应当尽可能的选择20 25这个相近的评分评分组件evaluator这个需要开始自行实行通过synchronizer进行调用open-match 提供了一个default实现 即default-evaluator使用以下命令进行构建即可 docker build –build-arg IMAGE_TITLEdefault-evaluator -f .\Dockerfile.cmd -t open-match-default-evaluator . 如果开发环境存在需要平凡需求的情况直接ide环境启动即可但是需要在 matchmaker_config_default.yaml中指明 evaluator的位置信息 api:evaluator:hostname: open-match-default-evaluatorhttpport: 5499grpcport: 5498 接着需要修改几个demo的hostname地址一个是frontend的hostname位置在 open-match/examples/demo/components/clients/clients.go:84 //修改前 conn, err : grpc.Dial(open-match-frontend.open-match.svc.cluster.local:50504, grpc.WithInsecure())//修改后 conn, err : grpc.Dial(localhost:50504, grpc.WithInsecure()) 另外一个是 backend的hostname open-match/examples/demo/components/director/director.go:71 //修改前 conn, err : grpc.Dial(open-match-backend.open-match.svc.cluster.local:50505, grpc.WithInsecure())//修改后 conn, err : grpc.Dial(localhost:50505, grpc.WithInsecure()) 然后还需要部署一个组件mmf负责判断给定的组合是否符合要求可以直接启动 cmd/scale-mmf或者build镜像一样的需要修改query的hostname位置信息如下 open-match/examples/scale/mmf/mmf.go:42 //修改前 conn, err : grpc.Dial(open-match-query.open-match.svc.cluster.local:50503, utilTesting.NewGRPCDialOptions(logger)…)//修改后 conn, err : grpc.Dial(localhost:50503, utilTesting.NewGRPCDialOptions(logger)…) mmf的服务地址是由director在fetchMatches指定的相关的代码位置在 open-match/examples/demo/components/director/director.go:82 不同版本可能会有所变化当前提及的代码内容来源于open-match的最新master代码2024年10月9日  req : pb.FetchMatchesRequest{Config: pb.FunctionConfig{Host: om-function.open-match-demo.svc.cluster.local,Port: 50502,Type: pb.FunctionConfig_GRPC,},Profile: pb.MatchProfile{Name: 1v1,Pools: []*pb.Pool{{Name: Everyone,},},},}所以我们需要改掉这里Host所指定的值修改为mmf的实际地址即可最后更新docker-compose.yaml并执行 docker-compose -f docker-compose.yaml up在cmd/demo-first-match/main.go 文件中运行main函数即可成功运行demo程序 demo程序的执行成功后会返回一个虚拟的链接地址该链接地址由director组件返回可以理解为在director中返回具体的dedicated server的ip地址demo中是随机产生的代码位置在 examples/demo/components/director/director.go:132  如果不正确可以搜索2222作为线索定位 for _, match : range matches {ids : []string{}for , t : range match.Tickets {ids append(ids, t.Id)}req : pb.AssignTicketsRequest{Assignments: []*pb.AssignmentGroup{{TicketIds: ids,Assignment: pb.Assignment{Connection: fmt.Sprintf(%d.%d.%d.%d:2222, rand.Intn(256), rand.Intn(256), rand.Intn(256), rand.Intn(256)),},},},}resp, err : be.AssignTickets(ds.Ctx, req)if err ! nil {panic(err)} resp} 匹配成功后返回的链接地址 open-match对mmf,evaluator,director 提供了多种游戏场景的默认实现可以在亦有模板的基础上结合业务进行开发具体内容可以查看examples/scale/README.md 感觉联机几千人同时在线这种方式应该够够吧先这样散会 补一张open-match 时序图看懂这个业务开发层面知道各个component的职责范围