From 9102110b984338c19d43313b7230ede430af2891 Mon Sep 17 00:00:00 2001 From: Zak <34372536+ZakShearman@users.noreply.github.com> Date: Sun, 3 Nov 2024 20:31:12 +0000 Subject: [PATCH] feat: add kurushimi service --- go.work | 1 + go.work.sum | 167 ++++-- services/game-player-data/go.mod | 1 + services/game-player-data/go.sum | 3 +- services/kurushimi/Dockerfile | 33 ++ services/kurushimi/cmd/kurushimi/main.go | 29 + services/kurushimi/go.mod | 89 +++ services/kurushimi/go.sum | 266 +++++++++ services/kurushimi/internal/app/kurushimi.go | 97 ++++ services/kurushimi/internal/config/global.go | 167 ++++++ .../kurushimi/internal/director/director.go | 542 ++++++++++++++++++ .../kurushimi/internal/gsallocation/common.go | 84 +++ .../internal/gsallocation/selector/common.go | 31 + .../gsallocation/selector/game_based.go | 56 ++ .../gsallocation/selector/player_based.go | 35 ++ services/kurushimi/internal/kafka/consumer.go | 109 ++++ services/kurushimi/internal/kafka/writer.go | 182 ++++++ .../internal/matchfunction/common.go | 1 + .../internal/matchfunction/countdown.go | 219 +++++++ .../internal/matchfunction/instant.go | 48 ++ .../internal/matchfunction/private_match.go | 3 + .../internal/repository/model/README.md | 26 + .../internal/repository/model/model.go | 162 ++++++ .../kurushimi/internal/repository/mongo.go | 164 ++++++ .../repository/mongo_pending_match.go | 100 ++++ .../repository/mongo_queued_player.go | 89 +++ .../internal/repository/mongo_ticket.go | 196 +++++++ .../kurushimi/internal/repository/public.go | 85 +++ .../repository/registrytypes/uuid_types.go | 58 ++ .../kurushimi/internal/service/matchmaker.go | 455 +++++++++++++++ services/kurushimi/internal/service/public.go | 61 ++ .../simplecontroller/simple_controller.go | 170 ++++++ .../internal/utils/grpczap/grpczap.go | 45 ++ .../internal/utils/kubernetes/client.go | 33 ++ .../kurushimi/internal/utils/kubeutils.go | 32 ++ .../kurushimi/internal/utils/math/math.go | 10 + services/kurushimi/internal/utils/pointer.go | 5 + .../internal/utils/protoutils/utils.go | 13 + .../internal/utils/runtime/runtime.go | 7 + services/kurushimi/run/config.yaml | 24 + .../run/config/gamemodes/120-block_sumo.json | 97 ++++ services/mc-player-service/go.mod | 1 + services/mc-player-service/go.sum | 3 +- services/message-handler/go.mod | 1 + services/message-handler/go.sum | 3 +- 45 files changed, 3959 insertions(+), 44 deletions(-) create mode 100644 services/kurushimi/Dockerfile create mode 100644 services/kurushimi/cmd/kurushimi/main.go create mode 100644 services/kurushimi/go.mod create mode 100644 services/kurushimi/go.sum create mode 100644 services/kurushimi/internal/app/kurushimi.go create mode 100644 services/kurushimi/internal/config/global.go create mode 100644 services/kurushimi/internal/director/director.go create mode 100644 services/kurushimi/internal/gsallocation/common.go create mode 100644 services/kurushimi/internal/gsallocation/selector/common.go create mode 100644 services/kurushimi/internal/gsallocation/selector/game_based.go create mode 100644 services/kurushimi/internal/gsallocation/selector/player_based.go create mode 100644 services/kurushimi/internal/kafka/consumer.go create mode 100644 services/kurushimi/internal/kafka/writer.go create mode 100644 services/kurushimi/internal/matchfunction/common.go create mode 100644 services/kurushimi/internal/matchfunction/countdown.go create mode 100644 services/kurushimi/internal/matchfunction/instant.go create mode 100644 services/kurushimi/internal/matchfunction/private_match.go create mode 100644 services/kurushimi/internal/repository/model/README.md create mode 100644 services/kurushimi/internal/repository/model/model.go create mode 100644 services/kurushimi/internal/repository/mongo.go create mode 100644 services/kurushimi/internal/repository/mongo_pending_match.go create mode 100644 services/kurushimi/internal/repository/mongo_queued_player.go create mode 100644 services/kurushimi/internal/repository/mongo_ticket.go create mode 100644 services/kurushimi/internal/repository/public.go create mode 100644 services/kurushimi/internal/repository/registrytypes/uuid_types.go create mode 100644 services/kurushimi/internal/service/matchmaker.go create mode 100644 services/kurushimi/internal/service/public.go create mode 100644 services/kurushimi/internal/simplecontroller/simple_controller.go create mode 100644 services/kurushimi/internal/utils/grpczap/grpczap.go create mode 100644 services/kurushimi/internal/utils/kubernetes/client.go create mode 100644 services/kurushimi/internal/utils/kubeutils.go create mode 100644 services/kurushimi/internal/utils/math/math.go create mode 100644 services/kurushimi/internal/utils/pointer.go create mode 100644 services/kurushimi/internal/utils/protoutils/utils.go create mode 100644 services/kurushimi/internal/utils/runtime/runtime.go create mode 100644 services/kurushimi/run/config.yaml create mode 100644 services/kurushimi/run/config/gamemodes/120-block_sumo.json diff --git a/go.work b/go.work index b1093e6..53bca9d 100644 --- a/go.work +++ b/go.work @@ -4,6 +4,7 @@ use ( . ./libraries/test ./services/game-player-data + ./services/kurushimi ./services/mc-player-service ./services/message-handler ) diff --git a/go.work.sum b/go.work.sum index a622414..6511b0a 100644 --- a/go.work.sum +++ b/go.work.sum @@ -1,3 +1,5 @@ +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.31.0-20230802163732-1c33ebd9ecfa.1 h1:tdpHgTbmbvEIARu+bixzmleMi14+3imnpoFXz+Qzjp4= +buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go v1.31.0-20230802163732-1c33ebd9ecfa.1/go.mod h1:xafc+XIsTxTy76GJQ1TKgvJWsSugFBqMaN27WhUblew= cel.dev/expr v0.16.0 h1:yloc84fytn4zmJX2GU3TkXGsaieaV7dQ057Qs4sIG2Y= cel.dev/expr v0.16.0/go.mod h1:TRSuuV7DlVCE/uwv5QbAiW/v8l5O8C4eEPHeu7gf7Sg= cloud.google.com/go v0.110.10/go.mod h1:v1OoFqYxiBkUrruItNM3eT4lLByNjxmJSV/xDKJNnic= @@ -47,6 +49,8 @@ cloud.google.com/go/certificatemanager v1.7.5 h1:UMBr/twXvH3jcT5J5/YjRxf2tvwTYIf cloud.google.com/go/certificatemanager v1.7.5/go.mod h1:uX+v7kWqy0Y3NG/ZhNvffh0kuqkKZIXdvlZRO7z0VtM= cloud.google.com/go/channel v1.17.5 h1:/omiBnyFjm4S1ETHoOmJbL7LH7Ljcei4rYG6Sj3hc80= cloud.google.com/go/channel v1.17.5/go.mod h1:FlpaOSINDAXgEext0KMaBq/vwpLMkkPAw9b2mApQeHc= +cloud.google.com/go/cloudbuild v1.13.0 h1:YBbAWcvE4x6xPWTyS+OU4eiUpz5rCS3VCM/aqmfddPA= +cloud.google.com/go/cloudbuild v1.13.0/go.mod h1:lyJg7v97SUIPq4RC2sGsz/9tNczhyv2AjML/ci4ulzU= cloud.google.com/go/cloudbuild v1.15.1 h1:ZB6oOmJo+MTov9n629fiCrO9YZPOg25FZvQ7gIHu5ng= cloud.google.com/go/cloudbuild v1.15.1/go.mod h1:gIofXZSu+XD2Uy+qkOrGKEx45zd7s28u/k8f99qKals= cloud.google.com/go/clouddms v1.7.4 h1:Sr0Zo5EAcPQiCBgHWICg3VGkcdS/LLP1d9SR7qQBM/s= @@ -162,6 +166,8 @@ cloud.google.com/go/memcache v1.10.5 h1:yeDv5qxRedFosvpMSEswrqUsJM5OdWvssPHFliNF cloud.google.com/go/memcache v1.10.5/go.mod h1:/FcblbNd0FdMsx4natdj+2GWzTq+cjZvMa1I+9QsuMA= cloud.google.com/go/metastore v1.13.4 h1:dR7vqWXlK6IYR8Wbu9mdFfwlVjodIBhd1JRrpZftTEg= cloud.google.com/go/metastore v1.13.4/go.mod h1:FMv9bvPInEfX9Ac1cVcRXp8EBBQnBcqH6gz3KvJ9BAE= +cloud.google.com/go/monitoring v1.15.1 h1:65JhLMd+JiYnXr6j5Z63dUYCuOg770p8a/VC+gil/58= +cloud.google.com/go/monitoring v1.15.1/go.mod h1:lADlSAlFdbqQuwwpaImhsJXu1QSdd3ojypXrFSMr2rM= cloud.google.com/go/monitoring v1.18.0 h1:NfkDLQDG2UR3WYZVQE8kwSbUIEyIqJUPl+aOQdFH1T4= cloud.google.com/go/monitoring v1.18.0/go.mod h1:c92vVBCeq/OB4Ioyo+NbN2U7tlg5ZH41PZcdvfc+Lcg= cloud.google.com/go/networkconnectivity v1.14.4 h1:GBfXFhLyPspnaBE3nI/BRjdhW8vcbpT9QjE/4kDCDdc= @@ -245,6 +251,8 @@ cloud.google.com/go/texttospeech v1.7.5 h1:dxY2Q5mHCbrGa3oPR2O3PCicdnvKa1JmwGQK3 cloud.google.com/go/texttospeech v1.7.5/go.mod h1:tzpCuNWPwrNJnEa4Pu5taALuZL4QRRLcb+K9pbhXT6M= cloud.google.com/go/tpu v1.6.5 h1:C8YyYda8WtNdBoCgFwwBzZd+S6+EScHOxM/z1h0NNp8= cloud.google.com/go/tpu v1.6.5/go.mod h1:P9DFOEBIBhuEcZhXi+wPoVy/cji+0ICFi4TtTkMHSSs= +cloud.google.com/go/trace v1.10.1 h1:EwGdOLCNfYOOPtgqo+D2sDLZmRCEO1AagRTJCU6ztdg= +cloud.google.com/go/trace v1.10.1/go.mod h1:gbtL94KE5AJLH3y+WVpfWILmqgc6dXcqgNXdOPAQTYk= cloud.google.com/go/trace v1.10.5 h1:0pr4lIKJ5XZFYD9GtxXEWr0KkVeigc3wlGpZco0X1oA= cloud.google.com/go/trace v1.10.5/go.mod h1:9hjCV1nGBCtXbAE4YK7OqJ8pmPYSxPA0I67JwRd5s3M= cloud.google.com/go/translate v1.10.1 h1:upovZ0wRMdzZvXnu+RPam41B0mRJ+coRXFP2cYFJ7ew= @@ -267,17 +275,33 @@ cloud.google.com/go/websecurityscanner v1.6.5 h1:YqWZrZYabG88TZt7364XWRJGhxmxhon cloud.google.com/go/websecurityscanner v1.6.5/go.mod h1:QR+DWaxAz2pWooylsBF854/Ijvuoa3FCyS1zBa1rAVQ= cloud.google.com/go/workflows v1.12.4 h1:uHNmUiatTbPQ4H1pabwfzpfEYD4BBnqDHqMm2IesOh4= cloud.google.com/go/workflows v1.12.4/go.mod h1:yQ7HUqOkdJK4duVtMeBCAOPiN1ZF1E9pAMX51vpwB/w= +contrib.go.opencensus.io/exporter/prometheus v0.1.0 h1:SByaIoWwNgMdPSgl5sMqM2KDE5H/ukPWBRo314xiDvg= +contrib.go.opencensus.io/exporter/prometheus v0.1.0/go.mod h1:cGFniUXGZlKRjzOyuZJ6mgB+PgBcCIa79kEKR8YCW+A= +contrib.go.opencensus.io/exporter/stackdriver v0.8.0 h1:HBofEuVSbRgTTAQmE8y9skbElwGgBs1ecH7fxJE7Nrg= +contrib.go.opencensus.io/exporter/stackdriver v0.8.0/go.mod h1:hNe5qQofPbg6bLQY5wHCvQ7o+2E5P8PkegEuQ+MyRw0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9 h1:VpgP7xuJadIUuKccphEpTJnWhS2jkQyMt6Y7pJCD7fY= +fortio.org/fortio v1.3.1 h1:XScQoLYEdMmlmPyueDwEZxrMOaoX9V9juSIkxkZf5zM= +fortio.org/fortio v1.3.1/go.mod h1:Go0fRqoPJ1xy5JOWcS23jyF58byVZxFyEePYsGmCR0k= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802 h1:1BDTz0u9nC3//pOCMdNH+CiXJVYJh5UQNCOBG7jbELc= github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4= github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46 h1:lsxEuwrXEAokXB9qhlbKWPpo3KMLZQ5WB5WLQRW1uq0= +github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ= +github.com/PuerkitoBio/purell v1.1.1 h1:WEQqlqaGbrPkxLJWfBwQmfEAE1Z7ONdDLqrN38tNFfI= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 h1:d+Bc7a5rLufV/sSk/8dngufqelfh6jnri85riMAaF/M= +github.com/ahmetb/gen-crd-api-reference-docs v0.3.0 h1:+XfOU14S4bGuwyvCijJwhhBIjYN+YXS18jrCY2EzJaY= +github.com/ahmetb/gen-crd-api-reference-docs v0.3.0/go.mod h1:TdjdkYhlOifCQWPs1UdTma97kQQMozf5h26hTuG70u8= github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 h1:JYp7IbQjafoB+tBA3gMyHYHrpOtNuDiK/uB5uXxq5wM= github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4 h1:Hs82Z41s6SdL1CELW+XaDYmOH4hkBN4/N9og/AsOv7E= github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwcg= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230512164433-5d1fd1a340c9 h1:goHVqTbFX3AIo0tzGr14pgfAW2ZfPChKO21Z9MGf/gk= +github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20230512164433-5d1fd1a340c9/go.mod h1:pSwJ0fSY5KhvocuWSx4fz3BA8OrA1bQn+K1Eli3BRwM= github.com/apache/arrow/go/v14 v14.0.2 h1:N8OkaJEOfI3mEZt07BIkvo4sC6XDbL+48MBPWO5IONw= github.com/apache/arrow/go/v14 v14.0.2/go.mod h1:u3fgh3EdgN/YQ8cVQRguVW3R+seMybFg8QBQ5LU+eBY= github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e h1:QEF07wC0T1rKkctt1RINW/+RMTVmiwxETico2l3gxJA= @@ -288,6 +312,12 @@ github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+ github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= github.com/armon/go-radix v1.0.0 h1:F4z6KzEeeQIMeLFa97iZU6vupzoecKdU5TX24SNppXI= github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5 h1:0CwZNZbxp69SHPdPJAN/hZIm0C4OItdklCFmMRWYpio= +github.com/armon/go-socks5 v0.0.0-20160902184237-e75332964ef5/go.mod h1:wHh0iHkYZB8zMSxRWpUBQtwG5a7fFgvEO+odwuTv2gs= +github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a h1:idn718Q4B6AGu/h5Sxe66HYVdqdGu2l9Iebqhi/AEoA= +github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= +github.com/aws/aws-sdk-go v1.44.176 h1:mxcfI3IWHemX+5fEKt5uqIS/hdbaR7qzGfJYo5UyjJE= +github.com/aws/aws-sdk-go v1.44.176/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= @@ -295,6 +325,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/bgentry/speakeasy v0.1.0 h1:ByYyxL9InA1OWqxJqqp2A5pYHUrCiAL6K3J+LKSsQkY= github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bufbuild/protovalidate-go v0.2.1 h1:pJr07sYhliyfj/STAM7hU4J3FKpVeLVKvOBmOTN8j+s= +github.com/bufbuild/protovalidate-go v0.2.1/go.mod h1:e7XXDtlxj5vlEyAgsrxpzayp4cEMKCSSb8ZCkin+MVA= github.com/census-instrumentation/opencensus-proto v0.4.1 h1:iKLQ0xPNFxR/2hzXZMrBo8f1j86j5WHzznCCQxV/b8g= github.com/census-instrumentation/opencensus-proto v0.4.1/go.mod h1:4T9NM4+4Vw91VeyqjLS6ao50K5bOcLKN6Q42XnYaRYw= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= @@ -309,6 +341,7 @@ github.com/circonus-labs/circonusllhist v0.1.3 h1:TJH+oke8D16535+jHExHj4nQvzlZrj github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= github.com/client9/misspell v0.3.4 h1:ta993UF76GwbvJcIo3Y68y/M3WxlpEHPWIGDkJYwzJI= github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f h1:WBZRG4aNOuI15bLRrCgN8fCq8E5Xuty6jGbmSNEvSsU= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe h1:QQ3GSy+MqSHxm/d8nCtnAiZdYFd45cYZPs8vOOIYKfk= github.com/cncf/udpa/go v0.0.0-20220112060539-c52dc94e7fbe/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= github.com/cncf/xds/go v0.0.0-20240723142845-024c85f92f20 h1:N+3sFI5GUjRKBi+i0TxYVST9h4Ie192jJWpHvthBBgg= @@ -318,7 +351,6 @@ github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3Ee github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/creack/pty v1.1.9 h1:uDmaGzcdjhF4i/plgjmEsriH11Y0o7RKapEf/LDaM3w= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= github.com/emortalmc/proto-specs/gen/go v0.0.0-20231007222717-fa39fcfe52f5/go.mod h1:se+tHcK9FWxeadkxLF5uj+SPauEye0X+Iq6cGczXGJY= @@ -344,7 +376,6 @@ github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9 github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= github.com/go-logfmt/logfmt v0.5.0 h1:TrB8swr/68K7m9CcGut2g3UOihhbcbiMAYiuTXdEih4= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= github.com/go-logr/logr v1.4.1/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= @@ -354,23 +385,37 @@ github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MG github.com/godbus/dbus/v5 v5.0.4 h1:9349emZab16e7zQvpmsbtjc18ykshndd8y2PG3sgJbA= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= github.com/golang/glog v1.2.2/go.mod h1:6AhwSGph0fcJtXVM/PEHPqZlFeoLxhs7/t5UDAwmO+w= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1 h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8= github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= +github.com/google/cel-go v0.17.1 h1:s2151PDGy/eqpCI80/8dl4VL3xTkqI/YubXLXCFw0mw= +github.com/google/cel-go v0.17.1/go.mod h1:HXZKzB0LXqer5lHHgfWAnlYwJaQBDKMjxjulNQzhwhY= github.com/google/flatbuffers v23.5.26+incompatible h1:M9dgRyhJemaM4Sw8+66GHBu8ioaQmyPLg1b8VwK5WJg= github.com/google/flatbuffers v23.5.26+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-pkcs11 v0.2.1-0.20230907215043-c6f79328ddf9 h1:OF1IPgv+F4NmqmJ98KTjdN97Vs1JxDPB3vbmYzV2dpk= github.com/google/go-pkcs11 v0.2.1-0.20230907215043-c6f79328ddf9/go.mod h1:6eQoGcuNJpa7jnd5pMGdkSaQpNDYvPlXWMcjXXThLlY= github.com/google/gofuzz v1.0.0 h1:A8PeW59pxE9IoFRqBp37U+mSNaQoZ46F1f0f863XSXw= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no= github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw= github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= @@ -378,6 +423,8 @@ github.com/google/pprof v0.0.0-20201218002935-b9804c9f04c2 h1:LR89qFljJ48s990kEK github.com/google/renameio v0.1.0 h1:GOZbcHa3HfsPKPlmyPyN2KEohoMXOhdMbHrvbpl2QaA= github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= github.com/google/s2a-go v0.1.7/go.mod h1:50CgR4k1jNlWBu4UfS4AcfhVe1r6pdZPygJ3R8F0Qdw= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.3.2 h1:Vie5ybvEvT75RniqhfFxPRy3Bf7vr3h0cechB90XaQs= github.com/googleapis/enterprise-certificate-proxy v0.3.2/go.mod h1:VLSiSSBs/ksPL8kq3OBOQ6WRI2QnaFynd1DCjZ62+V0= @@ -388,6 +435,10 @@ github.com/googleapis/gax-go/v2 v2.12.3 h1:5/zPPDvw8Q1SuXjrqrZslrqT7dL/uJT2CQii/ github.com/googleapis/gax-go/v2 v2.12.3/go.mod h1:AKloxT6GtNbaLm8QTNSidHUVsHYcBHwWRvkNFJUQcS4= github.com/googleapis/google-cloud-go-testing v0.0.0-20210719221736-1c9a4c676720 h1:zC34cGQu69FG7qzJ3WiKW244WfhDC3xxYMeNOX2gtUQ= github.com/googleapis/google-cloud-go-testing v0.0.0-20210719221736-1c9a4c676720/go.mod h1:dvDLG8qkwmyD9a/MJJN3XJcT3xFxOKAvTZGvuZmac9g= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7 h1:pdN6V1QBWetyv/0+wjACpqVH+eVULgEjkurDLq3goeM= +github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= @@ -431,6 +482,7 @@ github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/C github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI= github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y= @@ -441,19 +493,20 @@ github.com/hashicorp/memberlist v0.5.0 h1:EtYPN8DpAURiapus508I4n9CzHs2W+8NZGbmmR github.com/hashicorp/memberlist v0.5.0/go.mod h1:yvyXLpo0QaGE59Y7hDTsTzDD25JYBZ4mHgHUZ8lrOI0= github.com/hashicorp/serf v0.10.1 h1:Z1H2J60yRKvfDYAOZLd2MU0ND4AH/WDz7xYHDWQsIPY= github.com/hashicorp/serf v0.10.1/go.mod h1:yL2t6BqATOLGc5HF7qbFkTfXoPIY0WZdWHfEvMqbG+4= +github.com/heptiolabs/healthcheck v0.0.0-20171201210846-da5fdee475fb h1:OUNeTAbBEEv2RVHkuBtqjnM/gtWD+POdNYfIjY1Bg5A= +github.com/heptiolabs/healthcheck v0.0.0-20171201210846-da5fdee475fb/go.mod h1:NtmN9h8vrTveVQRLHcX2HQ5wIPBDCsZ351TGbZWgg38= github.com/iancoleman/strcase v0.3.0 h1:nTXanmYxhfFAMjZL34Ov6gkzEsSJZ5DbhxWjvSASxEI= github.com/iancoleman/strcase v0.3.0/go.mod h1:iwCmte+B7n89clKwxIoIXy/HfoL7AsD47ZCWhYzw7ho= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639 h1:mV02weKRL81bEnm8A0HT1/CAelMQDBuQIfLw8n+d6xI= +github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= +github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/jstemmer/go-junit-report v0.9.1 h1:6QPYqodiu3GuPL+7mfx+NwDdp2eTkp9IfEUpgAwUN0o= github.com/julienschmidt/httprouter v1.2.0 h1:TDTW5Yz1mjftljbcKqRcrYhd4XeOoI98t+9HbQbYf7g= github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= github.com/kisielk/errcheck v1.5.0 h1:e8esj/e4R+SAOwFwN+n3zr0nYeCyeweozKfO23MvHzY= github.com/kisielk/gotool v1.0.0 h1:AV2c/EiW3KqPNT9ZKl07ehoAGi4C5/01Cfbblndcapg= -github.com/klauspost/compress v1.17.0/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk= @@ -481,6 +534,10 @@ github.com/mattn/go-isatty v0.0.17 h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPn github.com/mattn/go-isatty v0.0.17/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= +github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= +github.com/mennanov/fmutils v0.2.0 h1:Hw/iuQPdKtiB2B9YYh+NX8iv7U7eQu1rICPjr8NvxSo= +github.com/mennanov/fmutils v0.2.0/go.mod h1:DE+qeI9Xy5s1GA4trgq8H26jr5DgJ4a9+0D1DPVCqyk= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= @@ -491,15 +548,14 @@ github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXx github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/moby/spdystream v0.2.0 h1:cjW1zVyyoiM0T7b6UoySUFqzXMoqRckQtXwGPiBhOM8= +github.com/moby/spdystream v0.2.0/go.mod h1:f7i0iNDQJ059oMTcWxx8MA/zKFIuD/lY+0GqbN2Wy8c= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223 h1:F9x/1yl3T2AeKLr2AMdilSD8+f9bvMnNN8VS5iDtovc= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f h1:y5//uYreIhSUg3J1GEMiLbxo1LJaP8RfCpH6pymGZus= +github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f/go.mod h1:ZdcZmHo+o7JKHSa8/e818NopupXU1YMK5fe1lsApnBw= github.com/nats-io/jwt/v2 v2.4.1 h1:Y35W1dgbbz2SQUYDPCaclXcuqleVmpbRa7646Jf2EX4= github.com/nats-io/jwt/v2 v2.4.1/go.mod h1:24BeQtRwxRV8ruvC4CojXlx/WQ/VjuwlYiH+vu/+ibI= github.com/nats-io/nats.go v1.34.0 h1:fnxnPCNiwIG5w08rlMcEKTUw4AV/nKyGCOJE8TdhSPk= @@ -512,12 +568,13 @@ github.com/opentracing/opentracing-go v1.1.0 h1:pWlfV3Bxv7k65HYwkikxat0+s3pV4bsq github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pelletier/go-toml/v2 v2.1.0/go.mod h1:tJU2Z3ZkXwnxa4DPO899bsyIoywizdUvyaeZurnPPDc= +github.com/pelletier/go-toml v1.2.0 h1:T5zMGML61Wp+FlcbWjRDT7yAxhJNAiPPLOFECq181zc= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/peterbourgon/diskv v2.0.1+incompatible h1:UBdAOUP5p4RWqPBg048CAvpKN+vxiaj6gdUUzhl4XmI= +github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e h1:aoZm08cpOy4WuID//EZDgcC4zIxODThtZNPirFr42+A= github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/sftp v1.13.6 h1:JFZT4XbOU7l77xGSpOdW+pwIMqP044IyjXX6FGyEKFo= github.com/pkg/sftp v1.13.6/go.mod h1:tz1ryNURKu77RL+GuCzmoJYxQczL3wLNNpPWagdg4Qk= github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 h1:GFCKgmp0tecUJ0sJuv4pzYCqS9+RGSn52M3FUwPs+uo= @@ -530,21 +587,33 @@ github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5Fsn github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= github.com/prometheus/client_golang v1.11.1 h1:+4eQaD7vAZ6DsfsxB15hbE0odUjGI5ARs9yskGu1v4s= github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.16.0 h1:yk/hx9hDbrGHovbci4BY+pRMfSuuat626eFsHb7tmT8= +github.com/prometheus/client_golang v1.16.0/go.mod h1:Zsulrv/L9oM40tJ7T815tM89lFEugiJ9HzIqaAx4LKc= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4 h1:gQz4mCbXsO+nc9n1hCxHcGA3Zx3Eo+UHZoInFGUIXNM= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.4.0 h1:5lQXD3cAg1OXBf4Wq03gTrXHeaV0TQvGfUooCfx1yqY= +github.com/prometheus/client_model v0.4.0/go.mod h1:oMQmHW1/JoDwqLtg57MGgP/Fb1CJEYF2imWWhWtMkYU= github.com/prometheus/client_model v0.6.0 h1:k1v3CzpSRUTrKMppY35TLwPvxHqBu0bYgxZzqGIgaos= github.com/prometheus/client_model v0.6.0/go.mod h1:NTQHnmxFpouOD0DpvP4XujX3CdOAGQPoaGhyTchlyt8= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= github.com/prometheus/common v0.26.0 h1:iMAkS2TDoNWnKM+Kopnx/8tnEStIfpYA0ur0xQzzhMQ= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.44.0 h1:+5BrQJwiBB9xsMygAB3TNvpQKOwlkc25LbISbrdOOfY= +github.com/prometheus/common v0.44.0/go.mod h1:ofAIvZbQ1e/nugmZGz4/qCb9Ap1VoSTIO7x0VV9VvuY= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= github.com/prometheus/procfs v0.6.0 h1:mxy4L2jP6qMonqmq+aTtOx1ifVWUgG/TAmntgbh3xv4= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.10.1 h1:kYK1Va/YMlutzCGazswoHKo//tZVlFpKYh+PymziUAg= +github.com/prometheus/procfs v0.10.1/go.mod h1:nwNm2aOCAYw8uTR/9bWRREkZFxAUcWzPHWJq+XBB/FM= +github.com/rogpeppe/fastuuid v1.2.0 h1:Ppwyp6VYCF1nvBTXL3trRso7mXMlRrw9ooo375wvi2s= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f h1:UFr9zpz4xgTnIE5yIMtWAMngCdZ9p/+q6lTbgelo80M= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sagikazarmark/crypt v0.19.0 h1:WMyLTjHBo64UvNcWqpzY3pbZTYgnemZU8FBZigKc42E= @@ -552,17 +621,28 @@ github.com/sagikazarmark/crypt v0.19.0/go.mod h1:c6vimRziqqERhtSe0MhIvzE1w54FrCH github.com/sagikazarmark/locafero v0.3.0/go.mod h1:w+v7UsPNFwzF1cHuOajOOzoq4U7v/ig1mpRjqV+Bu1U= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/segmentio/kafka-go v0.4.39/go.mod h1:T0MLgygYvmqmBvC+s8aCcbVNfJN4znVne5j0Pzowp/Q= github.com/segmentio/kafka-go v0.4.46/go.mod h1:HjF6XbOKh0Pjlkr5GVZxt6CsjjwnmhVOfURM5KMd8qg= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/spf13/afero v1.10.0/go.mod h1:UBogFpq8E9Hx+xc5CNTTEpTnuHVmXDwZcZcE1eb/UhQ= +github.com/spf13/jwalterweatherman v1.0.0 h1:XHEdyB+EcvlqZamSM4ZOMGlc93t6AcsBEu9Gc1vn7yk= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/viper v1.17.0/go.mod h1:BmMMMLQXSbcHK6KAOiFLz0l5JHrU89OdIRHvsk0+yVI= +github.com/stoewer/go-strcase v1.3.0 h1:g0eASXYtp+yvN9fK8sH94oCIk0fau9uV1/ZdJ0AVEzs= +github.com/stoewer/go-strcase v1.3.0/go.mod h1:fAH5hQ5pehh+j3nZfvwdk2RgEgQjAoM8wodgtPmh1xo= github.com/stretchr/objx v0.5.2 h1:xuMeJ0Sdp5ZMRXx/aWO6RZxdr3beISkG5/G/aIRr3pY= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= github.com/stretchr/testify v1.7.5/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75 h1:6fotK7otjonDflCTK0BCfls4SPy3NcCVb5dqqmbRknE= +github.com/tmc/grpc-websocket-proxy v0.0.0-20220101234140-673ab2c3ae75/go.mod h1:KO6IkyS8Y3j8OdNO85qEYBsRPuteD+YciPomcXdrMnk= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926 h1:G3dpKMzFDjgEh2q1Z7zUUtKa8ViPtH+ocF0bE0g00O8= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= +github.com/xdg/scram v1.0.5 h1:TuS0RFmt5Is5qm9Tm2SoD89OPqe4IRiFtyFY4iwWXsw= +github.com/xdg/scram v1.0.5/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= +github.com/xdg/stringprep v1.0.3 h1:cmL5Enob4W83ti/ZHuZLuKD/xqJfus4fVPwE+/BDm+4= +github.com/xdg/stringprep v1.0.3/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13 h1:fVcFKWvrslecOb/tg+Cc05dkeYx540o0FuFt3nUVDoE= github.com/zeebo/xxh3 v1.0.2 h1:xZmwmqxHZA8AI603jOQ0tMqmBr9lPeFwGg6d+xy9DC0= @@ -606,16 +686,18 @@ go.opentelemetry.io/proto/otlp v1.0.0 h1:T0TX0tmXU8a3CbNXzEKGeU5mIVOdf0oykP+u2lI go.opentelemetry.io/proto/otlp v1.0.0/go.mod h1:Sy6pihPLfYHkr3NkUbEhGHFhINUSI/v80hjKIs5JXpM= go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE= go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= +go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= -go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= +go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg= golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw= golang.org/x/crypto v0.16.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU= -golang.org/x/crypto v0.21.0/go.mod h1:0BP7YvVV9gBbVKyeTG0Gyn+gZm94bibOW5BjDEYAOMs= golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= golang.org/x/image v0.0.0-20190802002840-cff245a6509b h1:+qEpEAPhDZ1o0x3tHzZTQDArnOixOzGD9HUJfcg0mb4= golang.org/x/lint v0.0.0-20190930215403-16217165b5de h1:5hukYrvBGR8/eNkX5mdUezrA6JiaEZDtJb9Ei+1LlBs= @@ -625,26 +707,25 @@ golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= +golang.org/x/net v0.0.0-20220706163947-c90051bbdb60/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco= golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc= golang.org/x/net v0.19.0/go.mod h1:CfAk/cbD4CthTvqiEl8NpboMuiuOYsAr/7NOjZJtv1U= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44= golang.org/x/net v0.22.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= -golang.org/x/net v0.23.0/go.mod h1:JKghWKKOSdJwpW2GEx0Ja7fmaKnMsbu+MWVZTokSYmg= golang.org/x/net v0.26.0/go.mod h1:5YKkiSynbBIh3p6iOc/vibscux0x38BZDkn8sCUPxHE= -golang.org/x/oauth2 v0.15.0/go.mod h1:q48ptWNTY5XWf+JNten23lcvHpLJ0ZSxF5ttTHKVCAM= golang.org/x/oauth2 v0.16.0/go.mod h1:hqZ+0LWXsiVoZpeld6jVt06P3adbS2Uu911W1SsJv2o= golang.org/x/oauth2 v0.17.0/go.mod h1:OzPDGQiuQMguemayvdylqddI7qcD9lnSDb+1FiwQ5HA= golang.org/x/oauth2 v0.18.0/go.mod h1:Wf7knwG0MPoWIMMBgFlEaSUDaKskp0dCfrlJRJXbBi8= -golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= -golang.org/x/sync v0.5.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -654,6 +735,8 @@ golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -668,25 +751,19 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.21.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.23.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2 h1:IRJeR9r1pYWsHKTRe/IInb7lYvbBVIqOgsX/u0mbOWY= golang.org/x/telemetry v0.0.0-20240228155512-f48c80bd79b2/go.mod h1:TeRTkGYfJXctD9OcfyVLyj2J3IxLnKwHJR8f4D8a3YE= golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= golang.org/x/term v0.23.0/go.mod h1:DgV24QBUrK6jhZXl+20l6UWznPlwAHm1Q1mGHtydmSk= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= -golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= -golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 h1:H2TDz8ibqkAF6YGhCdN3jS9O0/s90v0rJh3X/OLHEUk= golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= @@ -702,25 +779,22 @@ google.golang.org/api v0.171.0 h1:w174hnBPqut76FzW5Qaupt7zY8Kql6fiVjgys4f58sU= google.golang.org/api v0.171.0/go.mod h1:Hnq5AHm4OTMt2BUVjael2CWZFD6vksJdWCWiUAmjC9o= google.golang.org/appengine v1.6.8 h1:IhEN5q69dyKagZPYMSdIjS2HqprW324FRQZJcGqPAsM= google.golang.org/appengine v1.6.8/go.mod h1:1jJ3jBArFh5pcgW8gCtRJnepW8FzD1V44FJffLiz/Ds= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= google.golang.org/genproto v0.0.0-20230110181048-76db0878b65f/go.mod h1:RGgjbofJ8xD9Sq1VVhDM1Vok1vRONV+rg+CjzG4SZKM= -google.golang.org/genproto v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:J7XzRzVy1+IPwWHZUzoD0IccYZIrXILAQpc+Qy9CMhY= google.golang.org/genproto v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:+Rvu7ElI+aLzyDQhpHMFMMltsD6m7nqpuWDd2CwJw3k= google.golang.org/genproto v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:cc8bqMqtv9gMOr0zHg2Vzff5ULhhL2IXP4sbcn32Dro= google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9 h1:9+tzLLstTlPTRyJTh+ah5wIMsBW5c4tQwGTN3thOW9Y= google.golang.org/genproto v0.0.0-20240213162025-012b6fc9bca9/go.mod h1:mqHbVIp48Muh7Ywss/AD6I5kNVKZMmAa/QEW58Gxp2s= -google.golang.org/genproto/googleapis/api v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:0xJLfVdJqpAPl8tDg1ujOCGzx6LFLttXT5NhllGOXY4= google.golang.org/genproto/googleapis/api v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:4jWUdICTdgc3Ibxmr8nAJiiLHwQBY0UI0XZcEMaFKaA= google.golang.org/genproto/googleapis/api v0.0.0-20240205150955-31a09d347014/go.mod h1:rbHMSEDyoYX62nRVLOCc4Qt1HbsdytAYoVwgjiOhF3I= google.golang.org/genproto/googleapis/api v0.0.0-20240221002015-b0ce06bbee7c/go.mod h1:5iCWqnniDlqZHrd3neWVTOwvh/v6s3232omMecelax8= google.golang.org/genproto/googleapis/api v0.0.0-20240304161311-37d4d3c04a78/go.mod h1:O1cOfN1Cy6QEYr7VxtjOyP5AdAuR0aJ/MYZaaof623Y= google.golang.org/genproto/googleapis/api v0.0.0-20240311132316-a219d84964c2/go.mod h1:O1cOfN1Cy6QEYr7VxtjOyP5AdAuR0aJ/MYZaaof623Y= -google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142/go.mod h1:d6be+8HhtEtucleCbxpPW9PA9XwISACu8nvpPqF0BVo= google.golang.org/genproto/googleapis/bytestream v0.0.0-20240314234333-6e1732d8331c h1:4z0DVWmDWWZ4OeQHLrb6lLBE3uCgSLs9DDA5Zb36DFg= google.golang.org/genproto/googleapis/bytestream v0.0.0-20240314234333-6e1732d8331c/go.mod h1:IN9OQUXZ0xT+26MDwZL8fJcYw+y99b0eYPA2U15Jt8o= google.golang.org/genproto/googleapis/rpc v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:KSqppvjFjtoCI+KGd4PELB0qLNxdJHRGqRI09mB6pQA= google.golang.org/genproto/googleapis/rpc v0.0.0-20231106174013-bbf56f31fb17/go.mod h1:oQ5rr10WTTMvP4A36n8JpR1OrO1BEiV4f78CneXZxkA= -google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f/go.mod h1:L9KNLi232K1/xB6f7AlSX692koaRnKaWSR0stBki0Yc= google.golang.org/genproto/googleapis/rpc v0.0.0-20240116215550-a9fa1716bcac/go.mod h1:daQN87bsDqDoe316QbbvX60nMoJQa4r6Ds0ZuoAe5yA= google.golang.org/genproto/googleapis/rpc v0.0.0-20240125205218-1f4bbc51befe/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s= google.golang.org/genproto/googleapis/rpc v0.0.0-20240205150955-31a09d347014/go.mod h1:SaPjaZGWb0lPqs6Ittu0spdfrOArqji4ZdeP5IC/9N4= @@ -729,6 +803,7 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20240304161311-37d4d3c04a78/go. google.golang.org/genproto/googleapis/rpc v0.0.0-20240311132316-a219d84964c2/go.mod h1:UCOku4NytXMJuLQE5VuqA5lX3PcHCBo8pxNyvkf4xBs= google.golang.org/genproto/googleapis/rpc v0.0.0-20240314234333-6e1732d8331c/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/genproto/googleapis/rpc v0.0.0-20240730163845-b1a4ccb954bf/go.mod h1:Ue6ibwXGpU+dqIcODieyLOcgj7z8+IcskoNIgZxtrFY= +google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= google.golang.org/grpc v1.54.0/go.mod h1:PUSEXI6iWghWaB6lXM4knEgpJNu2qUcKfDtNci3EC2g= google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= @@ -740,22 +815,38 @@ google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJai google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0 h1:M1YKkFIboKNieVO5DLUEVzQfGwJD30Nv2jfUgzb5UcE= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.32.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= +gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0 h1:FVCohIoYO7IJoDDVpV2pdq7SgrMH6wHnuTyrdrxJNoY= +gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0/go.mod h1:OdE7CF6DbADk7lN8LIKRzRJTTZXIjtWgA5THM5lhBAw= gopkg.in/alecthomas/kingpin.v2 v2.2.6 h1:jMFz6MfLP0/4fUyZle81rXUoxOBFi19VUFKVDOQfozc= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/errgo.v2 v2.1.0 h1:0vLT13EuvQ0hNvakwLuFZ/jYrLp5F3kcWHXdRggjCE8= +gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= +gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc h1:/hemPrYIhOhy8zYrNj+069zDB68us2sMGsfkFJO0iZs= honnef.co/go/tools v0.0.1-2020.1.4 h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8= +k8s.io/apiextensions-apiserver v0.28.6 h1:myB3iG/3v3jqCg28JDbOefu4sH2/erNEXgytRzJKBOo= +k8s.io/apiextensions-apiserver v0.28.6/go.mod h1:qlp6xRKBgyRhe5AYc81TQpLx4kLNK8/sGQUOwMkVjRk= +k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01 h1:pWEwq4Asjm4vjW7vcsmijwBhOr1/shsbSYiWXmNGlks= +k8s.io/gengo v0.0.0-20230829151522-9cce18d56c01/go.mod h1:FiNAH4ZV3gBg2Kwh89tzAEV2be7d5xI0vBa/VySYy3E= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= +k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= rsc.io/binaryregexp v0.2.0 h1:HfqmD5MEmC0zvwBuF187nq9mdnXjXsSivRiXN7SmRkE= rsc.io/quote/v3 v3.1.0 h1:9JKUTTIUgS6kzR9mK1YuGKv6Nl+DijDNIc0ghT58FaY= rsc.io/sampler v1.3.0 h1:7uVkIFmeBqHfdjD+gZwtXXI+RODJ2Wc4O7MPEh/QiW4= diff --git a/services/game-player-data/go.mod b/services/game-player-data/go.mod index 5daa217..51459b8 100644 --- a/services/game-player-data/go.mod +++ b/services/game-player-data/go.mod @@ -25,6 +25,7 @@ require ( github.com/montanaflynn/stats v0.7.1 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pierrec/lz4/v4 v4.1.18 // indirect + github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect diff --git a/services/game-player-data/go.sum b/services/game-player-data/go.sum index 7f874f4..70bdd0f 100644 --- a/services/game-player-data/go.sum +++ b/services/game-player-data/go.sum @@ -72,8 +72,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= diff --git a/services/kurushimi/Dockerfile b/services/kurushimi/Dockerfile new file mode 100644 index 0000000..f1dc4e5 --- /dev/null +++ b/services/kurushimi/Dockerfile @@ -0,0 +1,33 @@ +FROM --platform=$BUILDPLATFORM golang:1.23-alpine AS build + +ARG SERVICE_NAME=kurushimi + +WORKDIR /build + +# Copy sources +COPY . . + +WORKDIR /build/services/$SERVICE_NAME + +RUN go mod download + +WORKDIR /build + +ARG TARGETOS +ARG TARGETARCH + +RUN --mount=type=cache,target=/root/.cache/go-build \ + --mount=type=cache,target=/go/pkg \ + CGO_ENABLED=0 \ + GOOS=$TARGETOS \ + GOARCH=$TARGETARCH \ + go build -ldflags="-s -w" -o $SERVICE_NAME ./services/$SERVICE_NAME/cmd/$SERVICE_NAME + +FROM alpine + +ARG SERVICE_NAME=kurushimi + +WORKDIR /app + +COPY --from=build /build/$SERVICE_NAME /build/services/$SERVICE_NAME/run ./ +CMD ["./kurushimi"] \ No newline at end of file diff --git a/services/kurushimi/cmd/kurushimi/main.go b/services/kurushimi/cmd/kurushimi/main.go new file mode 100644 index 0000000..33f2311 --- /dev/null +++ b/services/kurushimi/cmd/kurushimi/main.go @@ -0,0 +1,29 @@ +package main + +import ( + "github.com/emortalmc/mono-services/services/kurushimi/internal/app" + "github.com/emortalmc/mono-services/services/kurushimi/internal/config" + "go.uber.org/zap" + "log" +) + +func main() { + cfg := config.LoadGlobalConfig() + + unsugared, err := createLogger(cfg) + if err != nil { + log.Fatal(err) + } + logger := unsugared.Sugar() + + app.Run(cfg, logger) +} + +func createLogger(cfg config.Config) (logger *zap.Logger, err error) { + if cfg.Development { + logger, err = zap.NewDevelopment() + } else { + logger, err = zap.NewProduction() + } + return +} diff --git a/services/kurushimi/go.mod b/services/kurushimi/go.mod new file mode 100644 index 0000000..c5fd603 --- /dev/null +++ b/services/kurushimi/go.mod @@ -0,0 +1,89 @@ +module github.com/emortalmc/mono-services/services/kurushimi + +go 1.23 + +require ( + agones.dev/agones v1.42.0 + github.com/emortalmc/live-config-parser/golang v0.0.0-20231228020729-d2b6294e5968 + github.com/emortalmc/proto-specs/gen/go v0.0.0-20240927103241-2584fd28e0f9 + github.com/google/uuid v1.6.0 + github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.1 + github.com/spf13/pflag v1.0.5 + github.com/spf13/viper v1.19.0 + go.mongodb.org/mongo-driver v1.17.1 + go.uber.org/zap v1.27.0 + golang.org/x/exp v0.0.0-20230905200255-921286631fa9 + google.golang.org/grpc v1.67.1 + google.golang.org/protobuf v1.35.1 + k8s.io/apimachinery v0.29.0 + k8s.io/client-go v0.29.0 +) + +require ( + github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect + github.com/emicklei/go-restful/v3 v3.11.0 // indirect + github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/go-logr/logr v1.4.1 // indirect + github.com/go-openapi/jsonpointer v0.19.6 // indirect + github.com/go-openapi/jsonreference v0.20.2 // indirect + github.com/go-openapi/spec v0.19.5 // indirect + github.com/go-openapi/swag v0.22.3 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.4 // indirect + github.com/golang/snappy v0.0.4 // indirect + github.com/google/gnostic-models v0.6.8 // indirect + github.com/google/gofuzz v1.2.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.17.1 // indirect + github.com/hashicorp/hcl v1.0.0 // indirect + github.com/imdario/mergo v0.3.6 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/compress v1.17.2 // indirect + github.com/magiconair/properties v1.8.7 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/mitchellh/hashstructure/v2 v2.0.2 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/montanaflynn/stats v0.7.1 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/pelletier/go-toml/v2 v2.2.2 // indirect + github.com/pierrec/lz4/v4 v4.1.18 // indirect + github.com/pkg/errors v0.9.1 // indirect + github.com/sagikazarmark/locafero v0.4.0 // indirect + github.com/sagikazarmark/slog-shim v0.1.0 // indirect + github.com/segmentio/kafka-go v0.4.47 // indirect + github.com/sirupsen/logrus v1.9.0 // indirect + github.com/sourcegraph/conc v0.3.0 // indirect + github.com/spf13/afero v1.11.0 // indirect + github.com/spf13/cast v1.6.0 // indirect + github.com/subosito/gotenv v1.6.0 // indirect + github.com/xdg-go/pbkdf2 v1.0.0 // indirect + github.com/xdg-go/scram v1.1.2 // indirect + github.com/xdg-go/stringprep v1.0.4 // indirect + github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 // indirect + go.uber.org/multierr v1.10.0 // indirect + golang.org/x/crypto v0.26.0 // indirect + golang.org/x/net v0.28.0 // indirect + golang.org/x/oauth2 v0.22.0 // indirect + golang.org/x/sync v0.8.0 // indirect + golang.org/x/sys v0.24.0 // indirect + golang.org/x/term v0.23.0 // indirect + golang.org/x/text v0.17.0 // indirect + golang.org/x/time v0.5.0 // indirect + gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect + gopkg.in/fsnotify.v1 v1.4.7 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/ini.v1 v1.67.0 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/api v0.29.0 // indirect + k8s.io/klog/v2 v2.110.1 // indirect + k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 // indirect + k8s.io/utils v0.0.0-20230726121419-3b25d923346b // indirect + sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect + sigs.k8s.io/yaml v1.3.0 // indirect +) diff --git a/services/kurushimi/go.sum b/services/kurushimi/go.sum new file mode 100644 index 0000000..4870092 --- /dev/null +++ b/services/kurushimi/go.sum @@ -0,0 +1,266 @@ +agones.dev/agones v1.42.0 h1:tB/NL95flkCxTglCvg6+G9FbcTkfwRZ9RmOBA++eXhc= +agones.dev/agones v1.42.0/go.mod h1:VZH+KpLuBYi8tbwaxd4nqUIPfjQYwTDCljDl3U0aVSc= +github.com/PuerkitoBio/purell v1.1.1/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0= +github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/emicklei/go-restful/v3 v3.11.0 h1:rAQeMHw1c7zTmncogyy8VvRZwtkmkZ4FxERmMY4rD+g= +github.com/emicklei/go-restful/v3 v3.11.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +github.com/emortalmc/live-config-parser/golang v0.0.0-20231228020729-d2b6294e5968 h1:ED4bQH4klluvp53DQBXKt4f4iZQf1NmYRfOVPRNNsfU= +github.com/emortalmc/live-config-parser/golang v0.0.0-20231228020729-d2b6294e5968/go.mod h1:CbOcbHzizWqxyflDiBKyU9LIVxZw6t5V2NlWLVfgkwY= +github.com/emortalmc/proto-specs/gen/go v0.0.0-20240927103241-2584fd28e0f9 h1:6xOnWrTvG2oJR1J6+B+tdZV5GdlbIgdQixdCCyfj4nA= +github.com/evanphx/json-patch v4.12.0+incompatible h1:4onqiflcdA9EOZ4RxV643DvftH5pOlLGNtQ5lPWQu84= +github.com/evanphx/json-patch v4.12.0+incompatible/go.mod h1:50XU6AFN0ol/bzJsmQLiYLvXMP4fmwYFNcr97nuDLSk= +github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8= +github.com/frankban/quicktest v1.14.6/go.mod h1:4ptaffx2x8+WTWXmUCuVU6aPUX1/Mz7zb5vbUoiM6w0= +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/logr v1.4.1 h1:pKouT5E8xu9zeFC39JXRDukb6JFQPXM5p5I91188VAQ= +github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= +github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= +github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= +github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= +github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE= +github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= +github.com/go-openapi/spec v0.19.5 h1:Xm0Ao53uqnk9QE/LlYV5DEU09UAgpliA85QoT9LzqPw= +github.com/go-openapi/spec v0.19.5/go.mod h1:Hm2Jr4jv8G1ciIAo+frC/Ft+rR2kQDh8JHKHb3gWUSk= +github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= +github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang/glog v1.2.2 h1:1+mZ9upx1Dh6FmUTFR1naJ77miKiXgALjWOZ3NVFPmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= +github.com/google/gnostic-models v0.6.8 h1:yo/ABAfM5IMRsS1VnXjTBvUb61tFIHozhlYvRgGre9I= +github.com/google/gnostic-models v0.6.8/go.mod h1:5n7qKqH0f5wFt+aWF8CW6pZLLNOfYuF5OpfBSENuI8U= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= +github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.1 h1:HcUWd006luQPljE73d5sk+/VgYPGUReEVz2y1/qylwY= +github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.1/go.mod h1:w9Y7gY31krpLmrVU5ZPG9H7l9fZuRu5/3R3S3FMtVQ4= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.17.1 h1:LSsiG61v9IzzxMkqEr6nrix4miJI62xlRjwT7BYD2SM= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.17.1/go.mod h1:Hbb13e3/WtqQ8U5hLGkek9gJvBLasHuPFI0UEGfnQ10= +github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= +github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= +github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= +github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +github.com/mitchellh/hashstructure/v2 v2.0.2 h1:vGKWl0YJqUNxE8d+h8f6NJLcCJrgbhC4NcD46KavDd4= +github.com/mitchellh/hashstructure/v2 v2.0.2/go.mod h1:MG3aRVU/N29oo/V/IhBX8GR/zz4kQkprJgF2EVszyDE= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/montanaflynn/stats v0.7.1 h1:etflOAAHORrCC44V+aR6Ftzort912ZU+YLiSTuV8eaE= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/onsi/ginkgo/v2 v2.13.0 h1:0jY9lJquiL8fcf3M4LAXN5aMlS/b2BV86HFFPCPMgE4= +github.com/onsi/ginkgo/v2 v2.13.0/go.mod h1:TE309ZR8s5FsKKpuB1YAQYBzCaAfUgatB/xlT/ETL/o= +github.com/onsi/gomega v1.29.0 h1:KIA/t2t5UBzoirT4H9tsML45GEbo3ouUnBHsCfD2tVg= +github.com/onsi/gomega v1.29.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ= +github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM= +github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= +github.com/pierrec/lz4/v4 v4.1.18 h1:xaKrnTkyoqfh1YItXl56+6KJNVYWlEEPuAQW9xsplYQ= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= +github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= +github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= +github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= +github.com/sagikazarmark/slog-shim v0.1.0/go.mod h1:SrcSrq8aKtyuqEI1uvTDTK1arOWRIczQRv+GVI1AkeQ= +github.com/segmentio/kafka-go v0.4.47 h1:IqziR4pA3vrZq7YdRxaT3w1/5fvIH5qpCwstUanQQB0= +github.com/segmentio/kafka-go v0.4.47/go.mod h1:HjF6XbOKh0Pjlkr5GVZxt6CsjjwnmhVOfURM5KMd8qg= +github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0= +github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= +github.com/sourcegraph/conc v0.3.0 h1:OQTbbt6P72L20UqAkXXuLOj79LfEanQ+YQFNpLA9ySo= +github.com/sourcegraph/conc v0.3.0/go.mod h1:Sdozi7LEKbFPqYX2/J+iBAM6HpqSLTASQIKqDmF7Mt0= +github.com/spf13/afero v1.11.0 h1:WJQKhtpdm3v2IzqG8VMqrr6Rf3UYpEF239Jy9wNepM8= +github.com/spf13/afero v1.11.0/go.mod h1:GH9Y3pIexgf1MTIWtNGyogA5MwRIDXGUr+hbWNoBjkY= +github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0= +github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.19.0 h1:RWq5SEjt8o25SROyN3z2OrDB9l7RPd3lwTWU8EcEdcI= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/subosito/gotenv v1.6.0 h1:9NlTDc1FTs4qu0DDq7AEtTPNw6SVm7uBMsUCUjABIf8= +github.com/subosito/gotenv v1.6.0/go.mod h1:Dk4QP5c2W3ibzajGcXpNraDfq2IrhjMIvMSWPKKo0FU= +github.com/xdg-go/pbkdf2 v1.0.0 h1:Su7DPu48wXMwC3bs7MCNG+z4FhcyEuz5dlvchbq0B0c= +github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI= +github.com/xdg-go/scram v1.1.2 h1:FHX5I5B4i4hKRVRBCFRxq1iQRej7WO3hhBuJf+UUySY= +github.com/xdg-go/scram v1.1.2/go.mod h1:RT/sEzTbU5y00aCK8UOx6R7YryM0iF1N2MOmC3kKLN4= +github.com/xdg-go/stringprep v1.0.4 h1:XLI/Ng3O1Atzq0oBs3TWm+5ZVgkq2aqdlvP9JtoZ6c8= +github.com/xdg-go/stringprep v1.0.4/go.mod h1:mPGuuIYwz7CmR2bT9j4GbQqutWS1zV24gijq1dTyGkM= +github.com/youmark/pkcs8 v0.0.0-20240726163527-a2c0da244d78 h1:ilQV1hzziu+LLM3zUTJ0trRztfwgjqKnBWNtSRkbmwM= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= +go.mongodb.org/mongo-driver v1.17.1 h1:Wic5cJIwJgSpBhe3lx3+/RybR5PiYRMpVFgO7cOHyIM= +go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= +go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= +go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= +go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4= +golang.org/x/crypto v0.26.0 h1:RrRspgV4mU+YwB4FYnuBoKsUapNIL5cohGAmSH3azsw= +golang.org/x/exp v0.0.0-20230905200255-921286631fa9 h1:GoHiUyI/Tp2nVkLI2mCxVkOjsbSXD66ic0XW0js0R9g= +golang.org/x/exp v0.0.0-20230905200255-921286631fa9/go.mod h1:S2oDrQGGwySpoQPVqRShND87VCbxmc6bL1Yd2oYrm6k= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= +golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= +golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= +golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= +golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= +golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= +golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U= +golang.org/x/term v0.23.0 h1:F6D4vR+EHoL9/sWAWgAR1H2DcHr4PareCbAaCo1RpuU= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ= +golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= +golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= +golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= +golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw= +gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY= +google.golang.org/genproto/googleapis/api v0.0.0-20240814211410-ddb44dafa142 h1:wKguEg1hsxI2/L3hUYrpo1RVi48K+uTyzKqprwLXsb8= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 h1:e7S5W7MGGLaSu8j3YjdezkZ+m1/Nm0uRVRMEMGk26Xs= +google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= +google.golang.org/protobuf v1.35.1 h1:m3LfL6/Ca+fqnjnlqQXNpFPABW1UD7mjh8KO2mKFytA= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= +gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +k8s.io/api v0.29.0 h1:NiCdQMY1QOp1H8lfRyeEf8eOwV6+0xA6XEE44ohDX2A= +k8s.io/api v0.29.0/go.mod h1:sdVmXoz2Bo/cb77Pxi71IPTSErEW32xa4aXwKH7gfBA= +k8s.io/apimachinery v0.29.0 h1:+ACVktwyicPz0oc6MTMLwa2Pw3ouLAfAon1wPLtG48o= +k8s.io/apimachinery v0.29.0/go.mod h1:eVBxQ/cwiJxH58eK/jd/vAk4mrxmVlnpBH5J2GbMeis= +k8s.io/client-go v0.29.0 h1:KmlDtFcrdUzOYrBhXHgKw5ycWzc3ryPX5mQe0SkG3y8= +k8s.io/client-go v0.29.0/go.mod h1:yLkXH4HKMAywcrD82KMSmfYg2DlE8mepPR4JGSo5n38= +k8s.io/klog/v2 v2.110.1 h1:U/Af64HJf7FcwMcXyKm2RPM22WZzyR7OSpYj5tg3cL0= +k8s.io/klog/v2 v2.110.1/go.mod h1:YGtd1984u+GgbuZ7e08/yBuAfKLSO0+uR1Fhi6ExXjo= +k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00 h1:aVUu9fTY98ivBPKR9Y5w/AuzbMm96cd3YHRTU83I780= +k8s.io/kube-openapi v0.0.0-20231010175941-2dd684a91f00/go.mod h1:AsvuZPBlUDVuCdzJ87iajxtXuR9oktsTctW/R9wwouA= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b h1:sgn3ZU783SCgtaSJjpcVVlRqd6GSnlTLKgpAAttJvpI= +k8s.io/utils v0.0.0-20230726121419-3b25d923346b/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= +sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4= +sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= +sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/services/kurushimi/internal/app/kurushimi.go b/services/kurushimi/internal/app/kurushimi.go new file mode 100644 index 0000000..0196fee --- /dev/null +++ b/services/kurushimi/internal/app/kurushimi.go @@ -0,0 +1,97 @@ +package app + +import ( + "context" + "fmt" + "github.com/emortalmc/live-config-parser/golang/pkg/liveconfig" + "github.com/emortalmc/mono-services/services/kurushimi/internal/config" + "github.com/emortalmc/mono-services/services/kurushimi/internal/director" + "github.com/emortalmc/mono-services/services/kurushimi/internal/kafka" + "github.com/emortalmc/mono-services/services/kurushimi/internal/repository" + "github.com/emortalmc/mono-services/services/kurushimi/internal/service" + "github.com/emortalmc/mono-services/services/kurushimi/internal/simplecontroller" + "github.com/emortalmc/mono-services/services/kurushimi/internal/utils/kubernetes" + "github.com/emortalmc/proto-specs/gen/go/grpc/party" + "go.uber.org/zap" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" + "os/signal" + "sync" + "syscall" + "time" +) + +func Run(cfg config.Config, logger *zap.SugaredLogger) { + ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM) + defer cancel() + wg := &sync.WaitGroup{} + + repoCtx, repoCancel := context.WithCancel(ctx) + repoWg := &sync.WaitGroup{} + + // Parse gamemode configs + gameModeController, err := liveconfig.NewGameModeConfigController(logger) + if err != nil { + logger.Fatalw("failed to create game mode config controller", err) + } + + gameModes := gameModeController.GetConfigs() + + modeNames := make([]string, 0) + for id := range gameModes { + modeNames = append(modeNames, id) + } + logger.Infow("loaded initial gamemodes", "modeCount", len(gameModes), "modes", modeNames) + + _, agonesClient := kubernetes.CreateClients() + + repo, err := repository.NewMongoRepository(repoCtx, repoWg, logger, cfg.MongoDB) + if err != nil { + logger.Fatalw("failed to connect to mongo", err) + } + + notifier := kafka.NewKafkaNotifier(ctx, wg, cfg.Kafka, logger) + + kafka.NewConsumer(ctx, wg, cfg.Kafka, logger, repo) + + err = repo.HealthCheck(ctx, 5*time.Second) + if err != nil { + logger.Fatalw("failed to initiate mongodb", err) + } + + pSConn, err := grpc.Dial(fmt.Sprintf("%s:%d", cfg.PartyService.SettingsHost, cfg.PartyService.SettingsPort), grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + logger.Fatalw("failed to connect to party service", err) + } + partySettingsService := party.NewPartySettingsServiceClient(pSConn) + + allocationClient := agonesClient.AllocationV1().GameServerAllocations(cfg.Namespace) + + pConn, err := grpc.Dial(fmt.Sprintf("%s:%d", cfg.PartyService.Host, cfg.PartyService.Port), grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + logger.Fatalw("failed to connect to party service", err) + } + + partyService := party.NewPartyServiceClient(pConn) + + // Simple controllers + lobbyCfg := cfg.Lobby + proxyCfg := cfg.Proxy + + lobbyCtrl := simplecontroller.NewJoinController(ctx, wg, logger, notifier, allocationClient, + lobbyCfg.FleetName, "lobby", lobbyCfg.MatchRate, lobbyCfg.MatchSize) + + velocityCtrl := simplecontroller.NewJoinController(ctx, wg, logger, notifier, allocationClient, + proxyCfg.FleetName, "proxy", proxyCfg.MatchRate, proxyCfg.MatchSize) + + service.RunServices(ctx, logger, wg, cfg, repo, notifier, gameModeController, lobbyCtrl, velocityCtrl, partyService, partySettingsService) + + directR := director.New(logger, repo, notifier, allocationClient, gameModeController) + directR.Start(ctx) + + wg.Wait() + + logger.Info("shutting down repository") + repoCancel() + repoWg.Wait() +} diff --git a/services/kurushimi/internal/config/global.go b/services/kurushimi/internal/config/global.go new file mode 100644 index 0000000..65575d7 --- /dev/null +++ b/services/kurushimi/internal/config/global.go @@ -0,0 +1,167 @@ +package config + +import ( + "github.com/emortalmc/mono-services/services/kurushimi/internal/utils/runtime" + "github.com/spf13/pflag" + "github.com/spf13/viper" + "strings" + "time" +) + +const ( + kafkaHostFlag = "kafka-host" + kafkaPortFlag = "kafka-port" + mongoDBURIFlag = "mongodb-uri" + + namespaceFlag = "namespace" + + partyServiceHostFlag = "party-service-host" + partyServicePortFlag = "party-service-port" + partyServiceSettingsHostFlag = "party-settings-service-host" + partyServiceSettingsPortFlag = "party-settings-service-port" + + lobbyFleetNameFlag = "lobby-fleet-name" + lobbyMatchRateFlag = "lobby-match-rate" + lobbyMatchSizeFlag = "lobby-match-size" + + proxyFleetNameFlag = "proxy-fleet-name" + proxyMatchRateFlag = "proxy-match-rate" + proxyMatchSizeFlag = "proxy-match-size" + + grpcPortFlag = "port" + developmentFlag = "development" +) + +type Config struct { + Kafka KafkaConfig + MongoDB MongoDBConfig + + PartyService PartyServiceConfig + + Lobby LobbyConfig + Proxy ProxyConfig + + Namespace string + GrpcPort int + Development bool +} + +type MongoDBConfig struct { + URI string +} + +type KafkaConfig struct { + Host string + Port int +} + +type PartyServiceConfig struct { + Host string + Port uint16 + + SettingsHost string + SettingsPort int +} + +type LobbyConfig struct { + FleetName string + MatchRate time.Duration + MatchSize int +} + +type ProxyConfig struct { + FleetName string + MatchRate time.Duration + MatchSize int +} + +func LoadGlobalConfig() Config { + // Kafka + viper.SetDefault(kafkaHostFlag, "localhost") + viper.SetDefault(kafkaPortFlag, 9092) + // MongoDBV + viper.SetDefault(mongoDBURIFlag, "mongodb://localhost:27017") + // PartyService + viper.SetDefault(partyServiceHostFlag, "localhost") + viper.SetDefault(partyServicePortFlag, 10006) + viper.SetDefault(partyServiceSettingsHostFlag, "localhost") + viper.SetDefault(partyServiceSettingsPortFlag, 10006) + // Lobby + viper.SetDefault(lobbyFleetNameFlag, "lobby") + viper.SetDefault(lobbyMatchRateFlag, 175_000_000) + viper.SetDefault(lobbyMatchSizeFlag, 50) + // Proxy + viper.SetDefault(proxyFleetNameFlag, "velocity") + viper.SetDefault(proxyMatchRateFlag, 175_000_000) + viper.SetDefault(proxyMatchSizeFlag, 50) + // Global + viper.SetDefault(namespaceFlag, "emortalmc") + viper.SetDefault(grpcPortFlag, 1007) + viper.SetDefault(developmentFlag, true) + + pflag.String(kafkaHostFlag, viper.GetString(kafkaHostFlag), "Kafka host") + pflag.Int32(kafkaPortFlag, viper.GetInt32(kafkaPortFlag), "Kafka port") + pflag.String(mongoDBURIFlag, viper.GetString(mongoDBURIFlag), "MongoDB URI") + pflag.String(partyServiceHostFlag, viper.GetString(partyServiceHostFlag), "PartyService host") + pflag.Int32(partyServicePortFlag, viper.GetInt32(partyServicePortFlag), "PartyService port") + pflag.String(partyServiceSettingsHostFlag, viper.GetString(partyServiceSettingsHostFlag), "PartyService settings host") + pflag.Int32(partyServiceSettingsPortFlag, viper.GetInt32(partyServiceSettingsPortFlag), "PartyService settings port") + pflag.String(lobbyFleetNameFlag, viper.GetString(lobbyFleetNameFlag), "Lobby fleet name") + pflag.Duration(lobbyMatchRateFlag, viper.GetDuration(lobbyMatchRateFlag), "Delay between creating lobby matches") + pflag.Int32(lobbyMatchSizeFlag, viper.GetInt32(lobbyMatchSizeFlag), "Maximum size of a lobby (accounts for players already in the lobby)") + pflag.String(proxyFleetNameFlag, viper.GetString(proxyFleetNameFlag), "Proxy fleet name (default velocity)") + pflag.Duration(proxyMatchRateFlag, viper.GetDuration(proxyMatchRateFlag), "Delay between creating proxy matches") + pflag.Int32(proxyMatchSizeFlag, viper.GetInt32(proxyMatchSizeFlag), "Maximum size of a proxy (accounts for players already in the proxy)") + pflag.String(namespaceFlag, viper.GetString(namespaceFlag), "Namespace that the resource is in") + pflag.Int32(grpcPortFlag, viper.GetInt32(grpcPortFlag), "gRPC port of THIS service") + pflag.Bool(developmentFlag, viper.GetBool(developmentFlag), "Development mode") + pflag.Parse() + + // Bind the viper flags to environment variables + viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_")) + runtime.Must(viper.BindEnv(kafkaHostFlag)) + runtime.Must(viper.BindEnv(kafkaPortFlag)) + runtime.Must(viper.BindEnv(mongoDBURIFlag)) + runtime.Must(viper.BindEnv(partyServiceHostFlag)) + runtime.Must(viper.BindEnv(partyServicePortFlag)) + runtime.Must(viper.BindEnv(partyServiceSettingsHostFlag)) + runtime.Must(viper.BindEnv(partyServiceSettingsPortFlag)) + runtime.Must(viper.BindEnv(lobbyFleetNameFlag)) + runtime.Must(viper.BindEnv(lobbyMatchRateFlag)) + runtime.Must(viper.BindEnv(lobbyMatchSizeFlag)) + runtime.Must(viper.BindEnv(proxyFleetNameFlag)) + runtime.Must(viper.BindEnv(proxyMatchRateFlag)) + runtime.Must(viper.BindEnv(proxyMatchSizeFlag)) + runtime.Must(viper.BindEnv(namespaceFlag)) + runtime.Must(viper.BindEnv(grpcPortFlag)) + runtime.Must(viper.BindEnv(developmentFlag)) + + return Config{ + Kafka: KafkaConfig{ + Host: viper.GetString(kafkaHostFlag), + Port: int(viper.GetInt32(kafkaPortFlag)), + }, + MongoDB: MongoDBConfig{ + URI: viper.GetString(mongoDBURIFlag), + }, + PartyService: PartyServiceConfig{ + Host: viper.GetString(partyServiceHostFlag), + Port: uint16(viper.GetInt32(partyServicePortFlag)), + SettingsHost: viper.GetString(partyServiceSettingsHostFlag), + SettingsPort: int(viper.GetInt32(partyServiceSettingsPortFlag)), + }, + Lobby: LobbyConfig{ + FleetName: viper.GetString(lobbyFleetNameFlag), + MatchRate: viper.GetDuration(lobbyMatchRateFlag), + MatchSize: int(viper.GetInt32(lobbyMatchSizeFlag)), + }, + Proxy: ProxyConfig{ + FleetName: viper.GetString(proxyFleetNameFlag), + MatchRate: viper.GetDuration(proxyMatchRateFlag), + MatchSize: int(viper.GetInt32(proxyMatchSizeFlag)), + }, + Namespace: viper.GetString(namespaceFlag), + GrpcPort: int(viper.GetInt32(grpcPortFlag)), + Development: viper.GetBool(developmentFlag), + } +} diff --git a/services/kurushimi/internal/director/director.go b/services/kurushimi/internal/director/director.go new file mode 100644 index 0000000..77b0ff6 --- /dev/null +++ b/services/kurushimi/internal/director/director.go @@ -0,0 +1,542 @@ +package director + +import ( + allocatorv1 "agones.dev/agones/pkg/apis/allocation/v1" + v1 "agones.dev/agones/pkg/client/clientset/versioned/typed/allocation/v1" + "context" + "fmt" + "github.com/emortalmc/live-config-parser/golang/pkg/liveconfig" + "github.com/emortalmc/mono-services/services/kurushimi/internal/gsallocation" + selector2 "github.com/emortalmc/mono-services/services/kurushimi/internal/gsallocation/selector" + "github.com/emortalmc/mono-services/services/kurushimi/internal/kafka" + matchfunction2 "github.com/emortalmc/mono-services/services/kurushimi/internal/matchfunction" + "github.com/emortalmc/mono-services/services/kurushimi/internal/repository" + "github.com/emortalmc/mono-services/services/kurushimi/internal/repository/model" + "github.com/emortalmc/mono-services/services/kurushimi/internal/utils" + "github.com/emortalmc/mono-services/services/kurushimi/internal/utils/protoutils" + msg "github.com/emortalmc/proto-specs/gen/go/message/matchmaker" + pb "github.com/emortalmc/proto-specs/gen/go/model/matchmaker" + "github.com/google/uuid" + "go.mongodb.org/mongo-driver/bson/primitive" + "go.uber.org/zap" + "golang.org/x/exp/rand" + "reflect" + "time" +) + +type Director interface { + Start(ctx context.Context) +} + +type directorImpl struct { + logger *zap.SugaredLogger + + repo repository.Repository + notifier kafka.Notifier + + allocationClient v1.GameServerAllocationInterface + + configs map[string]*liveconfig.GameModeConfig +} + +func New(logger *zap.SugaredLogger, repo repository.Repository, notifier kafka.Notifier, + allocationClient v1.GameServerAllocationInterface, cfgController liveconfig.GameModeConfigController) Director { + + // Filter for only enabled configs + configs := cfgController.GetConfigs() + for i, liveConfig := range configs { + if !liveConfig.Enabled { + delete(configs, i) + } + } + + d := &directorImpl{ + logger: logger, + + repo: repo, + notifier: notifier, + + allocationClient: allocationClient, + + configs: cfgController.GetConfigs(), + } + + cfgController.AddGlobalUpdateListener(d.onGameModeConfigUpdate) + return d +} + +func (d *directorImpl) Start(ctx context.Context) { + for _, c := range d.configs { + go func(config *liveconfig.GameModeConfig) { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + for { + lastRunTime := time.Now() + d.run(ctx, config) + + // Wait for the next run + timeSinceLastRun := time.Since(lastRunTime) + if timeSinceLastRun < config.MatchmakerInfo.Rate { + time.Sleep(config.MatchmakerInfo.Rate - timeSinceLastRun) + } + } + }(c) + } +} + +func (d *directorImpl) run(ctx context.Context, originalConfig *liveconfig.GameModeConfig) { + temp := *originalConfig + config := &temp + + // account for deletions + err := d.processDequeues(ctx, config) + if err != nil { + d.logger.Errorw("failed to process dequeues", "error", err) + return + } + + // run match function + matches, err := d.runMatchFunction(ctx, config) + if err != nil { + d.logger.Errorw("failed to run match function", "error", err) + return + } + + if len(matches) == 0 { + return + } + + d.logger.Debugw("match function returned matches", "count", len(matches)) + d.logger.Debugw("matches", "matches", matches) + + // todo allocate gameservers +} + +func (d *directorImpl) processDequeues(ctx context.Context, config *liveconfig.GameModeConfig) error { + configId := config.Id + + tickets, err := d.repo.GetTicketsWithDequeueRequest(ctx, configId) + if err != nil { + return err + } + + // ticketIdsToUpdate contains the ids of every ticket that isn't in the ticketIdsToDelete slice + ticketIdsToUpdate := make([]primitive.ObjectID, 0) + playerIdsToDelete := make([]uuid.UUID, 0) + ticketIdsToDelete := make([]primitive.ObjectID, 0) + + for _, ticket := range tickets { + removals := ticket.Removals + + if removals.MarkedForRemoval { + playerIdsToDelete = append(playerIdsToDelete, ticket.PlayerIds...) + ticketIdsToDelete = append(ticketIdsToDelete, ticket.Id) + } else { + playerIdsToDelete = append(playerIdsToDelete, removals.PlayersForRemoval...) + ticketIdsToUpdate = append(ticketIdsToUpdate, ticket.Id) + } + } + + // Delete tickets + if len(ticketIdsToDelete) > 0 { + modified, err := d.repo.DeleteAllTicketsById(ctx, ticketIdsToDelete) + if err != nil { + return fmt.Errorf("failed to delete tickets: %w", err) + } + + if int(modified) != len(ticketIdsToDelete) { + d.logger.Warnw("deleted tickets count does not match expected count", "deleted", modified, "expected", len(ticketIdsToDelete)) + } + + // Delete tickets from any PendingMatches they are in. + // NOTE: The modified count is irrelevant as we don't know if they were in any PendingMatches + _, err = d.repo.RemoveTicketsFromPendingMatchesById(ctx, ticketIdsToDelete) + if err != nil { + return fmt.Errorf("failed to remove tickets from pending matches: %w", err) + } + + // Send Kafka notifications + for _, ticket := range tickets { + if ticket.Removals.MarkedForRemoval { + if err := d.notifier.TicketDeleted(ctx, ticket.ToProto(), msg.TicketDeletedMessage_MANUAL_DEQUEUE); err != nil { + d.logger.Errorw("failed to send ticket deleted notification", "error", err) + } + } + } + } + + if len(ticketIdsToUpdate) > 0 { + // Update tickets removal requests. + modified, err := d.repo.ResetAllDequeueRequestsById(ctx, ticketIdsToUpdate) + if err != nil { + return fmt.Errorf("failed to reset dequeue requests: %w", err) + } + + if int(modified) != len(ticketIdsToUpdate) { + d.logger.Warnw("updated tickets count does not match expected count", "updated", modified, "expected", len(ticketIdsToUpdate)) + } + } + + if len(playerIdsToDelete) > 0 { + // Delete players + modified, err := d.repo.DeleteAllQueuedPlayersById(ctx, playerIdsToDelete) + if err != nil { + return fmt.Errorf("failed to delete players: %w", err) + } + + if int(modified) != len(playerIdsToDelete) { + d.logger.Warnw("deleted players count does not match expected count", "deleted", modified, "expected", len(playerIdsToDelete)) + } + return nil + } + + return err +} + +func (d *directorImpl) runMatchFunction(ctx context.Context, cfg *liveconfig.GameModeConfig) ([]*pb.Match, error) { + // NOTE: these tickets are ALL the tickets for this gamemode, even ones already in a PendingMatch + tickets, err := d.repo.GetTicketsByGameMode(ctx, cfg.Id) + if err != nil { + return nil, err + } + + if len(tickets) != 0 { + d.logger.Debugw("matchmaker running", "gamemode", cfg.Id, "tickets", len(tickets), "method", cfg.MatchmakerInfo.MatchMethod) + } + + // make matches + var matches []*pb.Match + switch cfg.MatchmakerInfo.MatchMethod { + case liveconfig.MatchMethodCountdown: + pendingMatches, err := d.repo.GetPendingMatchesByGameMode(ctx, cfg.Id) + if err != nil { + return nil, err + } + + // Create a pending matches map + pendingMatchesMap := make(map[primitive.ObjectID]*model.PendingMatch) + for _, pendingMatch := range pendingMatches { + pendingMatchesMap[pendingMatch.Id] = pendingMatch + } + + // Create a ticket map + ticketMap := make(map[primitive.ObjectID]*model.Ticket) + for _, ticket := range tickets { + ticketMap[ticket.Id] = ticket + } + + // Clean up existing pending matches + deletedPending := matchfunction2.CountdownRemoveInvalidPendingMatches(pendingMatchesMap, ticketMap, cfg) + + // Delete matches from db and notify with reason cancelled + if len(deletedPending) > 0 { + //ticketUpdates := make(map[primitive.ObjectID]bool) + + for _, match := range deletedPending { + if err := d.notifier.PendingMatchDeleted(ctx, match, msg.PendingMatchDeletedMessage_CANCELLED); err != nil { + d.logger.Errorw("failed to send pending match deleted notification", "error", err) + } + + for _, ticketId := range match.TicketIds { + ticket := ticketMap[ticketId] + if err := d.notifier.TicketUpdated(ctx, ticket); err != nil { + d.logger.Errorw("failed to send ticket updated notification", "error", err) + } + } + + //for _, ticketId := range match.TicketIds { + // ticketUpdates[ticketId] = false + //} + } + + // Update the tickets in the DB + //if _, err := d.repo.MassUpdateTicketInPendingMatch(ctx, ticketUpdates); err != nil { + // return nil, fmt.Errorf("failed to update tickets in pending match: %w", err) + //} + + // Delete the pending matches from the db + deletedIds := make([]primitive.ObjectID, 0) + for _, match := range deletedPending { + deletedIds = append(deletedIds, match.Id) + } + if err := d.repo.DeletePendingMatches(ctx, deletedIds); err != nil { + return nil, err + } + } + + createdPending, updatedPending, deletedPending, createdMatches, err := matchfunction2.RunCountdown(d.logger, ticketMap, pendingMatchesMap, cfg) + if err != nil { + return nil, err + } + + if len(createdPending) != 0 || len(updatedPending) != 0 || len(deletedPending) != 0 || len(createdMatches) != 0 { + d.logger.Debugw("countdown matchmaker results", + "gamemode", cfg.Id, + "pending (exists)", len(updatedPending), + "pending (created)", len(createdPending), + "pending (deleted)", len(deletedPending), + "matches", len(createdMatches), + ) + } + + matches = createdMatches // assign the created matches to the return value + + // handle the pending match stuff + if len(updatedPending) > 0 { + err = d.repo.UpdatePendingMatches(ctx, updatedPending) + if err != nil { + return nil, err + } + + for _, match := range updatedPending { + if err := d.notifier.PendingMatchUpdated(ctx, match); err != nil { + d.logger.Errorw("failed to notify pending match updated", "error", err) + } + } + } + + // handle created pending matches (just notify rn) + if len(createdPending) > 0 { + err = d.repo.CreatePendingMatches(ctx, createdPending) + if err != nil { + return nil, err + } + + for _, match := range createdPending { + + if err := d.notifier.PendingMatchCreated(ctx, match); err != nil { + d.logger.Errorw("failed to notify pending match created", "error", err) + } + } + } + + // Delete pending matches from DB and notify with reason match created + if len(deletedPending) > 0 { + deletedIds := make([]primitive.ObjectID, 0) + for _, pending := range deletedPending { + deletedIds = append(deletedIds, pending.Id) + } + + err = d.repo.DeletePendingMatches(ctx, deletedIds) + if err != nil { + return nil, err + } + + for _, match := range deletedPending { + if err := d.notifier.PendingMatchDeleted(ctx, match, msg.PendingMatchDeletedMessage_MATCH_CREATED); err != nil { + d.logger.Errorw("failed to notify pending match deleted", "error", err) + } + } + } + + inPendingMatchUpdates := make(map[primitive.ObjectID]bool) + for _, ticket := range tickets { + if ticket.InternalUpdates != nil && ticket.InternalUpdates.InPendingMatchUpdated { + inPendingMatchUpdates[ticket.Id] = ticket.InPendingMatch + } + } + if len(inPendingMatchUpdates) > 0 { + _, err = d.repo.MassUpdateTicketInPendingMatch(ctx, inPendingMatchUpdates) + if err != nil { + return nil, err + } + } + + // (Kafka) send notifications for updated tickets + for _, ticket := range tickets { + if ticket.InternalUpdates != nil { + if err := d.notifier.TicketUpdated(ctx, ticket); err != nil { + d.logger.Errorw("failed to send ticket updated notification", "error", err) + } + } + } + case liveconfig.MatchMethodInstant: + matches, err = matchfunction2.RunInstant(tickets, cfg) + } + if err != nil { + return nil, err + } + + if len(matches) != 0 { + d.logger.Debugw("matchmaker finished", "gamemode", cfg.Id, "matches", len(matches)) + } + + if len(matches) == 0 { + return nil, nil + } + + if len(cfg.Maps) > 0 { + err = d.calculateMaps(ctx, cfg, matches) + if err != nil { + return nil, err + } + } + + // Assign a server for each match + errorMap := d.allocateServers(ctx, cfg, matches) + if len(errorMap) > 0 { + d.logger.Error("failed to allocate servers", zap.String("gamemode", cfg.Id), loggableErrorMap(errorMap)) + } + // TODO let's use the errorMap to do some retry logic and not delete the Tickets and QueuedPlayers + + // Notify of match creation + for _, match := range matches { + d.logger.Infow("match created", "match", match.Id, "assignment", match.Assignment) + err = d.notifier.MatchCreated(ctx, match) + if err != nil { + d.logger.Errorw("error notifying of match creation", "match", match.Id, "error", err) + } + } + + // delete all Tickets and QueuedPlayers in Matches (not PendingMatches) + for _, match := range matches { + ticketIds := make([]primitive.ObjectID, 0) + playerIds := make([]uuid.UUID, 0) + for _, pbTicket := range match.Tickets { + var ticket *model.Ticket + for _, t := range tickets { + if t.Id.Hex() == pbTicket.Id { + ticket = t + break + } + } + + // (Kafka) Notify of ticket deletion + // TODO this is actually wrong. This match may have been deleted because there were no longer enough tickets to maintain the PendingMatch + if err := d.notifier.TicketDeleted(ctx, pbTicket, msg.TicketDeletedMessage_MATCH_CREATED); err != nil { + d.logger.Errorw("failed to notify ticket deleted", "error", err) + } + + ticketIds = append(ticketIds, ticket.Id) + + playerIds = append(playerIds, ticket.PlayerIds...) + } + + // Delete Tickets + deletedCount, err := d.repo.DeleteAllTicketsById(ctx, ticketIds) + if err != nil { + return nil, err + } + + if int(deletedCount) != len(ticketIds) { + d.logger.Warnw("deleted tickets count does not match expected count", "deleted", deletedCount, "expected", len(ticketIds)) + } + + // Delete QueuedPlayers + deletedCount, err = d.repo.DeleteAllQueuedPlayersById(ctx, playerIds) + if err != nil { + return nil, err + } + + if int(deletedCount) != len(playerIds) { + d.logger.Warnw("deleted players count does not match expected count", "deleted", deletedCount, "expected", len(playerIds)) + } + } + + return matches, nil +} + +// calculate map retrieves the map votes for those present in a Match +// and assigns the MapId field of a msg.Match +func (d *directorImpl) calculateMaps(ctx context.Context, cfg *liveconfig.GameModeConfig, matches []*pb.Match) error { + for _, match := range matches { + playerIds := make([]uuid.UUID, 0) + + for _, ticket := range match.Tickets { + for _, playerId := range ticket.PlayerIds { + parsedId, err := uuid.Parse(playerId) + if err != nil { + // Note: We're not returning the error as map selection isn't critical + d.logger.Errorw("failed to parse player id", "playerId", playerId) + continue + } + + playerIds = append(playerIds, parsedId) + } + } + + players, err := d.repo.GetAllQueuedPlayersByIds(ctx, playerIds) + if err != nil { + return err + } + + // map of map id to number of votes + mapVotes := make(map[string]int) + for _, player := range players { + if player.MapId != nil { + mapVotes[*player.MapId]++ + } + } + + // find the map with the most votes + mostVotedMapIds := make([]*string, 0) + mostVotes := 0 + + for mapId, votes := range mapVotes { + if votes > mostVotes { + mostVotedMapIds = []*string{&mapId} + mostVotes = votes + } + if votes == mostVotes { + mostVotedMapIds = append(mostVotedMapIds, &mapId) + } + } + + // If no maps are voted, add all to the pool + if len(mostVotedMapIds) == 0 { + for _, lMap := range cfg.Maps { + mostVotedMapIds = append(mostVotedMapIds, &lMap.Id) + } + } + + mapVoteLen := len(mostVotedMapIds) + if mapVoteLen > 1 { + match.MapId = mostVotedMapIds[rand.Intn(len(mostVotedMapIds))] + } else if mapVoteLen == 1 { + match.MapId = mostVotedMapIds[0] + } else { + random := rand.Intn(len(cfg.Maps)) + match.MapId = utils.PointerOf(reflect.ValueOf(cfg.Maps).MapKeys()[random].String()) + } + } + + return nil +} + +// allocateServers allocates servers for the given matches +// returns: map of match id to error +// NOTE: this function blocks until all matches have been allocated +// TODO let's make a system to retry failed allocations +func (d *directorImpl) allocateServers(ctx context.Context, config *liveconfig.GameModeConfig, matches []*pb.Match) map[*pb.Match]error { + allocationMap := make(map[*pb.Match]*allocatorv1.GameServerAllocation) + for _, match := range matches { + var selector *allocatorv1.GameServerAllocation + switch config.MatchmakerInfo.SelectMethod { + case liveconfig.SelectMethodAvailable: + selector = selector2.CreateAvailableSelector(config, match) + case liveconfig.SelectMethodPlayerCount: + selector = selector2.CreatePlayerBasedSelector(config.FleetName, match, protoutils.GetMatchPlayerCount(match)) + } + + allocationMap[match] = selector + } + + allocationErrs := gsallocation.AllocateServers(ctx, d.allocationClient, allocationMap) + return allocationErrs +} + +func (d *directorImpl) onGameModeConfigUpdate(update liveconfig.ConfigUpdate[liveconfig.GameModeConfig]) { + // TODO +} + +func loggableErrorMap(errorMap map[*pb.Match]error) []zap.Field { + logs := make([]zap.Field, len(errorMap)) + + i := 0 + for match, err := range errorMap { + logs[i] = zap.NamedError(match.Id, err) + } + + return logs +} diff --git a/services/kurushimi/internal/gsallocation/common.go b/services/kurushimi/internal/gsallocation/common.go new file mode 100644 index 0000000..39c723c --- /dev/null +++ b/services/kurushimi/internal/gsallocation/common.go @@ -0,0 +1,84 @@ +package gsallocation + +import ( + allocv1 "agones.dev/agones/pkg/apis/allocation/v1" + v1 "agones.dev/agones/pkg/client/clientset/versioned/typed/allocation/v1" + "context" + "fmt" + "github.com/emortalmc/mono-services/services/kurushimi/internal/utils" + pb "github.com/emortalmc/proto-specs/gen/go/model/matchmaker" + kubev1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "log" + "strconv" + "sync" +) + +func AllocateServers(ctx context.Context, allocationClient v1.GameServerAllocationInterface, + allocations map[*pb.Match]*allocv1.GameServerAllocation) map[*pb.Match]error { + + errors := make(map[*pb.Match]error) + errorsLock := sync.Mutex{} + + wg := sync.WaitGroup{} + wg.Add(len(allocations)) + + for match, allocation := range allocations { + go func(fMatch *pb.Match, fAllocation *allocv1.GameServerAllocation) { + defer wg.Done() + if err := AllocateServer(ctx, allocationClient, fMatch, fAllocation); err != nil { + errorsLock.Lock() + defer errorsLock.Unlock() + errors[fMatch] = err + } + }(match, allocation) + } + + wg.Wait() + return errors +} + +func AllocateServer(ctx context.Context, allocationClient v1.GameServerAllocationInterface, + match *pb.Match, allocationReq *allocv1.GameServerAllocation) error { + + resp, err := allocationClient.Create(ctx, allocationReq, kubev1.CreateOptions{}) + if err != nil { + return fmt.Errorf("failed to create allocation: %w", err) + } + + allocation := resp.Status + if allocation.State != allocv1.GameServerAllocationAllocated { + return fmt.Errorf("allocation was not successful: %s", allocation.State) + } + + log.Printf("Allocated: %+v", allocation) + log.Printf("Metadata: %+v", allocation.Metadata) + + protocolVersion, versionName := parseVersions(allocation.Metadata.Annotations) + + match.Assignment = &pb.Assignment{ + ServerId: allocation.GameServerName, + ServerAddress: allocation.Address, + ServerPort: uint32(allocation.Ports[0].Port), + ProtocolVersion: protocolVersion, + VersionName: versionName, + } + + return err +} + +func parseVersions(annotations map[string]string) (protocolVersion *int64, versionName *string) { + protocolStr, ok := annotations["agones.dev/sdk-emc-protocol-version"] + if ok { + protocol, err := strconv.Atoi(protocolStr) + if err == nil { + protocolVersion = utils.PointerOf(int64(protocol)) + } + } + + version, ok := annotations["agones.dev/sdk-emc-version-name"] + if ok { + versionName = &version + } + + return protocolVersion, versionName +} diff --git a/services/kurushimi/internal/gsallocation/selector/common.go b/services/kurushimi/internal/gsallocation/selector/common.go new file mode 100644 index 0000000..123cf62 --- /dev/null +++ b/services/kurushimi/internal/gsallocation/selector/common.go @@ -0,0 +1,31 @@ +package selector + +import ( + agonesv1 "agones.dev/agones/pkg/apis/agones/v1" + allocatorv1 "agones.dev/agones/pkg/apis/allocation/v1" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +var ( + AllocatedState = agonesv1.GameServerStateAllocated + ReadyState = agonesv1.GameServerStateReady + + notOutdatedExpression = v1.LabelSelectorRequirement{ + Key: "emortal.dev/outdated", + Operator: v1.LabelSelectorOpDoesNotExist, + } +) + +func createReadySelector(fleetName string) allocatorv1.GameServerSelector { + return allocatorv1.GameServerSelector{ + LabelSelector: v1.LabelSelector{ + MatchLabels: map[string]string{ + "agones.dev/fleet": fleetName, + }, + + MatchExpressions: []v1.LabelSelectorRequirement{notOutdatedExpression}, + }, + + GameServerState: &ReadyState, + } +} diff --git a/services/kurushimi/internal/gsallocation/selector/game_based.go b/services/kurushimi/internal/gsallocation/selector/game_based.go new file mode 100644 index 0000000..097a7fb --- /dev/null +++ b/services/kurushimi/internal/gsallocation/selector/game_based.go @@ -0,0 +1,56 @@ +package selector + +import ( + "agones.dev/agones/pkg/apis" + v2 "agones.dev/agones/pkg/apis/agones/v1" + allocatorv1 "agones.dev/agones/pkg/apis/allocation/v1" + "github.com/emortalmc/live-config-parser/golang/pkg/liveconfig" + "github.com/emortalmc/mono-services/services/kurushimi/internal/utils" + pb "github.com/emortalmc/proto-specs/gen/go/model/matchmaker" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +func CreateAvailableSelector(cfg *liveconfig.GameModeConfig, match *pb.Match) *allocatorv1.GameServerAllocation { + fleetName := cfg.FleetName + + return &allocatorv1.GameServerAllocation{ + Spec: allocatorv1.GameServerAllocationSpec{ + Scheduling: apis.Packed, + Priorities: []v2.Priority{ + { + Type: "Counter", + Key: "games", + Order: "Ascending", + }, + }, + Selectors: []allocatorv1.GameServerSelector{ + { + LabelSelector: v1.LabelSelector{ + MatchLabels: map[string]string{ + "agones.dev/fleet": fleetName, + }, + MatchExpressions: []v1.LabelSelectorRequirement{notOutdatedExpression}, + }, + Counters: map[string]allocatorv1.CounterSelector{ + "games": { + MinAvailable: 1, + }, + }, + GameServerState: &AllocatedState, + }, + createReadySelector(fleetName), + }, + Counters: map[string]allocatorv1.CounterAction{ + "games": { + Action: utils.PointerOf("Increment"), + Amount: utils.PointerOf(int64(1)), + }, + }, + Lists: map[string]allocatorv1.ListAction{ + "games": { + AddValues: []string{match.Id}, + }, + }, + }, + } +} diff --git a/services/kurushimi/internal/gsallocation/selector/player_based.go b/services/kurushimi/internal/gsallocation/selector/player_based.go new file mode 100644 index 0000000..1ce8e19 --- /dev/null +++ b/services/kurushimi/internal/gsallocation/selector/player_based.go @@ -0,0 +1,35 @@ +package selector + +import ( + "agones.dev/agones/pkg/apis" + allocatorv1 "agones.dev/agones/pkg/apis/allocation/v1" + pb "github.com/emortalmc/proto-specs/gen/go/model/matchmaker" + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// CreatePlayerBasedSelector selects a GameServer where there is no 'match'. +// This could be a singleplayer game (e.g. marathon) or a stateless drop-in drop-out game (e.g. the lobby) +func CreatePlayerBasedSelector(fleetName string, match *pb.Match, playerCount int64) *allocatorv1.GameServerAllocation { + return &allocatorv1.GameServerAllocation{ + Spec: allocatorv1.GameServerAllocationSpec{ + Scheduling: apis.Packed, + Selectors: []allocatorv1.GameServerSelector{ + { + LabelSelector: v1.LabelSelector{ + MatchLabels: map[string]string{ + "agones.dev/fleet": fleetName, + }, + MatchExpressions: []v1.LabelSelectorRequirement{notOutdatedExpression}, + }, + Counters: map[string]allocatorv1.CounterSelector{ + "players": { + MinAvailable: playerCount, + }, + }, + GameServerState: &AllocatedState, + }, + createReadySelector(fleetName), + }, + }, + } +} diff --git a/services/kurushimi/internal/kafka/consumer.go b/services/kurushimi/internal/kafka/consumer.go new file mode 100644 index 0000000..ae25431 --- /dev/null +++ b/services/kurushimi/internal/kafka/consumer.go @@ -0,0 +1,109 @@ +package kafka + +import ( + "context" + "fmt" + "github.com/emortalmc/mono-services/services/kurushimi/internal/config" + "github.com/emortalmc/mono-services/services/kurushimi/internal/repository" + "github.com/emortalmc/proto-specs/gen/go/message/party" + "github.com/emortalmc/proto-specs/gen/go/nongenerated/kafkautils" + "github.com/google/uuid" + "github.com/segmentio/kafka-go" + "go.mongodb.org/mongo-driver/bson/primitive" + "go.uber.org/zap" + "google.golang.org/protobuf/proto" + "sync" +) + +// NOTE: We don't listen to player connections as player disconnect = party leave or disband - so it's handled by that. +const partyTopic = "party-manager" + +type consumer struct { + logger *zap.SugaredLogger + + reader *kafka.Reader + + repo repository.Repository +} + +func NewConsumer(ctx context.Context, wg *sync.WaitGroup, config config.KafkaConfig, logger *zap.SugaredLogger, repo repository.Repository) { + reader := kafka.NewReader(kafka.ReaderConfig{ + Brokers: []string{fmt.Sprintf("%s:%d", config.Host, config.Port)}, + GroupID: "matchmaker", + GroupTopics: []string{partyTopic}, + + Logger: kafka.LoggerFunc(func(format string, args ...interface{}) { + logger.Infow(fmt.Sprintf(format, args...)) + }), + ErrorLogger: kafka.LoggerFunc(func(format string, args ...interface{}) { + logger.Errorw(fmt.Sprintf(format, args...)) + }), + }) + + c := &consumer{ + logger: logger, + reader: reader, + repo: repo, + } + + handler := kafkautils.NewConsumerHandler(logger, reader) + handler.RegisterHandler(&party.PartyDeletedMessage{}, c.handlePartyDisband) + handler.RegisterHandler(&party.PartyPlayerJoinedMessage{}, c.handlePartyPlayerJoined) + handler.RegisterHandler(&party.PartyPlayerLeftMessage{}, c.handlePartyPlayerLeft) + + logger.Infow("starting listening for kafka messages", "topics", reader.Config().GroupTopics) + + wg.Add(1) + go func() { + defer wg.Done() + handler.Run(ctx) // Run is blocking until the context is cancelled + if err := reader.Close(); err != nil { + logger.Errorw("error closing kafka reader", "error", err) + } + }() +} + +func (c *consumer) handlePartyDisband(ctx context.Context, _ *kafka.Message, uncast proto.Message) { + pMsg := uncast.(*party.PartyDeletedMessage) + + // Dequeue if possible + partyId, err := primitive.ObjectIDFromHex(pMsg.Party.Id) + if err != nil { + c.logger.Errorw("failed to parse party id", err) + return + } + + _, err = c.repo.AddTicketDequeueRequestByPartyId(ctx, partyId) + if err != nil { + c.logger.Errorw("failed to add ticket dequeue request", err) + return + } +} + +// TODO we don't account for if a ticket size increases and there isn't enough space in their existing PendingMatch +func (c *consumer) handlePartyPlayerJoined(ctx context.Context, _ *kafka.Message, uncast proto.Message) { + //pMsg := uncast.(*party.PartyPlayerJoinedMessage) + // TODO +} + +func (c *consumer) handlePartyPlayerLeft(ctx context.Context, _ *kafka.Message, uncast proto.Message) { + pMsg := uncast.(*party.PartyPlayerLeftMessage) + + partyId, err := primitive.ObjectIDFromHex(pMsg.PartyId) + if err != nil { + c.logger.Errorw("failed to parse party id", err) + return + } + + playerId, err := uuid.Parse(pMsg.Member.Id) + if err != nil { + c.logger.Errorw("failed to parse player id", err) + return + } + + err = c.repo.AddPlayerDequeueRequestByPartyId(ctx, partyId, playerId) + if err != nil { + c.logger.Errorw("failed to add player dequeue request", err) + return + } +} diff --git a/services/kurushimi/internal/kafka/writer.go b/services/kurushimi/internal/kafka/writer.go new file mode 100644 index 0000000..32c0ccb --- /dev/null +++ b/services/kurushimi/internal/kafka/writer.go @@ -0,0 +1,182 @@ +package kafka + +import ( + "context" + "fmt" + "github.com/emortalmc/mono-services/services/kurushimi/internal/config" + "github.com/emortalmc/mono-services/services/kurushimi/internal/repository/model" + msg "github.com/emortalmc/proto-specs/gen/go/message/matchmaker" + pb "github.com/emortalmc/proto-specs/gen/go/model/matchmaker" + "github.com/segmentio/kafka-go" + "go.uber.org/zap" + "google.golang.org/protobuf/proto" + "sync" + "time" +) + +const writeTopic = "matchmaker" + +// TODO fire these methods +type Notifier interface { + TicketCreated(ctx context.Context, ticket *model.Ticket) error + TicketUpdated(ctx context.Context, ticket *model.Ticket) error + TicketDeleted(ctx context.Context, ticket *pb.Ticket, reason msg.TicketDeletedMessage_Reason) error + + PendingMatchCreated(ctx context.Context, match *model.PendingMatch) error + PendingMatchUpdated(ctx context.Context, match *model.PendingMatch) error + PendingMatchDeleted(ctx context.Context, match *model.PendingMatch, reason msg.PendingMatchDeletedMessage_Reason) error + + MatchCreated(ctx context.Context, match *pb.Match) error +} + +type kafkaNotifier struct { + w *kafka.Writer +} + +func NewKafkaNotifier(ctx context.Context, wg *sync.WaitGroup, config config.KafkaConfig, logger *zap.SugaredLogger) Notifier { + w := &kafka.Writer{ + Addr: kafka.TCP(fmt.Sprintf("%s:%d", config.Host, config.Port)), + Topic: writeTopic, + Balancer: &kafka.LeastBytes{}, + Async: true, + BatchTimeout: 50 * time.Millisecond, + ErrorLogger: kafka.LoggerFunc(logger.Errorw), + } + + wg.Add(1) + go func() { + <-ctx.Done() + if err := w.Close(); err != nil { + logger.Errorw("failed to close kafka writer", "error", err) + } + wg.Done() + }() + + return &kafkaNotifier{w: w} +} + +func (k *kafkaNotifier) TicketCreated(ctx context.Context, ticket *model.Ticket) error { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + pMsg := &msg.TicketCreatedMessage{Ticket: ticket.ToProto()} + bytes, err := proto.Marshal(pMsg) + if err != nil { + return err + } + + err = k.w.WriteMessages(ctx, kafka.Message{ + Headers: []kafka.Header{{Key: "X-Proto-Type", Value: []byte(pMsg.ProtoReflect().Descriptor().FullName())}}, + Value: bytes, + }) + + return err +} + +func (k *kafkaNotifier) TicketUpdated(ctx context.Context, ticket *model.Ticket) error { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + pMsg := &msg.TicketUpdatedMessage{NewTicket: ticket.ToProto()} + bytes, err := proto.Marshal(pMsg) + if err != nil { + return err + } + + err = k.w.WriteMessages(ctx, kafka.Message{ + Headers: []kafka.Header{{Key: "X-Proto-Type", Value: []byte(pMsg.ProtoReflect().Descriptor().FullName())}}, + Value: bytes, + }) + + return err +} + +func (k *kafkaNotifier) TicketDeleted(ctx context.Context, ticket *pb.Ticket, reason msg.TicketDeletedMessage_Reason) error { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + pMsg := &msg.TicketDeletedMessage{Ticket: ticket, Reason: reason} + bytes, err := proto.Marshal(pMsg) + if err != nil { + return err + } + + err = k.w.WriteMessages(ctx, kafka.Message{ + Headers: []kafka.Header{{Key: "X-Proto-Type", Value: []byte(pMsg.ProtoReflect().Descriptor().FullName())}}, + Value: bytes, + }) + + return err +} + +func (k *kafkaNotifier) PendingMatchCreated(ctx context.Context, match *model.PendingMatch) error { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + pMsg := &msg.PendingMatchCreatedMessage{PendingMatch: match.ToProto()} + bytes, err := proto.Marshal(pMsg) + if err != nil { + return err + } + + err = k.w.WriteMessages(ctx, kafka.Message{ + Headers: []kafka.Header{{Key: "X-Proto-Type", Value: []byte(pMsg.ProtoReflect().Descriptor().FullName())}}, + Value: bytes, + }) + + return err +} + +func (k *kafkaNotifier) PendingMatchUpdated(ctx context.Context, match *model.PendingMatch) error { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + pMsg := &msg.PendingMatchUpdatedMessage{PendingMatch: match.ToProto()} + bytes, err := proto.Marshal(pMsg) + if err != nil { + return err + } + + err = k.w.WriteMessages(ctx, kafka.Message{ + Headers: []kafka.Header{{Key: "X-Proto-Type", Value: []byte(pMsg.ProtoReflect().Descriptor().FullName())}}, + Value: bytes, + }) + + return err +} + +func (k *kafkaNotifier) PendingMatchDeleted(ctx context.Context, match *model.PendingMatch, reason msg.PendingMatchDeletedMessage_Reason) error { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + pMsg := &msg.PendingMatchDeletedMessage{PendingMatch: match.ToProto(), Reason: reason} + bytes, err := proto.Marshal(pMsg) + if err != nil { + return err + } + + err = k.w.WriteMessages(ctx, kafka.Message{ + Headers: []kafka.Header{{Key: "X-Proto-Type", Value: []byte(pMsg.ProtoReflect().Descriptor().FullName())}}, + Value: bytes, + }) + + return err +} + +func (k *kafkaNotifier) MatchCreated(ctx context.Context, match *pb.Match) error { + ctx, cancel := context.WithCancel(ctx) + defer cancel() + + pMsg := &msg.MatchCreatedMessage{Match: match} + bytes, err := proto.Marshal(pMsg) + if err != nil { + return err + } + + err = k.w.WriteMessages(ctx, kafka.Message{ + Headers: []kafka.Header{{Key: "X-Proto-Type", Value: []byte(pMsg.ProtoReflect().Descriptor().FullName())}}, + Value: bytes, + }) + + return err +} diff --git a/services/kurushimi/internal/matchfunction/common.go b/services/kurushimi/internal/matchfunction/common.go new file mode 100644 index 0000000..486717e --- /dev/null +++ b/services/kurushimi/internal/matchfunction/common.go @@ -0,0 +1 @@ +package matchfunction diff --git a/services/kurushimi/internal/matchfunction/countdown.go b/services/kurushimi/internal/matchfunction/countdown.go new file mode 100644 index 0000000..0a27b15 --- /dev/null +++ b/services/kurushimi/internal/matchfunction/countdown.go @@ -0,0 +1,219 @@ +package matchfunction + +import ( + "github.com/emortalmc/live-config-parser/golang/pkg/liveconfig" + "github.com/emortalmc/mono-services/services/kurushimi/internal/repository/model" + pb "github.com/emortalmc/proto-specs/gen/go/model/matchmaker" + "go.mongodb.org/mongo-driver/bson/primitive" + "go.uber.org/zap" + "sort" + "time" +) + +// CountdownRemoveInvalidPendingMatches removes pending matches from the pendingMatches array that don't have enough players. +// returns the pending matches that have been removed. +// This method also updates the PlayerCount field of the pending matches that are still valid. +func CountdownRemoveInvalidPendingMatches(pendingMatches map[primitive.ObjectID]*model.PendingMatch, + tickets map[primitive.ObjectID]*model.Ticket, config *liveconfig.GameModeConfig) (deletedPendingMatches []*model.PendingMatch) { + + for id, pendingMatch := range pendingMatches { + playerCount := getPendingMatchPlayerCount(tickets, pendingMatch) + if playerCount < config.MinPlayers { + deletedPendingMatches = append(deletedPendingMatches, pendingMatch) + + // remove pending match from pendingMatches + delete(pendingMatches, id) + + // put tickets back into the pool + for _, ticketId := range pendingMatch.TicketIds { + if ticket, ok := tickets[ticketId]; ok { + ticket.UpdateInPendingMach(false) // TODO not working + } + } + } else { + pendingMatch.PlayerCount = playerCount + } + } + + return +} + +// RunCountdown +// returns: +// - updatedPendingMatches: pending matches that have been created or updated. These should be saved with upsert. +// - deletedPendingMatches: pending matches that have been deleted (either because < min players or converted to a Match) +// - createdMatches: matches that have been created. +// TODO what about the tickets no longer used? +func RunCountdown(logger *zap.SugaredLogger, ticketMap map[primitive.ObjectID]*model.Ticket, + pendingMatches map[primitive.ObjectID]*model.PendingMatch, config *liveconfig.GameModeConfig) ( + createdPendingMatches []*model.PendingMatch, updatedPendingMatches []*model.PendingMatch, + deletedPendingMatches []*model.PendingMatch, createdMatches []*pb.Match, err error) { + + updatedPendingMatches = make([]*model.PendingMatch, 0) + deletedPendingMatches = make([]*model.PendingMatch, 0) + createdMatches = make([]*pb.Match, 0) + + remainingTicketMap := make(map[primitive.ObjectID]*model.Ticket) + for ticketId, ticket := range ticketMap { + if !ticket.InPendingMatch { + remainingTicketMap[ticketId] = ticket + } + } + + // for remaining tickets, try to fill pending matches + filledPendingMatches := fillPendingMatches(remainingTicketMap, pendingMatches, config) + updatedPendingMatches = append(updatedPendingMatches, filledPendingMatches...) + + enoughPlayers := false + playerCount := 0 + for _, ticket := range remainingTicketMap { + playerCount += len(ticket.PlayerIds) + if playerCount >= config.MinPlayers { + enoughPlayers = true + break + } + } + + // create new pending matches if there are still tickets left + if enoughPlayers { + logger.Debugw("RunCountdown creating new pending matches", "remainingTicketMap", len(remainingTicketMap)) + remainingTickets := make([]*model.Ticket, len(remainingTicketMap)) + i := 0 + for _, ticket := range remainingTicketMap { + remainingTickets[i] = ticket + i++ + } + + newPendingMatches := createPendingMatches(remainingTickets, config) + createdPendingMatches = append(createdPendingMatches, newPendingMatches...) + + logger.Debugw("RunCountdown created new pending matches", "newPendingMatches", len(newPendingMatches)) + } + + // Go through PendingMatches and create Matches if TeleportTime has passed + for id, pendingMatch := range pendingMatches { + if pendingMatch.TeleportTime.Before(time.Now()) { + match := finalisePendingMatch(ticketMap, config, pendingMatch) + + createdMatches = append(createdMatches, match) + + // remove from pendingMatches + delete(pendingMatches, id) + deletedPendingMatches = append(deletedPendingMatches, pendingMatch) + + // TODO notify + } + } + + return +} + +func finalisePendingMatch(ticketMap map[primitive.ObjectID]*model.Ticket, config *liveconfig.GameModeConfig, pendingMatch *model.PendingMatch) *pb.Match { + pbTickets := make([]*pb.Ticket, len(pendingMatch.TicketIds)) + for j, ticketId := range pendingMatch.TicketIds { + ticket := ticketMap[ticketId] + pbTickets[j] = ticket.ToProto() + } + + // create match + match := &pb.Match{ + Id: primitive.NewObjectID().Hex(), + GameModeId: config.Id, + Tickets: pbTickets, + MapId: nil, // Done by the director + Assignment: nil, // Done by the director + } + + return match +} + +// fillPendingMatches +// NOTE: The tickets map passed in should be mutable and tolerate tickets being removed when they are assigned. +func fillPendingMatches(tickets map[primitive.ObjectID]*model.Ticket, pendingMatches map[primitive.ObjectID]*model.PendingMatch, config *liveconfig.GameModeConfig) []*model.PendingMatch { + updatedPendingMatches := make([]*model.PendingMatch, 0) + + for _, pendingMatch := range pendingMatches { + remainingSpace := config.MaxPlayers - getPendingMatchPlayerCount(tickets, pendingMatch) + updated := false + + for ticketId, ticket := range tickets { + if len(ticket.PlayerIds) <= remainingSpace { + // add ticket to pending match + pendingMatch.TicketIds = append(pendingMatch.TicketIds, ticketId) + ticket.UpdateInPendingMach(true) + + // remove ticket from the tickets map + delete(tickets, ticketId) + + remainingSpace -= len(ticket.PlayerIds) + updated = true + } + } + + if updated { + pendingMatch.PlayerCount = getPendingMatchPlayerCount(tickets, pendingMatch) + updatedPendingMatches = append(updatedPendingMatches, pendingMatch) + } + } + + return updatedPendingMatches +} + +func createPendingMatches(tickets []*model.Ticket, config *liveconfig.GameModeConfig) []*model.PendingMatch { + createdPendingMatches := make([]*model.PendingMatch, 0) + + remainingPlayerCount := 0 + for _, ticket := range tickets { + remainingPlayerCount += len(ticket.PlayerIds) + } + + sort.Slice(tickets, func(i, j int) bool { + return len(tickets[i].PlayerIds) > len(tickets[j].PlayerIds) + }) + + // Whilst sufficient players, make new PendingMatches + // Each iteration will create a new PendingMatch and fill it with tickets + // TODO still needs some rework to follow the above desc + for remainingPlayerCount >= config.MinPlayers { + teleportTime := time.Now().Add(10 * time.Second) // TODO make this predictive of when the batch is going to run to reduce perceived lag + currentPendingMatch := &model.PendingMatch{ + Id: primitive.NewObjectID(), + GameModeId: config.Id, + TicketIds: make([]primitive.ObjectID, 0), + TeleportTime: &teleportTime, + } + + pendingMatchSpace := config.MaxPlayers + + // fill the current pending match with tickets + for _, ticket := range tickets { + if len(ticket.PlayerIds) <= pendingMatchSpace { + currentPendingMatch.TicketIds = append(currentPendingMatch.TicketIds, ticket.Id) + currentPendingMatch.PlayerCount += len(ticket.PlayerIds) + ticket.UpdateInPendingMach(true) + + remainingPlayerCount -= len(ticket.PlayerIds) + pendingMatchSpace -= len(ticket.PlayerIds) + } + + if pendingMatchSpace == 0 { + break + } + } + + // Match is either full or we have no more tickets that fit into it + createdPendingMatches = append(createdPendingMatches, currentPendingMatch) + } + + return createdPendingMatches +} + +func getPendingMatchPlayerCount(tickets map[primitive.ObjectID]*model.Ticket, pendingMatch *model.PendingMatch) int { + count := 0 + for _, ticketId := range pendingMatch.TicketIds { + if ticket, ok := tickets[ticketId]; ok { + count += len(ticket.PlayerIds) + } + } + return count +} diff --git a/services/kurushimi/internal/matchfunction/instant.go b/services/kurushimi/internal/matchfunction/instant.go new file mode 100644 index 0000000..c91f590 --- /dev/null +++ b/services/kurushimi/internal/matchfunction/instant.go @@ -0,0 +1,48 @@ +package matchfunction + +import ( + "github.com/emortalmc/live-config-parser/golang/pkg/liveconfig" + "github.com/emortalmc/mono-services/services/kurushimi/internal/repository/model" + pb "github.com/emortalmc/proto-specs/gen/go/model/matchmaker" + "go.mongodb.org/mongo-driver/bson/primitive" +) + +func RunInstant(tickets []*model.Ticket, config *liveconfig.GameModeConfig) (createdMatches []*pb.Match, err error) { + createdMatches = make([]*pb.Match, 0) + + currentPlayerCount := 0 + currentMatch := &pb.Match{ + Id: primitive.NewObjectID().Hex(), + GameModeId: config.Id, + Tickets: make([]*pb.Ticket, 0), + MapId: nil, // Done by the director + Assignment: nil, // Done by the director + } + + for _, ticket := range tickets { + currentPlayerCount += len(ticket.PlayerIds) + + // The match becomes too full with this ticket, finalize this match + if currentPlayerCount > config.MaxPlayers { + createdMatches = append(createdMatches, currentMatch) + + // Note: we set the player count to the current ticket's player count as we continue creating matches here + currentPlayerCount = len(ticket.PlayerIds) + currentMatch = &pb.Match{ + Id: primitive.NewObjectID().Hex(), + GameModeId: config.Id, + Tickets: make([]*pb.Ticket, 0), + MapId: nil, // Done by the director + Assignment: nil, // Done by the director + } + } + + currentMatch.Tickets = append(currentMatch.Tickets, ticket.ToProto()) + } + + if currentPlayerCount >= config.MinPlayers { + createdMatches = append(createdMatches, currentMatch) + } + + return createdMatches, nil +} diff --git a/services/kurushimi/internal/matchfunction/private_match.go b/services/kurushimi/internal/matchfunction/private_match.go new file mode 100644 index 0000000..a0b4655 --- /dev/null +++ b/services/kurushimi/internal/matchfunction/private_match.go @@ -0,0 +1,3 @@ +package matchfunction + +//TODO func RunPrivateMatch diff --git a/services/kurushimi/internal/repository/model/README.md b/services/kurushimi/internal/repository/model/README.md new file mode 100644 index 0000000..7070963 --- /dev/null +++ b/services/kurushimi/internal/repository/model/README.md @@ -0,0 +1,26 @@ +# model + +## The lifecycle of models + +### QueuedPlayer + +A QueuedPlayer will exist from the time a ticket is created until the ticket is completely finished with. +This means it will be present until a Match is created (or a PendingMatch becomes a Match). + +### PendingMatch + +A PendingMatch exists for gamemodes that don't have instant matchmaking. A PendingMatch will exist +until the countdown is finished, and it is converted into a Match. A PendingMatch may also be deleted +if the countdown is cancelled (e.g. due to configuration changes) or if the minimum gamemode requirements are +no longer satisfied (e.g. the minimum player count is no longer satisfied). + +### Match + +A Match model doesn't exist as it isn't stored in the database. It exists only as a protobuf. +A Match is created when an instant match occurs or a PendingMatch is converted into one. +When a Match is created, it is at this point a server is allocated and a message is fired. + +### Ticket + +A Ticket represents one or more players that are queueing for gamemode. It may also contain data on the party +that player(s) belong to. A Ticket is created when a player queues for a gamemode and is deleted when a Match is made. diff --git a/services/kurushimi/internal/repository/model/model.go b/services/kurushimi/internal/repository/model/model.go new file mode 100644 index 0000000..5ad4b69 --- /dev/null +++ b/services/kurushimi/internal/repository/model/model.go @@ -0,0 +1,162 @@ +package model + +import ( + "github.com/emortalmc/mono-services/services/kurushimi/internal/utils" + pb "github.com/emortalmc/proto-specs/gen/go/model/matchmaker" + "github.com/google/uuid" + "go.mongodb.org/mongo-driver/bson/primitive" + "google.golang.org/protobuf/types/known/timestamppb" + "time" +) + +type QueuedPlayer struct { + PlayerId uuid.UUID `bson:"_id"` + TicketId primitive.ObjectID `bson:"ticketId"` + + // MapId the map the player has voted for, nil if not voted + MapId *string `bson:"mapId,omitempty"` +} + +func (q *QueuedPlayer) ToProto() *pb.QueuedPlayer { + return &pb.QueuedPlayer{ + Id: q.PlayerId.String(), + TicketId: q.TicketId.Hex(), + MapId: q.MapId, + } +} + +type Ticket struct { + Id primitive.ObjectID `bson:"_id"` + + Removals *TicketRemovals `bson:"removals,omitempty"` + + // InPendingMatch is true if the ticket is currently in a pending match + InPendingMatch bool `bson:"inPendingMatch"` + + // party fields are only present if the ticket is for a party + // YES, this is still possible. It's mainly used for when a player is requesting an initial lobby, + // so they aren't technically in a party yet. + PartyId *primitive.ObjectID `bson:"partyId, omitempty"` + PartySettings *ReducedPartySettings `bson:"partySettings"` + + PlayerIds []uuid.UUID `bson:"playerIds"` + GameModeId string `bson:"gameModeId"` + + AutoTeleport bool `bson:"autoTeleport"` + + InternalUpdates *TicketInternalUpdates `bson:"-"` +} + +func NewTicket(partyId *primitive.ObjectID, partySettings *ReducedPartySettings, playerIds []uuid.UUID, + gameModeId string, autoTeleport bool) *Ticket { + + return &Ticket{ + Id: primitive.NewObjectID(), + Removals: nil, + InPendingMatch: false, + PartyId: partyId, + PartySettings: partySettings, + PlayerIds: playerIds, + GameModeId: gameModeId, + AutoTeleport: autoTeleport, + } +} + +func (t *Ticket) ToProto() *pb.Ticket { + pbPlayerIds := make([]string, len(t.PlayerIds)) + for i, playerId := range t.PlayerIds { + pbPlayerIds[i] = playerId.String() + } + + var partyId *string + if t.PartyId != nil { + partyId = utils.PointerOf(t.PartyId.Hex()) + } + + return &pb.Ticket{ + Id: t.Id.Hex(), + PartyId: partyId, + CreatedAt: timestamppb.New(t.Id.Timestamp()), + PlayerIds: pbPlayerIds, + GameModeId: t.GameModeId, + AutoTeleport: t.AutoTeleport, + InPendingMatch: t.InPendingMatch, + } +} + +type TicketRemovals struct { + MarkedForRemoval bool `bson:"markedForRemoval"` + PlayersForRemoval []uuid.UUID `bson:"playersForRemoval"` +} + +type ReducedPartySettings struct { + LeaderId uuid.UUID `bson:"leaderId"` + + DequeueOnDisconnect bool `bson:"dequeueOnDisconnect"` + AllowMemberDequeue bool `bson:"allowMemberDequeue"` +} + +// TicketInternalUpdates are updates not stored in the database but used internally once extracted. +// e.g. marking when a ticket's InPendingMatchUpdated field is updated +// the presence of this struct indicates that the ticket has been updated +type TicketInternalUpdates struct { + InPendingMatchUpdated bool +} + +func (t *Ticket) UpdateInPendingMach(value bool) { + t.InPendingMatch = value + if t.InternalUpdates == nil { + t.InternalUpdates = &TicketInternalUpdates{} + } + + t.InternalUpdates.InPendingMatchUpdated = true +} + +// TODO use this method +// MarkUpdated doesn't perform any updates but marks the ticket as updated. +// This is currently only used by the director for Kafka events. +func (t *Ticket) MarkUpdated() { + if t.InternalUpdates == nil { + t.InternalUpdates = &TicketInternalUpdates{} + } +} + +type PendingMatch struct { + Id primitive.ObjectID `bson:"_id"` + + GameModeId string `bson:"gameModeId"` + + TicketIds []primitive.ObjectID `bson:"ticketIds"` + PlayerCount int `bson:"playerCount"` + + TeleportTime *time.Time `bson:"teleportTime"` +} + +func (m *PendingMatch) ToProto() *pb.PendingMatch { + pbTicketIds := make([]string, len(m.TicketIds)) + for i, ticketId := range m.TicketIds { + pbTicketIds[i] = ticketId.Hex() + } + + return &pb.PendingMatch{ + Id: m.Id.Hex(), + GameModeId: m.GameModeId, + TicketIds: pbTicketIds, + TeleportTime: timestamppb.New(*m.TeleportTime), + PlayerCount: int64(m.PlayerCount), + } +} + +// Backfill represents a backfill that is currently available. +// backfills are not yet finished or enabled :) +type Backfill struct { + Id primitive.ObjectID `bson:"_id"` + + ServerInfo *ServerInfo `bson:"serverInfo"` +} + +type ServerInfo struct { + Address string `bson:"address"` + Port uint32 `bson:"port"` + Name string `bson:"name"` +} diff --git a/services/kurushimi/internal/repository/mongo.go b/services/kurushimi/internal/repository/mongo.go new file mode 100644 index 0000000..c7e41b6 --- /dev/null +++ b/services/kurushimi/internal/repository/mongo.go @@ -0,0 +1,164 @@ +package repository + +import ( + "context" + "fmt" + "github.com/emortalmc/mono-services/services/kurushimi/internal/config" + "github.com/emortalmc/mono-services/services/kurushimi/internal/repository/registrytypes" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/bson/bsoncodec" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/mongo/options" + "go.mongodb.org/mongo-driver/mongo/writeconcern" + "go.uber.org/zap" + "sync" + "time" +) + +var _ Repository = &mongoRepository{} + +type mongoRepository struct { + client *mongo.Client + database *mongo.Database + + queuedPlayerCollection *mongo.Collection + ticketCollection *mongo.Collection + pendingMatchCollection *mongo.Collection + backfillCollection *mongo.Collection +} + +func NewMongoRepository(ctx context.Context, wg *sync.WaitGroup, logger *zap.SugaredLogger, cfg config.MongoDBConfig) (Repository, error) { + client, err := mongo.Connect(ctx, options.Client().ApplyURI(cfg.URI).SetRegistry(createCodecRegistry())) + if err != nil { + return nil, err + } + + database := client.Database(databaseName) + repo := &mongoRepository{ + client: client, + database: database, + + queuedPlayerCollection: database.Collection(queuedPlayerCollectionName), + ticketCollection: database.Collection(ticketCollectionName), + pendingMatchCollection: database.Collection(pendingMatchCollectionName), + backfillCollection: database.Collection(backfillCollectionName), + } + + wg.Add(1) + go func() { + defer wg.Done() + <-ctx.Done() + if err := client.Disconnect(ctx); err != nil { + logger.Errorw("failed to disconnect from mongo", err) + } + }() + + repo.createIndexes(ctx) + logger.Infow("created mongo indexes") + + return repo, nil +} + +var ( + // no queued player indexes + + ticketIndexes = []mongo.IndexModel{ + { + Keys: bson.M{"playerIds": 1}, + Options: options.Index().SetName("playerIds"), + }, + { + Keys: bson.M{"gameModeId": 1}, + Options: options.Index().SetName("gameModeId"), + }, + { + Keys: bson.D{{Key: "gameModeId", Value: 1}, {Key: "inPendingMatch", Value: 1}}, + Options: options.Index().SetName("gameModeId_inPendingMatch"), + }, + { + Keys: bson.D{{Key: "gameModeId", Value: 1}, {Key: "removals", Value: 1}}, + Options: options.Index().SetName("gameModeId_removals"), + }, + { + Keys: bson.M{"partyId": 1}, + Options: options.Index().SetName("partyId"), + }, + } + + pendingMatchIndexes = []mongo.IndexModel{ + { + Keys: bson.M{"gameModeId": 1}, + Options: options.Index().SetName("gameModeId"), + }, + { + Keys: bson.M{"ticketIds": 1}, + Options: options.Index().SetName("ticketIds"), + }, + } +) + +func (m *mongoRepository) createIndexes(ctx context.Context) { + collIndexes := map[*mongo.Collection][]mongo.IndexModel{ + m.ticketCollection: ticketIndexes, + m.pendingMatchCollection: pendingMatchIndexes, + } + + wg := sync.WaitGroup{} + wg.Add(len(collIndexes)) + + for coll, indexes := range collIndexes { + go func(coll *mongo.Collection, indexes []mongo.IndexModel) { + defer wg.Done() + _, err := m.createCollIndexes(ctx, coll, indexes) + if err != nil { + panic(fmt.Sprintf("failed to create indexes for collection %s: %s", coll.Name(), err)) + } + }(coll, indexes) + } + + wg.Wait() +} + +func (m *mongoRepository) createCollIndexes(ctx context.Context, coll *mongo.Collection, indexes []mongo.IndexModel) (int, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + result, err := coll.Indexes().CreateMany(ctx, indexes) + if err != nil { + return 0, err + } + + return len(result), nil +} + +func (m *mongoRepository) HealthCheck(ctx context.Context, timeout time.Duration) error { + ctx, cancel := context.WithTimeout(ctx, timeout) + defer cancel() + + return m.client.Ping(ctx, nil) +} + +func (m *mongoRepository) ExecuteTransaction(ctx context.Context, fn func(ctx mongo.SessionContext) error) error { + txnOpts := options.Transaction().SetWriteConcern(writeconcern.Majority()) + + session, err := m.client.StartSession() + if err != nil { + return err + } + defer session.EndSession(ctx) + + _, err = session.WithTransaction(ctx, func(sessCtx mongo.SessionContext) (interface{}, error) { + return nil, fn(sessCtx) + }, txnOpts) + + return err +} + +func createCodecRegistry() *bsoncodec.Registry { + r := bson.NewRegistry() + + r.RegisterTypeEncoder(registrytypes.UUIDType, bsoncodec.ValueEncoderFunc(registrytypes.UuidEncodeValue)) + r.RegisterTypeDecoder(registrytypes.UUIDType, bsoncodec.ValueDecoderFunc(registrytypes.UuidDecodeValue)) + + return r +} diff --git a/services/kurushimi/internal/repository/mongo_pending_match.go b/services/kurushimi/internal/repository/mongo_pending_match.go new file mode 100644 index 0000000..7719c79 --- /dev/null +++ b/services/kurushimi/internal/repository/mongo_pending_match.go @@ -0,0 +1,100 @@ +package repository + +import ( + "context" + "github.com/emortalmc/mono-services/services/kurushimi/internal/repository/model" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo" + "time" +) + +func (m *mongoRepository) CreatePendingMatch(ctx context.Context, match *model.PendingMatch) error { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + _, err := m.pendingMatchCollection.InsertOne(ctx, match) + return err +} + +func (m *mongoRepository) CreatePendingMatches(ctx context.Context, matches []*model.PendingMatch) error { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + converted := make([]interface{}, len(matches)) + for i, match := range matches { + converted[i] = match + } + _, err := m.pendingMatchCollection.InsertMany(ctx, converted) + return err +} + +func (m *mongoRepository) UpdatePendingMatches(ctx context.Context, matches []*model.PendingMatch) error { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + models := make([]mongo.WriteModel, len(matches)) + for i, match := range matches { + models[i] = mongo.NewUpdateOneModel(). + SetFilter(bson.M{"_id": match.Id}). + SetUpdate(bson.M{"$set": match}) + } + + _, err := m.pendingMatchCollection.BulkWrite(ctx, models) + return err +} + +func (m *mongoRepository) DeletePendingMatches(ctx context.Context, matchIds []primitive.ObjectID) error { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + filter := bson.M{"_id": bson.M{"$in": matchIds}} + _, err := m.pendingMatchCollection.DeleteMany(ctx, filter) + return err +} + +func (m *mongoRepository) GetPendingMatchesByGameMode(ctx context.Context, gameModeId string) ([]*model.PendingMatch, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + cursor, err := m.pendingMatchCollection.Find(ctx, bson.M{"gameModeId": gameModeId}) + if err != nil { + return nil, err + } + + var matches []*model.PendingMatch + err = cursor.All(ctx, &matches) + if err != nil { + return nil, err + } + + return matches, nil +} + +func (m *mongoRepository) GetPendingMatchByTicketId(ctx context.Context, ticketId primitive.ObjectID) (*model.PendingMatch, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + var match model.PendingMatch + + if err := m.pendingMatchCollection.FindOne(ctx, bson.M{"ticketIds": ticketId}).Decode(&match); err != nil { + return nil, err + } + + return &match, nil +} + +func (m *mongoRepository) RemoveTicketsFromPendingMatchesById(ctx context.Context, ticketIds []primitive.ObjectID) (int64, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + filter := bson.M{"ticketIds": bson.M{"$in": ticketIds}} + update := bson.M{"$pull": bson.M{"ticketIds": bson.M{"$in": ticketIds}}} + + result, err := m.pendingMatchCollection.UpdateMany(ctx, filter, update) + if err != nil { + return 0, err + } + + return result.ModifiedCount, nil +} diff --git a/services/kurushimi/internal/repository/mongo_queued_player.go b/services/kurushimi/internal/repository/mongo_queued_player.go new file mode 100644 index 0000000..a31accc --- /dev/null +++ b/services/kurushimi/internal/repository/mongo_queued_player.go @@ -0,0 +1,89 @@ +package repository + +import ( + "context" + "github.com/emortalmc/mono-services/services/kurushimi/internal/repository/model" + "github.com/google/uuid" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo" + "time" +) + +func (m *mongoRepository) CreateQueuedPlayers(ctx context.Context, players []*model.QueuedPlayer) error { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + converted := make([]interface{}, len(players)) + for i, player := range players { + converted[i] = player + } + + _, err := m.queuedPlayerCollection.InsertMany(ctx, converted) + return err +} + +func (m *mongoRepository) DeleteQueuedPlayer(ctx context.Context, playerId uuid.UUID) error { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + _, err := m.queuedPlayerCollection.DeleteOne(ctx, bson.M{"_id": playerId}) + return err +} + +func (m *mongoRepository) DeleteAllQueuedPlayersById(ctx context.Context, playerIds []uuid.UUID) (int64, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + result, err := m.queuedPlayerCollection.DeleteMany(ctx, bson.M{"_id": bson.M{"$in": playerIds}}) + if err != nil { + return 0, err + } + + return result.DeletedCount, nil +} + +func (m *mongoRepository) GetQueuedPlayerById(ctx context.Context, playerId uuid.UUID) (*model.QueuedPlayer, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + var player model.QueuedPlayer + if err := m.queuedPlayerCollection.FindOne(ctx, bson.M{"_id": playerId}).Decode(&player); err != nil { + return nil, err + } + + return &player, nil +} + +func (m *mongoRepository) GetAllQueuedPlayersByIds(ctx context.Context, playerIds []uuid.UUID) ([]*model.QueuedPlayer, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + cursor, err := m.queuedPlayerCollection.Find(ctx, bson.M{"_id": bson.M{"$in": playerIds}}) + if err != nil { + return nil, err + } + + var players []*model.QueuedPlayer + err = cursor.All(ctx, &players) + if err != nil { + return nil, err + } + + return players, nil +} + +func (m *mongoRepository) SetMapIdOfQueuedPlayer(ctx context.Context, playerId uuid.UUID, mapId string) error { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + result, err := m.queuedPlayerCollection.UpdateOne(ctx, bson.M{"_id": playerId}, bson.M{"$set": bson.M{"mapId": mapId}}) + if err != nil { + return err + } + + if result.MatchedCount == 0 { + return mongo.ErrNoDocuments + } + + return nil +} diff --git a/services/kurushimi/internal/repository/mongo_ticket.go b/services/kurushimi/internal/repository/mongo_ticket.go new file mode 100644 index 0000000..115a7aa --- /dev/null +++ b/services/kurushimi/internal/repository/mongo_ticket.go @@ -0,0 +1,196 @@ +package repository + +import ( + "context" + "github.com/emortalmc/mono-services/services/kurushimi/internal/repository/model" + "github.com/google/uuid" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo" + "time" +) + +func (m *mongoRepository) CreateTicket(ctx context.Context, ticket *model.Ticket) error { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + _, err := m.ticketCollection.InsertOne(ctx, ticket) + return err +} + +func (m *mongoRepository) DeleteTicket(ctx context.Context, ticketId primitive.ObjectID) error { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + res, err := m.ticketCollection.DeleteOne(ctx, bson.M{"_id": ticketId}) + if err != nil { + return err + } + if res.DeletedCount == 0 { + return mongo.ErrNoDocuments + } + return err +} + +func (m *mongoRepository) MassUpdateTicketInPendingMatch(ctx context.Context, values map[primitive.ObjectID]bool) (int64, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + var updates []mongo.WriteModel + for ticketId, inPendingMatch := range values { + updates = append(updates, mongo.NewUpdateOneModel().SetFilter(bson.M{"_id": ticketId}).SetUpdate(bson.M{"$set": bson.M{"inPendingMatch": inPendingMatch}})) + } + + res, err := m.ticketCollection.BulkWrite(ctx, updates) + if err != nil { + return 0, err + } + + return res.ModifiedCount, nil +} + +func (m *mongoRepository) DeleteAllTicketsById(ctx context.Context, ticketIds []primitive.ObjectID) (int64, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + result, err := m.ticketCollection.DeleteMany(ctx, bson.M{"_id": bson.M{"$in": ticketIds}}) + if err != nil { + return 0, err + } + + return result.DeletedCount, nil +} + +func (m *mongoRepository) GetTicketByPlayerId(ctx context.Context, playerId uuid.UUID) (*model.Ticket, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + var ticket model.Ticket + err := m.ticketCollection.FindOne(ctx, bson.M{"playerIds": playerId}).Decode(&ticket) + if err != nil { + return nil, err + } + + return &ticket, nil +} + +func (m *mongoRepository) GetTicketsByGameMode(ctx context.Context, gameModeId string) ([]*model.Ticket, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + cursor, err := m.ticketCollection.Find(ctx, bson.M{"gameModeId": gameModeId}) + if err != nil { + return nil, err + } + + var tickets []*model.Ticket + err = cursor.All(ctx, &tickets) + + return tickets, err +} + +func (m *mongoRepository) GetUnmatchedTicketsByGameMode(ctx context.Context, gameModeId string) ([]*model.Ticket, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + cursor, err := m.ticketCollection.Find(ctx, bson.M{"gameModeId": gameModeId, "inPendingMatch": false}) + if err != nil { + return nil, err + } + + var tickets []*model.Ticket + err = cursor.All(ctx, &tickets) + if err != nil { + return nil, err + } + + return tickets, nil +} + +func (m *mongoRepository) AddTicketDequeueRequest(ctx context.Context, ticketId primitive.ObjectID) (int64, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + result, err := m.ticketCollection.UpdateOne(ctx, bson.M{"_id": ticketId}, bson.M{"$set": bson.M{"removals.markedForRemoval": true}}) + if err != nil { + return 0, err + } + + return result.ModifiedCount, nil +} + +func (m *mongoRepository) AddPlayerDequeueRequest(ctx context.Context, ticketId primitive.ObjectID, playerId uuid.UUID) error { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + _, err := m.ticketCollection.UpdateOne(ctx, bson.M{"_id": ticketId}, bson.M{"$addToSet": bson.M{"removals.playersForRemoval": playerId}}) + return err +} + +func (m *mongoRepository) ResetAllDequeueRequestsById(ctx context.Context, ticketIds []primitive.ObjectID) (int64, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + result, err := m.ticketCollection.UpdateMany(ctx, bson.M{"_id": bson.M{"$in": ticketIds}}, bson.M{"$unset": bson.M{"removals": ""}}) + if err != nil { + return 0, err + } + + return result.ModifiedCount, nil +} + +func (m *mongoRepository) GetTicketsWithDequeueRequest(ctx context.Context, gameModeId string) ([]*model.Ticket, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + cursor, err := m.ticketCollection.Find(ctx, bson.M{"gameModeId": gameModeId, "removals": bson.M{"$exists": true}}) + if err != nil { + return nil, err + } + + var tickets []*model.Ticket + err = cursor.All(ctx, &tickets) + if err != nil { + return nil, err + } + + return tickets, nil +} + +func (m *mongoRepository) IsPartyQueued(ctx context.Context, partyId primitive.ObjectID) (bool, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + count, err := m.ticketCollection.CountDocuments(ctx, bson.M{"partyId": partyId}) + if err != nil { + return false, err + } + + return count > 0, nil +} + +func (m *mongoRepository) AddTicketDequeueRequestByPartyId(ctx context.Context, partyId primitive.ObjectID) (int64, error) { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + filter := bson.M{"partyId": partyId} + update := bson.M{"$set": bson.M{"removals.markedForRemoval": true}} + + result, err := m.ticketCollection.UpdateOne(ctx, filter, update) + if err != nil { + return 0, err + } + + return result.ModifiedCount, nil +} + +func (m *mongoRepository) AddPlayerDequeueRequestByPartyId(ctx context.Context, partyId primitive.ObjectID, playerId uuid.UUID) error { + ctx, cancel := context.WithTimeout(ctx, 5*time.Second) + defer cancel() + + filter := bson.M{"partyId": partyId} + update := bson.M{"$addToSet": bson.M{"removals.playersForRemoval": playerId}} + + _, err := m.ticketCollection.UpdateOne(ctx, filter, update) + return err +} diff --git a/services/kurushimi/internal/repository/public.go b/services/kurushimi/internal/repository/public.go new file mode 100644 index 0000000..7e3a8e4 --- /dev/null +++ b/services/kurushimi/internal/repository/public.go @@ -0,0 +1,85 @@ +package repository + +import ( + "context" + "github.com/emortalmc/mono-services/services/kurushimi/internal/repository/model" + "github.com/google/uuid" + "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo" + "time" +) + +const ( + databaseName = "matchmaker" + + queuedPlayerCollectionName = "queuedPlayer" + ticketCollectionName = "ticket" + pendingMatchCollectionName = "pendingMatch" + backfillCollectionName = "backfill" +) + +type Repository interface { + HealthCheck(ctx context.Context, timeout time.Duration) error + + ExecuteTransaction(ctx context.Context, fn func(ctx mongo.SessionContext) error) error + + // QueuedPlayer + + CreateQueuedPlayers(ctx context.Context, players []*model.QueuedPlayer) error + DeleteQueuedPlayer(ctx context.Context, playerId uuid.UUID) error + GetQueuedPlayerById(ctx context.Context, playerId uuid.UUID) (*model.QueuedPlayer, error) + + GetAllQueuedPlayersByIds(ctx context.Context, playerIds []uuid.UUID) ([]*model.QueuedPlayer, error) + + // DeleteAllQueuedPlayersById deletes all queued players with the given ids. + // returns: int64, the modified count. + DeleteAllQueuedPlayersById(ctx context.Context, playerIds []uuid.UUID) (int64, error) + + SetMapIdOfQueuedPlayer(ctx context.Context, playerId uuid.UUID, mapId string) error + + // Ticket + + CreateTicket(ctx context.Context, ticket *model.Ticket) error + DeleteTicket(ctx context.Context, ticketId primitive.ObjectID) error + + MassUpdateTicketInPendingMatch(ctx context.Context, values map[primitive.ObjectID]bool) (int64, error) + + // DeleteAllTicketsById deletes all tickets with the given ids. + // returns: int64, the modified count. + DeleteAllTicketsById(ctx context.Context, ticketIds []primitive.ObjectID) (int64, error) + + GetTicketByPlayerId(ctx context.Context, playerId uuid.UUID) (*model.Ticket, error) + GetTicketsByGameMode(ctx context.Context, gameModeId string) ([]*model.Ticket, error) + + // GetUnmatchedTicketsByGameMode TODO Might be unused + GetUnmatchedTicketsByGameMode(ctx context.Context, gameModeId string) ([]*model.Ticket, error) + + // AddTicketDequeueRequest requests that a ticket is void and removed from any PendingMatch. + // returns: int64, the modified count. Throws mongo.ErrNoDocuments if no matches are found. + AddTicketDequeueRequest(ctx context.Context, ticketId primitive.ObjectID) (int64, error) + + AddTicketDequeueRequestByPartyId(ctx context.Context, partyId primitive.ObjectID) (int64, error) + + // AddPlayerDequeueRequest requests that a player is removed from a ticket. + AddPlayerDequeueRequest(ctx context.Context, ticketId primitive.ObjectID, playerId uuid.UUID) error + AddPlayerDequeueRequestByPartyId(ctx context.Context, partyId primitive.ObjectID, playerId uuid.UUID) error + + ResetAllDequeueRequestsById(ctx context.Context, ticketIds []primitive.ObjectID) (int64, error) + + GetTicketsWithDequeueRequest(ctx context.Context, gameModeId string) ([]*model.Ticket, error) + + IsPartyQueued(ctx context.Context, partyId primitive.ObjectID) (bool, error) + + // PendingMatch + + CreatePendingMatch(ctx context.Context, match *model.PendingMatch) error + CreatePendingMatches(ctx context.Context, matches []*model.PendingMatch) error + UpdatePendingMatches(ctx context.Context, matches []*model.PendingMatch) error + DeletePendingMatches(ctx context.Context, matchIds []primitive.ObjectID) error + GetPendingMatchesByGameMode(ctx context.Context, gameModeId string) ([]*model.PendingMatch, error) + GetPendingMatchByTicketId(ctx context.Context, ticketId primitive.ObjectID) (*model.PendingMatch, error) + + // RemoveTicketsFromPendingMatchesById removes ticket IDs from PendingMatches they are present in. + // returns: int64, the modified count. + RemoveTicketsFromPendingMatchesById(ctx context.Context, ticketIds []primitive.ObjectID) (int64, error) +} diff --git a/services/kurushimi/internal/repository/registrytypes/uuid_types.go b/services/kurushimi/internal/repository/registrytypes/uuid_types.go new file mode 100644 index 0000000..eb2262d --- /dev/null +++ b/services/kurushimi/internal/repository/registrytypes/uuid_types.go @@ -0,0 +1,58 @@ +// Package registrytypes +// taken from https://gist.github.com/SupaHam/3afe982dc75039356723600ccc91ff77 +package registrytypes + +import ( + "fmt" + "github.com/google/uuid" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/bson/bsoncodec" + "go.mongodb.org/mongo-driver/bson/bsonrw" + "reflect" +) + +var ( + UUIDType = reflect.TypeOf(uuid.UUID{}) + uuidSubtype = byte(0x04) +) + +func UuidEncodeValue(ec bsoncodec.EncodeContext, vw bsonrw.ValueWriter, val reflect.Value) error { + if !val.IsValid() || val.Type() != UUIDType { + return bsoncodec.ValueEncoderError{Name: "uuidEncodeValue", Types: []reflect.Type{UUIDType}, Received: val} + } + b := val.Interface().(uuid.UUID) + return vw.WriteBinaryWithSubtype(b[:], uuidSubtype) +} + +func UuidDecodeValue(dc bsoncodec.DecodeContext, vr bsonrw.ValueReader, val reflect.Value) error { + if !val.CanSet() || val.Type() != UUIDType { + return bsoncodec.ValueDecoderError{Name: "uuidDecodeValue", Types: []reflect.Type{UUIDType}, Received: val} + } + + var data []byte + var subtype byte + var err error + switch vrType := vr.Type(); vrType { + case bson.TypeBinary: + data, subtype, err = vr.ReadBinary() + if subtype != uuidSubtype { + return fmt.Errorf("unsupported binary subtype %v for UUID", subtype) + } + case bson.TypeNull: + err = vr.ReadNull() + case bson.TypeUndefined: + err = vr.ReadUndefined() + default: + return fmt.Errorf("cannot decode %v into a UUID", vrType) + } + + if err != nil { + return err + } + uuid2, err := uuid.FromBytes(data) + if err != nil { + return err + } + val.Set(reflect.ValueOf(uuid2)) + return nil +} diff --git a/services/kurushimi/internal/service/matchmaker.go b/services/kurushimi/internal/service/matchmaker.go new file mode 100644 index 0000000..41073d6 --- /dev/null +++ b/services/kurushimi/internal/service/matchmaker.go @@ -0,0 +1,455 @@ +package service + +import ( + "context" + "fmt" + "github.com/emortalmc/live-config-parser/golang/pkg/liveconfig" + "github.com/emortalmc/mono-services/services/kurushimi/internal/kafka" + "github.com/emortalmc/mono-services/services/kurushimi/internal/repository" + "github.com/emortalmc/mono-services/services/kurushimi/internal/repository/model" + "github.com/emortalmc/mono-services/services/kurushimi/internal/simplecontroller" + "github.com/emortalmc/proto-specs/gen/go/grpc/matchmaker" + pbparty "github.com/emortalmc/proto-specs/gen/go/grpc/party" + pb "github.com/emortalmc/proto-specs/gen/go/model/matchmaker" + "github.com/google/uuid" + "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo" + "go.uber.org/zap" + "golang.org/x/exp/slices" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "sync" +) + +type matchmakerService struct { + matchmaker.UnimplementedMatchmakerServer + + logger *zap.SugaredLogger + repo repository.Repository + notifier kafka.Notifier + cfgController liveconfig.GameModeConfigController + + lobbyController simplecontroller.SimpleController + velocityController simplecontroller.SimpleController + + partyService pbparty.PartyServiceClient + partySettingsService pbparty.PartySettingsServiceClient +} + +func newMatchmakerService(logger *zap.SugaredLogger, repository repository.Repository, notifier kafka.Notifier, + cfgController liveconfig.GameModeConfigController, lobbyController simplecontroller.SimpleController, + velocityController simplecontroller.SimpleController, + partyService pbparty.PartyServiceClient, partySettingsService pbparty.PartySettingsServiceClient) matchmaker.MatchmakerServer { + + return &matchmakerService{ + logger: logger, + repo: repository, + notifier: notifier, + cfgController: cfgController, + + lobbyController: lobbyController, + velocityController: velocityController, + + partyService: partyService, + partySettingsService: partySettingsService, + } +} + +var ( + queueAlreadyInQueueErr = panicIfErr(status.New(codes.AlreadyExists, "party is already in queue"). + WithDetails(&matchmaker.QueueByPlayerErrorResponse{Reason: matchmaker.QueueByPlayerErrorResponse_ALREADY_IN_QUEUE})).Err() + + queueInvalidGameModeErr = panicIfErr(status.New(codes.InvalidArgument, "invalid game_mode_id"). + WithDetails(&matchmaker.QueueByPlayerErrorResponse{Reason: matchmaker.QueueByPlayerErrorResponse_INVALID_GAME_MODE})).Err() + + queueGameModeDisabledErr = panicIfErr(status.New(codes.InvalidArgument, "game_mode_id is disabled"). + WithDetails(&matchmaker.QueueByPlayerErrorResponse{Reason: matchmaker.QueueByPlayerErrorResponse_GAME_MODE_DISABLED})).Err() + + queueInvalidMapErr = panicIfErr(status.New(codes.InvalidArgument, "invalid map_id"). + WithDetails(&matchmaker.QueueByPlayerErrorResponse{Reason: matchmaker.QueueByPlayerErrorResponse_INVALID_MAP})).Err() + + queuePartyTooLargeErr = panicIfErr(status.New(codes.InvalidArgument, "party is too large"). + WithDetails(&matchmaker.QueueByPlayerErrorResponse{Reason: matchmaker.QueueByPlayerErrorResponse_PARTY_TOO_LARGE})).Err() + + queueNoPermissionErr = panicIfErr(status.New(codes.PermissionDenied, "player does not have permission to queue"). + WithDetails(&matchmaker.QueueByPlayerErrorResponse{Reason: matchmaker.QueueByPlayerErrorResponse_NO_PERMISSION})).Err() +) + +// QueueByPlayer requests a player is queued for a game. +// NOTE: A player is always in a party and we clean up when a player changes party. +// Therefore, we only need to check if the player's party is in a queue, not the player themselves. +func (m *matchmakerService) QueueByPlayer(ctx context.Context, request *matchmaker.QueueByPlayerRequest) (*matchmaker.QueueByPlayerResponse, error) { + playerId, err := uuid.Parse(request.PlayerId) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid player_id") + } + + // check if game_mode is valid + modeConfig := m.cfgController.GetCurrentConfig(request.GameModeId) + if modeConfig == nil { + return nil, queueInvalidGameModeErr + } + + if !modeConfig.Enabled { + return nil, queueGameModeDisabledErr + } + + // check if map is present + if request.MapId != nil { + _, ok := modeConfig.Maps[*request.MapId] + if !ok { + return nil, queueInvalidMapErr + } + // todo check if player has enough credits + } + + res, err := m.partyService.GetParty(ctx, &pbparty.GetPartyRequest{Id: &pbparty.GetPartyRequest_PlayerId{PlayerId: playerId.String()}}) + if err != nil { + return nil, err + } + + party := res.Party + partyId, err := primitive.ObjectIDFromHex(party.Id) + if err != nil { + return nil, err + } + + // check if the party is already in a queue + // if yes, return error + isInQueue, err := m.repo.IsPartyQueued(ctx, partyId) + if err != nil { + return nil, err + } + + if isInQueue { + return nil, queueAlreadyInQueueErr + } + + // check if player is leader of party + if playerId.String() != party.GetLeaderId() { + return nil, queueNoPermissionErr + } + + // party checks + partyRestrictions := modeConfig.PartyRestrictions + if partyRestrictions.MaxSize != nil && len(party.Members) > *modeConfig.PartyRestrictions.MaxSize { + return nil, queuePartyTooLargeErr + } + + // private game checks + var privateGame bool + if request.PrivateGame != nil { + privateGame = *request.PrivateGame + } else { + privateGame = false + } + + if privateGame { + // check if there are enough players + if len(party.Members) < modeConfig.MinPlayers { + return nil, status.Error(codes.InvalidArgument, "not enough players to create private game") + } + + // TODO check if player has enough credits + } + + // Get the party settings + settingsRes, err := m.partySettingsService.GetPartySettings(ctx, + &pbparty.GetPartySettingsRequest{Id: &pbparty.GetPartySettingsRequest_PlayerId{PlayerId: party.LeaderId}}, + ) + if err != nil { + return nil, fmt.Errorf("failed to get party settings (leaderId: %s): %w", party.LeaderId, err) + } + + settings := settingsRes.GetSettings() + + autoTeleport := true + if request.AutoTeleport != nil { + autoTeleport = *request.AutoTeleport + } + + memberIds := make([]uuid.UUID, 0) + for _, member := range party.Members { + id, err := uuid.Parse(member.Id) + if err != nil { + return nil, err + } + + memberIds = append(memberIds, id) + } + + partyLeaderId, err := uuid.Parse(party.LeaderId) + if err != nil { + return nil, err + } + + // create ticket + ticket := model.NewTicket(&partyId, &model.ReducedPartySettings{ + LeaderId: partyLeaderId, + DequeueOnDisconnect: settings.DequeueOnDisconnect, + AllowMemberDequeue: settings.AllowMemberDequeue, + }, memberIds, request.GameModeId, autoTeleport) + + err = m.repo.ExecuteTransaction(ctx, func(ctx mongo.SessionContext) error { + err = m.repo.CreateTicket(ctx, ticket) + if err != nil { + return err + } + + // save player map choice + queuedPlayers := make([]*model.QueuedPlayer, 0) + for _, playerId := range memberIds { + var mapId *string + if request.MapId != nil && playerId.String() == party.LeaderId { + mapId = request.MapId + } + + queuedPlayers = append(queuedPlayers, &model.QueuedPlayer{ + PlayerId: playerId, + TicketId: ticket.Id, + MapId: mapId, + }) + } + + err = m.repo.CreateQueuedPlayers(ctx, queuedPlayers) + if err != nil { + return err + } + + err = m.notifier.TicketCreated(ctx, ticket) + if err != nil { + return err + } + + return nil + }) + + if err != nil { + return nil, err + } + + return &matchmaker.QueueByPlayerResponse{}, nil +} + +func (m *matchmakerService) SendPlayersToLobby(ctx context.Context, request *matchmaker.SendPlayerToLobbyRequest) (*matchmaker.SendPlayerToLobbyResponse, error) { + playerIds := make([]uuid.UUID, 0) + for _, playerId := range request.PlayerIds { + id, err := uuid.Parse(playerId) + if err != nil { + return nil, err + } + + playerIds = append(playerIds, id) + } + + // If send parties, retrieve all the necessary player IDs + if request == nil || *request.SendParties { + playerIdsMutex := sync.Mutex{} + partyReqWaitGroup := sync.WaitGroup{} + partyReqWaitGroup.Add(len(playerIds)) + + for _, loopPlayerId := range request.PlayerIds { + go func(playerId string) { + defer partyReqWaitGroup.Done() + + resp, err := m.partyService.GetParty(ctx, &pbparty.GetPartyRequest{ + Id: &pbparty.GetPartyRequest_PlayerId{PlayerId: playerId}, + }) + if err != nil { + m.logger.Errorw("failed to get party", "error", err) + return + } + + party := resp.Party + for _, member := range party.Members { + id, err := uuid.Parse(member.Id) + if err != nil { + m.logger.Errorw("failed to parse party member id", "error", err) + return + } + + playerIdsMutex.Lock() + if !slices.Contains(playerIds, id) { + playerIds = append(playerIds, id) + } + playerIdsMutex.Unlock() + } + }(loopPlayerId) + } + + partyReqWaitGroup.Wait() + } + + for _, playerId := range playerIds { + m.lobbyController.QueuePlayer(playerId, true) + } + + return &matchmaker.SendPlayerToLobbyResponse{}, nil +} + +func (m *matchmakerService) LoginQueueByPlayer(_ context.Context, request *matchmaker.LoginQueueByPlayerRequest) (*matchmaker.LoginQueueByPlayerResponse, error) { + playerId, err := uuid.Parse(request.PlayerId) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid player_id") + } + + if !request.IsProxy { + m.lobbyController.QueuePlayer(playerId, false) + } else { + m.velocityController.QueuePlayer(playerId, false) + } + + return &matchmaker.LoginQueueByPlayerResponse{}, nil +} + +var ( + dequeueNotInQueueErr = panicIfErr(status.New(codes.NotFound, "player is not in queue"). + WithDetails(&matchmaker.DequeueByPlayerErrorResponse{Reason: matchmaker.DequeueByPlayerErrorResponse_NOT_IN_QUEUE})).Err() + + dequeueNoPermissionErr = panicIfErr(status.New(codes.PermissionDenied, "player does not have permission to dequeue"). + WithDetails(&matchmaker.DequeueByPlayerErrorResponse{Reason: matchmaker.DequeueByPlayerErrorResponse_NO_PERMISSION})).Err() + + dequeueAlreadyDequeuedErr = panicIfErr(status.New(codes.AlreadyExists, "party is already requested for dequeue"). + WithDetails(&matchmaker.DequeueByPlayerErrorResponse{Reason: matchmaker.DequeueByPlayerErrorResponse_ALREADY_MARKED_FOR_DEQUEUE})).Err() +) + +// DequeueByPlayer requests a player is dequeued from a game. Note that this player acts on behalf of the party, not themselves. +// NOTE: This DOES NOT actually dequeue the player, it just requests it. +// Not every error will be fed back as it happens lazily. +func (m *matchmakerService) DequeueByPlayer(ctx context.Context, request *matchmaker.DequeueByPlayerRequest) (*matchmaker.DequeueByPlayerResponse, error) { + playerId, err := uuid.Parse(request.PlayerId) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid player_id") + } + + ticket, err := m.repo.GetTicketByPlayerId(ctx, playerId) + if err != nil { + if err == mongo.ErrNoDocuments { + return nil, dequeueNotInQueueErr + } + + return nil, err + } + + // check if the player has permission to dequeue + if playerId != ticket.PartySettings.LeaderId && !ticket.PartySettings.AllowMemberDequeue { + return nil, dequeueNoPermissionErr + } + + // TODO we could do a preemptive check to predict if a PendingMatch is being processed and will become a Match + // if so, we could return an error here to prevent the player from being dequeued + + modCount, err := m.repo.AddTicketDequeueRequest(ctx, ticket.Id) + if err != nil { + return nil, err + } + + if modCount == 0 { + return nil, dequeueAlreadyDequeuedErr + } + + return &matchmaker.DequeueByPlayerResponse{}, nil +} + +var ( + changeMapInvalidMapErr = panicIfErr(status.New(codes.InvalidArgument, "invalid map_id"). + WithDetails(&matchmaker.ChangePlayerMapVoteErrorResponse{Reason: matchmaker.ChangePlayerMapVoteErrorResponse_INVALID_MAP})).Err() + + changeMapNotInQueueErr = panicIfErr(status.New(codes.NotFound, "player is not in queue"). + WithDetails(&matchmaker.ChangePlayerMapVoteErrorResponse{Reason: matchmaker.ChangePlayerMapVoteErrorResponse_NOT_IN_QUEUE})).Err() +) + +func (m *matchmakerService) ChangePlayerMapVote(ctx context.Context, request *matchmaker.ChangePlayerMapVoteRequest) (*matchmaker.ChangePlayerMapVoteResponse, error) { + playerId, err := uuid.Parse(request.PlayerId) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid player_id") + } + + ticket, err := m.repo.GetTicketByPlayerId(ctx, playerId) + if err != nil { + if err == mongo.ErrNoDocuments { + return nil, changeMapNotInQueueErr + } + + return nil, err + } + + ok := m.isMapIdValid(ticket.GameModeId, request.MapId) + if !ok { + return nil, changeMapInvalidMapErr + } + + err = m.repo.SetMapIdOfQueuedPlayer(ctx, playerId, request.MapId) + if err != nil { + if err == mongo.ErrNoDocuments { + return nil, changeMapNotInQueueErr + } + + return nil, err + } + + return &matchmaker.ChangePlayerMapVoteResponse{}, nil +} + +func (m *matchmakerService) GetPlayerQueueInfo(ctx context.Context, request *matchmaker.GetPlayerQueueInfoRequest) (*matchmaker.GetPlayerQueueInfoResponse, error) { + playerId, err := uuid.Parse(request.PlayerId) + if err != nil { + return nil, status.Error(codes.InvalidArgument, "invalid player_id") + } + + ticket, err := m.repo.GetTicketByPlayerId(ctx, playerId) + if err != nil { + if err == mongo.ErrNoDocuments { + return nil, status.Error(codes.NotFound, "player is not in queue") + } + + return nil, err + } + + queuedPlayer, err := m.repo.GetQueuedPlayerById(ctx, playerId) + if err != nil { + if err == mongo.ErrNoDocuments { + return nil, status.Error(codes.NotFound, "player is not in queue") + } + + return nil, err + } + + var pbPendingMatch *pb.PendingMatch + if ticket.InPendingMatch { + match, err := m.repo.GetPendingMatchByTicketId(ctx, ticket.Id) + if err == nil { + pbPendingMatch = match.ToProto() + } else if err != mongo.ErrNoDocuments { + return nil, err + } + } + + return &matchmaker.GetPlayerQueueInfoResponse{ + Ticket: ticket.ToProto(), + QueuedPlayer: queuedPlayer.ToProto(), + PendingMatch: pbPendingMatch, + }, nil +} + +func (m *matchmakerService) isMapIdValid(modeId string, mapId string) bool { + cfg := m.cfgController.GetCurrentConfig(modeId) + if cfg == nil { + return false + } + + for _, mapCfg := range cfg.Maps { + if mapCfg.Id == mapId { + return true + } + } + + return false +} + +func panicIfErr[T any](thing T, err error) T { + if err != nil { + panic(err) + } + return thing +} diff --git a/services/kurushimi/internal/service/public.go b/services/kurushimi/internal/service/public.go new file mode 100644 index 0000000..ae8a4fb --- /dev/null +++ b/services/kurushimi/internal/service/public.go @@ -0,0 +1,61 @@ +package service + +import ( + "context" + "fmt" + "github.com/emortalmc/live-config-parser/golang/pkg/liveconfig" + "github.com/emortalmc/mono-services/services/kurushimi/internal/config" + "github.com/emortalmc/mono-services/services/kurushimi/internal/kafka" + "github.com/emortalmc/mono-services/services/kurushimi/internal/repository" + "github.com/emortalmc/mono-services/services/kurushimi/internal/simplecontroller" + "github.com/emortalmc/mono-services/services/kurushimi/internal/utils/grpczap" + "github.com/emortalmc/proto-specs/gen/go/grpc/matchmaker" + "github.com/emortalmc/proto-specs/gen/go/grpc/party" + "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging" + "go.uber.org/zap" + "google.golang.org/grpc" + "google.golang.org/grpc/reflection" + "net" + "sync" +) + +func RunServices(ctx context.Context, logger *zap.SugaredLogger, wg *sync.WaitGroup, cfg config.Config, + repo repository.Repository, notifier kafka.Notifier, gameModeController liveconfig.GameModeConfigController, + lobbyCtrl simplecontroller.SimpleController, velocityCtrl simplecontroller.SimpleController, + partyService party.PartyServiceClient, partySettingsService party.PartySettingsServiceClient) { + + lis, err := net.Listen("tcp", fmt.Sprintf(":%d", cfg.GrpcPort)) + if err != nil { + logger.Fatalw("failed to listen", err) + } + + opts := []logging.Option{ + logging.WithLogOnEvents(logging.StartCall, logging.FinishCall), + // Add any other option (check functions starting with logging.With). + } + + s := grpc.NewServer(grpc.ChainUnaryInterceptor( + logging.UnaryServerInterceptor(grpczap.InterceptorLogger(logger.Desugar()), opts...), + )) + + if cfg.Development { + reflection.Register(s) + } + + matchmaker.RegisterMatchmakerServer(s, newMatchmakerService(logger, repo, notifier, gameModeController, lobbyCtrl, + velocityCtrl, partyService, partySettingsService)) + logger.Infow("listening for gRPC requests", "port", cfg.GrpcPort) + + go func() { + if err := s.Serve(lis); err != nil { + logger.Fatalw("failed to serve", err) + } + }() + + wg.Add(1) + go func() { + defer wg.Done() + <-ctx.Done() + s.GracefulStop() + }() +} diff --git a/services/kurushimi/internal/simplecontroller/simple_controller.go b/services/kurushimi/internal/simplecontroller/simple_controller.go new file mode 100644 index 0000000..ce91f49 --- /dev/null +++ b/services/kurushimi/internal/simplecontroller/simple_controller.go @@ -0,0 +1,170 @@ +package simplecontroller + +import ( + v13 "agones.dev/agones/pkg/apis/allocation/v1" + v1 "agones.dev/agones/pkg/client/clientset/versioned/typed/allocation/v1" + "context" + "github.com/emortalmc/mono-services/services/kurushimi/internal/gsallocation" + "github.com/emortalmc/mono-services/services/kurushimi/internal/gsallocation/selector" + "github.com/emortalmc/mono-services/services/kurushimi/internal/kafka" + pb "github.com/emortalmc/proto-specs/gen/go/model/matchmaker" + "github.com/google/uuid" + "go.mongodb.org/mongo-driver/bson/primitive" + "go.uber.org/zap" + "google.golang.org/protobuf/types/known/timestamppb" + "sync" + "time" +) + +// SimpleController is a controller to allocate players into matches for simple servers - not gamemodes. +// It is necessary due to Agones behaviours we want to work around for lobbies and proxies. +type SimpleController interface { + QueuePlayer(playerId uuid.UUID, autoTeleport bool) +} + +type simpleControllerImpl struct { + fleetName string + gameModeId string + matchmakingRate time.Duration + playersPerMatch int + + logger *zap.SugaredLogger + notifier kafka.Notifier + allocatorClient v1.GameServerAllocationInterface + + // queuedPlayers map[playerId]autoTeleport + queuedPlayers map[uuid.UUID]bool + queuedPlayersLock sync.Mutex +} + +func NewJoinController(ctx context.Context, wg *sync.WaitGroup, logger *zap.SugaredLogger, notifier kafka.Notifier, + allocatorClient v1.GameServerAllocationInterface, fleetName string, gameModeID string, matchRate time.Duration, + playersPerMatch int) SimpleController { + + c := &simpleControllerImpl{ + fleetName: fleetName, + gameModeId: gameModeID, + matchmakingRate: matchRate, + playersPerMatch: playersPerMatch, + + logger: logger, + notifier: notifier, + allocatorClient: allocatorClient, + + queuedPlayers: make(map[uuid.UUID]bool), + queuedPlayersLock: sync.Mutex{}, + } + + c.run(wg, ctx) + + return c +} + +func (l *simpleControllerImpl) QueuePlayer(playerId uuid.UUID, autoTeleport bool) { + l.queuedPlayersLock.Lock() + defer l.queuedPlayersLock.Unlock() + + l.queuedPlayers[playerId] = autoTeleport +} + +func (l *simpleControllerImpl) run(wg *sync.WaitGroup, ctx context.Context) { + go func() { + for { + if ctx.Err() != nil { + wg.Done() + return + } + + lastRunTime := time.Now() + + queuedPlayers := l.resetQueuedPlayers() + + matchAllocationReqMap := l.createMatchesFromPlayers(queuedPlayers) + + allocationErrors := gsallocation.AllocateServers(ctx, l.allocatorClient, matchAllocationReqMap) + for match, err := range allocationErrors { + l.logger.Errorw("failed to allocate server for match", "error", err, "match", match) + } + + if len(matchAllocationReqMap) > 0 { + l.logger.Infow("created matches", "matchCount", len(matchAllocationReqMap)) + } + for match := range matchAllocationReqMap { + if err := l.notifier.MatchCreated(ctx, match); err != nil { + l.logger.Errorw("failed to send match created message", "error", err) + } + } + + // Wait for the next run + timeSinceLastRun := time.Since(lastRunTime) + if timeSinceLastRun < l.matchmakingRate { + time.Sleep(l.matchmakingRate - timeSinceLastRun) + } + } + }() +} + +func (l *simpleControllerImpl) resetQueuedPlayers() map[uuid.UUID]bool { + l.queuedPlayersLock.Lock() + defer l.queuedPlayersLock.Unlock() + + queuedPlayers := make(map[uuid.UUID]bool, len(l.queuedPlayers)) + for playerId, autoTeleport := range l.queuedPlayers { + queuedPlayers[playerId] = autoTeleport + } + + l.queuedPlayers = make(map[uuid.UUID]bool) + + return queuedPlayers +} + +func (l *simpleControllerImpl) createMatchesFromPlayers(playerMap map[uuid.UUID]bool) map[*pb.Match]*v13.GameServerAllocation { + allocationReqs := make(map[*pb.Match]*v13.GameServerAllocation) + + if len(playerMap) > 0 { + l.logger.Infow("creating matches from players", "playerCount", len(playerMap)) + } + + currentMatch := &pb.Match{ + Id: primitive.NewObjectID().String(), + GameModeId: l.gameModeId, + MapId: nil, + Tickets: make([]*pb.Ticket, 0), + Assignment: nil, + } + + currentCount := 0 + for playerId, autoTeleport := range playerMap { + currentMatch.Tickets = append(currentMatch.Tickets, &pb.Ticket{ + PlayerIds: []string{playerId.String()}, + CreatedAt: timestamppb.Now(), + GameModeId: l.gameModeId, + AutoTeleport: autoTeleport, + DequeueOnDisconnect: false, + InPendingMatch: false, + }) + currentCount++ + + if currentCount >= l.playersPerMatch { + allocationReqs[currentMatch] = selector.CreatePlayerBasedSelector(l.fleetName, currentMatch, int64(currentCount)) + currentMatch = &pb.Match{ + Id: primitive.NewObjectID().Hex(), + GameModeId: l.gameModeId, + MapId: nil, + Tickets: make([]*pb.Ticket, 0), + Assignment: nil, + } + currentCount = 0 + } + } + + if currentCount > 0 { + allocationReqs[currentMatch] = selector.CreatePlayerBasedSelector(l.fleetName, currentMatch, int64(len(currentMatch.Tickets))) + } + + if len(allocationReqs) > 0 { + l.logger.Infow("created matches from players", "matchCount", len(allocationReqs), "playerCount", len(playerMap)) + } + + return allocationReqs +} diff --git a/services/kurushimi/internal/utils/grpczap/grpczap.go b/services/kurushimi/internal/utils/grpczap/grpczap.go new file mode 100644 index 0000000..9f7896f --- /dev/null +++ b/services/kurushimi/internal/utils/grpczap/grpczap.go @@ -0,0 +1,45 @@ +package grpczap + +import ( + "context" + "fmt" + "github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/logging" + "go.uber.org/zap" +) + +func InterceptorLogger(l *zap.Logger) logging.Logger { + return logging.LoggerFunc(func(ctx context.Context, lvl logging.Level, msg string, fields ...any) { + f := make([]zap.Field, 0, len(fields)/2) + + for i := 0; i < len(fields); i += 2 { + key := fields[i] + value := fields[i+1] + + switch v := value.(type) { + case string: + f = append(f, zap.String(key.(string), v)) + case int: + f = append(f, zap.Int(key.(string), v)) + case bool: + f = append(f, zap.Bool(key.(string), v)) + default: + f = append(f, zap.Any(key.(string), v)) + } + } + + logger := l.WithOptions(zap.AddCallerSkip(1)).With(f...) + + switch lvl { + case logging.LevelDebug: + logger.Debug(msg) + case logging.LevelInfo: + logger.Info(msg) + case logging.LevelWarn: + logger.Warn(msg) + case logging.LevelError: + logger.Error(msg) + default: + panic(fmt.Sprintf("unknown level %v", lvl)) + } + }) +} diff --git a/services/kurushimi/internal/utils/kubernetes/client.go b/services/kurushimi/internal/utils/kubernetes/client.go new file mode 100644 index 0000000..b2cecff --- /dev/null +++ b/services/kurushimi/internal/utils/kubernetes/client.go @@ -0,0 +1,33 @@ +package kubernetes + +import ( + "agones.dev/agones/pkg/client/clientset/versioned" + "github.com/emortalmc/mono-services/services/kurushimi/internal/utils" + "k8s.io/client-go/kubernetes" + "k8s.io/client-go/rest" + "time" +) + +func CreateClients() (kubeClient *kubernetes.Clientset, agonesClient *versioned.Clientset) { + kubeConfig, err := createKubernetesConfig() + if err != nil { + panic(err) + } + + kubeClient = kubernetes.NewForConfigOrDie(kubeConfig) + + // AgonesClient contains the Agones client for creating GameServerAllocation objects + agonesClient = versioned.NewForConfigOrDie(kubeConfig) + + return kubeClient, agonesClient +} + +func createKubernetesConfig() (*rest.Config, error) { + config, err := utils.CreateKubernetesConfig() + if err != nil { + return nil, err + } + + config.Timeout = time.Second * 5 + return config, nil +} diff --git a/services/kurushimi/internal/utils/kubeutils.go b/services/kurushimi/internal/utils/kubeutils.go new file mode 100644 index 0000000..95b0445 --- /dev/null +++ b/services/kurushimi/internal/utils/kubeutils.go @@ -0,0 +1,32 @@ +package utils + +import ( + "errors" + "flag" + "k8s.io/client-go/rest" + "k8s.io/client-go/tools/clientcmd" + "k8s.io/client-go/util/homedir" + "path/filepath" +) + +func CreateKubernetesConfig() (*rest.Config, error) { + var config *rest.Config + var err error + + config, err = rest.InClusterConfig() + if !errors.Is(err, rest.ErrNotInCluster) { + return config, err + } + + var kubeConfig *string + if home := homedir.HomeDir(); home != "" { + kubeConfig = flag.String("kubeconfig", filepath.Join(home, ".kube", "config"), "(optional) absolute path to the kubeconfig file") + } else { + kubeConfig = flag.String("kubeconfig", "", "absolute path to the kubeconfig file") + } + flag.Parse() + + config, err = clientcmd.BuildConfigFromFlags("", *kubeConfig) + + return config, err +} diff --git a/services/kurushimi/internal/utils/math/math.go b/services/kurushimi/internal/utils/math/math.go new file mode 100644 index 0000000..6b54fe1 --- /dev/null +++ b/services/kurushimi/internal/utils/math/math.go @@ -0,0 +1,10 @@ +package math + +import "golang.org/x/exp/constraints" + +func Min[T constraints.Ordered](a, b T) T { + if a < b { + return a + } + return b +} diff --git a/services/kurushimi/internal/utils/pointer.go b/services/kurushimi/internal/utils/pointer.go new file mode 100644 index 0000000..ff2cb28 --- /dev/null +++ b/services/kurushimi/internal/utils/pointer.go @@ -0,0 +1,5 @@ +package utils + +func PointerOf[T any](value T) *T { + return &value +} diff --git a/services/kurushimi/internal/utils/protoutils/utils.go b/services/kurushimi/internal/utils/protoutils/utils.go new file mode 100644 index 0000000..d83bdbd --- /dev/null +++ b/services/kurushimi/internal/utils/protoutils/utils.go @@ -0,0 +1,13 @@ +package protoutils + +import pb "github.com/emortalmc/proto-specs/gen/go/model/matchmaker" + +func GetMatchPlayerCount(match *pb.Match) int64 { + count := 0 + + for _, ticket := range match.Tickets { + count += len(ticket.PlayerIds) + } + + return int64(count) +} diff --git a/services/kurushimi/internal/utils/runtime/runtime.go b/services/kurushimi/internal/utils/runtime/runtime.go new file mode 100644 index 0000000..ca62601 --- /dev/null +++ b/services/kurushimi/internal/utils/runtime/runtime.go @@ -0,0 +1,7 @@ +package runtime + +func Must(err error) { + if err != nil { + panic(err) + } +} diff --git a/services/kurushimi/run/config.yaml b/services/kurushimi/run/config.yaml new file mode 100644 index 0000000..3d0c2ff --- /dev/null +++ b/services/kurushimi/run/config.yaml @@ -0,0 +1,24 @@ +mongodb: + uri: mongodb://localhost:27017 + +kafka: + host: localhost + port: 9092 + +namespace: emortalmc + +partyService: + serviceHost: localhost + servicePort: 10006 + + settingsServiceHost: localhost + settingsServicePort: 10006 + +lobbyFleetName: "lobby" +# Delay between each matchmaker run for lobby matches +lobbyMatchRate: 175_000_000 +lobbyMatchSize: 50 + +port: 10007 + +development: true \ No newline at end of file diff --git a/services/kurushimi/run/config/gamemodes/120-block_sumo.json b/services/kurushimi/run/config/gamemodes/120-block_sumo.json new file mode 100644 index 0000000..417027b --- /dev/null +++ b/services/kurushimi/run/config/gamemodes/120-block_sumo.json @@ -0,0 +1,97 @@ +{ + "id": "block_sumo", + "enabled": true, + "fleetName": "block-sumo", + "priority": 120, + "friendlyName": "Block Sumo", + "activityNoun": "playing", + "minPlayers": 2, + "maxPlayers": 12, + "displayItem": { + "material": "minecraft:fire_charge", + "slot": 22, + "name": "Block Sumo", + "lore": [ + "Fight other players", + "in a game where your", + "sole goal is to knock", + "other players off the edge!" + ] + }, + "displayNpc": { + "entityType": "PLAYER", + "titles": [ + "Block Sumo" + ], + "skin": { + "texture": "ewogICJ0aW1lc3RhbXAiIDogMTY0ODk0Njk5OTE3OSwKICAicHJvZmlsZUlkIiA6ICI3YmQ1YjQ1OTFlNmI0NzUzODI3NDFmYmQyZmU5YTRkNSIsCiAgInByb2ZpbGVOYW1lIiA6ICJlbW9ydGFsZGV2IiwKICAic2lnbmF0dXJlUmVxdWlyZWQiIDogdHJ1ZSwKICAidGV4dHVyZXMiIDogewogICAgIlNLSU4iIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzkxZDdhOWMwODBlZTdjYTZkZjlhYWJlM2I5NTliYWE4MThkYWUzYjQ1ZWI3YWRjMTMwZmYyNjU1YzlkOTRjY2YiCiAgICB9LAogICAgIkNBUEUiIDogewogICAgICAidXJsIiA6ICJodHRwOi8vdGV4dHVyZXMubWluZWNyYWZ0Lm5ldC90ZXh0dXJlLzIzNDBjMGUwM2RkMjRhMTFiMTVhOGIzM2MyYTdlOWUzMmFiYjIwNTFiMjQ4MWQwYmE3ZGVmZDYzNWNhN2E5MzMiCiAgICB9CiAgfQp9", + "signature": "prWY0EtGdAfqt/nc4Vv/sMBcVEb6WMvaRumTk72e/NKe3dUPxmzlDRm6rw/mEE332JND6+sEI9PmDQ4jj/W41cn/XR/uZIBS+1qLE+57slEQA+ds+/kffKt1358JEV5/qyqCnODLVjwsRwazXJstC3eKNByaTQEyZ2jv/mFeAIAOF+0eQqDaaMGgxdIMRvWR8Nj6uIiBFTdCPIw3OYZ5bxqxm8Epr5PppF+sj7ZK0UyQ5/f1UoO9B/YMUt0OW+UlF3NYcMDs5mrg1N8Ajxvqbe8l0X7eWHgSYd0S/FopSCiVVQOQdZHRyhicmzLv6rE+xW03SB8NRfoaEEvSh8+QiLGMcyETeriwdDzdf8H9Iin3vDkVbMyRTAJ5jL/xDkoFDFR5HtNkrwYBRJoVkiWbnWyoBFofAjmmMmGmT5SFABS7I0iWLEoP4EMzqy84zDbpwOOioQz9UFlZV8AqmyEDv8Hx6px20zdR/jPr7tRQgqRhcPyzNsElcNLhkBfHmhpKffkrEPOAaal49rtB+3Jq+nX8Z1VyEZSW4MYnuq91bFZ1ciMzopYulPwP4cZkrGaqV84lxsqStI5+STi105KP4Bws+XDpop1eyPdDuVL/axq3VVkKeRqSoMv+xRYONGZJQgZ1t0WRIsXk7DLsjtx8QgffxqOwjW5CmZR0liSPfYM=" + } + }, + "partyRestrictions": { + "minSize": 1, + "maxSize": 12 + }, + "maps": { + "blocksumo": { + "id": "blocksumo", + "enabled": true, + "friendlyName": "BlockSumo", + "priority": 100, + "displayItem": { + "slot": 0, + "material": "minecraft:purple_wool", + "name": "BlockSumo" + } + }, + "castle": { + "id": "castle", + "enabled": true, + "friendlyName": "Castle", + "priority": 100, + "displayItem": { + "slot": 1, + "material": "minecraft:dark_oak_log", + "name": "Castle" + } + }, + "end": { + "id": "end", + "enabled": true, + "friendlyName": "End", + "priority": 100, + "displayItem": { + "slot": 2, + "material": "minecraft:end_stone", + "name": "End" + } + }, + "icebs": { + "id": "icebs", + "enabled": true, + "friendlyName": "Ice", + "priority": 100, + "displayItem": { + "slot": 3, + "material": "minecraft:ice", + "name": "Ice" + } + }, + "ruinsbs": { + "id": "ruinsbs", + "enabled": true, + "friendlyName": "Ruins", + "priority": 100, + "displayItem": { + "slot": 4, + "material": "minecraft:mossy_cobblestone", + "name": "Ruins" + } + } + }, + "matchmakerInfo": { + "matchMethod": "COUNTDOWN", + "selectMethod": "AVAILABLE", + "rate": 750000000 + } +} diff --git a/services/mc-player-service/go.mod b/services/mc-player-service/go.mod index dcb8efe..290ad6b 100644 --- a/services/mc-player-service/go.mod +++ b/services/mc-player-service/go.mod @@ -28,6 +28,7 @@ require ( github.com/montanaflynn/stats v0.7.1 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pierrec/lz4/v4 v4.1.18 // indirect + github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect diff --git a/services/mc-player-service/go.sum b/services/mc-player-service/go.sum index 7f874f4..70bdd0f 100644 --- a/services/mc-player-service/go.sum +++ b/services/mc-player-service/go.sum @@ -72,8 +72,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE= diff --git a/services/message-handler/go.mod b/services/message-handler/go.mod index c8b1fc5..9580f43 100644 --- a/services/message-handler/go.mod +++ b/services/message-handler/go.mod @@ -21,6 +21,7 @@ require ( github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/pelletier/go-toml/v2 v2.2.2 // indirect github.com/pierrec/lz4/v4 v4.1.18 // indirect + github.com/rogpeppe/go-internal v1.10.0 // indirect github.com/sagikazarmark/locafero v0.4.0 // indirect github.com/sagikazarmark/slog-shim v0.1.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect diff --git a/services/message-handler/go.sum b/services/message-handler/go.sum index aee5cc0..d7ffe31 100644 --- a/services/message-handler/go.sum +++ b/services/message-handler/go.sum @@ -68,8 +68,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= -github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= github.com/sagikazarmark/locafero v0.4.0 h1:HApY1R9zGo4DBgr7dqsTH/JJxLTTsOt7u6keLGt6kNQ= github.com/sagikazarmark/locafero v0.4.0/go.mod h1:Pe1W6UlPYUk/+wc/6KFhbORCfqzgYEpgQ3O5fPuL3H4= github.com/sagikazarmark/slog-shim v0.1.0 h1:diDBnUNK9N/354PgrxMywXnAwEr1QZcOr6gto+ugjYE=