diff --git a/Makefile b/Makefile index 2afd99c07344..7ac146e39eb9 100644 --- a/Makefile +++ b/Makefile @@ -112,10 +112,8 @@ docker-image: #### Build utils ### swagger-spec: install-tools - go mod vendor - swag init --parseVendor --generalInfo server/api/router.go --exclude vendor/github.com/pingcap/tidb-dashboard --output docs/swagger - go mod tidy - rm -rf vendor + swag init --parseDependency --parseInternal --parseDepth 1 --dir server --generalInfo api/router.go --output docs/swagger + swag fmt --dir server dashboard-ui: ./scripts/embed-dashboard-ui.sh diff --git a/go.mod b/go.mod index 0a662f0f16b6..6c2a3c4380ba 100644 --- a/go.mod +++ b/go.mod @@ -40,7 +40,7 @@ require ( github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.7.0 github.com/swaggo/http-swagger v0.0.0-20200308142732-58ac5e232fba - github.com/swaggo/swag v1.6.6-0.20200529100950-7c765ddd0476 + github.com/swaggo/swag v1.8.3 github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965 github.com/tidwall/gjson v1.9.3 // indirect github.com/unrolled/render v1.0.1 @@ -50,9 +50,9 @@ require ( go.etcd.io/etcd v0.5.0-alpha.5.0.20191023171146-3cf2f69b5738 go.uber.org/goleak v1.1.12 go.uber.org/zap v1.19.1 - golang.org/x/text v0.3.3 + golang.org/x/text v0.3.7 golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 - golang.org/x/tools v0.1.5 + golang.org/x/tools v0.1.10 google.golang.org/grpc v1.26.0 gotest.tools/gotestsum v1.7.0 ) diff --git a/go.sum b/go.sum index ad3415e81168..54862125e1a1 100644 --- a/go.sum +++ b/go.sum @@ -79,6 +79,7 @@ github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:ma github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM= github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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= @@ -136,20 +137,24 @@ github.com/go-ole/go-ole v1.2.4 h1:nNBDSCOigTSiarFpYE9J/KtEA1IOW4CNeqT9TQDqCxI= github.com/go-ole/go-ole v1.2.4/go.mod h1:XCwSNxSkXRo4vlyPy93sltvi/qJq0jqQhjqQNIwKuxM= github.com/go-openapi/jsonpointer v0.17.0/go.mod h1:cOnomiV+CVVwFLk0A/MExoFMjwdsUdVpsRhURCKh+3M= github.com/go-openapi/jsonpointer v0.19.2/go.mod h1:3akKfEdA7DF1sugOqz1dVQHBcuDBPKZGEoHC/NkiQRg= -github.com/go-openapi/jsonpointer v0.19.3 h1:gihV7YNZK1iK6Tgwwsxo2rJbD1GTbdm72325Bq8FI3w= github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= github.com/go-openapi/jsonreference v0.17.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.19.0/go.mod h1:g4xxGn04lDIRh0GJb5QlpE3HfopLOL6uZrK/VgnsK9I= github.com/go-openapi/jsonreference v0.19.2/go.mod h1:jMjeRr2HHw6nAVajTXJ4eiUwohSTlpa0o73RUL1owJc= -github.com/go-openapi/jsonreference v0.19.3 h1:5cxNfTy0UVC3X8JL5ymxzyoUZmo8iZb+jeTWn7tUa8o= github.com/go-openapi/jsonreference v0.19.3/go.mod h1:rjx6GuL8TTa9VaixXglHmQmIL98+wF9xc8zWvFonSJ8= +github.com/go-openapi/jsonreference v0.19.6 h1:UBIxjkht+AWIgYzCDSv2GN+E/togfwXUJFRTWhl2Jjs= +github.com/go-openapi/jsonreference v0.19.6/go.mod h1:diGHMEHg2IqXZGKxqyvWdfWU/aim5Dprw5bqpKkTvns= github.com/go-openapi/spec v0.19.0/go.mod h1:XkF/MOi14NmjsfZ8VtAKf8pIlbZzyoTvZsdfssdxcBI= -github.com/go-openapi/spec v0.19.4 h1:ixzUSnHTd6hCemgtAJgluaTSGYpLNpJY4mA2DIkdOAo= github.com/go-openapi/spec v0.19.4/go.mod h1:FpwSN1ksY1eteniUU7X0N/BgJ7a4WvBFVA8Lj9mJglo= +github.com/go-openapi/spec v0.20.4 h1:O8hJrt0UMnhHcluhIdUgCLRWyM2x7QkBXRvOs7m+O1M= +github.com/go-openapi/spec v0.20.4/go.mod h1:faYFR1CvsJZ0mNsmsphTMSoRrNV3TEDoAM7FOEWeq8I= github.com/go-openapi/swag v0.17.0/go.mod h1:AByQ+nYG6gQg71GINrmuDXCPWdL640yX49/kXLo40Tg= github.com/go-openapi/swag v0.19.2/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= -github.com/go-openapi/swag v0.19.5 h1:lTz6Ys4CmqqCQmZPBlbQENR1/GucA2bzYTE12Pw4tFY= github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.19.15 h1:D2NRCBzS9/pEY3gP9Nl8aDqGUcPFrwG2p+CNFrLyrCM= +github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ= github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.13.0 h1:HyWk6mgj5qFqCT5fjGBuRArbVDfE4hi8+e8ceBS/t7Q= @@ -283,6 +288,8 @@ github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9q github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= github.com/joomcode/errorx v1.0.1 h1:CalpDWz14ZHd68fIqluJasJosAewpz2TFaJALrUxjrk= github.com/joomcode/errorx v1.0.1/go.mod h1:kgco15ekB6cs+4Xjzo7SPeXzx38PbJzBwbnu9qfVNHQ= +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.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.7/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= @@ -298,13 +305,13 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv github.com/konsorten/go-windows-terminal-sequences v1.0.2 h1:DB17ag19krx9CFsz4o3enTrPXyIXCl+2iCXH/aMAp9s= github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.5/go.mod h1:9r2w37qlBe7rQ6e1fg1S/9xpWHSnaqNdHD3WcMdbPDA= github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= 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/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y= github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= @@ -316,8 +323,9 @@ github.com/lucasb-eyer/go-colorful v1.0.3/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= -github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e h1:hB2xlXdHp/pmPZq0y3QnmWAArdw9PqbmotexnWx/FU8= github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.6 h1:8yTIVnZgCoiM1TgqoeTl+LfU5Jg6/xL3QhGQnimLYnA= +github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= @@ -365,6 +373,8 @@ github.com/montanaflynn/stats v0.5.0/go.mod h1:wL8QJuTMNUDYhXwkmfOly8iTdp5TEcJFW github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5 h1:BvoENQQU+fZ9uukda/RzCAL/191HHwJA5b13R6diVlY= github.com/nfnt/resize v0.0.0-20160724205520-891127d8d1b5/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/oleiade/reflections v1.0.1 h1:D1XO3LVEYroYskEsoSiGItp9RUxG6jWnCVvrqH0HHQM= github.com/oleiade/reflections v1.0.1/go.mod h1:rdFxbxq4QXVZWj0F+e9jqjDkc7dbp97vkRixKo2JR60= @@ -501,8 +511,9 @@ github.com/swaggo/http-swagger v0.0.0-20200308142732-58ac5e232fba h1:lUPlXKqgbqT github.com/swaggo/http-swagger v0.0.0-20200308142732-58ac5e232fba/go.mod h1:O1lAbCgAAX/KZ80LM/OXwtWFI/5TvZlwxSg8Cq08PV0= github.com/swaggo/swag v1.5.1/go.mod h1:1Bl9F/ZBpVWh22nY0zmYyASPO1lI/zIwRDrpZU+tv8Y= github.com/swaggo/swag v1.6.3/go.mod h1:wcc83tB4Mb2aNiL/HP4MFeQdpHUrca+Rp/DRNgWAUio= -github.com/swaggo/swag v1.6.6-0.20200529100950-7c765ddd0476 h1:UjnSXdNPIG+5FJ6xLQODEdk7gSnJlMldu3sPAxxCO+4= github.com/swaggo/swag v1.6.6-0.20200529100950-7c765ddd0476/go.mod h1:xDhTyuFIujYiN3DKWC/H/83xcfHp+UE/IzWWampG7Zc= +github.com/swaggo/swag v1.8.3 h1:3pZSSCQ//gAH88lfmxM3Cd1+JCsxV8Md6f36b9hrZ5s= +github.com/swaggo/swag v1.8.3/go.mod h1:jMLeXOOmYyjk8PvHTsXBdrubsNd9gUJTTCzL5iBnseg= github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965 h1:1oFLiOyVl+W7bnBzGhf7BbIv9loSFQcieWWYIjLqcAw= github.com/syndtr/goleveldb v1.0.1-0.20190318030020-c3a204f8e965/go.mod h1:9OrXJhf154huy1nPWmuSrkgjPUtUNhA+Zmy+6AESzuA= github.com/thoas/go-funk v0.8.0 h1:JP9tKSvnpFVclYgDM0Is7FD9M4fhPvqA0s0BsXmzSRQ= @@ -535,8 +546,9 @@ github.com/unrolled/render v1.0.1 h1:VDDnQQVfBMsOsp3VaCJszSO0nkBIVEYoPWeRThk9spY github.com/unrolled/render v1.0.1/go.mod h1:gN9T0NhL4Bfbwu8ann7Ry/TGHYfosul+J0obPf6NBdM= github.com/urfave/cli v1.20.0 h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw= github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= -github.com/urfave/cli/v2 v2.1.1 h1:Qt8FeAtxE/vfdrLmR3rxR6JRE0RoVmbXu8+6kZtYU4k= github.com/urfave/cli/v2 v2.1.1/go.mod h1:SE9GqnLQmjVa0iPEY0f1w3ygNIYcIJ0OKPMoW2caLfQ= +github.com/urfave/cli/v2 v2.3.0 h1:qph92Y649prgesehzOrQjdWyxFOp/QVM+6imKHad91M= +github.com/urfave/cli/v2 v2.3.0/go.mod h1:LJmUH05zAU44vOAcrfzZQKsZbVcdbOG8rtL3/XcUArI= github.com/urfave/negroni v0.3.0 h1:PaXOb61mWeZJxc1Ji2xJjpVg9QfPo0rrB+lHyBxGNSU= github.com/urfave/negroni v0.3.0/go.mod h1:Meg73S6kFm/4PpbYdq35yYWoCZ9mS/YSx+lKnmiohz4= github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9znI5mJU= @@ -549,6 +561,7 @@ github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1: 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.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= @@ -600,8 +613,9 @@ golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200204104054-c9f3fb736b72/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200323165209-0ec3e9974c59/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 h1:psW17arqaxU48Z5kZ0CQnkZWQJsqcURM6tKiBApRjXI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg= +golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/image v0.0.0-20200119044424-58c23975cae1 h1:5h3ngYt7+vXCDZCup/HkCQgW5XwmSvR/nA2JmJ0RErg= golang.org/x/image v0.0.0-20200119044424-58c23975cae1/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= @@ -615,8 +629,9 @@ golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKG golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= 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.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 h1:kQgndtyPBW/JIYERgdxfwMYh3AVStj88WQTlNDi2a+o= +golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -637,8 +652,12 @@ golang.org/x/net v0.0.0-20191002035440-2ec189313ef0/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200202094626-16171245cfb2/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-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210421230115-4e50805a0758/go.mod h1:72T/g9IO56b78aLF+1Kcs5dz7/ng1VjMUvfKvpfy+jM= +golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA= +golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be h1:vEDujvNQGv4jgYKudGeI/+DAX4Jffq6hpD55MmoEvKs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -677,16 +696,23 @@ golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210217105451-b926d437f341/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210420072515-93ed5bcd2bfe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac h1:oN6lz7iLW/YC7un8pq+9bOLyXrprv2+DKfkJY+2LJJw= golang.org/x/sys v0.0.0-20211007075335-d3039528d8ac/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E= +golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e h1:fLOSk5Q00efkSvAm+4xcoXD+RRmLmmulPn5I3Y9F2EM= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= 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 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20220224211638-0e9765cccd65 h1:M73Iuj3xbbb9Uk1DYhzydthsj6oOd6l9bpuFcNoUvTs= @@ -720,8 +746,9 @@ golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roY golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.0.0-20210112230658-8b4aab62c064/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.10 h1:QjFRCZxdOhBJ/UNgnBZLbNV13DlbnK0quyivTnXJM20= +golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E= golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -748,8 +775,9 @@ google.golang.org/grpc v1.26.0 h1:2dTRdpdFEEhJYQD8EMLB61nnrzSCTbG38PhqdhvOltg= google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/cheggaaa/pb.v1 v1.0.25/go.mod h1:V/YB90LKu/1FcN3WVnfiiE5oMCibMjukxqG/qStrOgw= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= @@ -770,6 +798,7 @@ 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.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gorm.io/driver/mysql v1.0.6 h1:mA0XRPjIKi4bkE9nv+NKs6qj6QWOchqUSdWOcpd3x1E= diff --git a/server/api/admin.go b/server/api/admin.go index 2954874d7fd5..1fa63c8ad9a3 100644 --- a/server/api/admin.go +++ b/server/api/admin.go @@ -38,13 +38,13 @@ func newAdminHandler(svr *server.Server, rd *render.Render) *adminHandler { } } -// @Tags admin -// @Summary Drop a specific region from cache. -// @Param id path integer true "Region Id" -// @Produce json -// @Success 200 {string} string "The region is removed from server cache." -// @Failure 400 {string} string "The input is invalid." -// @Router /admin/cache/region/{id} [delete] +// @Tags admin +// @Summary Drop a specific region from cache. +// @Param id path integer true "Region Id" +// @Produce json +// @Success 200 {string} string "The region is removed from server cache." +// @Failure 400 {string} string "The input is invalid." +// @Router /admin/cache/region/{id} [delete] func (h *adminHandler) DeleteRegionCache(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) vars := mux.Vars(r) @@ -59,16 +59,16 @@ func (h *adminHandler) DeleteRegionCache(w http.ResponseWriter, r *http.Request) } // FIXME: details of input json body params -// @Tags admin -// @Summary Reset the ts. -// @Accept json -// @Param body body object true "json params" -// @Produce json -// @Success 200 {string} string "Reset ts successfully." -// @Failure 400 {string} string "The input is invalid." -// @Failure 403 {string} string "Reset ts is forbidden." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /admin/reset-ts [post] +// @Tags admin +// @Summary Reset the ts. +// @Accept json +// @Param body body object true "json params" +// @Produce json +// @Success 200 {string} string "Reset ts successfully." +// @Failure 400 {string} string "The input is invalid." +// @Failure 403 {string} string "Reset ts is forbidden." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /admin/reset-ts [post] func (h *adminHandler) ResetTS(w http.ResponseWriter, r *http.Request) { handler := h.svr.GetHandler() var input map[string]interface{} diff --git a/server/api/checker.go b/server/api/checker.go index 9a01ad9c83f8..a62cedcf74c0 100644 --- a/server/api/checker.go +++ b/server/api/checker.go @@ -36,16 +36,16 @@ func newCheckerHandler(svr *server.Server, r *render.Render) *checkerHandler { } // FIXME: details of input json body params -// @Tags checker -// @Summary Pause or resume region merge. -// @Accept json -// @Param name path string true "The name of the checker." -// @Param body body object true "json params" -// @Produce json -// @Success 200 {string} string "Pause or resume the scheduler successfully." -// @Failure 400 {string} string "Bad format request." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /checker/{name} [post] +// @Tags checker +// @Summary Pause or resume region merge. +// @Accept json +// @Param name path string true "The name of the checker." +// @Param body body object true "json params" +// @Produce json +// @Success 200 {string} string "Pause or resume the scheduler successfully." +// @Failure 400 {string} string "Bad format request." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /checker/{name} [post] func (c *checkerHandler) PauseOrResumeChecker(w http.ResponseWriter, r *http.Request) { var input map[string]int if err := apiutil.ReadJSONRespondError(c.r, w, r.Body, &input); err != nil { @@ -74,13 +74,13 @@ func (c *checkerHandler) PauseOrResumeChecker(w http.ResponseWriter, r *http.Req } // FIXME: details of input json body params -// @Tags checker -// @Summary Get if checker is paused -// @Param name path string true "The name of the scheduler." -// @Produce json -// @Success 200 {string} string "Pause or resume the scheduler successfully." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /checker/{name} [get] +// @Tags checker +// @Summary Get if checker is paused +// @Param name path string true "The name of the scheduler." +// @Produce json +// @Success 200 {string} string "Pause or resume the scheduler successfully." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /checker/{name} [get] func (c *checkerHandler) GetCheckerStatus(w http.ResponseWriter, r *http.Request) { name := mux.Vars(r)["name"] isPaused, err := c.IsCheckerPaused(name) diff --git a/server/api/cluster.go b/server/api/cluster.go index f7ff6251353f..fcf972d56a7e 100644 --- a/server/api/cluster.go +++ b/server/api/cluster.go @@ -33,21 +33,21 @@ func newClusterHandler(svr *server.Server, rd *render.Render) *clusterHandler { } } -// @Tags cluster -// @Summary Get cluster info. -// @Produce json -// @Success 200 {object} metapb.Cluster -// @Router /cluster [get] +// @Tags cluster +// @Summary Get cluster info. +// @Produce json +// @Success 200 {object} metapb.Cluster +// @Router /cluster [get] func (h *clusterHandler) GetCluster(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, h.svr.GetCluster()) } -// @Tags cluster -// @Summary Get cluster status. -// @Produce json -// @Success 200 {object} cluster.Status -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /cluster/status [get] +// @Tags cluster +// @Summary Get cluster status. +// @Produce json +// @Success 200 {object} cluster.Status +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /cluster/status [get] func (h *clusterHandler) GetClusterStatus(w http.ResponseWriter, r *http.Request) { status, err := h.svr.GetClusterStatus() if err != nil { diff --git a/server/api/config.go b/server/api/config.go index 7ed3a9de56c6..b0d7260b2ed0 100644 --- a/server/api/config.go +++ b/server/api/config.go @@ -48,23 +48,23 @@ func newConfHandler(svr *server.Server, rd *render.Render) *confHandler { } } -// @Tags config -// @Summary Get full config. -// @Produce json -// @Success 200 {object} config.Config -// @Router /config [get] +// @Tags config +// @Summary Get full config. +// @Produce json +// @Success 200 {object} config.Config +// @Router /config [get] func (h *confHandler) GetConfig(w http.ResponseWriter, r *http.Request) { cfg := h.svr.GetConfig() cfg.Schedule.MaxMergeRegionKeys = cfg.Schedule.GetMaxMergeRegionKeys() h.rd.JSON(w, http.StatusOK, cfg) } -// @Tags config -// @Summary Get default config. -// @Produce json -// @Success 200 {object} config.Config -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /config/default [get] +// @Tags config +// @Summary Get default config. +// @Produce json +// @Success 200 {object} config.Config +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /config/default [get] func (h *confHandler) GetDefaultConfig(w http.ResponseWriter, r *http.Request) { config := config.NewConfig() err := config.Adjust(nil, false) @@ -76,16 +76,16 @@ func (h *confHandler) GetDefaultConfig(w http.ResponseWriter, r *http.Request) { } // FIXME: details of input json body params -// @Tags config -// @Summary Update a config item. -// @Accept json -// @Param ttlSecond query integer false "ttl". ttl param is only for BR and lightning now. Don't use it. -// @Param body body object false "json params" -// @Produce json -// @Success 200 {string} string "The config is updated." -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /config [post] +// @Tags config +// @Summary Update a config item. +// @Accept json +// @Param ttlSecond query integer false "ttl". ttl param is only for BR and lightning now. Don't use it. +// @Param body body object false "json params" +// @Produce json +// @Success 200 {string} string "The config is updated." +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /config [post] func (h *confHandler) SetConfig(w http.ResponseWriter, r *http.Request) { cfg := h.svr.GetConfig() data, err := io.ReadAll(r.Body) @@ -272,27 +272,27 @@ func getConfigMap(cfg map[string]interface{}, key []string, value interface{}) m return cfg } -// @Tags config -// @Summary Get schedule config. -// @Produce json -// @Success 200 {object} config.ScheduleConfig -// @Router /config/schedule [get] +// @Tags config +// @Summary Get schedule config. +// @Produce json +// @Success 200 {object} config.ScheduleConfig +// @Router /config/schedule [get] func (h *confHandler) GetScheduleConfig(w http.ResponseWriter, r *http.Request) { cfg := h.svr.GetScheduleConfig() cfg.MaxMergeRegionKeys = cfg.GetMaxMergeRegionKeys() h.rd.JSON(w, http.StatusOK, cfg) } -// @Tags config -// @Summary Update a schedule config item. -// @Accept json -// @Param body body object string "json params" -// @Produce json -// @Success 200 {string} string "The config is updated." -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Failure 503 {string} string "PD server has no leader." -// @Router /config/schedule [post] +// @Tags config +// @Summary Update a schedule config item. +// @Accept json +// @Param body body object string "json params" +// @Produce json +// @Success 200 {string} string "The config is updated." +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Failure 503 {string} string "PD server has no leader." +// @Router /config/schedule [post] func (h *confHandler) SetScheduleConfig(w http.ResponseWriter, r *http.Request) { data, err := io.ReadAll(r.Body) r.Body.Close() @@ -335,25 +335,25 @@ func (h *confHandler) SetScheduleConfig(w http.ResponseWriter, r *http.Request) h.rd.JSON(w, http.StatusOK, "The config is updated.") } -// @Tags config -// @Summary Get replication config. -// @Produce json -// @Success 200 {object} config.ReplicationConfig -// @Router /config/replicate [get] +// @Tags config +// @Summary Get replication config. +// @Produce json +// @Success 200 {object} config.ReplicationConfig +// @Router /config/replicate [get] func (h *confHandler) GetReplicationConfig(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, h.svr.GetReplicationConfig()) } -// @Tags config -// @Summary Update a replication config item. -// @Accept json -// @Param body body object string "json params" -// @Produce json -// @Success 200 {string} string "The config is updated." -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Failure 503 {string} string "PD server has no leader." -// @Router /config/replicate [post] +// @Tags config +// @Summary Update a replication config item. +// @Accept json +// @Param body body object string "json params" +// @Produce json +// @Success 200 {string} string "The config is updated." +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Failure 503 {string} string "PD server has no leader." +// @Router /config/replicate [post] func (h *confHandler) SetReplicationConfig(w http.ResponseWriter, r *http.Request) { config := h.svr.GetReplicationConfig() if err := apiutil.ReadJSONRespondError(h.rd, w, r.Body, &config); err != nil { @@ -367,24 +367,24 @@ func (h *confHandler) SetReplicationConfig(w http.ResponseWriter, r *http.Reques h.rd.JSON(w, http.StatusOK, "The config is updated.") } -// @Tags config -// @Summary Get label property config. -// @Produce json -// @Success 200 {object} config.LabelPropertyConfig -// @Router /config/label-property [get] +// @Tags config +// @Summary Get label property config. +// @Produce json +// @Success 200 {object} config.LabelPropertyConfig +// @Router /config/label-property [get] func (h *confHandler) GetLabelPropertyConfig(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, h.svr.GetLabelProperty()) } -// @Tags config -// @Summary Update label property config item. -// @Accept json -// @Param body body object string "json params" -// @Produce json -// @Success 200 {string} string "The config is updated." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Failure 503 {string} string "PD server has no leader." -// @Router /config/label-property [post] +// @Tags config +// @Summary Update label property config item. +// @Accept json +// @Param body body object string "json params" +// @Produce json +// @Success 200 {string} string "The config is updated." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Failure 503 {string} string "PD server has no leader." +// @Router /config/label-property [post] func (h *confHandler) SetLabelPropertyConfig(w http.ResponseWriter, r *http.Request) { input := make(map[string]string) if err := apiutil.ReadJSONRespondError(h.rd, w, r.Body, &input); err != nil { @@ -407,24 +407,24 @@ func (h *confHandler) SetLabelPropertyConfig(w http.ResponseWriter, r *http.Requ h.rd.JSON(w, http.StatusOK, "The config is updated.") } -// @Tags config -// @Summary Get cluster version. -// @Produce json -// @Success 200 {object} semver.Version -// @Router /config/cluster-version [get] +// @Tags config +// @Summary Get cluster version. +// @Produce json +// @Success 200 {object} semver.Version +// @Router /config/cluster-version [get] func (h *confHandler) GetClusterVersion(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, h.svr.GetClusterVersion()) } -// @Tags config -// @Summary Update cluster version. -// @Accept json -// @Param body body object string "json params" -// @Produce json -// @Success 200 {string} string "The cluster version is updated." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Failure 503 {string} string "PD server has no leader." -// @Router /config/cluster-version [post] +// @Tags config +// @Summary Update cluster version. +// @Accept json +// @Param body body object string "json params" +// @Produce json +// @Success 200 {string} string "The cluster version is updated." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Failure 503 {string} string "PD server has no leader." +// @Router /config/cluster-version [post] func (h *confHandler) SetClusterVersion(w http.ResponseWriter, r *http.Request) { input := make(map[string]string) if err := apiutil.ReadJSONRespondError(h.rd, w, r.Body, &input); err != nil { @@ -444,23 +444,23 @@ func (h *confHandler) SetClusterVersion(w http.ResponseWriter, r *http.Request) h.rd.JSON(w, http.StatusOK, "The cluster version is updated.") } -// @Tags config -// @Summary Get replication mode config. -// @Produce json -// @Success 200 {object} config.ReplicationModeConfig -// @Router /config/replication-mode [get] +// @Tags config +// @Summary Get replication mode config. +// @Produce json +// @Success 200 {object} config.ReplicationModeConfig +// @Router /config/replication-mode [get] func (h *confHandler) GetReplicationModeConfig(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, h.svr.GetReplicationModeConfig()) } -// @Tags config -// @Summary Set replication mode config. -// @Accept json -// @Param body body object string "json params" -// @Produce json -// @Success 200 {string} string "The replication mode config is updated." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /config/replication-mode [post] +// @Tags config +// @Summary Set replication mode config. +// @Accept json +// @Param body body object string "json params" +// @Produce json +// @Success 200 {string} string "The replication mode config is updated." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /config/replication-mode [post] func (h *confHandler) SetReplicationModeConfig(w http.ResponseWriter, r *http.Request) { config := h.svr.GetReplicationModeConfig() if err := apiutil.ReadJSONRespondError(h.rd, w, r.Body, &config); err != nil { @@ -474,11 +474,11 @@ func (h *confHandler) SetReplicationModeConfig(w http.ResponseWriter, r *http.Re h.rd.JSON(w, http.StatusOK, "The replication mode config is updated.") } -// @Tags config -// @Summary Get PD server config. -// @Produce json -// @Success 200 {object} config.PDServerConfig -// @Router /config/pd-server [get] +// @Tags config +// @Summary Get PD server config. +// @Produce json +// @Success 200 {object} config.PDServerConfig +// @Router /config/pd-server [get] func (h *confHandler) GetPDServerConfig(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, h.svr.GetPDServerConfig()) } diff --git a/server/api/health.go b/server/api/health.go index 982a663e9343..fbbc4a3672fa 100644 --- a/server/api/health.go +++ b/server/api/health.go @@ -43,11 +43,11 @@ func newHealthHandler(svr *server.Server, rd *render.Render) *healthHandler { } } -// @Summary Health status of PD servers. -// @Produce json -// @Success 200 {array} Health -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /health [get] +// @Summary Health status of PD servers. +// @Produce json +// @Success 200 {array} Health +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /health [get] func (h *healthHandler) GetHealthStatus(w http.ResponseWriter, r *http.Request) { client := h.svr.GetClient() members, err := cluster.GetMembers(client) @@ -73,6 +73,6 @@ func (h *healthHandler) GetHealthStatus(w http.ResponseWriter, r *http.Request) h.rd.JSON(w, http.StatusOK, healths) } -// @Summary Ping PD servers. -// @Router /ping [get] +// @Summary Ping PD servers. +// @Router /ping [get] func (h *healthHandler) Ping(w http.ResponseWriter, r *http.Request) {} diff --git a/server/api/hot_status.go b/server/api/hot_status.go index cbd537c7ac7f..1b04638a94da 100644 --- a/server/api/hot_status.go +++ b/server/api/hot_status.go @@ -62,11 +62,11 @@ func newHotStatusHandler(handler *server.Handler, rd *render.Render) *hotStatusH } } -// @Tags hotspot -// @Summary List the hot write regions. -// @Produce json -// @Success 200 {object} statistics.StoreHotPeersInfos -// @Router /hotspot/regions/write [get] +// @Tags hotspot +// @Summary List the hot write regions. +// @Produce json +// @Success 200 {object} statistics.StoreHotPeersInfos +// @Router /hotspot/regions/write [get] func (h *hotStatusHandler) GetHotWriteRegions(w http.ResponseWriter, r *http.Request) { storeIDs := r.URL.Query()["store_id"] if len(storeIDs) < 1 { @@ -98,11 +98,11 @@ func (h *hotStatusHandler) GetHotWriteRegions(w http.ResponseWriter, r *http.Req h.rd.JSON(w, http.StatusOK, rc.GetHotWriteRegions(ids...)) } -// @Tags hotspot -// @Summary List the hot read regions. -// @Produce json -// @Success 200 {object} statistics.StoreHotPeersInfos -// @Router /hotspot/regions/read [get] +// @Tags hotspot +// @Summary List the hot read regions. +// @Produce json +// @Success 200 {object} statistics.StoreHotPeersInfos +// @Router /hotspot/regions/read [get] func (h *hotStatusHandler) GetHotReadRegions(w http.ResponseWriter, r *http.Request) { storeIDs := r.URL.Query()["store_id"] if len(storeIDs) < 1 { @@ -134,11 +134,11 @@ func (h *hotStatusHandler) GetHotReadRegions(w http.ResponseWriter, r *http.Requ h.rd.JSON(w, http.StatusOK, rc.GetHotReadRegions(ids...)) } -// @Tags hotspot -// @Summary List the hot stores. -// @Produce json -// @Success 200 {object} HotStoreStats -// @Router /hotspot/stores [get] +// @Tags hotspot +// @Summary List the hot stores. +// @Produce json +// @Success 200 {object} HotStoreStats +// @Router /hotspot/stores [get] func (h *hotStatusHandler) GetHotStores(w http.ResponseWriter, r *http.Request) { stats := HotStoreStats{ BytesWriteStats: make(map[uint64]float64), @@ -169,14 +169,14 @@ func (h *hotStatusHandler) GetHotStores(w http.ResponseWriter, r *http.Request) h.rd.JSON(w, http.StatusOK, stats) } -// @Tags hotspot -// @Summary List the history hot regions. -// @Accept json -// @Produce json -// @Success 200 {object} storage.HistoryHotRegions -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /hotspot/regions/history [get] +// @Tags hotspot +// @Summary List the history hot regions. +// @Accept json +// @Produce json +// @Success 200 {object} storage.HistoryHotRegions +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /hotspot/regions/history [get] func (h *hotStatusHandler) GetHistoryHotRegions(w http.ResponseWriter, r *http.Request) { data, err := io.ReadAll(r.Body) r.Body.Close() diff --git a/server/api/label.go b/server/api/label.go index f9cbc49c8824..abaad02a4e34 100644 --- a/server/api/label.go +++ b/server/api/label.go @@ -37,11 +37,11 @@ func newLabelsHandler(svr *server.Server, rd *render.Render) *labelsHandler { } } -// @Tags label -// @Summary List all label values. -// @Produce json -// @Success 200 {array} metapb.StoreLabel -// @Router /labels [get] +// @Tags label +// @Summary List all label values. +// @Produce json +// @Success 200 {array} metapb.StoreLabel +// @Router /labels [get] func (h *labelsHandler) GetLabels(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) var labels []*metapb.StoreLabel @@ -59,14 +59,14 @@ func (h *labelsHandler) GetLabels(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, labels) } -// @Tags label -// @Summary List stores that have specific label values. -// @Param name query string true "name of store label filter" -// @Param value query string true "value of store label filter" -// @Produce json -// @Success 200 {object} StoresInfo -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /labels/stores [get] +// @Tags label +// @Summary List stores that have specific label values. +// @Param name query string true "name of store label filter" +// @Param value query string true "value of store label filter" +// @Produce json +// @Success 200 {object} StoresInfo +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /labels/stores [get] func (h *labelsHandler) GetStoresByLabel(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) name := r.URL.Query().Get("name") diff --git a/server/api/log.go b/server/api/log.go index 793338aba4c2..ed7a07e52795 100644 --- a/server/api/log.go +++ b/server/api/log.go @@ -37,16 +37,16 @@ func newLogHandler(svr *server.Server, rd *render.Render) *logHandler { } } -// @Tags admin -// @Summary Set log level. -// @Accept json -// @Param level body string true "json params" -// @Produce json -// @Success 200 {string} string "The log level is updated." -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Failure 503 {string} string "PD server has no leader." -// @Router /admin/log [post] +// @Tags admin +// @Summary Set log level. +// @Accept json +// @Param level body string true "json params" +// @Produce json +// @Success 200 {string} string "The log level is updated." +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Failure 503 {string} string "PD server has no leader." +// @Router /admin/log [post] func (h *logHandler) SetLogLevel(w http.ResponseWriter, r *http.Request) { var level string data, err := io.ReadAll(r.Body) diff --git a/server/api/member.go b/server/api/member.go index a6c5b7156f31..eaf743c0493b 100644 --- a/server/api/member.go +++ b/server/api/member.go @@ -45,12 +45,12 @@ func newMemberHandler(svr *server.Server, rd *render.Render) *memberHandler { } } -// @Tags member -// @Summary List all PD servers in the cluster. -// @Produce json -// @Success 200 {object} pdpb.GetMembersResponse -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /members [get] +// @Tags member +// @Summary List all PD servers in the cluster. +// @Produce json +// @Success 200 {object} pdpb.GetMembersResponse +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /members [get] func (h *memberHandler) GetMembers(w http.ResponseWriter, r *http.Request) { members, err := getMembers(h.svr) if err != nil { @@ -107,15 +107,15 @@ func getMembers(svr *server.Server) (*pdpb.GetMembersResponse, error) { return members, nil } -// @Tags member -// @Summary Remove a PD server from the cluster. -// @Param name path string true "PD server name" -// @Produce json -// @Success 200 {string} string "The PD server is successfully removed." -// @Failure 400 {string} string "The input is invalid." -// @Failure 404 {string} string "The member does not exist." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /members/name/{name} [delete] +// @Tags member +// @Summary Remove a PD server from the cluster. +// @Param name path string true "PD server name" +// @Produce json +// @Success 200 {string} string "The PD server is successfully removed." +// @Failure 400 {string} string "The input is invalid." +// @Failure 404 {string} string "The member does not exist." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /members/name/{name} [delete] func (h *memberHandler) DeleteMemberByName(w http.ResponseWriter, r *http.Request) { client := h.svr.GetClient() @@ -161,14 +161,14 @@ func (h *memberHandler) DeleteMemberByName(w http.ResponseWriter, r *http.Reques h.rd.JSON(w, http.StatusOK, fmt.Sprintf("removed, pd: %s", name)) } -// @Tags member -// @Summary Remove a PD server from the cluster. -// @Param id path integer true "PD server Id" -// @Produce json -// @Success 200 {string} string "The PD server is successfully removed." -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /members/id/{id} [delete] +// @Tags member +// @Summary Remove a PD server from the cluster. +// @Param id path integer true "PD server Id" +// @Produce json +// @Success 200 {string} string "The PD server is successfully removed." +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /members/id/{id} [delete] func (h *memberHandler) DeleteMemberByID(w http.ResponseWriter, r *http.Request) { idStr := mux.Vars(r)["id"] id, err := strconv.ParseUint(idStr, 10, 64) @@ -201,17 +201,17 @@ func (h *memberHandler) DeleteMemberByID(w http.ResponseWriter, r *http.Request) } // FIXME: details of input json body params -// @Tags member -// @Summary Set leader priority of a PD member. -// @Accept json -// @Param name path string true "PD server name" -// @Param body body object true "json params" -// @Produce json -// @Success 200 {string} string "The leader priority is updated." -// @Failure 400 {string} string "The input is invalid." -// @Failure 404 {string} string "The member does not exist." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /members/name/{name} [post] +// @Tags member +// @Summary Set leader priority of a PD member. +// @Accept json +// @Param name path string true "PD server name" +// @Param body body object true "json params" +// @Produce json +// @Success 200 {string} string "The leader priority is updated." +// @Failure 400 {string} string "The input is invalid." +// @Failure 404 {string} string "The member does not exist." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /members/name/{name} [post] func (h *memberHandler) SetMemberPropertyByName(w http.ResponseWriter, r *http.Request) { members, membersErr := getMembers(h.svr) if membersErr != nil { @@ -265,21 +265,21 @@ func newLeaderHandler(svr *server.Server, rd *render.Render) *leaderHandler { } } -// @Tags leader -// @Summary Get the leader PD server of the cluster. -// @Produce json -// @Success 200 {object} pdpb.Member -// @Router /leader [get] +// @Tags leader +// @Summary Get the leader PD server of the cluster. +// @Produce json +// @Success 200 {object} pdpb.Member +// @Router /leader [get] func (h *leaderHandler) GetLeader(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, h.svr.GetLeader()) } -// @Tags leader -// @Summary Transfer etcd leadership to another PD server. -// @Produce json -// @Success 200 {string} string "The resign command is submitted." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /leader/resign [post] +// @Tags leader +// @Summary Transfer etcd leadership to another PD server. +// @Produce json +// @Success 200 {string} string "The resign command is submitted." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /leader/resign [post] func (h *leaderHandler) ResignLeader(w http.ResponseWriter, r *http.Request) { err := h.svr.GetMember().ResignEtcdLeader(h.svr.Context(), h.svr.Name(), "") if err != nil { @@ -290,13 +290,13 @@ func (h *leaderHandler) ResignLeader(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, "The resign command is submitted.") } -// @Tags leader -// @Summary Transfer etcd leadership to the specific PD server. -// @Param nextLeader path string true "PD server that transfer leader to" -// @Produce json -// @Success 200 {string} string "The transfer command is submitted." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /leader/transfer/{nextLeader} [post] +// @Tags leader +// @Summary Transfer etcd leadership to the specific PD server. +// @Param nextLeader path string true "PD server that transfer leader to" +// @Produce json +// @Success 200 {string} string "The transfer command is submitted." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /leader/transfer/{nextLeader} [post] func (h *leaderHandler) TransferLeader(w http.ResponseWriter, r *http.Request) { err := h.svr.GetMember().ResignEtcdLeader(h.svr.Context(), h.svr.Name(), mux.Vars(r)["next_leader"]) if err != nil { diff --git a/server/api/min_resolved_ts.go b/server/api/min_resolved_ts.go index c717f0a3b42e..c367aabdd1f3 100644 --- a/server/api/min_resolved_ts.go +++ b/server/api/min_resolved_ts.go @@ -41,12 +41,12 @@ type minResolvedTS struct { PersistInterval typeutil.Duration `json:"persist_interval,omitempty"` } -// @Tags min_resolved_ts -// @Summary Get cluster-level min resolved ts. -// @Produce json -// @Success 200 {array} minResolvedTS -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /min-resolved-ts [get] +// @Tags min_resolved_ts +// @Summary Get cluster-level min resolved ts. +// @Produce json +// @Success 200 {array} minResolvedTS +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /min-resolved-ts [get] func (h *minResolvedTSHandler) GetMinResolvedTS(w http.ResponseWriter, r *http.Request) { c := h.svr.GetRaftCluster() value := c.GetMinResolvedTS() diff --git a/server/api/operator.go b/server/api/operator.go index d41c04f82921..dc0af9f8edae 100644 --- a/server/api/operator.go +++ b/server/api/operator.go @@ -40,14 +40,14 @@ func newOperatorHandler(handler *server.Handler, r *render.Render) *operatorHand } } -// @Tags operator -// @Summary Get a Region's pending operator. -// @Param region_id path int true "A Region's Id" -// @Produce json -// @Success 200 {object} schedule.OperatorWithStatus -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /operators/{region_id} [get] +// @Tags operator +// @Summary Get a Region's pending operator. +// @Param region_id path int true "A Region's Id" +// @Produce json +// @Success 200 {object} schedule.OperatorWithStatus +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /operators/{region_id} [get] func (h *operatorHandler) GetOperatorsByRegion(w http.ResponseWriter, r *http.Request) { id := mux.Vars(r)["region_id"] @@ -66,13 +66,13 @@ func (h *operatorHandler) GetOperatorsByRegion(w http.ResponseWriter, r *http.Re h.r.JSON(w, http.StatusOK, op) } -// @Tags operator -// @Summary List pending operators. -// @Param kind query string false "Specify the operator kind." Enums(admin, leader, region) -// @Produce json -// @Success 200 {array} operator.Operator -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /operators [get] +// @Tags operator +// @Summary List pending operators. +// @Param kind query string false "Specify the operator kind." Enums(admin, leader, region) +// @Produce json +// @Success 200 {array} operator.Operator +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /operators [get] func (h *operatorHandler) GetOperators(w http.ResponseWriter, r *http.Request) { var ( results []*operator.Operator @@ -111,15 +111,15 @@ func (h *operatorHandler) GetOperators(w http.ResponseWriter, r *http.Request) { } // FIXME: details of input json body params -// @Tags operator -// @Summary Create an operator. -// @Accept json -// @Param body body object true "json params" -// @Produce json -// @Success 200 {string} string "The operator is created." -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /operators [post] +// @Tags operator +// @Summary Create an operator. +// @Accept json +// @Param body body object true "json params" +// @Produce json +// @Success 200 {string} string "The operator is created." +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /operators [post] func (h *operatorHandler) CreateOperator(w http.ResponseWriter, r *http.Request) { var input map[string]interface{} if err := apiutil.ReadJSONRespondError(h.r, w, r.Body, &input); err != nil { @@ -320,14 +320,14 @@ func (h *operatorHandler) CreateOperator(w http.ResponseWriter, r *http.Request) h.r.JSON(w, http.StatusOK, "The operator is created.") } -// @Tags operator -// @Summary Cancel a Region's pending operator. -// @Param region_id path int true "A Region's Id" -// @Produce json -// @Success 200 {string} string "The pending operator is canceled." -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /operators/{region_id} [delete] +// @Tags operator +// @Summary Cancel a Region's pending operator. +// @Param region_id path int true "A Region's Id" +// @Produce json +// @Success 200 {string} string "The pending operator is canceled." +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /operators/{region_id} [delete] func (h *operatorHandler) DeleteOperatorByRegion(w http.ResponseWriter, r *http.Request) { id := mux.Vars(r)["region_id"] @@ -345,14 +345,14 @@ func (h *operatorHandler) DeleteOperatorByRegion(w http.ResponseWriter, r *http. h.r.JSON(w, http.StatusOK, "The pending operator is canceled.") } -// @Tags operator -// @Summary lists the finished operators since the given timestamp in second. -// @Param from query integer false "From Unix timestamp" -// @Produce json -// @Success 200 {object} []operator.OpRecord -// @Failure 400 {string} string "The request is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /operators/records [get] +// @Tags operator +// @Summary lists the finished operators since the given timestamp in second. +// @Param from query integer false "From Unix timestamp" +// @Produce json +// @Success 200 {object} []operator.OpRecord +// @Failure 400 {string} string "The request is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /operators/records [get] func (h *operatorHandler) GetOperatorRecords(w http.ResponseWriter, r *http.Request) { var from time.Time if fromStr := r.URL.Query()["from"]; len(fromStr) > 0 { diff --git a/server/api/plugin.go b/server/api/plugin.go index 3e1372ba8f57..16894304e9be 100644 --- a/server/api/plugin.go +++ b/server/api/plugin.go @@ -38,29 +38,29 @@ func newPluginHandler(handler *server.Handler, rd *render.Render) *pluginHandler } // FIXME: details of input json body params -// @Tags plugin -// @Summary Load plugin. -// @Accept json -// @Param body body object true "json params" -// @Produce json -// @Success 200 {string} string "Load plugin success." -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /plugin [post] +// @Tags plugin +// @Summary Load plugin. +// @Accept json +// @Param body body object true "json params" +// @Produce json +// @Success 200 {string} string "Load plugin success." +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /plugin [post] func (h *pluginHandler) LoadPlugin(w http.ResponseWriter, r *http.Request) { h.processPluginCommand(w, r, cluster.PluginLoad) } // FIXME: details of input json body params -// @Tags plugin -// @Summary Unload plugin. -// @Accept json -// @Param body body object true "json params" -// @Produce json -// @Success 200 {string} string "Load/Unload plugin successfully." -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /plugin [delete] +// @Tags plugin +// @Summary Unload plugin. +// @Accept json +// @Param body body object true "json params" +// @Produce json +// @Success 200 {string} string "Load/Unload plugin successfully." +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /plugin [delete] func (h *pluginHandler) UnloadPlugin(w http.ResponseWriter, r *http.Request) { h.processPluginCommand(w, r, cluster.PluginUnload) } diff --git a/server/api/pprof.go b/server/api/pprof.go index 9dd371badb18..0c180dda24ce 100644 --- a/server/api/pprof.go +++ b/server/api/pprof.go @@ -47,10 +47,10 @@ func newPprofHandler(svr *server.Server, rd *render.Render) *pprofHandler { } } -// @Tags debug -// @Summary debug zip of PD servers. -// @Produce application/octet-stream -// @Router /debug/pprof/zip [get] +// @Tags debug +// @Summary debug zip of PD servers. +// @Produce application/octet-stream +// @Router /debug/pprof/zip [get] func (h *pprofHandler) PProfZip(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Disposition", fmt.Sprintf(`attachment; filename="pd_debug"`+time.Now().Format("20060102_150405")+".zip")) @@ -145,65 +145,65 @@ func (h *pprofHandler) PProfZip(w http.ResponseWriter, r *http.Request) { } } -// @Tags debug -// @Summary debug profile of PD servers. -// @Router /debug/pprof/profile [get] +// @Tags debug +// @Summary debug profile of PD servers. +// @Router /debug/pprof/profile [get] func (h *pprofHandler) PProfProfile(w http.ResponseWriter, r *http.Request) { pp.Profile(w, r) } -// @Tags debug -// @Summary debug trace of PD servers. -// @Router /debug/pprof/trace [get] +// @Tags debug +// @Summary debug trace of PD servers. +// @Router /debug/pprof/trace [get] func (h *pprofHandler) PProfTrace(w http.ResponseWriter, r *http.Request) { pp.Trace(w, r) } -// @Tags debug -// @Summary debug symbol of PD servers. -// @Router /debug/pprof/symbol [get] +// @Tags debug +// @Summary debug symbol of PD servers. +// @Router /debug/pprof/symbol [get] func (h *pprofHandler) PProfSymbol(w http.ResponseWriter, r *http.Request) { pp.Symbol(w, r) } -// @Tags debug -// @Summary debug heap of PD servers. -// @Router /debug/pprof/heap [get] +// @Tags debug +// @Summary debug heap of PD servers. +// @Router /debug/pprof/heap [get] func (h *pprofHandler) PProfHeap(w http.ResponseWriter, r *http.Request) { pp.Handler("heap").ServeHTTP(w, r) } -// @Tags debug -// @Summary debug mutex of PD servers. -// @Router /debug/pprof/mutex [get] +// @Tags debug +// @Summary debug mutex of PD servers. +// @Router /debug/pprof/mutex [get] func (h *pprofHandler) PProfMutex(w http.ResponseWriter, r *http.Request) { pp.Handler("mutex").ServeHTTP(w, r) } -// @Tags debug -// @Summary debug allocs of PD servers. -// @Router /debug/pprof/allocs [get] +// @Tags debug +// @Summary debug allocs of PD servers. +// @Router /debug/pprof/allocs [get] func (h *pprofHandler) PProfAllocs(w http.ResponseWriter, r *http.Request) { pp.Handler("allocs").ServeHTTP(w, r) } -// @Tags debug -// @Summary debug block of PD servers. -// @Router /debug/pprof/block [get] +// @Tags debug +// @Summary debug block of PD servers. +// @Router /debug/pprof/block [get] func (h *pprofHandler) PProfBlock(w http.ResponseWriter, r *http.Request) { pp.Handler("block").ServeHTTP(w, r) } -// @Tags debug -// @Summary debug goroutine of PD servers. -// @Router /debug/pprof/goroutine [get] +// @Tags debug +// @Summary debug goroutine of PD servers. +// @Router /debug/pprof/goroutine [get] func (h *pprofHandler) PProfGoroutine(w http.ResponseWriter, r *http.Request) { pp.Handler("goroutine").ServeHTTP(w, r) } -// @Tags debug -// @Summary debug threadcreate of PD servers. -// @Router /debug/pprof/threadcreate [get] +// @Tags debug +// @Summary debug threadcreate of PD servers. +// @Router /debug/pprof/threadcreate [get] func (h *pprofHandler) PProfThreadcreate(w http.ResponseWriter, r *http.Request) { pp.Handler("threadcreate").ServeHTTP(w, r) } diff --git a/server/api/region.go b/server/api/region.go index fa25ca1bd17a..a4ae3fe0df9d 100644 --- a/server/api/region.go +++ b/server/api/region.go @@ -209,13 +209,13 @@ func newRegionHandler(svr *server.Server, rd *render.Render) *regionHandler { } } -// @Tags region -// @Summary Search for a region by region ID. -// @Param id path integer true "Region Id" -// @Produce json -// @Success 200 {object} RegionInfo -// @Failure 400 {string} string "The input is invalid." -// @Router /region/id/{id} [get] +// @Tags region +// @Summary Search for a region by region ID. +// @Param id path integer true "Region Id" +// @Produce json +// @Success 200 {object} RegionInfo +// @Failure 400 {string} string "The input is invalid." +// @Router /region/id/{id} [get] func (h *regionHandler) GetRegionByID(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) @@ -231,12 +231,12 @@ func (h *regionHandler) GetRegionByID(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, NewRegionInfo(regionInfo)) } -// @Tags region -// @Summary Search for a region by a key. GetRegion is named to be consistent with gRPC -// @Param key path string true "Region key" -// @Produce json -// @Success 200 {object} RegionInfo -// @Router /region/key/{key} [get] +// @Tags region +// @Summary Search for a region by a key. GetRegion is named to be consistent with gRPC +// @Param key path string true "Region key" +// @Produce json +// @Success 200 {object} RegionInfo +// @Router /region/key/{key} [get] func (h *regionHandler) GetRegion(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) vars := mux.Vars(r) @@ -250,14 +250,14 @@ func (h *regionHandler) GetRegion(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, NewRegionInfo(regionInfo)) } -// @Tags region -// @Summary Check if regions in the given key ranges are replicated. Returns 'REPLICATED', 'INPROGRESS', or 'PENDING'. 'PENDING' means that there is at least one region pending for scheduling. Similarly, 'INPROGRESS' means there is at least one region in scheduling. -// @Param startKey query string true "Regions start key, hex encoded" -// @Param endKey query string true "Regions end key, hex encoded" -// @Produce plain -// @Success 200 {string} string "INPROGRESS" -// @Failure 400 {string} string "The input is invalid." -// @Router /regions/replicated [get] +// @Tags region +// @Summary Check if regions in the given key ranges are replicated. Returns 'REPLICATED', 'INPROGRESS', or 'PENDING'. 'PENDING' means that there is at least one region pending for scheduling. Similarly, 'INPROGRESS' means there is at least one region in scheduling. +// @Param startKey query string true "Regions start key, hex encoded" +// @Param endKey query string true "Regions end key, hex encoded" +// @Produce plain +// @Success 200 {string} string "INPROGRESS" +// @Failure 400 {string} string "The input is invalid." +// @Router /regions/replicated [get] func (h *regionsHandler) CheckRegionsReplicated(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) @@ -318,11 +318,11 @@ func convertToAPIRegions(regions []*core.RegionInfo) *RegionsInfo { } } -// @Tags region -// @Summary List all regions in the cluster. -// @Produce json -// @Success 200 {object} RegionsInfo -// @Router /regions [get] +// @Tags region +// @Summary List all regions in the cluster. +// @Produce json +// @Success 200 {object} RegionsInfo +// @Router /regions [get] func (h *regionsHandler) GetRegions(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) regions := rc.GetRegions() @@ -330,15 +330,15 @@ func (h *regionsHandler) GetRegions(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, regionsInfo) } -// @Tags region -// @Summary List regions in a given range [startKey, endKey). -// @Param key query string true "Region range start key" -// @Param endkey query string true "Region range end key" -// @Param limit query integer false "Limit count" default(16) -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 400 {string} string "The input is invalid." -// @Router /regions/key [get] +// @Tags region +// @Summary List regions in a given range [startKey, endKey). +// @Param key query string true "Region range start key" +// @Param endkey query string true "Region range end key" +// @Param limit query integer false "Limit count" default(16) +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 400 {string} string "The input is invalid." +// @Router /regions/key [get] func (h *regionsHandler) ScanRegions(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) startKey := r.URL.Query().Get("key") @@ -361,24 +361,24 @@ func (h *regionsHandler) ScanRegions(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, regionsInfo) } -// @Tags region -// @Summary Get count of regions. -// @Produce json -// @Success 200 {object} RegionsInfo -// @Router /regions/count [get] +// @Tags region +// @Summary Get count of regions. +// @Produce json +// @Success 200 {object} RegionsInfo +// @Router /regions/count [get] func (h *regionsHandler) GetRegionCount(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) count := rc.GetRegionCount() h.rd.JSON(w, http.StatusOK, &RegionsInfo{Count: count}) } -// @Tags region -// @Summary List all regions of a specific store. -// @Param id path integer true "Store Id" -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 400 {string} string "The input is invalid." -// @Router /regions/store/{id} [get] +// @Tags region +// @Summary List all regions of a specific store. +// @Param id path integer true "Store Id" +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 400 {string} string "The input is invalid." +// @Router /regions/store/{id} [get] func (h *regionsHandler) GetStoreRegions(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) @@ -393,12 +393,12 @@ func (h *regionsHandler) GetStoreRegions(w http.ResponseWriter, r *http.Request) h.rd.JSON(w, http.StatusOK, regionsInfo) } -// @Tags region -// @Summary List all regions that miss peer. -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /regions/check/miss-peer [get] +// @Tags region +// @Summary List all regions that miss peer. +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /regions/check/miss-peer [get] func (h *regionsHandler) GetMissPeerRegions(w http.ResponseWriter, r *http.Request) { handler := h.svr.GetHandler() regions, err := handler.GetRegionsByType(statistics.MissPeer) @@ -410,12 +410,12 @@ func (h *regionsHandler) GetMissPeerRegions(w http.ResponseWriter, r *http.Reque h.rd.JSON(w, http.StatusOK, regionsInfo) } -// @Tags region -// @Summary List all regions that has extra peer. -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /regions/check/extra-peer [get] +// @Tags region +// @Summary List all regions that has extra peer. +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /regions/check/extra-peer [get] func (h *regionsHandler) GetExtraPeerRegions(w http.ResponseWriter, r *http.Request) { handler := h.svr.GetHandler() regions, err := handler.GetRegionsByType(statistics.ExtraPeer) @@ -427,12 +427,12 @@ func (h *regionsHandler) GetExtraPeerRegions(w http.ResponseWriter, r *http.Requ h.rd.JSON(w, http.StatusOK, regionsInfo) } -// @Tags region -// @Summary List all regions that has pending peer. -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /regions/check/pending-peer [get] +// @Tags region +// @Summary List all regions that has pending peer. +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /regions/check/pending-peer [get] func (h *regionsHandler) GetPendingPeerRegions(w http.ResponseWriter, r *http.Request) { handler := h.svr.GetHandler() regions, err := handler.GetRegionsByType(statistics.PendingPeer) @@ -444,12 +444,12 @@ func (h *regionsHandler) GetPendingPeerRegions(w http.ResponseWriter, r *http.Re h.rd.JSON(w, http.StatusOK, regionsInfo) } -// @Tags region -// @Summary List all regions that has down peer. -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /regions/check/down-peer [get] +// @Tags region +// @Summary List all regions that has down peer. +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /regions/check/down-peer [get] func (h *regionsHandler) GetDownPeerRegions(w http.ResponseWriter, r *http.Request) { handler := h.svr.GetHandler() regions, err := handler.GetRegionsByType(statistics.DownPeer) @@ -461,12 +461,12 @@ func (h *regionsHandler) GetDownPeerRegions(w http.ResponseWriter, r *http.Reque h.rd.JSON(w, http.StatusOK, regionsInfo) } -// @Tags region -// @Summary List all regions that has learner peer. -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /regions/check/learner-peer [get] +// @Tags region +// @Summary List all regions that has learner peer. +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /regions/check/learner-peer [get] func (h *regionsHandler) GetLearnerPeerRegions(w http.ResponseWriter, r *http.Request) { handler := h.svr.GetHandler() regions, err := handler.GetRegionsByType(statistics.LearnerPeer) @@ -478,12 +478,12 @@ func (h *regionsHandler) GetLearnerPeerRegions(w http.ResponseWriter, r *http.Re h.rd.JSON(w, http.StatusOK, regionsInfo) } -// @Tags region -// @Summary List all regions that has offline peer. -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /regions/check/offline-peer [get] +// @Tags region +// @Summary List all regions that has offline peer. +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /regions/check/offline-peer [get] func (h *regionsHandler) GetOfflinePeerRegions(w http.ResponseWriter, r *http.Request) { handler := h.svr.GetHandler() regions, err := handler.GetOfflinePeer(statistics.OfflinePeer) @@ -495,12 +495,12 @@ func (h *regionsHandler) GetOfflinePeerRegions(w http.ResponseWriter, r *http.Re h.rd.JSON(w, http.StatusOK, regionsInfo) } -// @Tags region -// @Summary List all regions that are oversized. -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /regions/check/oversized-region [get] +// @Tags region +// @Summary List all regions that are oversized. +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /regions/check/oversized-region [get] func (h *regionsHandler) GetOverSizedRegions(w http.ResponseWriter, r *http.Request) { handler := h.svr.GetHandler() regions, err := handler.GetRegionsByType(statistics.OversizedRegion) @@ -512,12 +512,12 @@ func (h *regionsHandler) GetOverSizedRegions(w http.ResponseWriter, r *http.Requ h.rd.JSON(w, http.StatusOK, regionsInfo) } -// @Tags region -// @Summary List all regions that are undersized. -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /regions/check/undersized-region [get] +// @Tags region +// @Summary List all regions that are undersized. +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /regions/check/undersized-region [get] func (h *regionsHandler) GetUndersizedRegions(w http.ResponseWriter, r *http.Request) { handler := h.svr.GetHandler() regions, err := handler.GetRegionsByType(statistics.UndersizedRegion) @@ -529,12 +529,12 @@ func (h *regionsHandler) GetUndersizedRegions(w http.ResponseWriter, r *http.Req h.rd.JSON(w, http.StatusOK, regionsInfo) } -// @Tags region -// @Summary List all empty regions. -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /regions/check/empty-region [get] +// @Tags region +// @Summary List all empty regions. +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /regions/check/empty-region [get] func (h *regionsHandler) GetEmptyRegions(w http.ResponseWriter, r *http.Request) { handler := h.svr.GetHandler() regions, err := handler.GetRegionsByType(statistics.EmptyRegion) @@ -566,13 +566,13 @@ func (hist histSlice) Less(i, j int) bool { return hist[i].Start < hist[j].Start } -// @Tags region -// @Summary Get size of histogram. -// @Param bound query integer false "Size bound of region histogram" minimum(1) -// @Produce json -// @Success 200 {array} histItem -// @Failure 400 {string} string "The input is invalid." -// @Router /regions/check/hist-size [get] +// @Tags region +// @Summary Get size of histogram. +// @Param bound query integer false "Size bound of region histogram" minimum(1) +// @Produce json +// @Success 200 {array} histItem +// @Failure 400 {string} string "The input is invalid." +// @Router /regions/check/hist-size [get] func (h *regionsHandler) GetSizeHistogram(w http.ResponseWriter, r *http.Request) { bound := minRegionHistogramSize bound, err := calBound(bound, r) @@ -590,13 +590,13 @@ func (h *regionsHandler) GetSizeHistogram(w http.ResponseWriter, r *http.Request h.rd.JSON(w, http.StatusOK, histItems) } -// @Tags region -// @Summary Get keys of histogram. -// @Param bound query integer false "Key bound of region histogram" minimum(1000) -// @Produce json -// @Success 200 {array} histItem -// @Failure 400 {string} string "The input is invalid." -// @Router /regions/check/hist-keys [get] +// @Tags region +// @Summary Get keys of histogram. +// @Param bound query integer false "Key bound of region histogram" minimum(1000) +// @Produce json +// @Success 200 {array} histItem +// @Failure 400 {string} string "The input is invalid." +// @Router /regions/check/hist-keys [get] func (h *regionsHandler) GetKeysHistogram(w http.ResponseWriter, r *http.Request) { bound := minRegionHistogramKeys bound, err := calBound(bound, r) @@ -649,24 +649,24 @@ func calHist(bound int, list *[]int64) *[]*histItem { return &histItems } -// @Tags region -// @Summary List all range holes whitout any region info. -// @Produce json -// @Success 200 {object} [][]string -// @Router /regions/range-holes [get] +// @Tags region +// @Summary List all range holes whitout any region info. +// @Produce json +// @Success 200 {object} [][]string +// @Router /regions/range-holes [get] func (h *regionsHandler) GetRangeHoles(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) h.rd.JSON(w, http.StatusOK, rc.GetRangeHoles()) } -// @Tags region -// @Summary List sibling regions of a specific region. -// @Param id path integer true "Region Id" -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 400 {string} string "The input is invalid." -// @Failure 404 {string} string "The region does not exist." -// @Router /regions/sibling/{id} [get] +// @Tags region +// @Summary List sibling regions of a specific region. +// @Param id path integer true "Region Id" +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 400 {string} string "The input is invalid." +// @Failure 404 {string} string "The region does not exist." +// @Router /regions/sibling/{id} [get] func (h *regionsHandler) GetRegionSiblings(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) @@ -694,89 +694,89 @@ const ( minRegionHistogramKeys = 1000 ) -// @Tags region -// @Summary List regions with the highest write flow. -// @Param limit query integer false "Limit count" default(16) -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 400 {string} string "The input is invalid." -// @Router /regions/writeflow [get] +// @Tags region +// @Summary List regions with the highest write flow. +// @Param limit query integer false "Limit count" default(16) +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 400 {string} string "The input is invalid." +// @Router /regions/writeflow [get] func (h *regionsHandler) GetTopWriteFlowRegions(w http.ResponseWriter, r *http.Request) { h.GetTopNRegions(w, r, func(a, b *core.RegionInfo) bool { return a.GetBytesWritten() < b.GetBytesWritten() }) } -// @Tags region -// @Summary List regions with the highest read flow. -// @Param limit query integer false "Limit count" default(16) -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 400 {string} string "The input is invalid." -// @Router /regions/readflow [get] +// @Tags region +// @Summary List regions with the highest read flow. +// @Param limit query integer false "Limit count" default(16) +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 400 {string} string "The input is invalid." +// @Router /regions/readflow [get] func (h *regionsHandler) GetTopReadFlowRegions(w http.ResponseWriter, r *http.Request) { h.GetTopNRegions(w, r, func(a, b *core.RegionInfo) bool { return a.GetBytesRead() < b.GetBytesRead() }) } -// @Tags region -// @Summary List regions with the largest conf version. -// @Param limit query integer false "Limit count" default(16) -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 400 {string} string "The input is invalid." -// @Router /regions/confver [get] +// @Tags region +// @Summary List regions with the largest conf version. +// @Param limit query integer false "Limit count" default(16) +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 400 {string} string "The input is invalid." +// @Router /regions/confver [get] func (h *regionsHandler) GetTopConfVerRegions(w http.ResponseWriter, r *http.Request) { h.GetTopNRegions(w, r, func(a, b *core.RegionInfo) bool { return a.GetMeta().GetRegionEpoch().GetConfVer() < b.GetMeta().GetRegionEpoch().GetConfVer() }) } -// @Tags region -// @Summary List regions with the largest version. -// @Param limit query integer false "Limit count" default(16) -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 400 {string} string "The input is invalid." -// @Router /regions/version [get] +// @Tags region +// @Summary List regions with the largest version. +// @Param limit query integer false "Limit count" default(16) +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 400 {string} string "The input is invalid." +// @Router /regions/version [get] func (h *regionsHandler) GetTopVersionRegions(w http.ResponseWriter, r *http.Request) { h.GetTopNRegions(w, r, func(a, b *core.RegionInfo) bool { return a.GetMeta().GetRegionEpoch().GetVersion() < b.GetMeta().GetRegionEpoch().GetVersion() }) } -// @Tags region -// @Summary List regions with the largest size. -// @Param limit query integer false "Limit count" default(16) -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 400 {string} string "The input is invalid." -// @Router /regions/size [get] +// @Tags region +// @Summary List regions with the largest size. +// @Param limit query integer false "Limit count" default(16) +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 400 {string} string "The input is invalid." +// @Router /regions/size [get] func (h *regionsHandler) GetTopSizeRegions(w http.ResponseWriter, r *http.Request) { h.GetTopNRegions(w, r, func(a, b *core.RegionInfo) bool { return a.GetApproximateSize() < b.GetApproximateSize() }) } -// @Tags region -// @Summary List regions with the largest keys. -// @Param limit query integer false "Limit count" default(16) -// @Produce json -// @Success 200 {object} RegionsInfo -// @Failure 400 {string} string "The input is invalid." -// @Router /regions/keys [get] +// @Tags region +// @Summary List regions with the largest keys. +// @Param limit query integer false "Limit count" default(16) +// @Produce json +// @Success 200 {object} RegionsInfo +// @Failure 400 {string} string "The input is invalid." +// @Router /regions/keys [get] func (h *regionsHandler) GetTopKeysRegions(w http.ResponseWriter, r *http.Request) { h.GetTopNRegions(w, r, func(a, b *core.RegionInfo) bool { return a.GetApproximateKeys() < b.GetApproximateKeys() }) } -// @Tags region -// @Summary Accelerate regions scheduling a in given range, only receive hex format for keys -// @Accept json -// @Param body body object true "json params" -// @Param limit query integer false "Limit count" default(256) -// @Produce json -// @Success 200 {string} string "Accelerate regions scheduling in a given range [startKey, endKey)" -// @Failure 400 {string} string "The input is invalid." -// @Router /regions/accelerate-schedule [post] +// @Tags region +// @Summary Accelerate regions scheduling a in given range, only receive hex format for keys +// @Accept json +// @Param body body object true "json params" +// @Param limit query integer false "Limit count" default(256) +// @Produce json +// @Success 200 {string} string "Accelerate regions scheduling in a given range [startKey, endKey)" +// @Failure 400 {string} string "The input is invalid." +// @Router /regions/accelerate-schedule [post] func (h *regionsHandler) AccelerateRegionsScheduleInRange(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) var input map[string]interface{} @@ -838,14 +838,14 @@ func (h *regionsHandler) GetTopNRegions(w http.ResponseWriter, r *http.Request, h.rd.JSON(w, http.StatusOK, regionsInfo) } -// @Tags region -// @Summary Scatter regions by given key ranges or regions id distributed by given group with given retry limit -// @Accept json -// @Param body body object true "json params" -// @Produce json -// @Success 200 {string} string "Scatter regions by given key ranges or regions id distributed by given group with given retry limit" -// @Failure 400 {string} string "The input is invalid." -// @Router /regions/scatter [post] +// @Tags region +// @Summary Scatter regions by given key ranges or regions id distributed by given group with given retry limit +// @Accept json +// @Param body body object true "json params" +// @Produce json +// @Success 200 {string} string "Scatter regions by given key ranges or regions id distributed by given group with given retry limit" +// @Failure 400 {string} string "The input is invalid." +// @Router /regions/scatter [post] func (h *regionsHandler) ScatterRegions(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) var input map[string]interface{} @@ -919,14 +919,14 @@ func (h *regionsHandler) ScatterRegions(w http.ResponseWriter, r *http.Request) h.rd.JSON(w, http.StatusOK, &s) } -// @Tags region -// @Summary Split regions with given split keys -// @Accept json -// @Param body body object true "json params" -// @Produce json -// @Success 200 {string} string "Split regions with given split keys" -// @Failure 400 {string} string "The input is invalid." -// @Router /regions/split [post] +// @Tags region +// @Summary Split regions with given split keys +// @Accept json +// @Param body body object true "json params" +// @Produce json +// @Success 200 {string} string "Split regions with given split keys" +// @Failure 400 {string} string "The input is invalid." +// @Router /regions/split [post] func (h *regionsHandler) SplitRegions(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) var input map[string]interface{} diff --git a/server/api/region_label.go b/server/api/region_label.go index 6eae4206914c..539f4126c1f7 100644 --- a/server/api/region_label.go +++ b/server/api/region_label.go @@ -39,26 +39,26 @@ func newRegionLabelHandler(s *server.Server, rd *render.Render) *regionLabelHand } } -// @Tags region_label -// @Summary List all label rules of cluster. -// @Produce json -// @Success 200 {array} labeler.LabelRule -// @Router /config/region-label/rules [get] +// @Tags region_label +// @Summary List all label rules of cluster. +// @Produce json +// @Success 200 {array} labeler.LabelRule +// @Router /config/region-label/rules [get] func (h *regionLabelHandler) GetAllRegionLabelRules(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) rules := cluster.GetRegionLabeler().GetAllLabelRules() h.rd.JSON(w, http.StatusOK, rules) } -// @Tags region_label -// @Summary Update region label rules in batch. -// @Accept json -// @Param patch body labeler.LabelRulePatch true "Patch to update rules" -// @Produce json -// @Success 200 {string} string "Update region label rules successfully." -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /config/region-label/rules [patch] +// @Tags region_label +// @Summary Update region label rules in batch. +// @Accept json +// @Param patch body labeler.LabelRulePatch true "Patch to update rules" +// @Produce json +// @Success 200 {string} string "Update region label rules successfully." +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /config/region-label/rules [patch] func (h *regionLabelHandler) PatchRegionLabelRules(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) var patch labeler.LabelRulePatch @@ -76,14 +76,14 @@ func (h *regionLabelHandler) PatchRegionLabelRules(w http.ResponseWriter, r *htt h.rd.JSON(w, http.StatusOK, "Update region label rules successfully.") } -// @Tags region_label -// @Summary Get label rules of cluster by ids. -// @Param body body []string true "IDs of query rules" -// @Produce json -// @Success 200 {array} labeler.LabelRule -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /config/region-label/rule/ids [get] +// @Tags region_label +// @Summary Get label rules of cluster by ids. +// @Param body body []string true "IDs of query rules" +// @Produce json +// @Success 200 {array} labeler.LabelRule +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /config/region-label/rule/ids [get] func (h *regionLabelHandler) GetRegionLabelRulesByIDs(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) var ids []string @@ -98,13 +98,13 @@ func (h *regionLabelHandler) GetRegionLabelRulesByIDs(w http.ResponseWriter, r * h.rd.JSON(w, http.StatusOK, rules) } -// @Tags region_label -// @Summary Get label rule of cluster by id. -// @Param id path string true "Rule Id" -// @Produce json -// @Success 200 {object} labeler.LabelRule -// @Failure 404 {string} string "The rule does not exist." -// @Router /config/region-label/rule/{id} [get] +// @Tags region_label +// @Summary Get label rule of cluster by id. +// @Param id path string true "Rule Id" +// @Produce json +// @Success 200 {object} labeler.LabelRule +// @Failure 404 {string} string "The rule does not exist." +// @Router /config/region-label/rule/{id} [get] func (h *regionLabelHandler) GetRegionLabelRuleByID(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) id, err := url.PathUnescape(mux.Vars(r)["id"]) @@ -120,14 +120,14 @@ func (h *regionLabelHandler) GetRegionLabelRuleByID(w http.ResponseWriter, r *ht h.rd.JSON(w, http.StatusOK, rule) } -// @Tags region_label -// @Summary Delete label rule of cluster by id. -// @Param id path string true "Rule Id" -// @Produce json -// @Success 200 {string} string "Delete rule successfully." -// @Failure 404 {string} string "The rule does not exist." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /config/region-label/rule/{id} [delete] +// @Tags region_label +// @Summary Delete label rule of cluster by id. +// @Param id path string true "Rule Id" +// @Produce json +// @Success 200 {string} string "Delete rule successfully." +// @Failure 404 {string} string "The rule does not exist." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /config/region-label/rule/{id} [delete] func (h *regionLabelHandler) DeleteRegionLabelRule(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) id, err := url.PathUnescape(mux.Vars(r)["id"]) @@ -147,15 +147,15 @@ func (h *regionLabelHandler) DeleteRegionLabelRule(w http.ResponseWriter, r *htt h.rd.Text(w, http.StatusOK, "Delete rule successfully.") } -// @Tags region_label -// @Summary Update region label rule of cluster. -// @Accept json -// @Param rule body labeler.LabelRule true "Parameters of label rule" -// @Produce json -// @Success 200 {string} string "Update rule successfully." -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /config/region-label/rule [post] +// @Tags region_label +// @Summary Update region label rule of cluster. +// @Accept json +// @Param rule body labeler.LabelRule true "Parameters of label rule" +// @Produce json +// @Success 200 {string} string "Update rule successfully." +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /config/region-label/rule [post] func (h *regionLabelHandler) SetRegionLabelRule(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) var rule labeler.LabelRule @@ -173,15 +173,15 @@ func (h *regionLabelHandler) SetRegionLabelRule(w http.ResponseWriter, r *http.R h.rd.JSON(w, http.StatusOK, "Update region label rule successfully.") } -// @Tags region_label -// @Summary Get label of a region. -// @Param id path integer true "Region Id" -// @Param key path string true "Label key" -// @Produce json -// @Success 200 {string} string -// @Failure 400 {string} string "The input is invalid." -// @Failure 404 {string} string "The region does not exist." -// @Router /region/id/{id}/label/{key} [get] +// @Tags region_label +// @Summary Get label of a region. +// @Param id path integer true "Region Id" +// @Param key path string true "Label key" +// @Produce json +// @Success 200 {string} string +// @Failure 400 {string} string "The input is invalid." +// @Failure 404 {string} string "The region does not exist." +// @Router /region/id/{id}/label/{key} [get] func (h *regionLabelHandler) GetRegionLabelByKey(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) regionID, labelKey := mux.Vars(r)["id"], mux.Vars(r)["key"] @@ -199,14 +199,14 @@ func (h *regionLabelHandler) GetRegionLabelByKey(w http.ResponseWriter, r *http. h.rd.JSON(w, http.StatusOK, labelValue) } -// @Tags region_label -// @Summary Get labels of a region. -// @Param id path integer true "Region Id" -// @Produce json -// @Success 200 {string} string -// @Failure 400 {string} string "The input is invalid." -// @Failure 404 {string} string "The region does not exist." -// @Router /region/id/{id}/labels [get] +// @Tags region_label +// @Summary Get labels of a region. +// @Param id path integer true "Region Id" +// @Produce json +// @Success 200 {string} string +// @Failure 400 {string} string "The input is invalid." +// @Failure 404 {string} string "The region does not exist." +// @Router /region/id/{id}/labels [get] func (h *regionLabelHandler) GetRegionLabels(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) regionID, err := strconv.ParseUint(mux.Vars(r)["id"], 10, 64) diff --git a/server/api/replication_mode.go b/server/api/replication_mode.go index 9ba7050dc242..4fe2ef5da090 100644 --- a/server/api/replication_mode.go +++ b/server/api/replication_mode.go @@ -33,11 +33,11 @@ func newReplicationModeHandler(svr *server.Server, rd *render.Render) *replicati } } -// @Tags replication_mode -// @Summary Get status of replication mode -// @Produce json -// @Success 200 {object} replication.HTTPReplicationStatus -// @Router /replication_mode/status [get] +// @Tags replication_mode +// @Summary Get status of replication mode +// @Produce json +// @Success 200 {object} replication.HTTPReplicationStatus +// @Router /replication_mode/status [get] func (h *replicationModeHandler) GetReplicationModeStatus(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, getCluster(r).GetReplicationMode().GetReplicationStatusHTTP()) } diff --git a/server/api/router.go b/server/api/router.go index 3e8061fd74e2..155a33845f2d 100644 --- a/server/api/router.go +++ b/server/api/router.go @@ -72,15 +72,15 @@ func getFunctionName(f interface{}) string { } // The returned function is used as a lazy router to avoid the data race problem. -// @title Placement Driver Core API -// @version 1.0 -// @description This is placement driver. -// @contact.name Placement Driver Support -// @contact.url https://github.com/tikv/pd/issues -// @contact.email info@pingcap.com -// @license.name Apache 2.0 -// @license.url http://www.apache.org/licenses/LICENSE-2.0.html -// @BasePath /pd/api/v1 +// @title Placement Driver Core API +// @version 1.0 +// @description This is placement driver. +// @contact.name Placement Driver Support +// @contact.url https://github.com/tikv/pd/issues +// @contact.email info@pingcap.com +// @license.name Apache 2.0 +// @license.url http://www.apache.org/licenses/LICENSE-2.0.html +// @BasePath /pd/api/v1 func createRouter(prefix string, svr *server.Server) *mux.Router { serviceMiddle := newServiceMiddlewareBuilder(svr) registerPrefix := func(router *mux.Router, prefixPath string, diff --git a/server/api/rule.go b/server/api/rule.go index f0eb43128f2c..4148cfcb6688 100644 --- a/server/api/rule.go +++ b/server/api/rule.go @@ -44,12 +44,12 @@ func newRulesHandler(svr *server.Server, rd *render.Render) *ruleHandler { } } -// @Tags rule -// @Summary List all rules of cluster. -// @Produce json -// @Success 200 {array} placement.Rule -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Router /config/rules [get] +// @Tags rule +// @Summary List all rules of cluster. +// @Produce json +// @Success 200 {array} placement.Rule +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Router /config/rules [get] func (h *ruleHandler) GetAllRules(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { @@ -60,15 +60,15 @@ func (h *ruleHandler) GetAllRules(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, rules) } -// @Tags rule -// @Summary Set all rules for the cluster. If there is an error, modifications are promised to be rollback in memory, but may fail to rollback disk. You probably want to request again to make rules in memory/disk consistent. -// @Produce json -// @Param rules body []placement.Rule true "Parameters of rules" -// @Success 200 {string} string "Update rules successfully." -// @Failure 400 {string} string "The input is invalid." -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /config/rules [get] +// @Tags rule +// @Summary Set all rules for the cluster. If there is an error, modifications are promised to be rollback in memory, but may fail to rollback disk. You probably want to request again to make rules in memory/disk consistent. +// @Produce json +// @Param rules body []placement.Rule true "Parameters of rules" +// @Success 200 {string} string "Update rules successfully." +// @Failure 400 {string} string "The input is invalid." +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /config/rules [get] func (h *ruleHandler) SetAllRules(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { @@ -97,13 +97,13 @@ func (h *ruleHandler) SetAllRules(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, "Update rules successfully.") } -// @Tags rule -// @Summary List all rules of cluster by group. -// @Param group path string true "The name of group" -// @Produce json -// @Success 200 {array} placement.Rule -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Router /config/rules/group/{group} [get] +// @Tags rule +// @Summary List all rules of cluster by group. +// @Param group path string true "The name of group" +// @Produce json +// @Success 200 {array} placement.Rule +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Router /config/rules/group/{group} [get] func (h *ruleHandler) GetRuleByGroup(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { @@ -115,15 +115,15 @@ func (h *ruleHandler) GetRuleByGroup(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, rules) } -// @Tags rule -// @Summary List all rules of cluster by region. -// @Param region path string true "The name of region" -// @Produce json -// @Success 200 {array} placement.Rule -// @Failure 400 {string} string "The input is invalid." -// @Failure 404 {string} string "The region does not exist." -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Router /config/rules/region/{region} [get] +// @Tags rule +// @Summary List all rules of cluster by region. +// @Param region path string true "The name of region" +// @Produce json +// @Success 200 {array} placement.Rule +// @Failure 400 {string} string "The input is invalid." +// @Failure 404 {string} string "The region does not exist." +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Router /config/rules/region/{region} [get] func (h *ruleHandler) GetRulesByRegion(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { @@ -145,14 +145,14 @@ func (h *ruleHandler) GetRulesByRegion(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, rules) } -// @Tags rule -// @Summary List all rules of cluster by key. -// @Param key path string true "The name of key" -// @Produce json -// @Success 200 {array} placement.Rule -// @Failure 400 {string} string "The input is invalid." -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Router /config/rules/key/{key} [get] +// @Tags rule +// @Summary List all rules of cluster by key. +// @Param key path string true "The name of key" +// @Produce json +// @Success 200 {array} placement.Rule +// @Failure 400 {string} string "The input is invalid." +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Router /config/rules/key/{key} [get] func (h *ruleHandler) GetRulesByKey(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { @@ -169,15 +169,15 @@ func (h *ruleHandler) GetRulesByKey(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, rules) } -// @Tags rule -// @Summary Get rule of cluster by group and id. -// @Param group path string true "The name of group" -// @Param id path string true "Rule Id" -// @Produce json -// @Success 200 {object} placement.Rule -// @Failure 404 {string} string "The rule does not exist." -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Router /config/rule/{group}/{id} [get] +// @Tags rule +// @Summary Get rule of cluster by group and id. +// @Param group path string true "The name of group" +// @Param id path string true "Rule Id" +// @Produce json +// @Success 200 {object} placement.Rule +// @Failure 404 {string} string "The rule does not exist." +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Router /config/rule/{group}/{id} [get] func (h *ruleHandler) GetRuleByGroupAndID(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { @@ -193,16 +193,16 @@ func (h *ruleHandler) GetRuleByGroupAndID(w http.ResponseWriter, r *http.Request h.rd.JSON(w, http.StatusOK, rule) } -// @Tags rule -// @Summary Update rule of cluster. -// @Accept json -// @Param rule body placement.Rule true "Parameters of rule" -// @Produce json -// @Success 200 {string} string "Update rule successfully." -// @Failure 400 {string} string "The input is invalid." -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /config/rule [post] +// @Tags rule +// @Summary Update rule of cluster. +// @Accept json +// @Param rule body placement.Rule true "Parameters of rule" +// @Produce json +// @Success 200 {string} string "Update rule successfully." +// @Failure 400 {string} string "The input is invalid." +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /config/rule [post] func (h *ruleHandler) SetRule(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { @@ -247,15 +247,15 @@ func (h *ruleHandler) syncReplicateConfigWithDefaultRule(rule *placement.Rule) e return nil } -// @Tags rule -// @Summary Delete rule of cluster. -// @Param group path string true "The name of group" -// @Param id path string true "Rule Id" -// @Produce json -// @Success 200 {string} string "Delete rule successfully." -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /config/rule/{group}/{id} [delete] +// @Tags rule +// @Summary Delete rule of cluster. +// @Param group path string true "The name of group" +// @Param id path string true "Rule Id" +// @Produce json +// @Success 200 {string} string "Delete rule successfully." +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /config/rule/{group}/{id} [delete] func (h *ruleHandler) DeleteRuleByGroup(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { @@ -275,15 +275,15 @@ func (h *ruleHandler) DeleteRuleByGroup(w http.ResponseWriter, r *http.Request) h.rd.JSON(w, http.StatusOK, "Delete rule successfully.") } -// @Tags rule -// @Summary Batch operations for the cluster. Operations should be independent(different ID). If there is an error, modifications are promised to be rollback in memory, but may fail to rollback disk. You probably want to request again to make rules in memory/disk consistent. -// @Produce json -// @Param operations body []placement.RuleOp true "Parameters of rule operations" -// @Success 200 {string} string "Batch operations successfully." -// @Failure 400 {string} string "The input is invalid." -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /config/rules/batch [post] +// @Tags rule +// @Summary Batch operations for the cluster. Operations should be independent(different ID). If there is an error, modifications are promised to be rollback in memory, but may fail to rollback disk. You probably want to request again to make rules in memory/disk consistent. +// @Produce json +// @Param operations body []placement.RuleOp true "Parameters of rule operations" +// @Success 200 {string} string "Batch operations successfully." +// @Failure 400 {string} string "The input is invalid." +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /config/rules/batch [post] func (h *ruleHandler) BatchRules(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { @@ -306,14 +306,14 @@ func (h *ruleHandler) BatchRules(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, "Batch operations successfully.") } -// @Tags rule -// @Summary Get rule group config by group id. -// @Param id path string true "Group Id" -// @Produce json -// @Success 200 {object} placement.RuleGroup -// @Failure 404 {string} string "The RuleGroup does not exist." -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Router /config/rule_group/{id} [get] +// @Tags rule +// @Summary Get rule group config by group id. +// @Param id path string true "Group Id" +// @Produce json +// @Success 200 {object} placement.RuleGroup +// @Failure 404 {string} string "The RuleGroup does not exist." +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Router /config/rule_group/{id} [get] func (h *ruleHandler) GetGroupConfig(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { @@ -329,16 +329,16 @@ func (h *ruleHandler) GetGroupConfig(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, group) } -// @Tags rule -// @Summary Update rule group config. -// @Accept json -// @Param rule body placement.RuleGroup true "Parameters of rule group" -// @Produce json -// @Success 200 {string} string "Update rule group config successfully." -// @Failure 400 {string} string "The input is invalid." -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /config/rule_group [post] +// @Tags rule +// @Summary Update rule group config. +// @Accept json +// @Param rule body placement.RuleGroup true "Parameters of rule group" +// @Produce json +// @Success 200 {string} string "Update rule group config successfully." +// @Failure 400 {string} string "The input is invalid." +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /config/rule_group [post] func (h *ruleHandler) SetGroupConfig(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { @@ -359,14 +359,14 @@ func (h *ruleHandler) SetGroupConfig(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, "Update rule group successfully.") } -// @Tags rule -// @Summary Delete rule group config. -// @Param id path string true "Group Id" -// @Produce json -// @Success 200 {string} string "Delete rule group config successfully." -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /config/rule_group/{id} [delete] +// @Tags rule +// @Summary Delete rule group config. +// @Param id path string true "Group Id" +// @Produce json +// @Success 200 {string} string "Delete rule group config successfully." +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /config/rule_group/{id} [delete] func (h *ruleHandler) DeleteGroupConfig(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { @@ -385,12 +385,12 @@ func (h *ruleHandler) DeleteGroupConfig(w http.ResponseWriter, r *http.Request) h.rd.JSON(w, http.StatusOK, "Delete rule group successfully.") } -// @Tags rule -// @Summary List all rule group configs. -// @Produce json -// @Success 200 {array} placement.RuleGroup -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Router /config/rule_groups [get] +// @Tags rule +// @Summary List all rule group configs. +// @Produce json +// @Success 200 {array} placement.RuleGroup +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Router /config/rule_groups [get] func (h *ruleHandler) GetAllGroupConfigs(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { @@ -401,12 +401,12 @@ func (h *ruleHandler) GetAllGroupConfigs(w http.ResponseWriter, r *http.Request) h.rd.JSON(w, http.StatusOK, ruleGroups) } -// @Tags rule -// @Summary List all rules and groups configuration. -// @Produce json -// @Success 200 {array} placement.GroupBundle -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Router /config/placement-rule [get] +// @Tags rule +// @Summary List all rules and groups configuration. +// @Produce json +// @Success 200 {array} placement.GroupBundle +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Router /config/placement-rule [get] func (h *ruleHandler) GetPlacementRules(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { @@ -417,15 +417,15 @@ func (h *ruleHandler) GetPlacementRules(w http.ResponseWriter, r *http.Request) h.rd.JSON(w, http.StatusOK, bundles) } -// @Tags rule -// @Summary Update all rules and groups configuration. -// @Param partial query bool false "if partially update rules" default(false) -// @Produce json -// @Success 200 {string} string "Update rules and groups successfully." -// @Failure 400 {string} string "The input is invalid." -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /config/placement-rule [post] +// @Tags rule +// @Summary Update all rules and groups configuration. +// @Param partial query bool false "if partially update rules" default(false) +// @Produce json +// @Success 200 {string} string "Update rules and groups successfully." +// @Failure 400 {string} string "The input is invalid." +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /config/placement-rule [post] func (h *ruleHandler) SetPlacementRules(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { @@ -449,13 +449,13 @@ func (h *ruleHandler) SetPlacementRules(w http.ResponseWriter, r *http.Request) h.rd.JSON(w, http.StatusOK, "Update rules and groups successfully.") } -// @Tags rule -// @Summary Get group config and all rules belong to the group. -// @Param group path string true "The name of group" -// @Produce json -// @Success 200 {object} placement.GroupBundle -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Router /config/placement-rule/{group} [get] +// @Tags rule +// @Summary Get group config and all rules belong to the group. +// @Param group path string true "The name of group" +// @Produce json +// @Success 200 {object} placement.GroupBundle +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Router /config/placement-rule/{group} [get] func (h *ruleHandler) GetPlacementRuleByGroup(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { @@ -466,15 +466,15 @@ func (h *ruleHandler) GetPlacementRuleByGroup(w http.ResponseWriter, r *http.Req h.rd.JSON(w, http.StatusOK, group) } -// @Tags rule -// @Summary Get group config and all rules belong to the group. -// @Param group path string true "The name or name pattern of group" -// @Param regexp query bool false "Use regular expression" default(false) -// @Produce plain -// @Success 200 {string} string "Delete group and rules successfully." -// @Failure 400 {string} string "Bad request." -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Router /config/placement-rule [delete] +// @Tags rule +// @Summary Get group config and all rules belong to the group. +// @Param group path string true "The name or name pattern of group" +// @Param regexp query bool false "Use regular expression" default(false) +// @Produce plain +// @Success 200 {string} string "Delete group and rules successfully." +// @Failure 400 {string} string "Bad request." +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Router /config/placement-rule [delete] func (h *ruleHandler) DeletePlacementRuleByGroup(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { @@ -495,14 +495,14 @@ func (h *ruleHandler) DeletePlacementRuleByGroup(w http.ResponseWriter, r *http. h.rd.JSON(w, http.StatusOK, "Delete group and rules successfully.") } -// @Tags rule -// @Summary Update group and all rules belong to it. -// @Produce json -// @Success 200 {string} string "Update group and rules successfully." -// @Failure 400 {string} string "The input is invalid." -// @Failure 412 {string} string "Placement rules feature is disabled." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /config/placement-rule/{group} [post] +// @Tags rule +// @Summary Update group and all rules belong to it. +// @Produce json +// @Success 200 {string} string "Update group and rules successfully." +// @Failure 400 {string} string "The input is invalid." +// @Failure 412 {string} string "Placement rules feature is disabled." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /config/placement-rule/{group} [post] func (h *ruleHandler) SetPlacementRuleByGroup(w http.ResponseWriter, r *http.Request) { cluster := getCluster(r) if !cluster.GetOpts().IsPlacementRulesEnabled() { diff --git a/server/api/scheduler.go b/server/api/scheduler.go index 5faa01c764b7..9b690a932499 100644 --- a/server/api/scheduler.go +++ b/server/api/scheduler.go @@ -51,12 +51,12 @@ type schedulerPausedPeriod struct { ResumeAt time.Time `json:"resume_at"` } -// @Tags scheduler -// @Summary List all created schedulers by status. -// @Produce json -// @Success 200 {array} string -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /schedulers [get] +// @Tags scheduler +// @Summary List all created schedulers by status. +// @Produce json +// @Success 200 {array} string +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /schedulers [get] func (h *schedulerHandler) GetSchedulers(w http.ResponseWriter, r *http.Request) { schedulers, err := h.Handler.GetSchedulers() if err != nil { @@ -128,15 +128,15 @@ func (h *schedulerHandler) GetSchedulers(w http.ResponseWriter, r *http.Request) } // FIXME: details of input json body params -// @Tags scheduler -// @Summary Create a scheduler. -// @Accept json -// @Param body body object true "json params" -// @Produce json -// @Success 200 {string} string "The scheduler is created." -// @Failure 400 {string} string "Bad format request." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /schedulers [post] +// @Tags scheduler +// @Summary Create a scheduler. +// @Accept json +// @Param body body object true "json params" +// @Produce json +// @Success 200 {string} string "The scheduler is created." +// @Failure 400 {string} string "Bad format request." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /schedulers [post] func (h *schedulerHandler) CreateScheduler(w http.ResponseWriter, r *http.Request) { var input map[string]interface{} if err := apiutil.ReadJSONRespondError(h.r, w, r.Body, &input); err != nil { @@ -269,14 +269,14 @@ func (h *schedulerHandler) addEvictOrGrant(w http.ResponseWriter, input map[stri } } -// @Tags scheduler -// @Summary Delete a scheduler. -// @Param name path string true "The name of the scheduler." -// @Produce json -// @Success 200 {string} string "The scheduler is removed." -// @Failure 404 {string} string "The scheduler is not found." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /schedulers/{name} [delete] +// @Tags scheduler +// @Summary Delete a scheduler. +// @Param name path string true "The name of the scheduler." +// @Produce json +// @Success 200 {string} string "The scheduler is removed." +// @Failure 404 {string} string "The scheduler is not found." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /schedulers/{name} [delete] func (h *schedulerHandler) DeleteScheduler(w http.ResponseWriter, r *http.Request) { name := mux.Vars(r)["name"] switch { @@ -316,16 +316,16 @@ func (h *schedulerHandler) redirectSchedulerDelete(w http.ResponseWriter, name, } // FIXME: details of input json body params -// @Tags scheduler -// @Summary Pause or resume a scheduler. -// @Accept json -// @Param name path string true "The name of the scheduler." -// @Param body body object true "json params" -// @Produce json -// @Success 200 {string} string "Pause or resume the scheduler successfully." -// @Failure 400 {string} string "Bad format request." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /schedulers/{name} [post] +// @Tags scheduler +// @Summary Pause or resume a scheduler. +// @Accept json +// @Param name path string true "The name of the scheduler." +// @Param body body object true "json params" +// @Produce json +// @Success 200 {string} string "Pause or resume the scheduler successfully." +// @Failure 400 {string} string "Bad format request." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /schedulers/{name} [post] func (h *schedulerHandler) PauseOrResumeScheduler(w http.ResponseWriter, r *http.Request) { var input map[string]int64 if err := apiutil.ReadJSONRespondError(h.r, w, r.Body, &input); err != nil { diff --git a/server/api/service_gc_safepoint.go b/server/api/service_gc_safepoint.go index 40c3aff1076a..9df3700a30b7 100644 --- a/server/api/service_gc_safepoint.go +++ b/server/api/service_gc_safepoint.go @@ -41,12 +41,12 @@ type listServiceGCSafepoint struct { GCSafePoint uint64 `json:"gc_safe_point"` } -// @Tags service_gc_safepoint -// @Summary Get all service GC safepoint. -// @Produce json -// @Success 200 {array} listServiceGCSafepoint -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /gc/safepoint [get] +// @Tags service_gc_safepoint +// @Summary Get all service GC safepoint. +// @Produce json +// @Success 200 {array} listServiceGCSafepoint +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /gc/safepoint [get] func (h *serviceGCSafepointHandler) GetGCSafePoint(w http.ResponseWriter, r *http.Request) { storage := h.svr.GetStorage() gcSafepoint, err := storage.LoadGCSafePoint() @@ -66,14 +66,14 @@ func (h *serviceGCSafepointHandler) GetGCSafePoint(w http.ResponseWriter, r *htt h.rd.JSON(w, http.StatusOK, list) } -// @Tags service_gc_safepoint -// @Summary Delete a service GC safepoint. -// @Param service_id path string true "Service ID" -// @Produce json -// @Success 200 {string} string "Delete service GC safepoint successfully." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /gc/safepoint/{service_id} [delete] -// @Tags rule +// @Tags service_gc_safepoint +// @Summary Delete a service GC safepoint. +// @Param service_id path string true "Service ID" +// @Produce json +// @Success 200 {string} string "Delete service GC safepoint successfully." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /gc/safepoint/{service_id} [delete] +// @Tags rule func (h *serviceGCSafepointHandler) DeleteGCSafePoint(w http.ResponseWriter, r *http.Request) { storage := h.svr.GetStorage() serviceID := mux.Vars(r)["service_id"] diff --git a/server/api/service_middleware.go b/server/api/service_middleware.go index 426399a1d6e9..c4489e93fa17 100644 --- a/server/api/service_middleware.go +++ b/server/api/service_middleware.go @@ -45,24 +45,24 @@ func newServiceMiddlewareHandler(svr *server.Server, rd *render.Render) *service } } -// @Tags service_middleware -// @Summary Get Service Middleware config. -// @Produce json -// @Success 200 {object} config.Config -// @Router /service-middleware/config [get] +// @Tags service_middleware +// @Summary Get Service Middleware config. +// @Produce json +// @Success 200 {object} config.Config +// @Router /service-middleware/config [get] func (h *serviceMiddlewareHandler) GetServiceMiddlewareConfig(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, h.svr.GetServiceMiddlewareConfig()) } -// @Tags service_middleware -// @Summary Update some service-middleware's config items. -// @Accept json -// @Param body body object false "json params" -// @Produce json -// @Success 200 {string} string "The config is updated." -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /service-middleware/config [post] +// @Tags service_middleware +// @Summary Update some service-middleware's config items. +// @Accept json +// @Param body body object false "json params" +// @Produce json +// @Success 200 {string} string "The config is updated." +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /service-middleware/config [post] func (h *serviceMiddlewareHandler) SetServiceMiddlewareConfig(w http.ResponseWriter, r *http.Request) { cfg := h.svr.GetServiceMiddlewareConfig() data, err := io.ReadAll(r.Body) @@ -131,14 +131,14 @@ func (h *serviceMiddlewareHandler) updateAudit(config *config.ServiceMiddlewareC return err } -// @Tags service_middleware -// @Summary update ratelimit config -// @Param body body object string "json params" -// @Produce json -// @Success 200 {string} string -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "config item not found" -// @Router /service-middleware/config/rate-limit [POST] +// @Tags service_middleware +// @Summary update ratelimit config +// @Param body body object string "json params" +// @Produce json +// @Success 200 {string} string +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "config item not found" +// @Router /service-middleware/config/rate-limit [POST] func (h *serviceMiddlewareHandler) SetRatelimitConfig(w http.ResponseWriter, r *http.Request) { var input map[string]interface{} if err := apiutil.ReadJSONRespondError(h.rd, w, r.Body, &input); err != nil { diff --git a/server/api/stats.go b/server/api/stats.go index d0a14e9a0515..9a5983f43ba7 100644 --- a/server/api/stats.go +++ b/server/api/stats.go @@ -33,13 +33,13 @@ func newStatsHandler(svr *server.Server, rd *render.Render) *statsHandler { } } -// @Tags stats -// @Summary Get region statistics of a specified range. -// @Param start_key query string true "Start key" -// @Param end_key query string true "End key" -// @Produce json -// @Success 200 {object} statistics.RegionStats -// @Router /stats/region [get] +// @Tags stats +// @Summary Get region statistics of a specified range. +// @Param start_key query string true "Start key" +// @Param end_key query string true "End key" +// @Produce json +// @Success 200 {object} statistics.RegionStats +// @Router /stats/region [get] func (h *statsHandler) GetRegionStatus(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) startKey, endKey := r.URL.Query().Get("start_key"), r.URL.Query().Get("end_key") diff --git a/server/api/status.go b/server/api/status.go index 1f318fbb546c..12a25554f462 100644 --- a/server/api/status.go +++ b/server/api/status.go @@ -42,10 +42,10 @@ func newStatusHandler(svr *server.Server, rd *render.Render) *statusHandler { } } -// @Summary Get the build info of PD server. -// @Produce json -// @Success 200 {object} status -// @Router /status [get] +// @Summary Get the build info of PD server. +// @Produce json +// @Success 200 {object} status +// @Router /status [get] func (h *statusHandler) GetPDStatus(w http.ResponseWriter, r *http.Request) { version := status{ BuildTS: versioninfo.PDBuildTS, diff --git a/server/api/store.go b/server/api/store.go index 27aa7b596559..b0ad741aed2c 100644 --- a/server/api/store.go +++ b/server/api/store.go @@ -140,15 +140,15 @@ func newStoreHandler(handler *server.Handler, rd *render.Render) *storeHandler { } } -// @Tags store -// @Summary Get a store's information. -// @Param id path integer true "Store Id" -// @Produce json -// @Success 200 {object} StoreInfo -// @Failure 400 {string} string "The input is invalid." -// @Failure 404 {string} string "The store does not exist." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /store/{id} [get] +// @Tags store +// @Summary Get a store's information. +// @Param id path integer true "Store Id" +// @Produce json +// @Success 200 {object} StoreInfo +// @Failure 400 {string} string "The input is invalid." +// @Failure 404 {string} string "The store does not exist." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /store/{id} [get] func (h *storeHandler) GetStore(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) vars := mux.Vars(r) @@ -168,17 +168,17 @@ func (h *storeHandler) GetStore(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, storeInfo) } -// @Tags store -// @Summary Take down a store from the cluster. -// @Param id path integer true "Store Id" -// @Param force query string true "force" Enums(true, false), when force is true it means the store is physically destroyed and can never up gain -// @Produce json -// @Success 200 {string} string "The store is set as Offline." -// @Failure 400 {string} string "The input is invalid." -// @Failure 404 {string} string "The store does not exist." -// @Failure 410 {string} string "The store has already been removed." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /store/{id} [delete] +// @Tags store +// @Summary Take down a store from the cluster. +// @Param id path integer true "Store Id" +// @Param force query string true "force" Enums(true, false), when force is true it means the store is physically destroyed and can never up gain +// @Produce json +// @Success 200 {string} string "The store is set as Offline." +// @Failure 400 {string} string "The input is invalid." +// @Failure 404 {string} string "The store does not exist." +// @Failure 410 {string} string "The store has already been removed." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /store/{id} [delete] func (h *storeHandler) DeleteStore(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) vars := mux.Vars(r) @@ -199,16 +199,16 @@ func (h *storeHandler) DeleteStore(w http.ResponseWriter, r *http.Request) { h.rd.JSON(w, http.StatusOK, "The store is set as Offline.") } -// @Tags store -// @Summary Set the store's state. -// @Param id path integer true "Store Id" -// @Param state query string true "state" Enums(Up, Offline) -// @Produce json -// @Success 200 {string} string "The store's state is updated." -// @Failure 400 {string} string "The input is invalid." -// @Failure 404 {string} string "The store does not exist." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /store/{id}/state [post] +// @Tags store +// @Summary Set the store's state. +// @Param id path integer true "Store Id" +// @Param state query string true "state" Enums(Up, Offline) +// @Produce json +// @Success 200 {string} string "The store's state is updated." +// @Failure 400 {string} string "The input is invalid." +// @Failure 404 {string} string "The store does not exist." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /store/{id}/state [post] func (h *storeHandler) SetStoreState(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) vars := mux.Vars(r) @@ -252,15 +252,15 @@ func (h *storeHandler) responseStoreErr(w http.ResponseWriter, err error, storeI } // FIXME: details of input json body params -// @Tags store -// @Summary Set the store's label. -// @Param id path integer true "Store Id" -// @Param body body object true "Labels in json format" -// @Produce json -// @Success 200 {string} string "The store's label is updated." -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /store/{id}/label [post] +// @Tags store +// @Summary Set the store's label. +// @Param id path integer true "Store Id" +// @Param body body object true "Labels in json format" +// @Produce json +// @Success 200 {string} string "The store's label is updated." +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /store/{id}/label [post] func (h *storeHandler) SetStoreLabel(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) vars := mux.Vars(r) @@ -298,15 +298,15 @@ func (h *storeHandler) SetStoreLabel(w http.ResponseWriter, r *http.Request) { } // FIXME: details of input json body params -// @Tags store -// @Summary Set the store's leader/region weight. -// @Param id path integer true "Store Id" -// @Param body body object true "json params" -// @Produce json -// @Success 200 {string} string "The store's label is updated." -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /store/{id}/weight [post] +// @Tags store +// @Summary Set the store's leader/region weight. +// @Param id path integer true "Store Id" +// @Param body body object true "json params" +// @Produce json +// @Success 200 {string} string "The store's label is updated." +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /store/{id}/weight [post] func (h *storeHandler) SetStoreWeight(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) vars := mux.Vars(r) @@ -351,16 +351,16 @@ func (h *storeHandler) SetStoreWeight(w http.ResponseWriter, r *http.Request) { } // FIXME: details of input json body params -// @Tags store -// @Summary Set the store's limit. -// @Param ttlSecond query integer false "ttl". ttl param is only for BR and lightning now. Don't use it. -// @Param id path integer true "Store Id" -// @Param body body object true "json params" -// @Produce json -// @Success 200 {string} string "The store's label is updated." -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /store/{id}/limit [post] +// @Tags store +// @Summary Set the store's limit. +// @Param ttlSecond query integer false "ttl". ttl param is only for BR and lightning now. Don't use it. +// @Param id path integer true "Store Id" +// @Param body body object true "json params" +// @Produce json +// @Success 200 {string} string "The store's label is updated." +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /store/{id}/limit [post] func (h *storeHandler) SetStoreLimit(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) vars := mux.Vars(r) @@ -435,12 +435,12 @@ func newStoresHandler(handler *server.Handler, rd *render.Render) *storesHandler } } -// @Tags store -// @Summary Remove tombstone records in the cluster. -// @Produce json -// @Success 200 {string} string "Remove tombstone successfully." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /stores/remove-tombstone [delete] +// @Tags store +// @Summary Remove tombstone records in the cluster. +// @Produce json +// @Success 200 {string} string "Remove tombstone successfully." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /stores/remove-tombstone [delete] func (h *storesHandler) RemoveTombStone(w http.ResponseWriter, r *http.Request) { err := getCluster(r).RemoveTombStoneRecords() if err != nil { @@ -452,16 +452,16 @@ func (h *storesHandler) RemoveTombStone(w http.ResponseWriter, r *http.Request) } // FIXME: details of input json body params -// @Tags store -// @Summary Set limit of all stores in the cluster. -// @Accept json -// @Param ttlSecond query integer false "ttl". ttl param is only for BR and lightning now. Don't use it. -// @Param body body object true "json params" -// @Produce json -// @Success 200 {string} string "Set store limit successfully." -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /stores/limit [post] +// @Tags store +// @Summary Set limit of all stores in the cluster. +// @Accept json +// @Param ttlSecond query integer false "ttl". ttl param is only for BR and lightning now. Don't use it. +// @Param body body object true "json params" +// @Produce json +// @Success 200 {string} string "Set store limit successfully." +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /stores/limit [post] func (h *storesHandler) SetAllStoresLimit(w http.ResponseWriter, r *http.Request) { var input map[string]interface{} if err := apiutil.ReadJSONRespondError(h.rd, w, r.Body, &input); err != nil { @@ -535,13 +535,13 @@ func (h *storesHandler) SetAllStoresLimit(w http.ResponseWriter, r *http.Request } // FIXME: details of output json body -// @Tags store -// @Summary Get limit of all stores in the cluster. -// @Param include_tombstone query bool false "include Tombstone" default(false) -// @Produce json -// @Success 200 {object} string -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /stores/limit [get] +// @Tags store +// @Summary Get limit of all stores in the cluster. +// @Param include_tombstone query bool false "include Tombstone" default(false) +// @Produce json +// @Success 200 {object} string +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /stores/limit [get] func (h *storesHandler) GetAllStoresLimit(w http.ResponseWriter, r *http.Request) { limits := h.GetScheduleConfig().StoreLimit includeTombstone := false @@ -569,15 +569,15 @@ func (h *storesHandler) GetAllStoresLimit(w http.ResponseWriter, r *http.Request h.rd.JSON(w, http.StatusOK, limits) } -// @Tags store -// @Summary Set limit scene in the cluster. -// @Accept json -// @Param body body storelimit.Scene true "Store limit scene" -// @Produce json -// @Success 200 {string} string "Set store limit scene successfully." -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /stores/limit/scene [post] +// @Tags store +// @Summary Set limit scene in the cluster. +// @Accept json +// @Param body body storelimit.Scene true "Store limit scene" +// @Produce json +// @Success 200 {string} string "Set store limit scene successfully." +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /stores/limit/scene [post] func (h *storesHandler) SetStoreLimitScene(w http.ResponseWriter, r *http.Request) { typeName := r.URL.Query().Get("type") typeValue, err := parseStoreLimitType(typeName) @@ -593,11 +593,11 @@ func (h *storesHandler) SetStoreLimitScene(w http.ResponseWriter, r *http.Reques h.rd.JSON(w, http.StatusOK, "Set store limit scene successfully.") } -// @Tags store -// @Summary Get limit scene in the cluster. -// @Produce json -// @Success 200 {string} string "Get store limit scene successfully." -// @Router /stores/limit/scene [get] +// @Tags store +// @Summary Get limit scene in the cluster. +// @Produce json +// @Success 200 {string} string "Get store limit scene successfully." +// @Router /stores/limit/scene [get] func (h *storesHandler) GetStoreLimitScene(w http.ResponseWriter, r *http.Request) { typeName := r.URL.Query().Get("type") typeValue, err := parseStoreLimitType(typeName) @@ -618,13 +618,13 @@ type Progress struct { LeftSeconds float64 `json:"left_seconds"` } -// @Tags stores -// @Summary Get store progress in the cluster. -// @Produce json -// @Success 200 {object} Progress -// @Failure 400 {string} string "The input is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /stores/progress [get] +// @Tags stores +// @Summary Get store progress in the cluster. +// @Produce json +// @Success 200 {object} Progress +// @Failure 400 {string} string "The input is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /stores/progress [get] func (h *storesHandler) GetStoresProgress(w http.ResponseWriter, r *http.Request) { if v := r.URL.Query().Get("id"); v != "" { storeID, err := strconv.ParseUint(v, 10, 64) @@ -668,13 +668,13 @@ func (h *storesHandler) GetStoresProgress(w http.ResponseWriter, r *http.Request h.rd.JSON(w, http.StatusBadRequest, "need query parameters") } -// @Tags store -// @Summary Get stores in the cluster. -// @Param state query array true "Specify accepted store states." -// @Produce json -// @Success 200 {object} StoresInfo -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /stores [get] +// @Tags store +// @Summary Get stores in the cluster. +// @Param state query array true "Specify accepted store states." +// @Produce json +// @Success 200 {object} StoresInfo +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /stores [get] func (h *storesHandler) GetStores(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) stores := rc.GetMetaStores() diff --git a/server/api/trend.go b/server/api/trend.go index 537167705fce..e100b31cbd9a 100644 --- a/server/api/trend.go +++ b/server/api/trend.go @@ -80,14 +80,14 @@ func newTrendHandler(s *server.Server, rd *render.Render) *trendHandler { } } -// @Tags trend -// @Summary Get the growth and changes of data in the most recent period of time. -// @Param from query integer false "From Unix timestamp" -// @Produce json -// @Success 200 {object} Trend -// @Failure 400 {string} string "The request is invalid." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /trend [get] +// @Tags trend +// @Summary Get the growth and changes of data in the most recent period of time. +// @Param from query integer false "From Unix timestamp" +// @Produce json +// @Success 200 {object} Trend +// @Failure 400 {string} string "The request is invalid." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /trend [get] func (h *trendHandler) GetTrend(w http.ResponseWriter, r *http.Request) { var from time.Time if fromStr := r.URL.Query()["from"]; len(fromStr) > 0 { diff --git a/server/api/tso.go b/server/api/tso.go index df7db500899a..cbe30887b734 100644 --- a/server/api/tso.go +++ b/server/api/tso.go @@ -35,17 +35,17 @@ func newTSOHandler(svr *server.Server, rd *render.Render) *tsoHandler { } } -// @Tags tso -// @Summary Transfer Local TSO Allocator -// @Accept json -// @Param name path string true "PD server name" -// @Param body body object true "json params" -// @Produce json -// @Success 200 {string} string "The transfer command is submitted." -// @Failure 400 {string} string "The input is invalid." -// @Failure 404 {string} string "The member does not exist." -// @Failure 500 {string} string "PD server failed to proceed the request." -// @Router /tso/allocator/transfer/{name} [post] +// @Tags tso +// @Summary Transfer Local TSO Allocator +// @Accept json +// @Param name path string true "PD server name" +// @Param body body object true "json params" +// @Produce json +// @Success 200 {string} string "The transfer command is submitted." +// @Failure 400 {string} string "The input is invalid." +// @Failure 404 {string} string "The member does not exist." +// @Failure 500 {string} string "PD server failed to proceed the request." +// @Router /tso/allocator/transfer/{name} [post] func (h *tsoHandler) TransferLocalTSOAllocator(w http.ResponseWriter, r *http.Request) { members, membersErr := getMembers(h.svr) if membersErr != nil { diff --git a/server/api/unsafe_operation.go b/server/api/unsafe_operation.go index 83912c120a00..c45771619b0f 100644 --- a/server/api/unsafe_operation.go +++ b/server/api/unsafe_operation.go @@ -35,15 +35,15 @@ func newUnsafeOperationHandler(svr *server.Server, rd *render.Render) *unsafeOpe } } -// @Tags unsafe -// @Summary Remove failed stores unsafely. -// @Accept json -// @Param body body object true "json params" -// @Produce json +// @Tags unsafe +// @Summary Remove failed stores unsafely. +// @Accept json +// @Param body body object true "json params" +// @Produce json // Success 200 {string} string "Request has been accepted." // Failure 400 {string} string "The input is invalid." // Failure 500 {string} string "PD server failed to proceed the request." -// @Router /admin/unsafe/remove-failed-stores [POST] +// @Router /admin/unsafe/remove-failed-stores [POST] func (h *unsafeOperationHandler) RemoveFailedStores(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) var input map[string]interface{} @@ -72,11 +72,11 @@ func (h *unsafeOperationHandler) RemoveFailedStores(w http.ResponseWriter, r *ht h.rd.JSON(w, http.StatusOK, "Request has been accepted.") } -// @Tags unsafe -// @Summary Show the current status of failed stores removal. -// @Produce json +// @Tags unsafe +// @Summary Show the current status of failed stores removal. +// @Produce json // Success 200 {object} []StageOutput -// @Router /admin/unsafe/remove-failed-stores/show [GET] +// @Router /admin/unsafe/remove-failed-stores/show [GET] func (h *unsafeOperationHandler) GetFailedStoresRemovalStatus(w http.ResponseWriter, r *http.Request) { rc := getCluster(r) h.rd.JSON(w, http.StatusOK, rc.GetUnsafeRecoveryController().Show()) diff --git a/server/api/version.go b/server/api/version.go index 2a1d7e36fbda..38e5a12d8c28 100644 --- a/server/api/version.go +++ b/server/api/version.go @@ -39,10 +39,10 @@ func newVersionHandler(rd *render.Render) *versionHandler { } } -// @Summary Get the version of PD server. -// @Produce json -// @Success 200 {object} version -// @Router /version [get] +// @Summary Get the version of PD server. +// @Produce json +// @Success 200 {object} version +// @Router /version [get] func (h *versionHandler) GetVersion(w http.ResponseWriter, r *http.Request) { version := &version{ Version: versioninfo.PDReleaseVersion,