From 89fc69f0694e1b9b894360ee2b2ee6c5bac89064 Mon Sep 17 00:00:00 2001 From: CaioIcy Date: Wed, 24 Mar 2021 21:28:08 -0300 Subject: [PATCH 01/16] Fix dependencies: bumps pitaya 0.14.3 to 0.15.4 Error was the following: go: github.com/topfreegames/pitaya@v0.14.3 requires github.com/jhump/protoreflect@v0.0.0-20181126200011-b5ebaabe89bf requires google.golang.org/genproto@v0.0.0-20170818100345-ee236bd376b0: invalid pseudo-version: does not match version-control timestamp (2017-08-18T01:03:45Z) --- go.mod | 5 ++--- go.sum | 53 ++++++++++++++++++++++++++++++++++------------------- 2 files changed, 36 insertions(+), 22 deletions(-) diff --git a/go.mod b/go.mod index c6ac3c6..f8eb500 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/bsm/redis-lock v6.0.0+incompatible // indirect github.com/evanphx/json-patch v4.1.0+incompatible // indirect github.com/go-redis/redis v6.13.2+incompatible - github.com/gogo/protobuf v1.2.1 + github.com/gogo/protobuf v1.3.0 github.com/google/btree v1.0.0 // indirect github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect github.com/google/uuid v1.0.0 @@ -18,7 +18,6 @@ require ( github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/json-iterator/go v1.1.5 // indirect github.com/magiconair/properties v1.8.0 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/mapstructure v0.0.0-20180715050151-f15292f7a699 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect @@ -37,7 +36,7 @@ require ( github.com/spf13/viper v1.1.0 github.com/stretchr/testify v1.2.2 github.com/topfreegames/extensions v8.2.2+incompatible - github.com/topfreegames/pitaya v0.14.3 + github.com/topfreegames/pitaya v0.15.4 golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890 // indirect golang.org/x/time v0.0.0-20181108054448-85acf8d2951c // indirect google.golang.org/appengine v1.3.0 // indirect diff --git a/go.sum b/go.sum index db9ce48..5482c68 100644 --- a/go.sum +++ b/go.sum @@ -13,8 +13,6 @@ github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869 h1:DDGfHa7BWjL4Yn github.com/bmizerany/assert v0.0.0-20160611221934-b7ed37b82869/go.mod h1:Ekp36dRnpXw/yCqJaO+ZrUyxD+3VXMFFr56k5XYrpB4= github.com/bsm/redis-lock v6.0.0+incompatible h1:d0xI3kIfcxOA0Zx/fowYbf7eE5AYhQRt6eCxAQKMK2c= github.com/bsm/redis-lock v6.0.0+incompatible/go.mod h1:8dGkQ5GimBCahwF2R67tqGCJbyDZSp0gzO7wq3pDrik= -github.com/bsm/redis-lock v8.0.0+incompatible h1:QgB0J2pNG8hUfndTIvpPh38F5XsUTTvO7x8Sls++9Mk= -github.com/bsm/redis-lock v8.0.0+incompatible/go.mod h1:8dGkQ5GimBCahwF2R67tqGCJbyDZSp0gzO7wq3pDrik= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd h1:qMd81Ts1T2OTKmB4acZcyKaMtRnY5Y44NuXGX2GFJ1w= github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI= @@ -48,17 +46,18 @@ github.com/go-playground/universal-translator v0.16.0 h1:X++omBR/4cE2MNg91AoC3rm github.com/go-playground/universal-translator v0.16.0/go.mod h1:1AnU7NaIRDWWzGEKwgtJRd2xk99HeFyHw3yid4rvQIY= github.com/go-redis/redis v6.13.2+incompatible h1:kfEWSpgBs4XmuzGg7nYPqhQejjzU9eKdIL0PmE2TtRY= github.com/go-redis/redis v6.13.2+incompatible/go.mod h1:NAIEuMOZ/fxfXJIrKDQDz8wamY7mA7PouImQ2Jvg6kA= -github.com/gogo/protobuf v1.2.1 h1:/s5zKNz0uPFCZ5hddgPdo2TK2TVrUNMn0OOX8/aZMTE= -github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/gogo/protobuf v1.3.0 h1:G8O7TerXerS4F6sx9OV7/nRfJdnXgHZu/S/7F2SN+UE= +github.com/gogo/protobuf v1.3.0/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20180203143532-66deaeb636df h1:Sf/EWTqecLGj5mn9KFu3L4Cc4O/6kGnbtbDtXrjzv5A= github.com/golang/groupcache v0.0.0-20180203143532-66deaeb636df/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1 h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.1.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/google/btree v0.0.0-20180124185431-e89373fe6b4a/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0 h1:0udJVsspx3VBr5FwtLhQQtuAsVc79tTq0ocGIPAU6qo= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= @@ -88,13 +87,13 @@ github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= -github.com/jhump/protoreflect v0.0.0-20181126200011-b5ebaabe89bf h1:4Cg4Shjf7mV/dor66ofLDvEzdCC1RYMo5zQD5ckfyJY= -github.com/jhump/protoreflect v0.0.0-20181126200011-b5ebaabe89bf/go.mod h1:kG/zRVeS2M91gYaCvvUbPkMjjtFQS4qqjcPFzFkh2zE= +github.com/jhump/protoreflect v1.5.0 h1:NgpVT+dX71c8hZnxHof2M7QDK7QtohIJ7DYycjnkyfc= +github.com/jhump/protoreflect v1.5.0/go.mod h1:eaTn3RZAmMBcV0fifFvlm6VHNz3wSkYyXYWUh7ymB74= github.com/jonboulle/clockwork v0.1.0 h1:VKV+ZcuP6l3yW9doeqz6ziZGgcynBVQO+obU0+0hcPo= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v1.1.5 h1:gL2yXlmiIo4+t+y32d4WGwOjKGYcGOuyrg46vadswDE= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= @@ -104,7 +103,6 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/magiconair/properties v1.7.6/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.0 h1:LLgXmsheXeRoUOBOjtwPQCWIYqM/LU1ayDtDePerRcY= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= -github.com/matttproud/golang_protobuf_extensions v1.0.0/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= 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/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -116,13 +114,24 @@ github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg= github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/nats-io/gnatsd v1.1.0 h1:Yo5uA2vay3xMMDysJruJrzogJyv3MBSCYfj+pR2zTD0= -github.com/nats-io/gnatsd v1.1.0/go.mod h1:nqco77VO78hLCJpIcVfygDP2rPGfsEHkGTUk94uh5DQ= +github.com/nats-io/gnatsd v1.4.1 h1:RconcfDeWpKCD6QIIwiVFcvForlXpWeJP7i5/lDLy44= +github.com/nats-io/gnatsd v1.4.1/go.mod h1:nqco77VO78hLCJpIcVfygDP2rPGfsEHkGTUk94uh5DQ= github.com/nats-io/go-nats v1.4.0/go.mod h1:+t7RHT5ApZebkrQdnn6AhQJmhJJiKAvJUio1PiiCtj0= github.com/nats-io/go-nats v1.5.0 h1:OrEQSvQQrP+A+9EBBxY86Z4Es6uaUdObZ5UhWHn9b08= github.com/nats-io/go-nats v1.5.0/go.mod h1:+t7RHT5ApZebkrQdnn6AhQJmhJJiKAvJUio1PiiCtj0= -github.com/nats-io/nuid v1.0.0 h1:44QGdhbiANq8ZCbUkdn6W5bqtg+mHuDE4wOUuxxndFs= -github.com/nats-io/nuid v1.0.0/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= +github.com/nats-io/jwt v0.2.14 h1:wA50KvFz/JXGXMHRygTWsRGh/ixxgC5E3kHvmtGLNf4= +github.com/nats-io/jwt v0.2.14/go.mod h1:fRYCDE99xlTsqUzISS1Bi75UBJ6ljOJQOAAu5VglpSg= +github.com/nats-io/nats-server v1.4.1 h1:Ul1oSOGNV/L8kjr4v6l2f9Yet6WY+LevH1/7cRZ/qyA= +github.com/nats-io/nats-server v1.4.1/go.mod h1:c8f/fHd2B6Hgms3LtCaI7y6pC4WD1f4SUxcCud5vhBc= +github.com/nats-io/nats-server/v2 v2.0.4 h1:XOMeQRbhl1lGNTIctPhih6pTa15NGif54Uas6ZW5q7g= +github.com/nats-io/nats-server/v2 v2.0.4/go.mod h1:AWdGEVbjKRS9ZIx4DSP5eKW48nfFm7q3uiSkP/1KD7M= +github.com/nats-io/nats.go v1.8.1 h1:6lF/f1/NN6kzUDBz6pyvQDEXO39jqXcWRLu/tKjtOUQ= +github.com/nats-io/nats.go v1.8.1/go.mod h1:BrFz9vVn0fU3AcH9Vn4Kd7W0NpJ651tD5omQ3M8LwxM= +github.com/nats-io/nkeys v0.0.2/go.mod h1:dab7URMsZm6Z/jp9Z5UGa87Uutgc2mVpXLC4B7TDb/4= +github.com/nats-io/nkeys v0.1.0 h1:qMd4+pRHgdr1nAClu+2h/2a5F2TmKcCzjCDazVgRoX4= +github.com/nats-io/nkeys v0.1.0/go.mod h1:xpnFELMwJABBLVhffcfd1MZx6VsNRFpEugbxziKVo7w= +github.com/nats-io/nuid v1.0.1 h1:5iA8DT8V7q8WK2EScv2padNa/rTESc1KdnPw4TC2paw= +github.com/nats-io/nuid v1.0.1/go.mod h1:19wcPz3Ph3q0Jbyiqsd0kePYG7A95tJPxeL+1OSON2c= github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/ginkgo v1.8.0 h1:VkHVNpR4iVnU8XQR6DBm8BqYjN7CRzw+xKUbVVbbW9w= github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= @@ -181,8 +190,8 @@ github.com/topfreegames/extensions v8.2.2+incompatible h1:JTyOlttU88JB97Y1a5L82n github.com/topfreegames/extensions v8.2.2+incompatible/go.mod h1:VbIAks7aNbkANieZyVShAV3FSxEbV6useS4r3neXVzc= github.com/topfreegames/go-workers v1.0.0 h1:R53uIT6nwlT45WBm79ZDnxG8W2ec9lJk3uJhZUmd3GI= github.com/topfreegames/go-workers v1.0.0/go.mod h1:FZ45GKJrHNIChLw008zoR8lvoMTxK9RprdE2c3uLrCQ= -github.com/topfreegames/pitaya v0.14.3 h1:PXU1ggr66VvLWrqpjYppupO+Ov9KXk9Wk7VnUEre36I= -github.com/topfreegames/pitaya v0.14.3/go.mod h1:aCNdQDTJybo9vRkmn+pis1MC8V0/TAQqBEXt/apt510= +github.com/topfreegames/pitaya v0.15.4 h1:GsrdCZNTvDiC+zoBVwGVarfy6hbpjhwlU/3Qdftgkg8= +github.com/topfreegames/pitaya v0.15.4/go.mod h1:2UaEoglDroRu3YvM4tF5PMV2UCqVyh/UTVFc6biFCDk= github.com/uber-go/atomic v1.3.2 h1:Azu9lPBWRNKzYXSIwRfgRuDuS0YKsK4NFhiQv98gkxo= github.com/uber-go/atomic v1.3.2/go.mod h1:/Ct5t2lcmbJ4OSe/waGBoaVvVqtO0bmtfVNex1PFV8g= github.com/uber/jaeger-client-go v2.13.0+incompatible h1:BQ7GxyS54wK+5kfRNoMVOhgQ7VAjhYlFq4rAhV7pnHc= @@ -195,34 +204,40 @@ github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18 h1:MPPkRncZLN9Kh4M github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= go.uber.org/atomic v1.3.2 h1:2Oa65PReHzfn29GpvgsYwloV9AVFHPDk8tYxt2c2tr4= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4 h1:HuIa8hRrWRSrqYzx1qI49NNxhdi2PrY7gxVSq1JjLDc= +golang.org/x/crypto v0.0.0-20190701094942-4def268fd1a4/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/net v0.0.0-20180530234432-1e491301e022/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a h1:oWX7TPOiFAMXLq8o0ikBYfCJVlRHBcsciT5bXOrH628= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3 h1:0GoQqolDA55aaLxZyTzK/Y2ePZzZTUrRacwib7cNsYQ= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890 h1:uESlIz09WIHT2I+pasSXcpLYqYK8wHcdCetU3VuMBJE= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190412183630-56d357773e84 h1:IqXQ59gzdXv58Jmm2xn0tSOR9i6HqroaOFRQ3wR/dJQ= -golang.org/x/sync v0.0.0-20190412183630-56d357773e84/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= 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-20190726091711-fc99dfbffb4e h1:D5TXcfTk7xF7hvieo4QErS3qqCB4teTffacDWr7CI+0= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/time v0.0.0-20180314180208-26559e0f760e/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c h1:fqgJT0MGcGpPgpWU7VRdRjuArfcOvC4AoJmILihzhDg= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.3.0 h1:FBSsiFRMz3LBeXIomRnVzrQwSDj4ibvcRexLG0LZGQk= google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/genproto v0.0.0-20170818100345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20170818010345-ee236bd376b0/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8 h1:Nw54tB0rB7hY/N0NQvRW8DG4Yk3Q6T9cu9RcFQDu1tc= google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= google.golang.org/grpc v1.8.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw= From 4ec06f4c8ed5f61241f0635a4ffea3f33ed359c3 Mon Sep 17 00:00:00 2001 From: CaioIcy Date: Wed, 24 Mar 2021 21:28:08 -0300 Subject: [PATCH 02/16] Fix panic on JSON example server test --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 77ae2e3..b72a308 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ setup-protobuf-macos: @go get -u github.com/gogo/protobuf/protoc-gen-gogofaster run-testing-server: - @docker-compose -f ./testing/json/docker-compose.yml up -d etcd nats && go run ./testing/json/main.go + @docker-compose -f ./testing/json/docker-compose.yml up -d etcd nats redis && go run ./testing/json/main.go run-testing-bots: @go run *.go run -d ./testing/json/specs/ --config ./testing/json/config/config.yaml From f3d21eda55273a6972d1480ffe30264b3f25232b Mon Sep 17 00:00:00 2001 From: CaioIcy Date: Wed, 24 Mar 2021 21:28:08 -0300 Subject: [PATCH 03/16] Add build-mac command to Makefile --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index b72a308..8454047 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,10 @@ run-testing-proto-bots: kill-testing-proto-deps: @docker-compose -f ./testing/protobuffer/docker-compose.yml down; true +build-mac: + @mkdir -p out + @GOOS=darwin GOARCH=amd64 go build -o ./out/pitaya-bot-darwin ./main.go + build-linux: @mkdir -p out @GOOS=linux GOARCH=amd64 go build -o ./out/pitaya-bot-linux ./main.go From 07329a290f0d49f4b76b549ce02b7067305cdd05 Mon Sep 17 00:00:00 2001 From: CaioIcy Date: Wed, 24 Mar 2021 21:28:08 -0300 Subject: [PATCH 04/16] Bump pitaya version (0.15.4 to 1.1.5) Also removes TLS option, the client will try to connect in every way until it succedes. --- bot/pitaya_client.go | 36 +++++++++++++++++++++++------------- bot/sequential.go | 3 +-- cmd/root.go | 1 - docs/configuration.rst | 4 ---- docs/test_writing.md | 3 +-- go.mod | 13 ++----------- go.sum | 10 ++++++++++ 7 files changed, 37 insertions(+), 33 deletions(-) diff --git a/bot/pitaya_client.go b/bot/pitaya_client.go index 3b0aa2f..0f622f5 100644 --- a/bot/pitaya_client.go +++ b/bot/pitaya_client.go @@ -1,6 +1,7 @@ package bot import ( + "crypto/tls" "encoding/json" "fmt" "sync" @@ -44,8 +45,25 @@ func getProtoInfo(host string, docs string, pushinfo map[string]string) *client. return instance } +func tryConnect(pClient client.PitayaClient, addr string) error { + if err := pClient.ConnectToWS(addr, "", &tls.Config{ + InsecureSkipVerify: true, + }); err != nil { + if err := pClient.ConnectToWS(addr, ""); err != nil { + if err := pClient.ConnectTo(addr, &tls.Config{ + InsecureSkipVerify: true, + }); err != nil { + if err := pClient.ConnectTo(addr); err != nil { + return err + } + } + } + } + return nil +} + // NewPClient is the PCLient constructor -func NewPClient(host string, useTLS bool, docs string, pushinfo map[string]string) (*PClient, error) { +func NewPClient(host string, docs string, pushinfo map[string]string) (*PClient, error) { var pclient client.PitayaClient if docs != "" { protoclient := client.NewProto(docs, logrus.InfoLevel) @@ -57,18 +75,10 @@ func NewPClient(host string, useTLS bool, docs string, pushinfo map[string]strin pclient = client.New(logrus.InfoLevel) } - if useTLS { - if err := pclient.ConnectToTLS(host, true); err != nil { - fmt.Println("Error connecting to server") - fmt.Println(err) - return nil, err - } - } else { - if err := pclient.ConnectTo(host); err != nil { - fmt.Println("Error connecting to server") - fmt.Println(err) - return nil, err - } + if err := tryConnect(pclient, host); err != nil { + fmt.Println("Error connecting to server") + fmt.Println(err) + return nil, err } return &PClient{ diff --git a/bot/sequential.go b/bot/sequential.go index b5294d7..f521e10 100644 --- a/bot/sequential.go +++ b/bot/sequential.go @@ -254,8 +254,7 @@ func (b *SequentialBot) Connect(hosts ...string) error { docs = b.config.GetString("server.protobuffer.docs") } - tls := b.config.GetBool("server.tls") - client, err := NewPClient(b.host, tls, docs, pushinfo) + client, err := NewPClient(b.host, docs, pushinfo) if err != nil { b.logger.WithError(err).Error("Unable to create client...") return err diff --git a/cmd/root.go b/cmd/root.go index 6ba4097..89824ac 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -100,7 +100,6 @@ func fillDefaultValues(config *viper.Viper) { "game": "", "prometheus.port": 9191, "server.host": "localhost", - "server.tls": false, "server.serializer": "json", "server.protobuffer.docs": "connector.docsHandler.docs", "storage.type": "memory", diff --git a/docs/configuration.rst b/docs/configuration.rst index 9d76d9e..790d08f 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -60,10 +60,6 @@ The configurations needed to access the Pitaya server being tested - localhost - string - Pitaya server host - * - server.tls - - false - - bool - - Boolean to enable/disable TLS to connect with Pitaya server * - server.serializer - json - string diff --git a/docs/test_writing.md b/docs/test_writing.md index e47e959..5031831 100644 --- a/docs/test_writing.md +++ b/docs/test_writing.md @@ -60,8 +60,7 @@ storage: type: "memory" server: - host: "localhost", - tls: true + host: "localhost" prometheus: port: 9191 diff --git a/go.mod b/go.mod index f8eb500..71a4392 100644 --- a/go.mod +++ b/go.mod @@ -13,30 +13,21 @@ require ( github.com/googleapis/gnostic v0.2.0 // indirect github.com/gregjones/httpcache v0.0.0-20181110185634-c63ab54fda8f // indirect github.com/hashicorp/golang-lru v0.5.0 // indirect - github.com/hashicorp/hcl v0.0.0-20180404174102-ef8a98b0bbce // indirect github.com/imdario/mergo v0.3.6 // indirect github.com/inconshreveable/mousetrap v1.0.0 // indirect github.com/json-iterator/go v1.1.5 // indirect - github.com/magiconair/properties v1.8.0 // indirect github.com/mitchellh/go-homedir v1.1.0 - github.com/mitchellh/mapstructure v0.0.0-20180715050151-f15292f7a699 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 // indirect - github.com/nats-io/go-nats v1.5.0 // indirect - github.com/pelletier/go-toml v1.2.0 // indirect github.com/peterbourgon/diskv v2.0.1+incompatible // indirect github.com/prometheus/client_golang v0.8.0 - github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910 // indirect - github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e // indirect - github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273 // indirect github.com/sirupsen/logrus v1.0.6 - github.com/spf13/afero v1.1.1 // indirect github.com/spf13/cobra v0.0.3 github.com/spf13/pflag v1.0.2 // indirect github.com/spf13/viper v1.1.0 - github.com/stretchr/testify v1.2.2 + github.com/stretchr/testify v1.3.0 github.com/topfreegames/extensions v8.2.2+incompatible - github.com/topfreegames/pitaya v0.15.4 + github.com/topfreegames/pitaya v1.1.5 golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890 // indirect golang.org/x/time v0.0.0-20181108054448-85acf8d2951c // indirect google.golang.org/appengine v1.3.0 // indirect diff --git a/go.sum b/go.sum index 5482c68..9c6cc6e 100644 --- a/go.sum +++ b/go.sum @@ -30,6 +30,8 @@ github.com/customerio/gospec v0.0.0-20130710230057-a5cc0e48aa39 h1:O0YTztXI3XeJX github.com/customerio/gospec v0.0.0-20130710230057-a5cc0e48aa39/go.mod h1:OzYUFhPuL2JbjwFwrv6CZs23uBawekc6OZs+g19F0mY= github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/evanphx/json-patch v4.1.0+incompatible h1:K1MDoo4AZ4wU0GIU/fPmtZg7VpzLjCxu+UwBD1FvwOc= @@ -54,6 +56,7 @@ github.com/golang/groupcache v0.0.0-20180203143532-66deaeb636df h1:Sf/EWTqecLGj5 github.com/golang/groupcache v0.0.0-20180203143532-66deaeb636df/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.1.1 h1:G5FRp8JnTd7RQH5kemVNlMeyXQAztQ3mOWV95KxsXH8= github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1 h1:YF8+flBXS5eO826T4nzqPrxfhQThhXl0YzfuUPu4SBg= @@ -176,14 +179,17 @@ github.com/spf13/cobra v0.0.3/go.mod h1:1l0Ry5zgKvJasoi3XT1TypsSe7PqH0Sj9dhYf7v3 github.com/spf13/jwalterweatherman v0.0.0-20180109140146-7c0cea34c8ec h1:2ZXvIUGghLpdTVHR1UfvfrzoVlZaE/yOWC5LueIHZig= github.com/spf13/jwalterweatherman v0.0.0-20180109140146-7c0cea34c8ec/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= github.com/spf13/pflag v1.0.0/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.1/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/pflag v1.0.2 h1:Fy0orTDgHdbnzHcsOgfCN4LtHf0ec3wwtiwJqwvf3Gc= github.com/spf13/pflag v1.0.2/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= github.com/spf13/viper v1.0.2/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM= github.com/spf13/viper v1.1.0 h1:V7OZpY8i3C1x/pDmU0zNNlfVoDz112fSYvtWMjjS3f4= github.com/spf13/viper v1.1.0/go.mod h1:A8kyI5cUJhb8N+3pkfONlcEcZbueH6nhAm0Fq7SrnBM= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6 h1:lYIiVDtZnyTWlNwiAxLj0bbpTcx1BWCFhXjfsvmPdNc= github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/topfreegames/extensions v8.2.2+incompatible h1:JTyOlttU88JB97Y1a5L82nAC7u2zGB7gThLzjAc2QUg= @@ -192,6 +198,8 @@ github.com/topfreegames/go-workers v1.0.0 h1:R53uIT6nwlT45WBm79ZDnxG8W2ec9lJk3uJ github.com/topfreegames/go-workers v1.0.0/go.mod h1:FZ45GKJrHNIChLw008zoR8lvoMTxK9RprdE2c3uLrCQ= github.com/topfreegames/pitaya v0.15.4 h1:GsrdCZNTvDiC+zoBVwGVarfy6hbpjhwlU/3Qdftgkg8= github.com/topfreegames/pitaya v0.15.4/go.mod h1:2UaEoglDroRu3YvM4tF5PMV2UCqVyh/UTVFc6biFCDk= +github.com/topfreegames/pitaya v1.1.5 h1:3tOE4o6WcdKFAVIKCv/zIGf+o9jw6E5pb6T+JJuot0w= +github.com/topfreegames/pitaya v1.1.5/go.mod h1:P/54Da/4k9FWy0LfkYtXWva8ddqojRbBKAONfNT8OXc= github.com/uber-go/atomic v1.3.2 h1:Azu9lPBWRNKzYXSIwRfgRuDuS0YKsK4NFhiQv98gkxo= github.com/uber-go/atomic v1.3.2/go.mod h1:/Ct5t2lcmbJ4OSe/waGBoaVvVqtO0bmtfVNex1PFV8g= github.com/uber/jaeger-client-go v2.13.0+incompatible h1:BQ7GxyS54wK+5kfRNoMVOhgQ7VAjhYlFq4rAhV7pnHc= @@ -221,6 +229,7 @@ golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAG golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890 h1:uESlIz09WIHT2I+pasSXcpLYqYK8wHcdCetU3VuMBJE= golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a h1:1BGLXjeY4akVXGgbC9HugT3Jv3hCI0z56oJR5vAMgBU= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -234,6 +243,7 @@ golang.org/x/time v0.0.0-20181108054448-85acf8d2951c h1:fqgJT0MGcGpPgpWU7VRdRjuA golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= google.golang.org/appengine v1.3.0 h1:FBSsiFRMz3LBeXIomRnVzrQwSDj4ibvcRexLG0LZGQk= google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= From f11a9dbed50cb042e4bb44dbcc38e965f211b471 Mon Sep 17 00:00:00 2001 From: CaioIcy Date: Wed, 24 Mar 2021 21:28:08 -0300 Subject: [PATCH 05/16] Fix protobuffer example test --- testing/protobuffer/main.go | 42 +- testing/protobuffer/protos/example.pb.go | 485 +++++++++++++---------- 2 files changed, 305 insertions(+), 222 deletions(-) diff --git a/testing/protobuffer/main.go b/testing/protobuffer/main.go index 11d3d31..a1cb109 100644 --- a/testing/protobuffer/main.go +++ b/testing/protobuffer/main.go @@ -25,18 +25,22 @@ import ( "encoding/json" "flag" "fmt" + "reflect" "strings" "time" + gogoproto "github.com/gogo/protobuf/proto" "github.com/google/uuid" "github.com/sirupsen/logrus" "github.com/spf13/viper" "github.com/topfreegames/pitaya" - "github.com/topfreegames/pitaya-bot/testing/protobuffer/protos" "github.com/topfreegames/pitaya/acceptor" "github.com/topfreegames/pitaya/component" + "github.com/topfreegames/pitaya/constants" pitayaprotos "github.com/topfreegames/pitaya/protos" "github.com/topfreegames/pitaya/serialize/protobuf" + + "github.com/topfreegames/pitaya-bot/testing/protobuffer/protos" ) // DocsHandler ... @@ -127,29 +131,34 @@ func (p *PlayerHandler) FindMatch(ctx context.Context, arg *protos.FindMatchArg) } // Docs returns documentation -func (c *DocsHandler) Docs(ctx context.Context) (*pitayaprotos.Doc, error) { - d, err := pitaya.Documentation(true) +func (d *DocsHandler) Docs(ctx context.Context) (*pitayaprotos.Doc, error) { + docs, err := pitaya.Documentation(true) if err != nil { return nil, err } - doc, err := json.Marshal(d) + jsonDocs, err := json.Marshal(docs) if err != nil { return nil, err } - return &pitayaprotos.Doc{Doc: string(doc)}, nil + return &pitayaprotos.Doc{Doc: string(jsonDocs)}, nil } // Protos return protobuffers descriptors -func (c *DocsHandler) Protos(ctx context.Context, message *pitayaprotos.ProtoNames) (*pitayaprotos.ProtoDescriptors, error) { +func (d *DocsHandler) Protos(ctx context.Context, message *pitayaprotos.ProtoNames) (*pitayaprotos.ProtoDescriptors, error) { var descriptors [][]byte for _, name := range message.GetName() { protoDescriptor, err := pitaya.Descriptor(name) if err != nil { - return nil, err + // Not a default pitaya proto, so we can probably find it here + protoDescriptor, err = getDescriptorFromName(name) + if err != nil { + return nil, constants.ErrProtodescriptor + } } + descriptors = append(descriptors, protoDescriptor) } @@ -158,6 +167,22 @@ func (c *DocsHandler) Protos(ctx context.Context, message *pitayaprotos.ProtoNam }, nil } +// taken partly from pitaya/docgenerator/descriptors.go +func getDescriptorFromName(protoName string) ([]byte, error) { + protoReflectTypePointer := gogoproto.MessageType(protoName) + protoReflectType := protoReflectTypePointer.Elem() + protoValue := reflect.New(protoReflectType) + descriptorMethod, ok := protoReflectTypePointer.MethodByName("Descriptor") + if !ok { + return nil, constants.ErrProtodescriptor + } + + descriptorValue := descriptorMethod.Func.Call([]reflect.Value{protoValue}) + protoDescriptor := descriptorValue[0].Bytes() + + return protoDescriptor, nil +} + func main() { port := flag.Int("port", 30124, "the port to listen") svType := flag.String("type", "connector", "the server type") @@ -195,7 +220,8 @@ func main() { pitaya.AddAcceptor(tcp) cfg := viper.New() cfg.Set("pitaya.cluster.sd.etcd.prefix", *sdPrefix) - pitaya.Configure(true, *svType, pitaya.Cluster, map[string]string{}, cfg) + isFrontend := true + pitaya.Configure(isFrontend, *svType, pitaya.Cluster, map[string]string{}, cfg) pitaya.Start() } diff --git a/testing/protobuffer/protos/example.pb.go b/testing/protobuffer/protos/example.pb.go index ae54d0b..f9e9d9e 100644 --- a/testing/protobuffer/protos/example.pb.go +++ b/testing/protobuffer/protos/example.pb.go @@ -3,11 +3,13 @@ package protos -import proto "github.com/gogo/protobuf/proto" -import fmt "fmt" -import math "math" - -import io "io" +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) // Reference imports to suppress errors if they are not otherwise used. var _ = proto.Marshal @@ -18,7 +20,7 @@ var _ = math.Inf // is compatible with the proto package it is being compiled against. // A compilation error at this line likely means your copy of the // proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion2 // please upgrade the proto package +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // Response represents a rpc message type Player struct { @@ -33,7 +35,7 @@ func (m *Player) Reset() { *m = Player{} } func (m *Player) String() string { return proto.CompactTextString(m) } func (*Player) ProtoMessage() {} func (*Player) Descriptor() ([]byte, []int) { - return fileDescriptor_example_4c07b9927c24f8f0, []int{0} + return fileDescriptor_15a1dc8d40dadaa6, []int{0} } func (m *Player) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -43,15 +45,15 @@ func (m *Player) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_Player.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } return b[:n], nil } } -func (dst *Player) XXX_Merge(src proto.Message) { - xxx_messageInfo_Player.Merge(dst, src) +func (m *Player) XXX_Merge(src proto.Message) { + xxx_messageInfo_Player.Merge(m, src) } func (m *Player) XXX_Size() int { return m.Size() @@ -100,14 +102,14 @@ func (m *Player) GetTrophies() int32 { type AuthResponse struct { Code string `protobuf:"bytes,1,opt,name=Code,proto3" json:"Code,omitempty"` Msg string `protobuf:"bytes,2,opt,name=Msg,proto3" json:"Msg,omitempty"` - Player *Player `protobuf:"bytes,3,opt,name=Player" json:"Player,omitempty"` + Player *Player `protobuf:"bytes,3,opt,name=Player,proto3" json:"Player,omitempty"` } func (m *AuthResponse) Reset() { *m = AuthResponse{} } func (m *AuthResponse) String() string { return proto.CompactTextString(m) } func (*AuthResponse) ProtoMessage() {} func (*AuthResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_example_4c07b9927c24f8f0, []int{1} + return fileDescriptor_15a1dc8d40dadaa6, []int{1} } func (m *AuthResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -117,15 +119,15 @@ func (m *AuthResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return xxx_messageInfo_AuthResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } return b[:n], nil } } -func (dst *AuthResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_AuthResponse.Merge(dst, src) +func (m *AuthResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_AuthResponse.Merge(m, src) } func (m *AuthResponse) XXX_Size() int { return m.Size() @@ -165,7 +167,7 @@ func (m *AuthArg) Reset() { *m = AuthArg{} } func (m *AuthArg) String() string { return proto.CompactTextString(m) } func (*AuthArg) ProtoMessage() {} func (*AuthArg) Descriptor() ([]byte, []int) { - return fileDescriptor_example_4c07b9927c24f8f0, []int{2} + return fileDescriptor_15a1dc8d40dadaa6, []int{2} } func (m *AuthArg) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -175,15 +177,15 @@ func (m *AuthArg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return xxx_messageInfo_AuthArg.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } return b[:n], nil } } -func (dst *AuthArg) XXX_Merge(src proto.Message) { - xxx_messageInfo_AuthArg.Merge(dst, src) +func (m *AuthArg) XXX_Merge(src proto.Message) { + xxx_messageInfo_AuthArg.Merge(m, src) } func (m *AuthArg) XXX_Size() int { return m.Size() @@ -209,7 +211,7 @@ func (m *FindMatchArg) Reset() { *m = FindMatchArg{} } func (m *FindMatchArg) String() string { return proto.CompactTextString(m) } func (*FindMatchArg) ProtoMessage() {} func (*FindMatchArg) Descriptor() ([]byte, []int) { - return fileDescriptor_example_4c07b9927c24f8f0, []int{3} + return fileDescriptor_15a1dc8d40dadaa6, []int{3} } func (m *FindMatchArg) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -219,15 +221,15 @@ func (m *FindMatchArg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return xxx_messageInfo_FindMatchArg.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } return b[:n], nil } } -func (dst *FindMatchArg) XXX_Merge(src proto.Message) { - xxx_messageInfo_FindMatchArg.Merge(dst, src) +func (m *FindMatchArg) XXX_Merge(src proto.Message) { + xxx_messageInfo_FindMatchArg.Merge(m, src) } func (m *FindMatchArg) XXX_Size() int { return m.Size() @@ -254,7 +256,7 @@ func (m *FindMatchResponse) Reset() { *m = FindMatchResponse{} } func (m *FindMatchResponse) String() string { return proto.CompactTextString(m) } func (*FindMatchResponse) ProtoMessage() {} func (*FindMatchResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_example_4c07b9927c24f8f0, []int{4} + return fileDescriptor_15a1dc8d40dadaa6, []int{4} } func (m *FindMatchResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -264,15 +266,15 @@ func (m *FindMatchResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return xxx_messageInfo_FindMatchResponse.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } return b[:n], nil } } -func (dst *FindMatchResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_FindMatchResponse.Merge(dst, src) +func (m *FindMatchResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_FindMatchResponse.Merge(m, src) } func (m *FindMatchResponse) XXX_Size() int { return m.Size() @@ -307,7 +309,7 @@ func (m *FindMatchPush) Reset() { *m = FindMatchPush{} } func (m *FindMatchPush) String() string { return proto.CompactTextString(m) } func (*FindMatchPush) ProtoMessage() {} func (*FindMatchPush) Descriptor() ([]byte, []int) { - return fileDescriptor_example_4c07b9927c24f8f0, []int{5} + return fileDescriptor_15a1dc8d40dadaa6, []int{5} } func (m *FindMatchPush) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -317,15 +319,15 @@ func (m *FindMatchPush) XXX_Marshal(b []byte, deterministic bool) ([]byte, error return xxx_messageInfo_FindMatchPush.Marshal(b, m, deterministic) } else { b = b[:cap(b)] - n, err := m.MarshalTo(b) + n, err := m.MarshalToSizedBuffer(b) if err != nil { return nil, err } return b[:n], nil } } -func (dst *FindMatchPush) XXX_Merge(src proto.Message) { - xxx_messageInfo_FindMatchPush.Merge(dst, src) +func (m *FindMatchPush) XXX_Merge(src proto.Message) { + xxx_messageInfo_FindMatchPush.Merge(m, src) } func (m *FindMatchPush) XXX_Size() int { return m.Size() @@ -365,10 +367,38 @@ func init() { proto.RegisterType((*FindMatchResponse)(nil), "protos.FindMatchResponse") proto.RegisterType((*FindMatchPush)(nil), "protos.FindMatchPush") } + +func init() { proto.RegisterFile("example.proto", fileDescriptor_15a1dc8d40dadaa6) } + +var fileDescriptor_15a1dc8d40dadaa6 = []byte{ + // 327 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x51, 0x3d, 0x4f, 0x02, 0x41, + 0x14, 0x64, 0xf9, 0x12, 0x1e, 0x1f, 0xd1, 0xad, 0x2e, 0xc4, 0x5c, 0xc8, 0x16, 0x86, 0x68, 0x42, + 0xa1, 0x95, 0x25, 0x62, 0x34, 0x14, 0x98, 0xcd, 0x4a, 0x69, 0xb3, 0x1e, 0x4f, 0x20, 0xc2, 0xed, + 0x65, 0x77, 0x31, 0xf2, 0x2f, 0xfc, 0x01, 0xfe, 0x20, 0x4b, 0x4a, 0x4b, 0x03, 0x7f, 0xc4, 0xdc, + 0xde, 0x71, 0x62, 0x62, 0x63, 0x75, 0xf3, 0x66, 0xde, 0xbc, 0x9b, 0xc9, 0x42, 0x03, 0x5f, 0xe5, + 0x22, 0x9a, 0x63, 0x37, 0xd2, 0xca, 0x2a, 0x5a, 0x76, 0x1f, 0xc3, 0xde, 0x09, 0x94, 0xf9, 0x5c, + 0xae, 0x50, 0xd3, 0x63, 0xa8, 0x72, 0x3d, 0x7b, 0x91, 0x16, 0x07, 0xd7, 0x1e, 0x69, 0x93, 0x4e, + 0x55, 0xfc, 0x10, 0xb4, 0x0d, 0xb5, 0x5e, 0x10, 0xa0, 0x31, 0x23, 0xf5, 0x8c, 0xa1, 0x97, 0x77, + 0xfa, 0x3e, 0x45, 0x29, 0x14, 0xef, 0xe4, 0x02, 0xbd, 0x82, 0x93, 0x1c, 0xa6, 0x0c, 0xea, 0xf7, + 0xea, 0xc9, 0xf6, 0x97, 0x5a, 0x63, 0x18, 0xac, 0xbc, 0x62, 0x9b, 0x74, 0x4a, 0xe2, 0x17, 0x47, + 0x5b, 0x50, 0x19, 0x69, 0x15, 0x4d, 0x67, 0x68, 0xbc, 0x92, 0xd3, 0xb3, 0x99, 0x3d, 0x40, 0xbd, + 0xb7, 0xb4, 0x53, 0x81, 0x26, 0x52, 0xa1, 0xc1, 0xf8, 0x1f, 0x7d, 0x35, 0xc6, 0x34, 0x9e, 0xc3, + 0xf4, 0x10, 0x0a, 0x43, 0x33, 0x49, 0x13, 0xc5, 0x90, 0x9e, 0xec, 0x3a, 0xb9, 0x2c, 0xb5, 0xf3, + 0x66, 0x52, 0xda, 0x74, 0x13, 0x56, 0xa4, 0x2a, 0x3b, 0x83, 0x83, 0xf8, 0x7a, 0x4f, 0x4f, 0xe2, + 0x7a, 0x72, 0xaf, 0x5e, 0x72, 0x7f, 0x9f, 0x62, 0xa7, 0x50, 0xbf, 0x99, 0x85, 0xe3, 0xa1, 0xb4, + 0x81, 0x73, 0xb4, 0xa0, 0x22, 0x94, 0x5a, 0x8c, 0x56, 0xd1, 0x2e, 0x4e, 0x36, 0xb3, 0x4b, 0x38, + 0xca, 0x76, 0xff, 0x97, 0x9d, 0xdd, 0x42, 0x23, 0xb3, 0xf2, 0xa5, 0x99, 0xfe, 0x69, 0x6b, 0x42, + 0x7e, 0xc0, 0x53, 0x57, 0x7e, 0xc0, 0xe3, 0x1d, 0xae, 0xb4, 0x75, 0x75, 0x4b, 0xc2, 0xe1, 0x2b, + 0xef, 0x63, 0xe3, 0x93, 0xf5, 0xc6, 0x27, 0x5f, 0x1b, 0x9f, 0xbc, 0x6d, 0xfd, 0xdc, 0x7a, 0xeb, + 0xe7, 0x3e, 0xb7, 0x7e, 0xee, 0x31, 0x79, 0xfb, 0x8b, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x71, + 0x44, 0x40, 0x9d, 0x13, 0x02, 0x00, 0x00, +} + func (m *Player) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -376,45 +406,53 @@ func (m *Player) Marshal() (dAtA []byte, err error) { } func (m *Player) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Player) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if len(m.PrivateID) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintExample(dAtA, i, uint64(len(m.PrivateID))) - i += copy(dAtA[i:], m.PrivateID) + if m.Trophies != 0 { + i = encodeVarintExample(dAtA, i, uint64(m.Trophies)) + i-- + dAtA[i] = 0x28 } - if len(m.AccessToken) > 0 { - dAtA[i] = 0x12 - i++ - i = encodeVarintExample(dAtA, i, uint64(len(m.AccessToken))) - i += copy(dAtA[i:], m.AccessToken) + if m.SoftCurrency != 0 { + i = encodeVarintExample(dAtA, i, uint64(m.SoftCurrency)) + i-- + dAtA[i] = 0x20 } if len(m.Name) > 0 { - dAtA[i] = 0x1a - i++ + i -= len(m.Name) + copy(dAtA[i:], m.Name) i = encodeVarintExample(dAtA, i, uint64(len(m.Name))) - i += copy(dAtA[i:], m.Name) + i-- + dAtA[i] = 0x1a } - if m.SoftCurrency != 0 { - dAtA[i] = 0x20 - i++ - i = encodeVarintExample(dAtA, i, uint64(m.SoftCurrency)) + if len(m.AccessToken) > 0 { + i -= len(m.AccessToken) + copy(dAtA[i:], m.AccessToken) + i = encodeVarintExample(dAtA, i, uint64(len(m.AccessToken))) + i-- + dAtA[i] = 0x12 } - if m.Trophies != 0 { - dAtA[i] = 0x28 - i++ - i = encodeVarintExample(dAtA, i, uint64(m.Trophies)) + if len(m.PrivateID) > 0 { + i -= len(m.PrivateID) + copy(dAtA[i:], m.PrivateID) + i = encodeVarintExample(dAtA, i, uint64(len(m.PrivateID))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *AuthResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -422,39 +460,48 @@ func (m *AuthResponse) Marshal() (dAtA []byte, err error) { } func (m *AuthResponse) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AuthResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if len(m.Code) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintExample(dAtA, i, uint64(len(m.Code))) - i += copy(dAtA[i:], m.Code) + if m.Player != nil { + { + size, err := m.Player.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintExample(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a } if len(m.Msg) > 0 { - dAtA[i] = 0x12 - i++ + i -= len(m.Msg) + copy(dAtA[i:], m.Msg) i = encodeVarintExample(dAtA, i, uint64(len(m.Msg))) - i += copy(dAtA[i:], m.Msg) + i-- + dAtA[i] = 0x12 } - if m.Player != nil { - dAtA[i] = 0x1a - i++ - i = encodeVarintExample(dAtA, i, uint64(m.Player.Size())) - n1, err := m.Player.MarshalTo(dAtA[i:]) - if err != nil { - return 0, err - } - i += n1 + if len(m.Code) > 0 { + i -= len(m.Code) + copy(dAtA[i:], m.Code) + i = encodeVarintExample(dAtA, i, uint64(len(m.Code))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *AuthArg) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -462,23 +509,29 @@ func (m *AuthArg) Marshal() (dAtA []byte, err error) { } func (m *AuthArg) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *AuthArg) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l if len(m.AccessToken) > 0 { - dAtA[i] = 0xa - i++ + i -= len(m.AccessToken) + copy(dAtA[i:], m.AccessToken) i = encodeVarintExample(dAtA, i, uint64(len(m.AccessToken))) - i += copy(dAtA[i:], m.AccessToken) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *FindMatchArg) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -486,23 +539,29 @@ func (m *FindMatchArg) Marshal() (dAtA []byte, err error) { } func (m *FindMatchArg) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FindMatchArg) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l if len(m.RoomType) > 0 { - dAtA[i] = 0xa - i++ + i -= len(m.RoomType) + copy(dAtA[i:], m.RoomType) i = encodeVarintExample(dAtA, i, uint64(len(m.RoomType))) - i += copy(dAtA[i:], m.RoomType) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func (m *FindMatchResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -510,29 +569,36 @@ func (m *FindMatchResponse) Marshal() (dAtA []byte, err error) { } func (m *FindMatchResponse) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FindMatchResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if len(m.Code) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintExample(dAtA, i, uint64(len(m.Code))) - i += copy(dAtA[i:], m.Code) - } if len(m.Msg) > 0 { - dAtA[i] = 0x12 - i++ + i -= len(m.Msg) + copy(dAtA[i:], m.Msg) i = encodeVarintExample(dAtA, i, uint64(len(m.Msg))) - i += copy(dAtA[i:], m.Msg) + i-- + dAtA[i] = 0x12 } - return i, nil + if len(m.Code) > 0 { + i -= len(m.Code) + copy(dAtA[i:], m.Code) + i = encodeVarintExample(dAtA, i, uint64(len(m.Code))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } func (m *FindMatchPush) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) - n, err := m.MarshalTo(dAtA) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) if err != nil { return nil, err } @@ -540,38 +606,47 @@ func (m *FindMatchPush) Marshal() (dAtA []byte, err error) { } func (m *FindMatchPush) MarshalTo(dAtA []byte) (int, error) { - var i int + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *FindMatchPush) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) _ = i var l int _ = l - if len(m.Code) > 0 { - dAtA[i] = 0xa - i++ - i = encodeVarintExample(dAtA, i, uint64(len(m.Code))) - i += copy(dAtA[i:], m.Code) + if m.Port != 0 { + i = encodeVarintExample(dAtA, i, uint64(m.Port)) + i-- + dAtA[i] = 0x18 } if len(m.IP) > 0 { - dAtA[i] = 0x12 - i++ + i -= len(m.IP) + copy(dAtA[i:], m.IP) i = encodeVarintExample(dAtA, i, uint64(len(m.IP))) - i += copy(dAtA[i:], m.IP) + i-- + dAtA[i] = 0x12 } - if m.Port != 0 { - dAtA[i] = 0x18 - i++ - i = encodeVarintExample(dAtA, i, uint64(m.Port)) + if len(m.Code) > 0 { + i -= len(m.Code) + copy(dAtA[i:], m.Code) + i = encodeVarintExample(dAtA, i, uint64(len(m.Code))) + i-- + dAtA[i] = 0xa } - return i, nil + return len(dAtA) - i, nil } func encodeVarintExample(dAtA []byte, offset int, v uint64) int { + offset -= sovExample(v) + base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) v >>= 7 offset++ } dAtA[offset] = uint8(v) - return offset + 1 + return base } func (m *Player) Size() (n int) { if m == nil { @@ -685,14 +760,7 @@ func (m *FindMatchPush) Size() (n int) { } func sovExample(x uint64) (n int) { - for { - n++ - x >>= 7 - if x == 0 { - break - } - } - return n + return (math_bits.Len64(x|1) + 6) / 7 } func sozExample(x uint64) (n int) { return sovExample(uint64((x << 1) ^ uint64((int64(x) >> 63)))) @@ -712,7 +780,7 @@ func (m *Player) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -740,7 +808,7 @@ func (m *Player) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -750,6 +818,9 @@ func (m *Player) Unmarshal(dAtA []byte) error { return ErrInvalidLengthExample } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExample + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -769,7 +840,7 @@ func (m *Player) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -779,6 +850,9 @@ func (m *Player) Unmarshal(dAtA []byte) error { return ErrInvalidLengthExample } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExample + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -798,7 +872,7 @@ func (m *Player) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -808,6 +882,9 @@ func (m *Player) Unmarshal(dAtA []byte) error { return ErrInvalidLengthExample } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExample + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -827,7 +904,7 @@ func (m *Player) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.SoftCurrency |= (int32(b) & 0x7F) << shift + m.SoftCurrency |= int32(b&0x7F) << shift if b < 0x80 { break } @@ -846,7 +923,7 @@ func (m *Player) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Trophies |= (int32(b) & 0x7F) << shift + m.Trophies |= int32(b&0x7F) << shift if b < 0x80 { break } @@ -857,7 +934,7 @@ func (m *Player) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthExample } if (iNdEx + skippy) > l { @@ -887,7 +964,7 @@ func (m *AuthResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -915,7 +992,7 @@ func (m *AuthResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -925,6 +1002,9 @@ func (m *AuthResponse) Unmarshal(dAtA []byte) error { return ErrInvalidLengthExample } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExample + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -944,7 +1024,7 @@ func (m *AuthResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -954,6 +1034,9 @@ func (m *AuthResponse) Unmarshal(dAtA []byte) error { return ErrInvalidLengthExample } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExample + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -973,7 +1056,7 @@ func (m *AuthResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - msglen |= (int(b) & 0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } @@ -982,6 +1065,9 @@ func (m *AuthResponse) Unmarshal(dAtA []byte) error { return ErrInvalidLengthExample } postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthExample + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -998,7 +1084,7 @@ func (m *AuthResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthExample } if (iNdEx + skippy) > l { @@ -1028,7 +1114,7 @@ func (m *AuthArg) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1056,7 +1142,7 @@ func (m *AuthArg) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1066,6 +1152,9 @@ func (m *AuthArg) Unmarshal(dAtA []byte) error { return ErrInvalidLengthExample } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExample + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -1077,7 +1166,7 @@ func (m *AuthArg) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthExample } if (iNdEx + skippy) > l { @@ -1107,7 +1196,7 @@ func (m *FindMatchArg) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1135,7 +1224,7 @@ func (m *FindMatchArg) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1145,6 +1234,9 @@ func (m *FindMatchArg) Unmarshal(dAtA []byte) error { return ErrInvalidLengthExample } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExample + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -1156,7 +1248,7 @@ func (m *FindMatchArg) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthExample } if (iNdEx + skippy) > l { @@ -1186,7 +1278,7 @@ func (m *FindMatchResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1214,7 +1306,7 @@ func (m *FindMatchResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1224,6 +1316,9 @@ func (m *FindMatchResponse) Unmarshal(dAtA []byte) error { return ErrInvalidLengthExample } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExample + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -1243,7 +1338,7 @@ func (m *FindMatchResponse) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1253,6 +1348,9 @@ func (m *FindMatchResponse) Unmarshal(dAtA []byte) error { return ErrInvalidLengthExample } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExample + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -1264,7 +1362,7 @@ func (m *FindMatchResponse) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthExample } if (iNdEx + skippy) > l { @@ -1294,7 +1392,7 @@ func (m *FindMatchPush) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - wire |= (uint64(b) & 0x7F) << shift + wire |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1322,7 +1420,7 @@ func (m *FindMatchPush) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1332,6 +1430,9 @@ func (m *FindMatchPush) Unmarshal(dAtA []byte) error { return ErrInvalidLengthExample } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExample + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -1351,7 +1452,7 @@ func (m *FindMatchPush) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= (uint64(b) & 0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } @@ -1361,6 +1462,9 @@ func (m *FindMatchPush) Unmarshal(dAtA []byte) error { return ErrInvalidLengthExample } postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthExample + } if postIndex > l { return io.ErrUnexpectedEOF } @@ -1380,7 +1484,7 @@ func (m *FindMatchPush) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Port |= (int32(b) & 0x7F) << shift + m.Port |= int32(b&0x7F) << shift if b < 0x80 { break } @@ -1391,7 +1495,7 @@ func (m *FindMatchPush) Unmarshal(dAtA []byte) error { if err != nil { return err } - if skippy < 0 { + if (skippy < 0) || (iNdEx+skippy) < 0 { return ErrInvalidLengthExample } if (iNdEx + skippy) > l { @@ -1409,6 +1513,7 @@ func (m *FindMatchPush) Unmarshal(dAtA []byte) error { func skipExample(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 + depth := 0 for iNdEx < l { var wire uint64 for shift := uint(0); ; shift += 7 { @@ -1440,10 +1545,8 @@ func skipExample(dAtA []byte) (n int, err error) { break } } - return iNdEx, nil case 1: iNdEx += 8 - return iNdEx, nil case 2: var length int for shift := uint(0); ; shift += 7 { @@ -1460,80 +1563,34 @@ func skipExample(dAtA []byte) (n int, err error) { break } } - iNdEx += length if length < 0 { return 0, ErrInvalidLengthExample } - return iNdEx, nil + iNdEx += length case 3: - for { - var innerWire uint64 - var start int = iNdEx - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowExample - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - innerWire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - innerWireType := int(innerWire & 0x7) - if innerWireType == 4 { - break - } - next, err := skipExample(dAtA[start:]) - if err != nil { - return 0, err - } - iNdEx = start + next - } - return iNdEx, nil + depth++ case 4: - return iNdEx, nil + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupExample + } + depth-- case 5: iNdEx += 4 - return iNdEx, nil default: return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } + if iNdEx < 0 { + return 0, ErrInvalidLengthExample + } + if depth == 0 { + return iNdEx, nil + } } - panic("unreachable") + return 0, io.ErrUnexpectedEOF } var ( - ErrInvalidLengthExample = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowExample = fmt.Errorf("proto: integer overflow") + ErrInvalidLengthExample = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowExample = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupExample = fmt.Errorf("proto: unexpected end of group") ) - -func init() { proto.RegisterFile("example.proto", fileDescriptor_example_4c07b9927c24f8f0) } - -var fileDescriptor_example_4c07b9927c24f8f0 = []byte{ - // 327 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x51, 0x3d, 0x4f, 0x02, 0x41, - 0x14, 0x64, 0xf9, 0x12, 0x1e, 0x1f, 0xd1, 0xad, 0x2e, 0xc4, 0x5c, 0xc8, 0x16, 0x86, 0x68, 0x42, - 0xa1, 0x95, 0x25, 0x62, 0x34, 0x14, 0x98, 0xcd, 0x4a, 0x69, 0xb3, 0x1e, 0x4f, 0x20, 0xc2, 0xed, - 0x65, 0x77, 0x31, 0xf2, 0x2f, 0xfc, 0x01, 0xfe, 0x20, 0x4b, 0x4a, 0x4b, 0x03, 0x7f, 0xc4, 0xdc, - 0xde, 0x71, 0x62, 0x62, 0x63, 0x75, 0xf3, 0x66, 0xde, 0xbc, 0x9b, 0xc9, 0x42, 0x03, 0x5f, 0xe5, - 0x22, 0x9a, 0x63, 0x37, 0xd2, 0xca, 0x2a, 0x5a, 0x76, 0x1f, 0xc3, 0xde, 0x09, 0x94, 0xf9, 0x5c, - 0xae, 0x50, 0xd3, 0x63, 0xa8, 0x72, 0x3d, 0x7b, 0x91, 0x16, 0x07, 0xd7, 0x1e, 0x69, 0x93, 0x4e, - 0x55, 0xfc, 0x10, 0xb4, 0x0d, 0xb5, 0x5e, 0x10, 0xa0, 0x31, 0x23, 0xf5, 0x8c, 0xa1, 0x97, 0x77, - 0xfa, 0x3e, 0x45, 0x29, 0x14, 0xef, 0xe4, 0x02, 0xbd, 0x82, 0x93, 0x1c, 0xa6, 0x0c, 0xea, 0xf7, - 0xea, 0xc9, 0xf6, 0x97, 0x5a, 0x63, 0x18, 0xac, 0xbc, 0x62, 0x9b, 0x74, 0x4a, 0xe2, 0x17, 0x47, - 0x5b, 0x50, 0x19, 0x69, 0x15, 0x4d, 0x67, 0x68, 0xbc, 0x92, 0xd3, 0xb3, 0x99, 0x3d, 0x40, 0xbd, - 0xb7, 0xb4, 0x53, 0x81, 0x26, 0x52, 0xa1, 0xc1, 0xf8, 0x1f, 0x7d, 0x35, 0xc6, 0x34, 0x9e, 0xc3, - 0xf4, 0x10, 0x0a, 0x43, 0x33, 0x49, 0x13, 0xc5, 0x90, 0x9e, 0xec, 0x3a, 0xb9, 0x2c, 0xb5, 0xf3, - 0x66, 0x52, 0xda, 0x74, 0x13, 0x56, 0xa4, 0x2a, 0x3b, 0x83, 0x83, 0xf8, 0x7a, 0x4f, 0x4f, 0xe2, - 0x7a, 0x72, 0xaf, 0x5e, 0x72, 0x7f, 0x9f, 0x62, 0xa7, 0x50, 0xbf, 0x99, 0x85, 0xe3, 0xa1, 0xb4, - 0x81, 0x73, 0xb4, 0xa0, 0x22, 0x94, 0x5a, 0x8c, 0x56, 0xd1, 0x2e, 0x4e, 0x36, 0xb3, 0x4b, 0x38, - 0xca, 0x76, 0xff, 0x97, 0x9d, 0xdd, 0x42, 0x23, 0xb3, 0xf2, 0xa5, 0x99, 0xfe, 0x69, 0x6b, 0x42, - 0x7e, 0xc0, 0x53, 0x57, 0x7e, 0xc0, 0xe3, 0x1d, 0xae, 0xb4, 0x75, 0x75, 0x4b, 0xc2, 0xe1, 0x2b, - 0xef, 0x63, 0xe3, 0x93, 0xf5, 0xc6, 0x27, 0x5f, 0x1b, 0x9f, 0xbc, 0x6d, 0xfd, 0xdc, 0x7a, 0xeb, - 0xe7, 0x3e, 0xb7, 0x7e, 0xee, 0x31, 0x79, 0xfb, 0x8b, 0xef, 0x00, 0x00, 0x00, 0xff, 0xff, 0x71, - 0x44, 0x40, 0x9d, 0x13, 0x02, 0x00, 0x00, -} From ed1a5a9e51cddbb9a7436c4aec627843527833c4 Mon Sep 17 00:00:00 2001 From: CaioIcy Date: Wed, 24 Mar 2021 21:28:08 -0300 Subject: [PATCH 06/16] Update README --- Makefile | 6 +++--- README.md | 21 +++++++-------------- go.sum | 1 + 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 8454047..f72097f 100644 --- a/Makefile +++ b/Makefile @@ -13,13 +13,13 @@ setup-protobuf-macos: @brew install protobuf @go get -u github.com/gogo/protobuf/protoc-gen-gogofaster -run-testing-server: +run-testing-json-server: @docker-compose -f ./testing/json/docker-compose.yml up -d etcd nats redis && go run ./testing/json/main.go -run-testing-bots: +run-testing-json-bots: @go run *.go run -d ./testing/json/specs/ --config ./testing/json/config/config.yaml -kill-testing-deps: +kill-testing-json-deps: @docker-compose -f ./testing/json/docker-compose.yml down; true run-testing-proto-server: diff --git a/README.md b/README.md index 29ebd72..0e6d146 100644 --- a/README.md +++ b/README.md @@ -40,27 +40,20 @@ make setup Here's how to run the testing example with JSON serializer: -Start etcd and nats (this command requires docker-compose and will run etcd and nats containers locally, you may run etcd and/or nats without docker if you prefer) +Start the dependencies (this command requires docker-compose, but you may run the dependencies locally if need be) and the pitaya server: ``` -docker-compose -f ./testing/json/docker-compose.yml up -d etcd -``` -run the server from testing example -``` -make run-testing-server +$ make run-testing-json-server ``` -Now a pitaya server should be running in one terminal. In another one, you can use pitaya-bot testing example: +Now a pitaya server should be running in one terminal. In another one, you can run pitaya-bot with the test specs: ``` -$ pitaya-bot run -d ./testing/json/specs/ --config ./testing/json/config/config.yaml -testing/json/specs/default.json 1755 -INFO[0000] Found 1 specs to be executed function=launch source=pitaya-bot -... +$ make run-testing-json-bots ``` -To run the protobuf example you can run: +For the examples with protobuf, instead run: ``` -make run-testing-proto-server -pitaya-bot run -d ./testing/protobuffer/specs --config ./testing/protobuffer/config/config.yaml +$ make run-testing-proto-server +$ make run-testing-proto-server ``` ## Running the tests diff --git a/go.sum b/go.sum index 9c6cc6e..b8b4f53 100644 --- a/go.sum +++ b/go.sum @@ -189,6 +189,7 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+ github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2 h1:bSDNvY7ZPG5RlJ8otE/7V6gMiyenm9RtJ7IUVIAoJ1w= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6 h1:lYIiVDtZnyTWlNwiAxLj0bbpTcx1BWCFhXjfsvmPdNc= github.com/tmc/grpc-websocket-proxy v0.0.0-20171017195756-830351dc03c6/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= From 1f7bd9bdea31d4cc5913df450bf7dcc45e9824c3 Mon Sep 17 00:00:00 2001 From: CaioIcy Date: Thu, 25 Mar 2021 14:07:01 -0300 Subject: [PATCH 07/16] Add warning log to a failed sequential step In some cases where the spec couldn't finish this failure wouldn't be logged at all --- bot/sequential.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bot/sequential.go b/bot/sequential.go index f521e10..1c2d7b3 100644 --- a/bot/sequential.go +++ b/bot/sequential.go @@ -78,9 +78,10 @@ func (b *SequentialBot) Run() (err error) { }() steps := b.spec.SequentialOperations - for _, step := range steps { + for idx, step := range steps { err = b.runOperation(step) if err != nil { + b.logger.WithError(err).Warnf("failed sequential step %d (%s/%s)", idx, step.Type, step.URI) return } } From c5a57999fa10c2d199439214c8a901cc3f587f86 Mon Sep 17 00:00:00 2001 From: CaioIcy Date: Thu, 25 Mar 2021 16:01:49 -0300 Subject: [PATCH 08/16] Improve compound errors log legibility --- launcher/launcher.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/launcher/launcher.go b/launcher/launcher.go index 7e24cee..e4aa9b9 100644 --- a/launcher/launcher.go +++ b/launcher/launcher.go @@ -166,13 +166,15 @@ func Launch( var wg sync.WaitGroup errmutex := sync.Mutex{} - compoundError := []error{} + compoundErrorHist := make(map[string]int) for _, spec := range specs { wg.Add(1) go func(spec *models.Spec) { - if err := runSpec(app, spec, config, duration, logger); err != nil { + if errs := runSpec(app, spec, config, duration, logger); errs != nil { errmutex.Lock() - compoundError = append(compoundError, err...) + for _, err := range errs { + compoundErrorHist[err.Error()]++ + } errmutex.Unlock() } wg.Done() @@ -193,9 +195,10 @@ func Launch( } } - if len(compoundError) > 0 { - logger.Error("Spec execution failed") - logger.Error(compoundError) + if len(compoundErrorHist) > 0 { + logger.WithFields(logrus.Fields{ + "errors": compoundErrorHist, + }).Error("Spec execution failed") os.Exit(1) } } From 43420adc4d50d9fa19349d01a25dfdd04fa924db Mon Sep 17 00:00:00 2001 From: CaioIcy Date: Mon, 29 Mar 2021 16:19:19 -0300 Subject: [PATCH 09/16] Restore server.tls config --- bot/pitaya_client.go | 25 +++++++++++++++---------- bot/sequential.go | 3 ++- cmd/root.go | 1 + docs/configuration.rst | 4 ++++ docs/test_writing.md | 1 + 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/bot/pitaya_client.go b/bot/pitaya_client.go index 0f622f5..8e9bce3 100644 --- a/bot/pitaya_client.go +++ b/bot/pitaya_client.go @@ -45,17 +45,22 @@ func getProtoInfo(host string, docs string, pushinfo map[string]string) *client. return instance } -func tryConnect(pClient client.PitayaClient, addr string) error { - if err := pClient.ConnectToWS(addr, "", &tls.Config{ - InsecureSkipVerify: true, - }); err != nil { - if err := pClient.ConnectToWS(addr, ""); err != nil { +func tryConnect(pClient client.PitayaClient, addr string, useTLS bool) error { + fmt.Printf("Connecting (tls=[%v])...\n", useTLS) + if useTLS { + if err := pClient.ConnectToWS(addr, "", &tls.Config{ + InsecureSkipVerify: true, + }); err != nil { if err := pClient.ConnectTo(addr, &tls.Config{ InsecureSkipVerify: true, }); err != nil { - if err := pClient.ConnectTo(addr); err != nil { - return err - } + return err + } + } + } else { + if err := pClient.ConnectToWS(addr, ""); err != nil { + if err := pClient.ConnectTo(addr); err != nil { + return err } } } @@ -63,7 +68,7 @@ func tryConnect(pClient client.PitayaClient, addr string) error { } // NewPClient is the PCLient constructor -func NewPClient(host string, docs string, pushinfo map[string]string) (*PClient, error) { +func NewPClient(host string, useTLS bool, docs string, pushinfo map[string]string) (*PClient, error) { var pclient client.PitayaClient if docs != "" { protoclient := client.NewProto(docs, logrus.InfoLevel) @@ -75,7 +80,7 @@ func NewPClient(host string, docs string, pushinfo map[string]string) (*PClient, pclient = client.New(logrus.InfoLevel) } - if err := tryConnect(pclient, host); err != nil { + if err := tryConnect(pclient, host, useTLS); err != nil { fmt.Println("Error connecting to server") fmt.Println(err) return nil, err diff --git a/bot/sequential.go b/bot/sequential.go index 1c2d7b3..9fbdc27 100644 --- a/bot/sequential.go +++ b/bot/sequential.go @@ -255,7 +255,8 @@ func (b *SequentialBot) Connect(hosts ...string) error { docs = b.config.GetString("server.protobuffer.docs") } - client, err := NewPClient(b.host, docs, pushinfo) + useTLS := b.config.GetBool("server.tls") + client, err := NewPClient(b.host, useTLS, docs, pushinfo) if err != nil { b.logger.WithError(err).Error("Unable to create client...") return err diff --git a/cmd/root.go b/cmd/root.go index 89824ac..0410934 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -100,6 +100,7 @@ func fillDefaultValues(config *viper.Viper) { "game": "", "prometheus.port": 9191, "server.host": "localhost", + "server.tls": "false", "server.serializer": "json", "server.protobuffer.docs": "connector.docsHandler.docs", "storage.type": "memory", diff --git a/docs/configuration.rst b/docs/configuration.rst index 790d08f..9d76d9e 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -60,6 +60,10 @@ The configurations needed to access the Pitaya server being tested - localhost - string - Pitaya server host + * - server.tls + - false + - bool + - Boolean to enable/disable TLS to connect with Pitaya server * - server.serializer - json - string diff --git a/docs/test_writing.md b/docs/test_writing.md index 5031831..b1bc33f 100644 --- a/docs/test_writing.md +++ b/docs/test_writing.md @@ -61,6 +61,7 @@ storage: server: host: "localhost" + tls: true prometheus: port: 9191 From 4389a6619f2f6e1b5a1dd1fb90973d4bfa0d5365 Mon Sep 17 00:00:00 2001 From: CaioIcy Date: Mon, 29 Mar 2021 16:46:29 -0300 Subject: [PATCH 10/16] Set default verbosity to 2 (info) --- cmd/root.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/root.go b/cmd/root.go index 0410934..245d02b 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -63,7 +63,7 @@ func init() { // will be global for your application. rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "./config/config.yaml", "config file") rootCmd.PersistentFlags().IntVarP( - &verbose, "verbose", "v", 3, + &verbose, "verbose", "v", 2, "Verbosity level => v0: Error, v1=Warning, v2=Info, v3=Debug", ) rootCmd.PersistentFlags().BoolVarP(&logJSON, "logJSON", "j", false, "logJSON output mode") From 8fc5ea0dfbaf77261153bea9a1f6053e84869144 Mon Sep 17 00:00:00 2001 From: CaioIcy Date: Mon, 29 Mar 2021 17:13:20 -0300 Subject: [PATCH 11/16] Add configurable request timeout --- bot/pitaya_client.go | 25 ++++++++++++++----------- bot/sequential.go | 3 ++- cmd/root.go | 1 + 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/bot/pitaya_client.go b/bot/pitaya_client.go index 8e9bce3..0e68e7b 100644 --- a/bot/pitaya_client.go +++ b/bot/pitaya_client.go @@ -26,9 +26,12 @@ type PClient struct { pushesMutex sync.Mutex pushes map[string]chan []byte + + timeout time.Duration + logger logrus.FieldLogger } -func getProtoInfo(host string, docs string, pushinfo map[string]string) *client.ProtoBufferInfo { +func getProtoInfo(host string, docs string, pushinfo map[string]string, logger logrus.FieldLogger) *client.ProtoBufferInfo { once.Do(func() { cli := client.NewProto(docs, logrus.InfoLevel) for k, v := range pushinfo { @@ -36,8 +39,7 @@ func getProtoInfo(host string, docs string, pushinfo map[string]string) *client. } err := cli.LoadServerInfo(host) if err != nil { - fmt.Println("Unable to load server documentation.") - fmt.Println(err) + logger.WithError(err).Error("Unable to load server documentation.") } else { instance = cli.ExportInformation() } @@ -45,8 +47,8 @@ func getProtoInfo(host string, docs string, pushinfo map[string]string) *client. return instance } -func tryConnect(pClient client.PitayaClient, addr string, useTLS bool) error { - fmt.Printf("Connecting (tls=[%v])...\n", useTLS) +func tryConnect(pClient client.PitayaClient, addr string, useTLS bool, logger logrus.FieldLogger) error { + logger.Debugf("Connecting (tls=[%v])...\n", useTLS) if useTLS { if err := pClient.ConnectToWS(addr, "", &tls.Config{ InsecureSkipVerify: true, @@ -68,21 +70,20 @@ func tryConnect(pClient client.PitayaClient, addr string, useTLS bool) error { } // NewPClient is the PCLient constructor -func NewPClient(host string, useTLS bool, docs string, pushinfo map[string]string) (*PClient, error) { +func NewPClient(host string, useTLS bool, timeout time.Duration, logger logrus.FieldLogger, docs string, pushinfo map[string]string) (*PClient, error) { var pclient client.PitayaClient if docs != "" { protoclient := client.NewProto(docs, logrus.InfoLevel) pclient = protoclient - if err := protoclient.LoadInfo(getProtoInfo(host, docs, pushinfo)); err != nil { + if err := protoclient.LoadInfo(getProtoInfo(host, docs, pushinfo, logger)); err != nil { return nil, err } } else { pclient = client.New(logrus.InfoLevel) } - if err := tryConnect(pclient, host, useTLS); err != nil { - fmt.Println("Error connecting to server") - fmt.Println(err) + if err := tryConnect(pclient, host, useTLS, logger); err != nil { + logger.WithError(err).Error("Error connecting to server") return nil, err } @@ -90,6 +91,8 @@ func NewPClient(host string, useTLS bool, docs string, pushinfo map[string]strin client: pclient, responses: make(map[uint]chan []byte), pushes: make(map[string]chan []byte), + timeout: timeout, + logger: logger, }, nil } @@ -149,7 +152,7 @@ func (c *PClient) Request(route string, data []byte) (Response, []byte, error) { } return ret, responseData, nil - case <-time.After(5 * time.Second): // TODO - pass timeout as config + case <-time.After(c.timeout): return nil, nil, fmt.Errorf("Timeout waiting for response on route %s", route) } } diff --git a/bot/sequential.go b/bot/sequential.go index 9fbdc27..6f3d581 100644 --- a/bot/sequential.go +++ b/bot/sequential.go @@ -256,7 +256,8 @@ func (b *SequentialBot) Connect(hosts ...string) error { } useTLS := b.config.GetBool("server.tls") - client, err := NewPClient(b.host, useTLS, docs, pushinfo) + timeout := b.config.GetDuration("server.requestTimeout") + client, err := NewPClient(b.host, useTLS, timeout, b.logger, docs, pushinfo) if err != nil { b.logger.WithError(err).Error("Unable to create client...") return err diff --git a/cmd/root.go b/cmd/root.go index 245d02b..c5bd0f6 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -103,6 +103,7 @@ func fillDefaultValues(config *viper.Viper) { "server.tls": "false", "server.serializer": "json", "server.protobuffer.docs": "connector.docsHandler.docs", + "server.requestTimeout": "5s", "storage.type": "memory", "kubernetes.config": filepath.Join(homedir.HomeDir(), ".kube", "config"), "kubernetes.context": "", From 9b5d44541e9697dbe3f26b620dd85a39bd4298a6 Mon Sep 17 00:00:00 2001 From: CaioIcy Date: Mon, 29 Mar 2021 17:15:07 -0300 Subject: [PATCH 12/16] Document server.requestTimeout --- docs/configuration.rst | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/configuration.rst b/docs/configuration.rst index 9d76d9e..aa38cd0 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -64,6 +64,10 @@ The configurations needed to access the Pitaya server being tested - false - bool - Boolean to enable/disable TLS to connect with Pitaya server + * - server.requestTimeout + - 5s + - time.Duration + - Request timeout for the Pitaya client * - server.serializer - json - string From c82709a67440cecf00eff91b2f0fc7b275300280 Mon Sep 17 00:00:00 2001 From: CaioIcy Date: Tue, 30 Mar 2021 16:55:43 -0300 Subject: [PATCH 13/16] Add validations to spec before running bot --- constants/errors.go | 7 +++++++ models/spec.go | 24 ++++++++++++++++++++++++ models/spec_test.go | 29 +++++++++++++++++++++++++++++ runner/runner.go | 7 +++++++ 4 files changed, 67 insertions(+) create mode 100644 models/spec_test.go diff --git a/constants/errors.go b/constants/errors.go index 5bc7731..7ce76de 100644 --- a/constants/errors.go +++ b/constants/errors.go @@ -8,3 +8,10 @@ var ( ErrStorageTypeNotFound = errors.New("storage type not found") ErrMalformedObject = errors.New("malformed object type argument") ) + +// Errors that are related to a spec +var ( + ErrSpecInvalidNil = errors.New("invalid spec: nil") + ErrSpecInvalidType = errors.New("invalid spec: Type") + ErrSpecInvalidURI = errors.New("invalid spec: URI") +) diff --git a/models/spec.go b/models/spec.go index a32ac1e..77862e9 100644 --- a/models/spec.go +++ b/models/spec.go @@ -1,5 +1,9 @@ package models +import ( + "github.com/topfreegames/pitaya-bot/constants" +) + // Spec defines the bots' spec type Spec struct { Name string `json:"name"` @@ -58,3 +62,23 @@ type Operation struct { Store StoreSpec `json:"store,omitempty"` Change map[string]interface{} `json:"change,omitempty"` } + +// Validate returns an error if the operation is malformed +// TODO -- more validations +func (o *Operation) Validate() error { + if o == nil { + return constants.ErrSpecInvalidNil + } + + if o.Type == "" { + // must have a Type specified + return constants.ErrSpecInvalidType + } + + if o.URI == "" { + // must have a URI specified + return constants.ErrSpecInvalidURI + } + + return nil +} diff --git a/models/spec_test.go b/models/spec_test.go new file mode 100644 index 0000000..80f1e91 --- /dev/null +++ b/models/spec_test.go @@ -0,0 +1,29 @@ +package models + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/topfreegames/pitaya-bot/constants" +) + +func TestOperationValidate(t *testing.T) { + var tables = map[string]struct { + op *Operation + err error + }{ + "success_default": {&Operation{Type: "listen", URI: "metagame.someHandler.someRoute"}, nil}, + + "err_nil": {nil, constants.ErrSpecInvalidNil}, + "err_no_type": {&Operation{Type: ""}, constants.ErrSpecInvalidType}, + "err_no_uri": {&Operation{Type: "listen"}, constants.ErrSpecInvalidURI}, + } + + for name, table := range tables { + t.Run(name, func(t *testing.T) { + err := table.op.Validate() + assert.Equal(t, table.err, err) + }) + } +} + diff --git a/runner/runner.go b/runner/runner.go index 7ff0cd8..6b1085c 100644 --- a/runner/runner.go +++ b/runner/runner.go @@ -39,6 +39,13 @@ func Run( logger.Infof("Starting bot with id: %d", id) if spec.SequentialOperations != nil { logger.Debug("Found sequential operations") + for idx, step := range spec.SequentialOperations { + if err := step.Validate(); err != nil { + logger.WithError(err).Errorf("invalid step=[%d]", idx) + return err + } + } + bot, err = pbot.NewSequentialBot(config, spec, id, app.MetricsReporter, logger) if err != nil { logger.WithError(err).Error("Failed to create bot") From ecf874fd2eedcbe8153415e9f66d18f6a5e8c409 Mon Sep 17 00:00:00 2001 From: CaioIcy Date: Tue, 30 Mar 2021 16:58:31 -0300 Subject: [PATCH 14/16] Set small duration for json/proto test examples --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index f72097f..5ee5e66 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ run-testing-json-server: @docker-compose -f ./testing/json/docker-compose.yml up -d etcd nats redis && go run ./testing/json/main.go run-testing-json-bots: - @go run *.go run -d ./testing/json/specs/ --config ./testing/json/config/config.yaml + @go run *.go run --duration 5s -d ./testing/json/specs/ --config ./testing/json/config/config.yaml kill-testing-json-deps: @docker-compose -f ./testing/json/docker-compose.yml down; true @@ -27,7 +27,7 @@ run-testing-proto-server: @docker-compose -f ./testing/protobuffer/docker-compose.yml up -d etcd nats && go run ./testing/protobuffer/main.go run-testing-proto-bots: - @go run *.go run --duration 10s -d ./testing/protobuffer/specs/ --config ./testing/protobuffer/config/config.yaml + @go run *.go run --duration 5s -d ./testing/protobuffer/specs/ --config ./testing/protobuffer/config/config.yaml kill-testing-proto-deps: @docker-compose -f ./testing/protobuffer/docker-compose.yml down; true From c52834aec02223635dd593f0e305727b806f4e28 Mon Sep 17 00:00:00 2001 From: CaioIcy Date: Tue, 30 Mar 2021 19:34:13 -0300 Subject: [PATCH 15/16] Return raw response on ReceivePush To match Request behaviour so we can also build a NewExpectError --- bot/pitaya_client.go | 8 ++++---- bot/sequential.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/bot/pitaya_client.go b/bot/pitaya_client.go index 0e68e7b..00b3d25 100644 --- a/bot/pitaya_client.go +++ b/bot/pitaya_client.go @@ -164,7 +164,7 @@ func (c *PClient) Notify(route string, data []byte) error { } // ReceivePush ... -func (c *PClient) ReceivePush(route string, timeout int) (Response, error) { +func (c *PClient) ReceivePush(route string, timeout int) (Response, []byte, error) { ch := c.getPushChannelForRoute(route) select { @@ -172,12 +172,12 @@ func (c *PClient) ReceivePush(route string, timeout int) (Response, error) { var ret Response if err := json.Unmarshal(data, &ret); err != nil { err = fmt.Errorf("Error unmarshaling response: %s", err) - return nil, err + return nil, nil, err } - return ret, nil + return ret, data, nil case <-time.After(time.Duration(timeout) * time.Millisecond): - return nil, fmt.Errorf("Timeout waiting for push on route %s", route) + return nil, nil, fmt.Errorf("Timeout waiting for push on route %s", route) } } diff --git a/bot/sequential.go b/bot/sequential.go index 6f3d581..00e5ca0 100644 --- a/bot/sequential.go +++ b/bot/sequential.go @@ -171,7 +171,7 @@ func (b *SequentialBot) runFunction(op *models.Operation) error { func (b *SequentialBot) listenToPush(op *models.Operation) error { b.logger.Debug("Waiting for push on route: " + op.URI) - resp, err := b.client.ReceivePush(op.URI, op.Timeout) + resp, rawResp, err := b.client.ReceivePush(op.URI, op.Timeout) if err != nil { return err } @@ -179,7 +179,7 @@ func (b *SequentialBot) listenToPush(op *models.Operation) error { b.logger.Debug("validating expectations") err = validateExpectations(op.Expect, resp, b.storage) if err != nil { - return err + return NewExpectError(err, rawResp, op.Expect) } b.logger.Debug("received valid response") From f320f5bfd4206f6c03773dc2b6575d6b9bcadb70 Mon Sep 17 00:00:00 2001 From: CaioIcy Date: Tue, 6 Apr 2021 12:25:10 -0300 Subject: [PATCH 16/16] Fix README: update command for running proto tests --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0e6d146..eec6b5f 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ $ make run-testing-json-bots For the examples with protobuf, instead run: ``` $ make run-testing-proto-server -$ make run-testing-proto-server +$ make run-testing-proto-bots ``` ## Running the tests