diff --git a/.gitignore b/.gitignore index 3362f51..fdd108b 100644 --- a/.gitignore +++ b/.gitignore @@ -20,4 +20,4 @@ vendor/ # IDEs directories .idea -.vscode +.vscode \ No newline at end of file diff --git a/go.mod b/go.mod index 9267ce4..5618511 100644 --- a/go.mod +++ b/go.mod @@ -4,44 +4,36 @@ go 1.17 require ( github.com/caarlos0/env/v6 v6.9.1 + github.com/dgrijalva/jwt-go v3.2.0+incompatible github.com/go-chi/chi/v5 v5.0.7 github.com/go-resty/resty/v2 v2.7.0 github.com/google/uuid v1.3.0 + github.com/gostaticanalysis/sqlrows v0.0.0-20200307153552-ea5697937269 + github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa github.com/lib/pq v1.10.6 + github.com/reillywatson/lintservemux v0.0.0-20191102120836-0e75fcfb6a46 github.com/stretchr/testify v1.8.0 golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 + golang.org/x/tools v0.1.12 + google.golang.org/grpc v1.49.0 + google.golang.org/protobuf v1.27.1 + honnef.co/go/tools v0.3.3 ) require ( github.com/davecgh/go-spew v1.1.1 // indirect - github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect - github.com/go-critic/go-critic v0.6.4 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/go-cmp v0.5.8 // indirect github.com/gostaticanalysis/analysisutil v0.7.1 // indirect github.com/gostaticanalysis/comment v1.4.2 // indirect - github.com/gostaticanalysis/sqlrows v0.0.0-20200307153552-ea5697937269 // indirect - github.com/jackc/chunkreader/v2 v2.0.1 // indirect - github.com/jackc/pgconn v1.13.0 // indirect - github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa // indirect - github.com/jackc/pgio v1.0.0 // indirect - github.com/jackc/pgpassfile v1.0.0 // indirect - github.com/jackc/pgproto3/v2 v2.3.1 // indirect - github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect - github.com/jackc/pgtype v1.12.0 // indirect - github.com/jackc/pgx/v4 v4.17.0 // indirect - github.com/jgautheron/goconst v1.5.1 // indirect github.com/kr/pretty v0.1.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect - github.com/quasilyte/go-ruleguard/dsl v0.3.21 // indirect - github.com/reillywatson/lintservemux v0.0.0-20191102120836-0e75fcfb6a46 // indirect - github.com/stretchr/objx v0.4.0 // indirect - golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171 // indirect golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect golang.org/x/net v0.0.0-20220722155237-a158d28d115b // indirect golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 // indirect golang.org/x/text v0.3.7 // indirect - golang.org/x/tools v0.1.12 // indirect + google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 // indirect gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - honnef.co/go/tools v0.3.3 // indirect ) diff --git a/go.sum b/go.sum index 7aa4073..61e2f28 100644 --- a/go.sum +++ b/go.sum @@ -1,46 +1,66 @@ +cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= +cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs= +github.com/BurntSushi/toml v0.4.1 h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw= +github.com/BurntSushi/toml v0.4.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/caarlos0/env/v6 v6.9.1 h1:zOkkjM0F6ltnQ5eBX6IPI41UP/KDGEK7rRPwGCNos8k= github.com/caarlos0/env/v6 v6.9.1/go.mod h1:hvp/ryKXKipEkcuYjs9mI4bBCg+UI0Yhgm5Zu0ddvwc= -github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ= -github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= -github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= -github.com/cristalhq/acmd v0.7.0/go.mod h1:LG5oa43pE/BbxtfMoImHCQN++0Su7dzipdgBjMCBVDQ= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= +github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= +github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= +github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/go-chi/chi/v5 v5.0.7 h1:rDTPXLDHGATaeHvVlLcR4Qe0zftYethFucbjVQ1PxU8= github.com/go-chi/chi/v5 v5.0.7/go.mod h1:DslCQbL2OYiznFReuXYUmQ2hGd1aDpCnlMNITLSKoi8= -github.com/go-critic/go-critic v0.6.4 h1:tucuG1pvOyYgpBIrVxw0R6gwO42lNa92Aq3VaDoIs+E= -github.com/go-critic/go-critic v0.6.4/go.mod h1:qL5SOlk7NtY6sJPoVCTKDIgzNOxHkkkOCVDyi9wJe1U= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-resty/resty/v2 v2.7.0 h1:me+K9p3uhSmXtrBZ4k9jcEAfJmuC8IivWHwaLZwPrFY= github.com/go-resty/resty/v2 v2.7.0/go.mod h1:9PWDzw47qPphMRFfhsyk0NnSgvluHcljSMVIq3w7q0I= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-toolsmith/astcast v1.0.0/go.mod h1:mt2OdQTeAQcY4DQgPSArJjHCcOwlX+Wl/kwN+LbLGQ4= -github.com/go-toolsmith/astcopy v1.0.0/go.mod h1:vrgyG+5Bxrnz4MZWPF+pI4R8h3qKRjjyvV/DSez4WVQ= -github.com/go-toolsmith/astcopy v1.0.1/go.mod h1:4TcEdbElGc9twQEYpVo/aieIXfHhiuLh4aLAck6dO7Y= -github.com/go-toolsmith/astequal v1.0.0/go.mod h1:H+xSiq0+LtiDC11+h1G32h7Of5O3CYFJ99GVbS5lDKY= -github.com/go-toolsmith/astequal v1.0.1/go.mod h1:4oGA3EZXTVItV/ipGiOx7NWkY5veFfcsOJVS2YxltLw= -github.com/go-toolsmith/astequal v1.0.2/go.mod h1:9Ai4UglvtR+4up+bAD4+hCj7iTo4m/OXVTSLnCyTAx4= -github.com/go-toolsmith/astfmt v1.0.0/go.mod h1:cnWmsOAuq4jJY6Ct5YWlVLmcmLMn1JUPuQIHCY7CJDw= -github.com/go-toolsmith/astp v1.0.0/go.mod h1:RSyrtpVlfTFGDYRbrjyWP1pYu//tSFcvdYrA8meBmLI= -github.com/go-toolsmith/pkgload v1.0.2-0.20220101231613-e814995d17c5/go.mod h1:3NAwwmD4uY/yggRxoEjk/S00MIV3A+H7rrE3i87eYxM= -github.com/go-toolsmith/strparse v1.0.0/go.mod h1:YI2nUKP9YGZnL/L1/DLFBfixrcjslWct4wyljWhSRy8= -github.com/go-toolsmith/typep v1.0.2/go.mod h1:JSQCQMUPdRlMZFswiq3TGpNp1GMktqkR2Ns5AIQkATU= -github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/gostaticanalysis/analysisutil v0.0.0-20190329151158-56bca42c7635 h1:I/ckdXlVHde3unRCAcN/Tcpu7LFwgvyHqnFTeklC9oA= github.com/gostaticanalysis/analysisutil v0.0.0-20190329151158-56bca42c7635/go.mod h1:eEOZF4jCKGi+aprrirO9e7WKB3beBRtWgqGunKl6pKE= github.com/gostaticanalysis/analysisutil v0.7.1 h1:ZMCjoue3DtDWQ5WyU16YbjbQEQ3VuzwxALrpYd+HeKk= github.com/gostaticanalysis/analysisutil v0.7.1/go.mod h1:v21E3hY37WKMGSnbsw2S/ojApNWb6C1//mXO48CXbVc= @@ -48,255 +68,164 @@ github.com/gostaticanalysis/comment v1.4.2 h1:hlnx5+S2fY9Zo9ePo4AhgYsYHbM2+eAv8m github.com/gostaticanalysis/comment v1.4.2/go.mod h1:KLUTGDv6HOCotCH8h2erHKmpci2ZoR8VPu34YA2uzdM= github.com/gostaticanalysis/sqlrows v0.0.0-20200307153552-ea5697937269 h1:3Oz+PvsnTtbK3Q0Rk5mZtEwrFF6UzwQj/DR+l917E90= github.com/gostaticanalysis/sqlrows v0.0.0-20200307153552-ea5697937269/go.mod h1:e1pmG/kyEnqo7xy7ZgrKgfMnqR07yFpDsvB/fMWnNq8= +github.com/gostaticanalysis/testutil v0.3.1-0.20210208050101-bfb5c8eec0e4 h1:d2/eIbH9XjD1fFwD5SHv8x168fjbQ9PB8hvs8DSEC08= github.com/gostaticanalysis/testutil v0.3.1-0.20210208050101-bfb5c8eec0e4/go.mod h1:D+FIZ+7OahH3ePw/izIEeH5I06eKs1IKI4Xr64/Am3M= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI= github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/jackc/chunkreader v1.0.0 h1:4s39bBR8ByfqH+DKm8rQA3E1LHZWB9XWcrz8fqaZbe0= -github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo= -github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= -github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8= -github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk= -github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA= -github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE= -github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s= -github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o= -github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY= -github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI= -github.com/jackc/pgconn v1.13.0 h1:3L1XMNV2Zvca/8BYhzcRFS70Lr0WlDg16Di6SFGAbys= -github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI= github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa h1:s+4MhCQ6YrzisK6hFJUX53drDT4UsSW3DEhKn0ifuHw= github.com/jackc/pgerrcode v0.0.0-20220416144525-469b46aa5efa/go.mod h1:a/s9Lp5W7n/DD0VrVoyJ00FbP2ytTPDVOivvn2bMlds= -github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE= -github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8= -github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE= -github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c= -github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak= -github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM= -github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg= -github.com/jackc/pgproto3 v1.1.0 h1:FYYE4yRw+AgI8wXIinMlNjBbp/UitDJwfj5LqqewP1A= -github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78= -github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA= -github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg= -github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= -github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM= -github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgproto3/v2 v2.3.1 h1:nwj7qwf0S+Q7ISFfBndqeLwSwxs+4DPsbRFjECT1Y4Y= -github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA= -github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg= -github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E= -github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg= -github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc= -github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw= -github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM= -github.com/jackc/pgtype v1.12.0 h1:Dlq8Qvcch7kiehm8wPGIW0W3KsCCHJnRacKW0UM8n5w= -github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4= -github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y= -github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM= -github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc= -github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs= -github.com/jackc/pgx/v4 v4.17.0 h1:Hsx+baY8/zU2WtPLQyZi8WbecgcsWEeyoK1jvg/WgIo= -github.com/jackc/pgx/v4 v4.17.0/go.mod h1:Gd6RmOhtFLTu8cp/Fhq4kP195KrshxYJH3oW8AWJ1pw= -github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jackc/puddle v1.2.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk= -github.com/jgautheron/goconst v1.5.1 h1:HxVbL1MhydKs8R8n/HE5NPvzfaYmQJA3o879lE4+WcM= -github.com/jgautheron/goconst v1.5.1/go.mod h1:aAosetZ5zaeC/2EfMeRswtxUFBpe2Hr7HzkgX4fanO4= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= 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.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/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/lib/pq v1.10.6 h1:jbk+ZieJ0D7EVGJYpL9QTz7/YW6UHbmdnZWYyK5cdBs= github.com/lib/pq v1.10.6/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ= -github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/otiai10/copy v1.2.0 h1:HvG945u96iNadPoG2/Ja2+AUJeW5YuFQMixq9yirC+k= github.com/otiai10/copy v1.2.0/go.mod h1:rrF5dJ5F0t/EWSYODDu4j9/vEeYHMkc8jt0zJChqQWw= github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE= github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs= github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo= github.com/otiai10/mint v1.3.1/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/quasilyte/go-ruleguard v0.3.1-0.20210203134552-1b5a410e1cc8/go.mod h1:KsAh3x0e7Fkpgs+Q9pNLS5XpFSvYCEVl5gP9Pp1xp30= -github.com/quasilyte/go-ruleguard v0.3.17 h1:cDdoaSbQg11LXPDQqiCK54QmQXsEQQCTIgdcpeULGSI= -github.com/quasilyte/go-ruleguard v0.3.17/go.mod h1:sST5PvaR7yb/Az5ksX8oc88usJ4EGjmJv7cK7y3jyig= -github.com/quasilyte/go-ruleguard/dsl v0.3.0/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= -github.com/quasilyte/go-ruleguard/dsl v0.3.21 h1:vNkC6fC6qMLzCOGbnIHOd5ixUGgTbp3Z4fGnUgULlDA= -github.com/quasilyte/go-ruleguard/dsl v0.3.21/go.mod h1:KeCP03KrjuSO0H1kTuZQCWlQPulDV6YMIXmpQss17rU= -github.com/quasilyte/go-ruleguard/rules v0.0.0-20201231183845-9e62ed36efe1/go.mod h1:7JTjp89EGyU1d6XfBiXihJNG37wB2VRkd125Q1u7Plc= -github.com/quasilyte/go-ruleguard/rules v0.0.0-20211022131956-028d6511ab71/go.mod h1:4cgAphtvu7Ftv7vOT2ZOYhC6CvBxZixcasr8qIOTA50= -github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5/go.mod h1:wSEyW6O61xRV6zb6My3HxrQ5/8ke7NE2OayqCHa3xRM= -github.com/quasilyte/regex/syntax v0.0.0-20200407221936-30656e2c4a95/go.mod h1:rlzQ04UMyJXu/aOvhd8qT+hvDrFpiwqp8MRXDY9szc0= -github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567/go.mod h1:DWNGW8A4Y+GyBgPuaQJuWiy0XYftx4Xm/y5Jqk9I6VQ= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/reillywatson/lintservemux v0.0.0-20191102120836-0e75fcfb6a46 h1:TK/do6eJkhRJMXb/BlMZdHekYBLSp+PuUNERL1aQdyo= github.com/reillywatson/lintservemux v0.0.0-20191102120836-0e75fcfb6a46/go.mod h1:Vaf6lmtrzJ4wxip9P7e715bscBmBG7W3Cb/XEkUF4AY= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= -github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU= -github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc= -github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= -github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= -github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= -github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE= -github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/tenntenn/modver v1.0.1 h1:2klLppGhDgzJrScMpkj9Ujy3rXPUspSjAcev9tSEBgA= github.com/tenntenn/modver v1.0.1/go.mod h1:bePIyQPb7UeioSRkw3Q0XeMhYZSMx9B8ePqg6SAMGH0= +github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3 h1:f+jULpRQGxTSkNYKJ51yaw6ChIqO+Je8UqsTKN/cDag= github.com/tenntenn/text/transform v0.0.0-20200319021203-7eef512accb3/go.mod h1:ON8b8w4BN/kE1EOhwT0o+d62W65a6aPw1nouo9LMgyY= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q= -go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= -go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= -go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= -go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= -go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU= -go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA= -go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= -go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa h1:zuSxTR4o9y82ebqCUJYNGJbGPo6sKVl54f/TVDObg1c= -golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= -golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e h1:qyrTQ++p1afMkO4DPEeLGq/3oTsdlvdH4vqZUBWzUKM= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4 h1:c2HOrn5iMezYjSlGPncknSEr/8x5LELb/ilJbXi9DEA= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp/typeparams v0.0.0-20220218215828-6cf2b201936e/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171 h1:DZhP7zSquENyG3Yb6ZpGqNEtgE8dfXhcLcheIF9RQHY= golang.org/x/exp/typeparams v0.0.0-20220428152302-39d4317da171/go.mod h1:AbB0pIl9nAr9wVwH+Z2ZpaocVmF5I4GyWCDIsVjR0bk= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.5.1/go.mod h1:5OXOZSfqPIIbmVBIIKWRFfZjPR0E5r58TLhUjH0a2Ro= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s= golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= +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-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211029224645-99673261e6eb h1:pirldcYWx7rx7kE5r+9WsOXPXK0+WH5+uZ7uPmJ44uM= golang.org/x/net v0.0.0-20211029224645-99673261e6eb/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b h1:PxfKdU9lEEDYjdIzOtC4qFWgkU2rGHdKlKowJSMN9h0= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/sync v0.0.0-20190423024810-112230192c58 h1:8gQV6CLnAEikrhgkHFbMAEhagSSnXWGV915qUMm9mrU= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f h1:v4INt8xihDGvnrfjMDVXGxw9wrfxYyCjk0KbXjhR55s= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220818161305-2296e01440c6 h1:Sx/u41w+OwrInGdEckYmEuU5gHoGSL4QbDz3S9s6j4U= golang.org/x/sys v0.0.0-20220818161305-2296e01440c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/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/tools v0.0.0-20180917221912-90fa682c2a6e h1:FDhOuMEY4JVRztM/gsbk+IKUQ8kj74bxZrgw87eMMVc= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190311215038-5c2858a9cfe5/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20190401205534-4c644d7e323d/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= golang.org/x/tools v0.0.0-20190719005602-e377ae9d6386/go.mod h1:jcCCGcm9btYwXyDqrUWc6MKQKKGJCWEQ3AfLSRIbEuI= -golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200812195022-5ae4c3c160a0/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20201230224404-63754364767c/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.1-0.20210205202024-ef80cdb6ec6d/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU= golang.org/x/tools v0.1.1-0.20210302220138-2ac05c832e1a/go.mod h1:9bzcO0MWcOuT0tm1iBGzDVPshzfwoVvREIui8C+MHqU= -golang.org/x/tools v0.1.9-0.20211228192929-ee1ca4ffc4da/go.mod h1:nABZi5QlRsZVlzPpHl034qft6wpY4eDcsTt5AaioBiU= +golang.org/x/tools v0.1.11-0.20220513221640-090b14e8501f/go.mod h1:SgwaegtQh8clINPpECJMqnxLv9I09HLqnW3RMqW0CA4= golang.org/x/tools v0.1.12 h1:VveCTK38A2rkS8ZqFY25HIDFscX5X9OoEhJd3quQmXU= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -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= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013 h1:+kGHl1aib/qcwaRi1CbqBZ1rk19r85MNUf8HaBghugY= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.49.0 h1:WTLtQzmQori5FUH25Pq4WT22oCsv8USpQ+F6rqtsmxw= +google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1 h1:SnqbnDw1V7RiZcXPx5MEeqPv2s79L9i7BJUlG/+RurQ= +google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= 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/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/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= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.3.3 h1:oDx7VAwstgpYpb3wv0oxiZlxY+foCpRAwY7Vk6XpAgA= honnef.co/go/tools v0.3.3/go.mod h1:jzwdWgg7Jdq75wlfblQxO4neNaFFSvgc1tD5Wv8U0Yw= diff --git a/internal/app/app.go b/internal/app/app.go index 98b8d16..42d3873 100644 --- a/internal/app/app.go +++ b/internal/app/app.go @@ -10,6 +10,7 @@ import ( "github.com/zhel1/yandex-practicum-go/internal/storage/inmemory" "github.com/zhel1/yandex-practicum-go/internal/storage/inpsql" "log" + "net" nethttp "net/http" "os" "os/signal" @@ -50,28 +51,42 @@ func Run() { log.Fatal(err) } + var ipnet *net.IPNet = nil + if cfg.TrustedSubnet != "" { + _, ipnet, err = net.ParseCIDR(cfg.TrustedSubnet) + if err != nil { + log.Fatal(err) + } + } + deps := service.Deps{ - Storage: strg, - BaseURL: cfg.BaseURL, - TokenManager: tokenManager, + Storage: strg, + BaseURL: cfg.BaseURL, + TokenManager: tokenManager, + TrustedSubnet: ipnet, } services := service.NewServices(deps) + + // HTTP server handlers := http.NewHandler(services) + httpSrv := server.NewHTTPServer(&cfg, handlers.Init()) + + //GRPC server + grpcSrv := server.NewGRPCServer(&cfg, services) - // HTTP Server - srv := server.NewServer(&cfg, handlers.Init()) connectionsClosed := make(chan struct{}) interrupt := make(chan os.Signal, 1) - signal.Notify(interrupt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT) go func() { <-interrupt - if err := srv.Stop(context.Background()); err != nil { + if err := httpSrv.Stop(context.Background()); err != nil { log.Printf("HTTP server shutdown: %v", err) } + grpcSrv.Stop() + if err := strg.Close(); err != nil { log.Printf("Storage shutdown: %v", err) } @@ -79,9 +94,16 @@ func Run() { close(connectionsClosed) }() - if err := srv.Run(); err != nethttp.ErrServerClosed { - log.Fatalf("HTTP server ListenAndServe: %v", err) - } + go func() { + if err := httpSrv.Run(); err != nethttp.ErrServerClosed { + log.Fatalf("HTTP server ListenAndServe: %v", err) + } + }() + + go func() { + grpcSrv.Run() + }() + <-connectionsClosed log.Println("Server shutdown gracefully") } diff --git a/internal/config/config.go b/internal/config/config.go index a2c475d..cf2447d 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -19,6 +19,7 @@ type Config struct { UserKey string `env:"USER_KEY" envDefault:"PaSsW0rD" json:"user_key"` DatabaseDSN string `env:"DATABASE_DSN" json:"database_dsn"` EnableHTTPS bool `env:"ENABLE_HTTPS" json:"enable_https"` + TrustedSubnet string `env:"TRUSTED_SUBNET" json:"trusted_subnet"` Config string `env:"CONFIG" json:"-"` } @@ -47,6 +48,7 @@ func (c *Config) Parse() error { flag.StringVar(&tempConf.UserKey, "p", "", "UserKey for encryption cookie") flag.StringVar(&tempConf.DatabaseDSN, "d", "", "The line with the address to connect to the database") flag.BoolVar(&tempConf.EnableHTTPS, "s", false, "Enable HTTPS mode in web-server") + flag.StringVar(&tempConf.TrustedSubnet, "t", "192.168.1.0/24", "Trusted subnet") flag.StringVar(&tempConf.Config, "config", "", "Config file") flag.StringVar(&tempConf.Config, "c", "", "Config file") flag.Parse() @@ -82,6 +84,9 @@ func (c *Config) Parse() error { if isFlagPassed("s") { c.EnableHTTPS = tempConf.EnableHTTPS } + if isFlagPassed("t") { + c.TrustedSubnet = tempConf.TrustedSubnet + } // settings redefinition from evn err := env.Parse(c) diff --git a/internal/dto/errors.go b/internal/dto/errors.go index 671a759..ba2af7b 100644 --- a/internal/dto/errors.go +++ b/internal/dto/errors.go @@ -3,9 +3,10 @@ package dto import "errors" var ( - ErrNotFound = errors.New("not found") - ErrDeleted = errors.New("marked as deleted") - ErrAlreadyExists = errors.New("already exists") - ErrExecutionPSQL = errors.New("execution PSQL error") - ErrStatementPSQL = errors.New("statement PSQL error") + ErrNotFound = errors.New("not found") + ErrDeleted = errors.New("marked as deleted") + ErrAlreadyExists = errors.New("already exists") + ErrExecutionPSQL = errors.New("execution PSQL error") + ErrStatementPSQL = errors.New("statement PSQL error") + ErrInvalidArgument = errors.New("bad userID") ) diff --git a/internal/dto/internal.go b/internal/dto/internal.go new file mode 100644 index 0000000..ab3f74b --- /dev/null +++ b/internal/dto/internal.go @@ -0,0 +1,7 @@ +package dto + +//Statistic struct +type Statistic struct { + URLsCount int `json:"urls"` + UsersCount int `json:"users"` +} diff --git a/internal/http/handler.go b/internal/http/handler.go index ad857e5..702ea42 100644 --- a/internal/http/handler.go +++ b/internal/http/handler.go @@ -9,6 +9,7 @@ import ( "github.com/zhel1/yandex-practicum-go/internal/http/middleware" v1 "github.com/zhel1/yandex-practicum-go/internal/http/v1" "github.com/zhel1/yandex-practicum-go/internal/service" + "github.com/zhel1/yandex-practicum-go/internal/utils" "io" "net/http" ) @@ -47,7 +48,7 @@ func (h *Handler) initAPI(router chi.Router) { // AddLink accepts a URL string in the request body for shortening. func (h *Handler) AddLink() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - userID, err := middleware.TakeUserID(r.Context()) + userID, err := utils.ExtractValueFromContext(r.Context(), dto.UserIDCtxName) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return diff --git a/internal/http/handlers_test.go b/internal/http/handlers_test.go index ff6e1bb..9205bc7 100644 --- a/internal/http/handlers_test.go +++ b/internal/http/handlers_test.go @@ -83,22 +83,22 @@ func (ht *HandlersTestSuite) TestGetLink() { wantCode: http.StatusTemporaryRedirect, }, { - name: "Positive test #1", + name: "Positive test #2", value: "1234568", wantCode: http.StatusTemporaryRedirect, }, { - name: "Negative test #2. No link in database.", + name: "Negative test #3. No link in database.", value: "1234569", wantCode: http.StatusBadRequest, }, { - name: "Negative test #3 . Not existing path.", + name: "Negative test #4 . Not existing path.", value: "1234567/1234567", wantCode: http.StatusNotFound, }, { - name: "Negative test #4. Empty path (redirection test).", + name: "Negative test #5. Empty path (redirection test).", value: "", wantCode: http.StatusNotFound, }, @@ -186,3 +186,17 @@ func (ht *HandlersTestSuite) TestAddLink() { }) } } + +func (ht *HandlersTestSuite) TestPing() { + ht.router.Use(ht.cookieHandler.CookieHandler) + ht.router.Get("/ping", ht.handler.Ping()) + defer ht.ts.Close() + + ht.T().Run("Ping", func(t *testing.T) { + client := resty.New() + resp, err := client.R().Get(ht.ts.URL + "/ping") + require.NoError(t, err) + + assert.Equal(t, http.StatusOK, resp.StatusCode()) + }) +} diff --git a/internal/http/middleware/cookie.go b/internal/http/middleware/cookie.go index 750fc88..c977c51 100644 --- a/internal/http/middleware/cookie.go +++ b/internal/http/middleware/cookie.go @@ -33,13 +33,13 @@ func (h *CookieHandler) CookieHandler(next http.Handler) http.Handler { var userID string if errors.Is(err, http.ErrNoCookie) { //no cookie userID = uuid.New().String() - http.SetCookie(w, h.CreateNewCookie(r.Context(), userID)) + http.SetCookie(w, h.createNewCookie(r.Context(), userID)) } else if err != nil { http.Error(w, "Cookie crumbled", http.StatusInternalServerError) } else { //cookie found userID, err = h.services.Users.CheckToken(r.Context(), userIDCookie.Value) if err != nil { - http.SetCookie(w, h.CreateNewCookie(r.Context(), userID)) + http.SetCookie(w, h.createNewCookie(r.Context(), userID)) } } @@ -48,21 +48,7 @@ func (h *CookieHandler) CookieHandler(next http.Handler) http.Handler { }) } -func TakeUserID(context context.Context) (string, error) { - userIDCtx := "" - if id := context.Value(dto.UserIDCtxName); id != nil { - userIDCtx = id.(string) - } - - if userIDCtx == "" { - return "", errors.New("empty user id") - } - return userIDCtx, nil -} - -//********************************************************************************************************************** - -func (h *CookieHandler) CreateNewCookie(ctx context.Context, userID string) *http.Cookie { +func (h *CookieHandler) createNewCookie(ctx context.Context, userID string) *http.Cookie { token, err := h.services.Users.CreateNewToken(ctx, userID) if err != nil { panic(err.Error()) diff --git a/internal/http/v1/handler.go b/internal/http/v1/handler.go index 3e028d0..13a6a2b 100644 --- a/internal/http/v1/handler.go +++ b/internal/http/v1/handler.go @@ -19,4 +19,5 @@ func NewHandler(services *service.Services) *Handler { func (h *Handler) Init(r chi.Router) { h.initShortenRoutes(r) h.initUserRoutes(r) + h.initInternalRoutes(r) } diff --git a/internal/http/v1/internal.go b/internal/http/v1/internal.go new file mode 100644 index 0000000..d2fcc41 --- /dev/null +++ b/internal/http/v1/internal.go @@ -0,0 +1,52 @@ +package v1 + +import ( + "bytes" + "encoding/json" + "fmt" + "github.com/go-chi/chi/v5" + "net/http" +) + +func (h *Handler) initInternalRoutes(r chi.Router) { + r.Route("/internal", func(r chi.Router) { + r.Get("/stats", h.GetStats()) + }) +} + +// GetUserLinks returns to the user all links ever saved by him. +func (h *Handler) GetStats() http.HandlerFunc { + return func(w http.ResponseWriter, r *http.Request) { + ipStr := r.Header.Get("X-Real-IP") + + //TODO move it in middleware + trusted, err := h.services.Security.IsIpAddrTrusted(r.Context(), ipStr) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + if !trusted { + http.Error(w, "the ip address is not on a trusted network", http.StatusForbidden) + return + } + + stat, err := h.services.Internal.GetStatistic(r.Context()) + if err != nil { + http.Error(w, err.Error(), http.StatusNoContent) + return + } + + buf := bytes.NewBuffer([]byte{}) + encoder := json.NewEncoder(buf) + encoder.SetEscapeHTML(false) + if err = encoder.Encode(stat); err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + + w.Header().Set("content-type", "application/json; charset=utf-8") + w.WriteHeader(http.StatusOK) + fmt.Fprint(w, buf) + } +} diff --git a/internal/http/v1/shorten.go b/internal/http/v1/shorten.go index 9fa9cbd..af56396 100644 --- a/internal/http/v1/shorten.go +++ b/internal/http/v1/shorten.go @@ -8,7 +8,7 @@ import ( "fmt" "github.com/go-chi/chi/v5" "github.com/zhel1/yandex-practicum-go/internal/dto" - "github.com/zhel1/yandex-practicum-go/internal/http/middleware" + "github.com/zhel1/yandex-practicum-go/internal/utils" "net/http" ) @@ -22,7 +22,7 @@ func (h *Handler) initShortenRoutes(r chi.Router) { // AddLinkJSON accepts a JSON object in the request body and returning a JSON object in response. func (h *Handler) AddLinkJSON() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - userID, err := middleware.TakeUserID(r.Context()) + userID, err := utils.ExtractValueFromContext(r.Context(), dto.UserIDCtxName) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return @@ -62,7 +62,7 @@ func (h *Handler) AddLinkJSON() http.HandlerFunc { // AddLinkBatchJSON accepts in the request body a set of URLs for shortening in the format. func (h *Handler) AddLinkBatchJSON() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - userID, err := middleware.TakeUserID(r.Context()) + userID, err := utils.ExtractValueFromContext(r.Context(), dto.UserIDCtxName) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return diff --git a/internal/http/v1/user.go b/internal/http/v1/user.go index 048c864..e13e11e 100644 --- a/internal/http/v1/user.go +++ b/internal/http/v1/user.go @@ -6,7 +6,8 @@ import ( "encoding/json" "fmt" "github.com/go-chi/chi/v5" - "github.com/zhel1/yandex-practicum-go/internal/http/middleware" + "github.com/zhel1/yandex-practicum-go/internal/dto" + "github.com/zhel1/yandex-practicum-go/internal/utils" "net/http" ) @@ -20,7 +21,7 @@ func (h *Handler) initUserRoutes(r chi.Router) { // GetUserLinks returns to the user all links ever saved by him. func (h *Handler) GetUserLinks() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - userID, err := middleware.TakeUserID(r.Context()) + userID, err := utils.ExtractValueFromContext(r.Context(), dto.UserIDCtxName) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return @@ -54,7 +55,7 @@ func (h *Handler) GetUserLinks() http.HandlerFunc { // DeleteUserLinksBatch accepts a list of abbreviated URL IDs to delete. func (h *Handler) DeleteUserLinksBatch() http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { - userID, err := middleware.TakeUserID(r.Context()) + userID, err := utils.ExtractValueFromContext(r.Context(), dto.UserIDCtxName) if err != nil { http.Error(w, err.Error(), http.StatusBadRequest) return diff --git a/internal/rpc/hendlers.go b/internal/rpc/hendlers.go new file mode 100644 index 0000000..5a80de9 --- /dev/null +++ b/internal/rpc/hendlers.go @@ -0,0 +1,190 @@ +package rpc + +import ( + "context" + "errors" + "github.com/zhel1/yandex-practicum-go/internal/dto" + pb "github.com/zhel1/yandex-practicum-go/internal/rpc/proto" + "github.com/zhel1/yandex-practicum-go/internal/service" + "github.com/zhel1/yandex-practicum-go/internal/utils" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "net/url" +) + +// UsersServer поддерживает все необходимые методы сервера. +type ShortenerServer struct { + // you need to embed the pb.Unimplemented type + // for compatibility with future versions + pb.UnimplementedShortenerServer + services *service.Services +} + +func NewBaseServer(services *service.Services) *ShortenerServer { + return &ShortenerServer{ + services: services, + } +} + +func (s *ShortenerServer) AddLink(ctx context.Context, in *pb.AddLinkRequest) (*pb.AddLinkResponse, error) { + userID, err := utils.ExtractValueFromContext(ctx, dto.UserIDCtxName) + if err != nil { + return nil, status.Error(codes.NotFound, err.Error()) + } + + shortLink, err := s.services.Shorten.ShortenURL(ctx, userID, dto.ModelOriginalURL{ + OriginalURL: in.LongLink, + }) + + if err != nil { + switch { + case errors.Is(err, dto.ErrAlreadyExists): + return &pb.AddLinkResponse{ + ShortLink: shortLink.ShortURL, + }, status.Error(codes.AlreadyExists, err.Error()) + default: + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + } + + return &pb.AddLinkResponse{ + ShortLink: shortLink.ShortURL, + }, nil +} + +func (s *ShortenerServer) GetLink(ctx context.Context, in *pb.GetLinkRequest) (*pb.GetLinkResponse, error) { + u, err := url.Parse(in.ShortLink) + if err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + + if len(u.Path) < 2 { + return nil, status.Error(codes.InvalidArgument, "bad short id") + } + + originalLink, err := s.services.Users.GetOriginalURLByShort(ctx, u.Path[1:]) + if err != nil { + switch err { + case dto.ErrDeleted: + return nil, status.Error(codes.NotFound, err.Error()) + default: + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + } + + return &pb.GetLinkResponse{ + LongLink: originalLink, + }, nil +} + +func (s *ShortenerServer) Ping(ctx context.Context, in *pb.PingRequest) (*pb.PingResponse, error) { + err := s.services.Users.Ping(ctx) + if err != nil { + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + return &pb.PingResponse{}, nil +} + +func (s *ShortenerServer) AddLinkBatch(ctx context.Context, in *pb.AddLinkBatchRequest) (*pb.AddLinkBatchResponse, error) { + userID, err := utils.ExtractValueFromContext(ctx, dto.UserIDCtxName) + if err != nil { + return nil, status.Error(codes.NotFound, err.Error()) + } + + bReq := make([]dto.ModelOriginalURLBatch, 0, len(in.Items)) + for _, item := range in.Items { + bReq = append(bReq, dto.ModelOriginalURLBatch{ + CorrelationID: item.CorrelationId, + OriginalURL: item.LongUrl, + }) + } + + bResArr, err := s.services.Shorten.ShortenBatchURL(ctx, userID, bReq) + if err != nil { + switch { + case errors.Is(err, dto.ErrAlreadyExists): + return nil, status.Error(codes.AlreadyExists, err.Error()) + default: + return nil, status.Error(codes.InvalidArgument, err.Error()) + } + } + + respItems := make([]*pb.AddLinkBatchResponse_Item, 0, len(bResArr)) + for _, item := range bResArr { + respItems = append(respItems, &pb.AddLinkBatchResponse_Item{ + CorrelationId: item.CorrelationID, + ShortUrl: item.ShortURL, + }) + } + + return &pb.AddLinkBatchResponse{ + Items: respItems, + }, nil +} + +func (s *ShortenerServer) GetUserLinks(ctx context.Context, in *pb.GetUsersLinksRequest) (*pb.GetUsersLinksResponse, error) { + userID, err := utils.ExtractValueFromContext(ctx, dto.UserIDCtxName) + if err != nil { + return nil, status.Error(codes.NotFound, err.Error()) + } + + modelURLs, err := s.services.Users.GetURLsByUserID(ctx, userID) + if err != nil { + switch { + case errors.Is(err, dto.ErrInvalidArgument): + return nil, status.Error(codes.InvalidArgument, err.Error()) + default: + return nil, status.Error(codes.NotFound, err.Error()) + } + } + + if len(modelURLs) == 0 { + return &pb.GetUsersLinksResponse{}, nil + } + + respItems := make([]*pb.GetUsersLinksResponse_Item, 0, len(modelURLs)) + for _, item := range modelURLs { + respItems = append(respItems, &pb.GetUsersLinksResponse_Item{ + LongUrl: item.OriginalURL, + ShortUrl: item.ShortURL, + }) + } + + return &pb.GetUsersLinksResponse{ + Items: respItems, + }, nil +} + +func (s *ShortenerServer) DeleteUserLinksBatch(ctx context.Context, in *pb.DeleteUserLinksBatchRequest) (*pb.DeleteUserLinksBatchResponse, error) { + userID, err := utils.ExtractValueFromContext(ctx, dto.UserIDCtxName) + if err != nil { + return nil, status.Error(codes.NotFound, err.Error()) + } + + err = s.services.Users.DeleteBatchURL(ctx, userID, in.Items) + if err != nil { + switch { + case errors.Is(err, dto.ErrInvalidArgument): + return nil, status.Error(codes.InvalidArgument, err.Error()) + default: + return nil, status.Error(codes.Internal, err.Error()) + } + } + return &pb.DeleteUserLinksBatchResponse{}, nil +} + +func (s *ShortenerServer) GetStatistic(ctx context.Context, in *pb.GetStatRequest) (*pb.GetStatResponse, error) { + stat, err := s.services.Internal.GetStatistic(ctx) + if err != nil { + switch { + case errors.Is(err, dto.ErrInvalidArgument): + return nil, status.Error(codes.InvalidArgument, err.Error()) + default: + return nil, status.Error(codes.Internal, err.Error()) + } + } + return &pb.GetStatResponse{ + UrlsCont: int32(stat.URLsCount), + UsersCont: int32(stat.URLsCount), + }, nil +} diff --git a/internal/rpc/hendlers_test.go b/internal/rpc/hendlers_test.go new file mode 100644 index 0000000..01b7e37 --- /dev/null +++ b/internal/rpc/hendlers_test.go @@ -0,0 +1,385 @@ +package rpc + +import ( + "context" + "github.com/google/uuid" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/stretchr/testify/suite" + "github.com/zhel1/yandex-practicum-go/internal/auth" + "github.com/zhel1/yandex-practicum-go/internal/config" + "github.com/zhel1/yandex-practicum-go/internal/dto" + "github.com/zhel1/yandex-practicum-go/internal/rpc/interceptors" + pb "github.com/zhel1/yandex-practicum-go/internal/rpc/proto" + "github.com/zhel1/yandex-practicum-go/internal/service" + "github.com/zhel1/yandex-practicum-go/internal/storage" + "github.com/zhel1/yandex-practicum-go/internal/storage/inmemory" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/credentials/insecure" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" + "log" + "net" + "net/url" + "strings" + "testing" +) + +type HandlersTestSuite struct { + suite.Suite + storage storage.Storage + cfg *config.Config + ts *grpc.Server + baseURL string + services *service.Services +} + +func (ht *HandlersTestSuite) SetupTest() { + cfg := config.Config{} + cfg.Addr = "localhost:8080" + cfg.BaseURL = "http://localhost:8080/" + cfg.FileStoragePath = "" + cfg.UserKey = "PaSsW0rD" + + tokenManager, err := auth.NewManager(cfg.UserKey) + if err != nil { + log.Fatal(err) + } + + deps := service.Deps{ + Storage: inmemory.NewStorage(), + BaseURL: cfg.BaseURL, + TokenManager: tokenManager, + } + + services := service.NewServices(deps) + + // TODO Get addr from config + listener, err := net.Listen("tcp", ":3200") + if err != nil { + log.Fatal(err) + } + + midl := interceptors.InitInterceptors(services) + + ht.cfg = &cfg + ht.storage = deps.Storage + ht.baseURL = "http://localhost:8080/" + ht.services = services + ht.ts = grpc.NewServer(grpc.UnaryInterceptor(midl.UserIDInterceptor)) + pb.RegisterShortenerServer(ht.ts, NewBaseServer(services)) + go ht.ts.Serve(listener) +} + +func (ht *HandlersTestSuite) TearDownTest() { + ht.ts.GracefulStop() +} + +func TestHandlersTestSuite(t *testing.T) { + suite.Run(t, new(HandlersTestSuite)) +} + +func (ht *HandlersTestSuite) TestAddLink() { + // TODO Get addr from config + conn, err := grpc.Dial(":3200", grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + log.Fatal(err) + } + defer conn.Close() + + client := pb.NewShortenerClient(conn) + + type want struct { + code codes.Code + } + + tests := []struct { + name string + body string + want want + }{ + { + name: "positive test #1", + body: "https://yandex.ru/news/story/Minoborony_zayavilo_ob_unichtozhenii_podLvovom_sklada_inostrannogo_oruzhiya--5da2bb9cc9ddc47c0adb17be6d81bd72?lang=ru&rubric=index&fan=1&stid=yjizNz0bbyG1LTQtz2jv&t=1650312349&tt=true&persistent_id=192628644&story=4bc48b1b-a772-571f-a583-40d87f145dd6", + want: want{ + code: codes.OK, + }, + }, + { + name: "negative test #2", + body: "", + want: want{ + code: codes.InvalidArgument, + }, + }, + { + name: "negative test #3", + body: "12312343214", + want: want{ + code: codes.InvalidArgument, + }, + }, + } + + for _, tt := range tests { + ht.T().Run(tt.name, func(t *testing.T) { + var trailer metadata.MD + res, err := client.AddLink(context.Background(), &pb.AddLinkRequest{ + LongLink: tt.body, + }, grpc.Trailer(&trailer)) + + if tt.want.code == codes.OK { + require.NoError(t, err) + _, err := url.ParseRequestURI(res.ShortLink) + require.NoError(t, err) + + //get only id and check in db + id := strings.Replace(res.ShortLink, ht.cfg.BaseURL, "", -1) + _, err = ht.storage.Get(context.Background(), id) + require.NoError(t, err) + + //check token + values := trailer.Get(dto.UserIDCtxName.String()) + require.NotEqual(t, 0, len(values)) + + if len(values) > 0 { + require.NotEqual(t, "", values[0]) + } + } else { + e, ok := status.FromError(err) + assert.Equal(t, true, ok) + if ok { + assert.Equal(t, tt.want.code, e.Code()) + } + } + }) + } +} + +func (ht *HandlersTestSuite) TestGetLink() { + // TODO Get addr from config + conn, err := grpc.Dial(":3200", grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + log.Fatal(err) + } + defer conn.Close() + + client := pb.NewShortenerClient(conn) + + userID := uuid.New().String() + ht.storage.Put(context.Background(), userID, "1234567", "https://yandex.ru/news/story/Minoborony_zayavilo_ob_unichtozhenii_podLvovom_sklada_inostrannogo_oruzhiya--5da2bb9cc9ddc47c0adb17be6d81bd72?lang=ru&rubric=index&fan=1&stid=yjizNz0bbyG1LTQtz2jv&t=1650312349&tt=true&persistent_id=192628644&story=4bc48b1b-a772-571f-a583-40d87f145dd6") + ht.storage.Put(context.Background(), userID, "1234568", "https://yandex.ru/news/") + + tests := []struct { + name string + value string + wantCode codes.Code + }{ + { + name: "Positive test #1", + value: "1234567", + wantCode: codes.OK, + }, + { + name: "Positive test #2", + value: "1234568", + wantCode: codes.OK, + }, + { + name: "Negative test #3. No link in database.", + value: "1234569", + wantCode: codes.InvalidArgument, + }, + { + name: "Negative test #4 . Not existing path.", + value: "1234567/1234567", + wantCode: codes.InvalidArgument, + }, + { + name: "Negative test #5. Empty path (redirection test).", + value: "", + wantCode: codes.InvalidArgument, + }, + } + + for _, tt := range tests { + ht.T().Run(tt.name, func(t *testing.T) { + res, err := client.GetLink(context.Background(), &pb.GetLinkRequest{ + ShortLink: ht.baseURL + tt.value, + }) + + if tt.wantCode == codes.OK { + require.NoError(t, err) + _, err := url.ParseRequestURI(res.LongLink) + require.NoError(t, err) + } else { + e, ok := status.FromError(err) + assert.Equal(t, true, ok) + if ok { + assert.Equal(t, tt.wantCode, e.Code()) + } + } + }) + } +} + +func (ht *HandlersTestSuite) TestPing() { + // TODO Get addr from config + conn, err := grpc.Dial(":3200", grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + log.Fatal(err) + } + defer conn.Close() + + client := pb.NewShortenerClient(conn) + + ht.T().Run("Ping", func(t *testing.T) { + _, err := client.Ping(context.Background(), &pb.PingRequest{}) + require.NoError(t, err) + }) +} + +func (ht *HandlersTestSuite) TestAddLinkBatch() { + // TODO Get addr from config + conn, err := grpc.Dial(":3200", grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + log.Fatal(err) + } + defer conn.Close() + + client := pb.NewShortenerClient(conn) + + type want struct { + code codes.Code + } + + tests := []struct { + name string + body *pb.AddLinkBatchRequest + want want + }{ + { + name: "positive test #1", + body: &pb.AddLinkBatchRequest{ + Items: []*pb.AddLinkBatchRequest_Item{ + { + CorrelationId: "1", + LongUrl: "http://khawesxujm.biz/fdapyknrhiywl0", + }, + { + CorrelationId: "2", + LongUrl: "http://jlth8bcthyp01q.ru/zkd2d", + }, + }, + }, + want: want{ + code: codes.OK, + }, + }, + { + name: "negative test #2", + body: &pb.AddLinkBatchRequest{}, + want: want{ + code: codes.InvalidArgument, + }, + }, + } + + for _, tt := range tests { + ht.T().Run(tt.name, func(t *testing.T) { + var trailer metadata.MD + res, err := client.AddLinkBatch(context.Background(), tt.body, grpc.Trailer(&trailer)) + if tt.want.code == codes.OK { + require.NoError(t, err) + for _, item := range res.Items { + u, err := url.ParseRequestURI(item.ShortUrl) + require.NoError(t, err) + + require.NotEqual(t, 0, len(u.Path)) + require.NotEqual(t, 1, len(u.Path)) + + _, err = ht.storage.Get(context.Background(), u.Path[1:]) + require.NoError(t, err) + } + + //check token + values := trailer.Get(dto.UserIDCtxName.String()) + require.NotEqual(t, 0, len(values)) + + if len(values) > 0 { + require.NotEqual(t, "", values[0]) + } + } else { + e, ok := status.FromError(err) + assert.Equal(t, true, ok) + if ok { + assert.Equal(t, tt.want.code, e.Code()) + } + } + }) + } +} + +func (ht *HandlersTestSuite) TestGetUserLinks() { + // TODO Get addr from config + conn, err := grpc.Dial(":3200", grpc.WithTransportCredentials(insecure.NewCredentials())) + if err != nil { + log.Fatal(err) + } + defer conn.Close() + + client := pb.NewShortenerClient(conn) + + userID := uuid.New().String() + token, err := ht.services.Users.CreateNewToken(context.Background(), userID) + if err != nil { + panic(err.Error()) + } + + idLink := "1234568" + origLink := "https://yandex.ru/news/" + + tests := []struct { + name string + value string + stData bool + wantCode codes.Code + }{ + { + name: "Negative test #1. No user in database.", + stData: false, + wantCode: codes.NotFound, + }, + { + name: "Positive test #2", + stData: true, + wantCode: codes.OK, + }, + } + + for _, tt := range tests { + if tt.stData { + ht.storage.Put(context.Background(), userID, idLink, origLink) + } + ht.T().Run(tt.name, func(t *testing.T) { + md := metadata.New(map[string]string{dto.UserIDCtxName.String(): token}) + ctx := metadata.NewOutgoingContext(context.Background(), md) + res, err := client.GetUserLinks(ctx, &pb.GetUsersLinksRequest{}) + if tt.stData { + require.NoError(t, err) + require.Equal(t, origLink, res.Items[0].LongUrl) + + u, err := url.ParseRequestURI(res.Items[0].ShortUrl) + require.NoError(t, err) + require.Equal(t, "/"+idLink, u.Path) + } else { + e, ok := status.FromError(err) + assert.Equal(t, true, ok) + if ok { + assert.Equal(t, tt.wantCode, e.Code()) + } + } + }) + } +} diff --git a/internal/rpc/interceptors/userid.go b/internal/rpc/interceptors/userid.go new file mode 100644 index 0000000..fd58646 --- /dev/null +++ b/internal/rpc/interceptors/userid.go @@ -0,0 +1,56 @@ +package interceptors + +import ( + "context" + "fmt" + "github.com/google/uuid" + "github.com/zhel1/yandex-practicum-go/internal/dto" + "github.com/zhel1/yandex-practicum-go/internal/service" + "google.golang.org/grpc" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/metadata" + "google.golang.org/grpc/status" +) + +type Interceptors struct { + services *service.Services +} + +func InitInterceptors(services *service.Services) *Interceptors { + if services == nil { + panic(fmt.Errorf("nil services was passed to grpc interceptors")) + } + + return &Interceptors{ + services: services, + } +} + +func (i *Interceptors) UserIDInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error) { + var userID string + var token string + var err error + if md, ok := metadata.FromIncomingContext(ctx); ok { + values := md.Get(dto.UserIDCtxName.String()) + if len(values) > 0 { + userID, err = i.services.Users.CheckToken(ctx, values[0]) + if err == nil { + return handler(context.WithValue(ctx, dto.UserIDCtxName, userID), req) + } + } + } + + userID = uuid.New().String() + token, err = i.services.Users.CreateNewToken(ctx, userID) + if err != nil { + return nil, status.Errorf(codes.Internal, `create token error:`+err.Error()) + } + + md := metadata.New(map[string]string{dto.UserIDCtxName.String(): token}) + err = grpc.SetTrailer(ctx, md) + if err != nil { + return nil, status.Errorf(codes.Internal, `set trailer error:`+err.Error()) + } + + return handler(context.WithValue(ctx, dto.UserIDCtxName, userID), req) +} diff --git a/internal/rpc/proto/shortener.pb.go b/internal/rpc/proto/shortener.pb.go new file mode 100644 index 0000000..4bd0b29 --- /dev/null +++ b/internal/rpc/proto/shortener.pb.go @@ -0,0 +1,1205 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v3.21.5 +// source: internal/rpc/proto/shortener.proto + +package proto + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type AddLinkRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LongLink string `protobuf:"bytes,1,opt,name=long_link,json=longLink,proto3" json:"long_link,omitempty"` +} + +func (x *AddLinkRequest) Reset() { + *x = AddLinkRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddLinkRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddLinkRequest) ProtoMessage() {} + +func (x *AddLinkRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddLinkRequest.ProtoReflect.Descriptor instead. +func (*AddLinkRequest) Descriptor() ([]byte, []int) { + return file_internal_rpc_proto_shortener_proto_rawDescGZIP(), []int{0} +} + +func (x *AddLinkRequest) GetLongLink() string { + if x != nil { + return x.LongLink + } + return "" +} + +type AddLinkResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ShortLink string `protobuf:"bytes,1,opt,name=short_link,json=shortLink,proto3" json:"short_link,omitempty"` +} + +func (x *AddLinkResponse) Reset() { + *x = AddLinkResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddLinkResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddLinkResponse) ProtoMessage() {} + +func (x *AddLinkResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddLinkResponse.ProtoReflect.Descriptor instead. +func (*AddLinkResponse) Descriptor() ([]byte, []int) { + return file_internal_rpc_proto_shortener_proto_rawDescGZIP(), []int{1} +} + +func (x *AddLinkResponse) GetShortLink() string { + if x != nil { + return x.ShortLink + } + return "" +} + +type GetLinkRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ShortLink string `protobuf:"bytes,1,opt,name=short_link,json=shortLink,proto3" json:"short_link,omitempty"` +} + +func (x *GetLinkRequest) Reset() { + *x = GetLinkRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetLinkRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetLinkRequest) ProtoMessage() {} + +func (x *GetLinkRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetLinkRequest.ProtoReflect.Descriptor instead. +func (*GetLinkRequest) Descriptor() ([]byte, []int) { + return file_internal_rpc_proto_shortener_proto_rawDescGZIP(), []int{2} +} + +func (x *GetLinkRequest) GetShortLink() string { + if x != nil { + return x.ShortLink + } + return "" +} + +type GetLinkResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LongLink string `protobuf:"bytes,1,opt,name=long_link,json=longLink,proto3" json:"long_link,omitempty"` +} + +func (x *GetLinkResponse) Reset() { + *x = GetLinkResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetLinkResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetLinkResponse) ProtoMessage() {} + +func (x *GetLinkResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetLinkResponse.ProtoReflect.Descriptor instead. +func (*GetLinkResponse) Descriptor() ([]byte, []int) { + return file_internal_rpc_proto_shortener_proto_rawDescGZIP(), []int{3} +} + +func (x *GetLinkResponse) GetLongLink() string { + if x != nil { + return x.LongLink + } + return "" +} + +type PingRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *PingRequest) Reset() { + *x = PingRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PingRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingRequest) ProtoMessage() {} + +func (x *PingRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingRequest.ProtoReflect.Descriptor instead. +func (*PingRequest) Descriptor() ([]byte, []int) { + return file_internal_rpc_proto_shortener_proto_rawDescGZIP(), []int{4} +} + +type PingResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *PingResponse) Reset() { + *x = PingResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PingResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PingResponse) ProtoMessage() {} + +func (x *PingResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use PingResponse.ProtoReflect.Descriptor instead. +func (*PingResponse) Descriptor() ([]byte, []int) { + return file_internal_rpc_proto_shortener_proto_rawDescGZIP(), []int{5} +} + +type AddLinkBatchRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Items []*AddLinkBatchRequest_Item `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` +} + +func (x *AddLinkBatchRequest) Reset() { + *x = AddLinkBatchRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddLinkBatchRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddLinkBatchRequest) ProtoMessage() {} + +func (x *AddLinkBatchRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddLinkBatchRequest.ProtoReflect.Descriptor instead. +func (*AddLinkBatchRequest) Descriptor() ([]byte, []int) { + return file_internal_rpc_proto_shortener_proto_rawDescGZIP(), []int{6} +} + +func (x *AddLinkBatchRequest) GetItems() []*AddLinkBatchRequest_Item { + if x != nil { + return x.Items + } + return nil +} + +type AddLinkBatchResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Items []*AddLinkBatchResponse_Item `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` +} + +func (x *AddLinkBatchResponse) Reset() { + *x = AddLinkBatchResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddLinkBatchResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddLinkBatchResponse) ProtoMessage() {} + +func (x *AddLinkBatchResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddLinkBatchResponse.ProtoReflect.Descriptor instead. +func (*AddLinkBatchResponse) Descriptor() ([]byte, []int) { + return file_internal_rpc_proto_shortener_proto_rawDescGZIP(), []int{7} +} + +func (x *AddLinkBatchResponse) GetItems() []*AddLinkBatchResponse_Item { + if x != nil { + return x.Items + } + return nil +} + +type GetUsersLinksRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *GetUsersLinksRequest) Reset() { + *x = GetUsersLinksRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetUsersLinksRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUsersLinksRequest) ProtoMessage() {} + +func (x *GetUsersLinksRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetUsersLinksRequest.ProtoReflect.Descriptor instead. +func (*GetUsersLinksRequest) Descriptor() ([]byte, []int) { + return file_internal_rpc_proto_shortener_proto_rawDescGZIP(), []int{8} +} + +type GetUsersLinksResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Items []*GetUsersLinksResponse_Item `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` +} + +func (x *GetUsersLinksResponse) Reset() { + *x = GetUsersLinksResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetUsersLinksResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUsersLinksResponse) ProtoMessage() {} + +func (x *GetUsersLinksResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetUsersLinksResponse.ProtoReflect.Descriptor instead. +func (*GetUsersLinksResponse) Descriptor() ([]byte, []int) { + return file_internal_rpc_proto_shortener_proto_rawDescGZIP(), []int{9} +} + +func (x *GetUsersLinksResponse) GetItems() []*GetUsersLinksResponse_Item { + if x != nil { + return x.Items + } + return nil +} + +type DeleteUserLinksBatchRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Items []string `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` +} + +func (x *DeleteUserLinksBatchRequest) Reset() { + *x = DeleteUserLinksBatchRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteUserLinksBatchRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteUserLinksBatchRequest) ProtoMessage() {} + +func (x *DeleteUserLinksBatchRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteUserLinksBatchRequest.ProtoReflect.Descriptor instead. +func (*DeleteUserLinksBatchRequest) Descriptor() ([]byte, []int) { + return file_internal_rpc_proto_shortener_proto_rawDescGZIP(), []int{10} +} + +func (x *DeleteUserLinksBatchRequest) GetItems() []string { + if x != nil { + return x.Items + } + return nil +} + +type DeleteUserLinksBatchResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *DeleteUserLinksBatchResponse) Reset() { + *x = DeleteUserLinksBatchResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DeleteUserLinksBatchResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DeleteUserLinksBatchResponse) ProtoMessage() {} + +func (x *DeleteUserLinksBatchResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DeleteUserLinksBatchResponse.ProtoReflect.Descriptor instead. +func (*DeleteUserLinksBatchResponse) Descriptor() ([]byte, []int) { + return file_internal_rpc_proto_shortener_proto_rawDescGZIP(), []int{11} +} + +type GetStatRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *GetStatRequest) Reset() { + *x = GetStatRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetStatRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetStatRequest) ProtoMessage() {} + +func (x *GetStatRequest) ProtoReflect() protoreflect.Message { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetStatRequest.ProtoReflect.Descriptor instead. +func (*GetStatRequest) Descriptor() ([]byte, []int) { + return file_internal_rpc_proto_shortener_proto_rawDescGZIP(), []int{12} +} + +type GetStatResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UrlsCont int32 `protobuf:"varint,1,opt,name=urls_cont,json=urlsCont,proto3" json:"urls_cont,omitempty"` + UsersCont int32 `protobuf:"varint,2,opt,name=users_cont,json=usersCont,proto3" json:"users_cont,omitempty"` +} + +func (x *GetStatResponse) Reset() { + *x = GetStatResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetStatResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetStatResponse) ProtoMessage() {} + +func (x *GetStatResponse) ProtoReflect() protoreflect.Message { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetStatResponse.ProtoReflect.Descriptor instead. +func (*GetStatResponse) Descriptor() ([]byte, []int) { + return file_internal_rpc_proto_shortener_proto_rawDescGZIP(), []int{13} +} + +func (x *GetStatResponse) GetUrlsCont() int32 { + if x != nil { + return x.UrlsCont + } + return 0 +} + +func (x *GetStatResponse) GetUsersCont() int32 { + if x != nil { + return x.UsersCont + } + return 0 +} + +type AddLinkBatchRequest_Item struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CorrelationId string `protobuf:"bytes,1,opt,name=correlation_id,json=correlationId,proto3" json:"correlation_id,omitempty"` + LongUrl string `protobuf:"bytes,2,opt,name=long_url,json=longUrl,proto3" json:"long_url,omitempty"` +} + +func (x *AddLinkBatchRequest_Item) Reset() { + *x = AddLinkBatchRequest_Item{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddLinkBatchRequest_Item) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddLinkBatchRequest_Item) ProtoMessage() {} + +func (x *AddLinkBatchRequest_Item) ProtoReflect() protoreflect.Message { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddLinkBatchRequest_Item.ProtoReflect.Descriptor instead. +func (*AddLinkBatchRequest_Item) Descriptor() ([]byte, []int) { + return file_internal_rpc_proto_shortener_proto_rawDescGZIP(), []int{6, 0} +} + +func (x *AddLinkBatchRequest_Item) GetCorrelationId() string { + if x != nil { + return x.CorrelationId + } + return "" +} + +func (x *AddLinkBatchRequest_Item) GetLongUrl() string { + if x != nil { + return x.LongUrl + } + return "" +} + +type AddLinkBatchResponse_Item struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CorrelationId string `protobuf:"bytes,1,opt,name=correlation_id,json=correlationId,proto3" json:"correlation_id,omitempty"` + ShortUrl string `protobuf:"bytes,2,opt,name=short_url,json=shortUrl,proto3" json:"short_url,omitempty"` +} + +func (x *AddLinkBatchResponse_Item) Reset() { + *x = AddLinkBatchResponse_Item{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *AddLinkBatchResponse_Item) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*AddLinkBatchResponse_Item) ProtoMessage() {} + +func (x *AddLinkBatchResponse_Item) ProtoReflect() protoreflect.Message { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use AddLinkBatchResponse_Item.ProtoReflect.Descriptor instead. +func (*AddLinkBatchResponse_Item) Descriptor() ([]byte, []int) { + return file_internal_rpc_proto_shortener_proto_rawDescGZIP(), []int{7, 0} +} + +func (x *AddLinkBatchResponse_Item) GetCorrelationId() string { + if x != nil { + return x.CorrelationId + } + return "" +} + +func (x *AddLinkBatchResponse_Item) GetShortUrl() string { + if x != nil { + return x.ShortUrl + } + return "" +} + +type GetUsersLinksResponse_Item struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LongUrl string `protobuf:"bytes,1,opt,name=long_url,json=longUrl,proto3" json:"long_url,omitempty"` + ShortUrl string `protobuf:"bytes,2,opt,name=short_url,json=shortUrl,proto3" json:"short_url,omitempty"` +} + +func (x *GetUsersLinksResponse_Item) Reset() { + *x = GetUsersLinksResponse_Item{} + if protoimpl.UnsafeEnabled { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetUsersLinksResponse_Item) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUsersLinksResponse_Item) ProtoMessage() {} + +func (x *GetUsersLinksResponse_Item) ProtoReflect() protoreflect.Message { + mi := &file_internal_rpc_proto_shortener_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetUsersLinksResponse_Item.ProtoReflect.Descriptor instead. +func (*GetUsersLinksResponse_Item) Descriptor() ([]byte, []int) { + return file_internal_rpc_proto_shortener_proto_rawDescGZIP(), []int{9, 0} +} + +func (x *GetUsersLinksResponse_Item) GetLongUrl() string { + if x != nil { + return x.LongUrl + } + return "" +} + +func (x *GetUsersLinksResponse_Item) GetShortUrl() string { + if x != nil { + return x.ShortUrl + } + return "" +} + +var File_internal_rpc_proto_shortener_proto protoreflect.FileDescriptor + +var file_internal_rpc_proto_shortener_proto_rawDesc = []byte{ + 0x0a, 0x22, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x72, 0x70, 0x63, 0x2f, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x2f, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x65, 0x6e, 0x65, 0x72, 0x2e, 0x70, + 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x12, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x72, + 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x2d, 0x0a, 0x0e, 0x41, 0x64, 0x64, 0x4c, + 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1b, 0x0a, 0x09, 0x6c, 0x6f, + 0x6e, 0x67, 0x5f, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6c, + 0x6f, 0x6e, 0x67, 0x4c, 0x69, 0x6e, 0x6b, 0x22, 0x30, 0x0a, 0x0f, 0x41, 0x64, 0x64, 0x4c, 0x69, + 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1d, 0x0a, 0x0a, 0x73, 0x68, + 0x6f, 0x72, 0x74, 0x5f, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, + 0x73, 0x68, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x22, 0x2f, 0x0a, 0x0e, 0x47, 0x65, 0x74, + 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x73, + 0x68, 0x6f, 0x72, 0x74, 0x5f, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x22, 0x2e, 0x0a, 0x0f, 0x47, 0x65, + 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, + 0x09, 0x6c, 0x6f, 0x6e, 0x67, 0x5f, 0x6c, 0x69, 0x6e, 0x6b, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x08, 0x6c, 0x6f, 0x6e, 0x67, 0x4c, 0x69, 0x6e, 0x6b, 0x22, 0x0d, 0x0a, 0x0b, 0x50, 0x69, + 0x6e, 0x67, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x0e, 0x0a, 0x0c, 0x50, 0x69, 0x6e, + 0x67, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0xa3, 0x01, 0x0a, 0x13, 0x41, 0x64, + 0x64, 0x4c, 0x69, 0x6e, 0x6b, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x12, 0x42, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, + 0x32, 0x2c, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x72, 0x70, 0x63, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x4c, 0x69, 0x6e, 0x6b, 0x42, 0x61, 0x74, + 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, + 0x69, 0x74, 0x65, 0x6d, 0x73, 0x1a, 0x48, 0x0a, 0x04, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x25, 0x0a, + 0x0e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x6f, 0x6e, 0x67, 0x5f, 0x75, 0x72, 0x6c, + 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6c, 0x6f, 0x6e, 0x67, 0x55, 0x72, 0x6c, 0x22, + 0xa7, 0x01, 0x0a, 0x14, 0x41, 0x64, 0x64, 0x4c, 0x69, 0x6e, 0x6b, 0x42, 0x61, 0x74, 0x63, 0x68, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x43, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2d, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, + 0x61, 0x6c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, + 0x4c, 0x69, 0x6e, 0x6b, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, + 0x65, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x1a, 0x4a, 0x0a, + 0x04, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x25, 0x0a, 0x0e, 0x63, 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, + 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0d, 0x63, + 0x6f, 0x72, 0x72, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, + 0x73, 0x68, 0x6f, 0x72, 0x74, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x72, 0x6c, 0x22, 0x16, 0x0a, 0x14, 0x47, 0x65, 0x74, + 0x55, 0x73, 0x65, 0x72, 0x73, 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x22, 0x9d, 0x01, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x4c, 0x69, + 0x6e, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x44, 0x0a, 0x05, 0x69, + 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2e, 0x2e, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x05, 0x69, 0x74, 0x65, 0x6d, + 0x73, 0x1a, 0x3e, 0x0a, 0x04, 0x49, 0x74, 0x65, 0x6d, 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x6f, 0x6e, + 0x67, 0x5f, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6c, 0x6f, 0x6e, + 0x67, 0x55, 0x72, 0x6c, 0x12, 0x1b, 0x0a, 0x09, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x5f, 0x75, 0x72, + 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x73, 0x68, 0x6f, 0x72, 0x74, 0x55, 0x72, + 0x6c, 0x22, 0x33, 0x0a, 0x1b, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x4c, + 0x69, 0x6e, 0x6b, 0x73, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, + 0x12, 0x14, 0x0a, 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, + 0x05, 0x69, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x1e, 0x0a, 0x1c, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x55, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x10, 0x0a, 0x0e, 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, + 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x22, 0x4d, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x53, + 0x74, 0x61, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x1b, 0x0a, 0x09, 0x75, + 0x72, 0x6c, 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, + 0x75, 0x72, 0x6c, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x12, 0x1d, 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, + 0x73, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x75, 0x73, + 0x65, 0x72, 0x73, 0x43, 0x6f, 0x6e, 0x74, 0x32, 0x95, 0x05, 0x0a, 0x09, 0x53, 0x68, 0x6f, 0x72, + 0x74, 0x65, 0x6e, 0x65, 0x72, 0x12, 0x52, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x4c, 0x69, 0x6e, 0x6b, + 0x12, 0x22, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x72, 0x70, 0x63, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, + 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x4c, 0x69, 0x6e, + 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x52, 0x0a, 0x07, 0x47, 0x65, 0x74, + 0x4c, 0x69, 0x6e, 0x6b, 0x12, 0x22, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, + 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x6e, + 0x6b, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x61, 0x6c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, + 0x74, 0x4c, 0x69, 0x6e, 0x6b, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x49, 0x0a, + 0x04, 0x50, 0x69, 0x6e, 0x67, 0x12, 0x1f, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, + 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x69, 0x6e, 0x67, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x20, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, + 0x6c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x69, 0x6e, 0x67, + 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x61, 0x0a, 0x0c, 0x41, 0x64, 0x64, 0x4c, + 0x69, 0x6e, 0x6b, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x27, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x61, 0x6c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, + 0x64, 0x4c, 0x69, 0x6e, 0x6b, 0x42, 0x61, 0x74, 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x28, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x72, 0x70, 0x63, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x4c, 0x69, 0x6e, 0x6b, 0x42, 0x61, + 0x74, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x63, 0x0a, 0x0c, 0x47, + 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x12, 0x28, 0x2e, 0x69, 0x6e, + 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x29, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, + 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x55, 0x73, + 0x65, 0x72, 0x73, 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x12, 0x79, 0x0a, 0x14, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x69, + 0x6e, 0x6b, 0x73, 0x42, 0x61, 0x74, 0x63, 0x68, 0x12, 0x2f, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, + 0x6e, 0x61, 0x6c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, 0x65, + 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x42, 0x61, 0x74, + 0x63, 0x68, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x30, 0x2e, 0x69, 0x6e, 0x74, 0x65, + 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x44, + 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x69, 0x6e, 0x6b, 0x73, 0x42, 0x61, + 0x74, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x52, 0x0a, 0x07, 0x47, + 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x12, 0x22, 0x2e, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, + 0x6c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x47, 0x65, 0x74, 0x53, + 0x74, 0x61, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x23, 0x2e, 0x69, 0x6e, 0x74, + 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x47, 0x65, 0x74, 0x53, 0x74, 0x61, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x42, + 0x14, 0x5a, 0x12, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x6e, 0x61, 0x6c, 0x2f, 0x72, 0x70, 0x63, 0x2f, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_internal_rpc_proto_shortener_proto_rawDescOnce sync.Once + file_internal_rpc_proto_shortener_proto_rawDescData = file_internal_rpc_proto_shortener_proto_rawDesc +) + +func file_internal_rpc_proto_shortener_proto_rawDescGZIP() []byte { + file_internal_rpc_proto_shortener_proto_rawDescOnce.Do(func() { + file_internal_rpc_proto_shortener_proto_rawDescData = protoimpl.X.CompressGZIP(file_internal_rpc_proto_shortener_proto_rawDescData) + }) + return file_internal_rpc_proto_shortener_proto_rawDescData +} + +var file_internal_rpc_proto_shortener_proto_msgTypes = make([]protoimpl.MessageInfo, 17) +var file_internal_rpc_proto_shortener_proto_goTypes = []interface{}{ + (*AddLinkRequest)(nil), // 0: internal.rpc.proto.AddLinkRequest + (*AddLinkResponse)(nil), // 1: internal.rpc.proto.AddLinkResponse + (*GetLinkRequest)(nil), // 2: internal.rpc.proto.GetLinkRequest + (*GetLinkResponse)(nil), // 3: internal.rpc.proto.GetLinkResponse + (*PingRequest)(nil), // 4: internal.rpc.proto.PingRequest + (*PingResponse)(nil), // 5: internal.rpc.proto.PingResponse + (*AddLinkBatchRequest)(nil), // 6: internal.rpc.proto.AddLinkBatchRequest + (*AddLinkBatchResponse)(nil), // 7: internal.rpc.proto.AddLinkBatchResponse + (*GetUsersLinksRequest)(nil), // 8: internal.rpc.proto.GetUsersLinksRequest + (*GetUsersLinksResponse)(nil), // 9: internal.rpc.proto.GetUsersLinksResponse + (*DeleteUserLinksBatchRequest)(nil), // 10: internal.rpc.proto.DeleteUserLinksBatchRequest + (*DeleteUserLinksBatchResponse)(nil), // 11: internal.rpc.proto.DeleteUserLinksBatchResponse + (*GetStatRequest)(nil), // 12: internal.rpc.proto.GetStatRequest + (*GetStatResponse)(nil), // 13: internal.rpc.proto.GetStatResponse + (*AddLinkBatchRequest_Item)(nil), // 14: internal.rpc.proto.AddLinkBatchRequest.Item + (*AddLinkBatchResponse_Item)(nil), // 15: internal.rpc.proto.AddLinkBatchResponse.Item + (*GetUsersLinksResponse_Item)(nil), // 16: internal.rpc.proto.GetUsersLinksResponse.Item +} +var file_internal_rpc_proto_shortener_proto_depIdxs = []int32{ + 14, // 0: internal.rpc.proto.AddLinkBatchRequest.items:type_name -> internal.rpc.proto.AddLinkBatchRequest.Item + 15, // 1: internal.rpc.proto.AddLinkBatchResponse.items:type_name -> internal.rpc.proto.AddLinkBatchResponse.Item + 16, // 2: internal.rpc.proto.GetUsersLinksResponse.items:type_name -> internal.rpc.proto.GetUsersLinksResponse.Item + 0, // 3: internal.rpc.proto.Shortener.AddLink:input_type -> internal.rpc.proto.AddLinkRequest + 2, // 4: internal.rpc.proto.Shortener.GetLink:input_type -> internal.rpc.proto.GetLinkRequest + 4, // 5: internal.rpc.proto.Shortener.Ping:input_type -> internal.rpc.proto.PingRequest + 6, // 6: internal.rpc.proto.Shortener.AddLinkBatch:input_type -> internal.rpc.proto.AddLinkBatchRequest + 8, // 7: internal.rpc.proto.Shortener.GetUserLinks:input_type -> internal.rpc.proto.GetUsersLinksRequest + 10, // 8: internal.rpc.proto.Shortener.DeleteUserLinksBatch:input_type -> internal.rpc.proto.DeleteUserLinksBatchRequest + 12, // 9: internal.rpc.proto.Shortener.GetStat:input_type -> internal.rpc.proto.GetStatRequest + 1, // 10: internal.rpc.proto.Shortener.AddLink:output_type -> internal.rpc.proto.AddLinkResponse + 3, // 11: internal.rpc.proto.Shortener.GetLink:output_type -> internal.rpc.proto.GetLinkResponse + 5, // 12: internal.rpc.proto.Shortener.Ping:output_type -> internal.rpc.proto.PingResponse + 7, // 13: internal.rpc.proto.Shortener.AddLinkBatch:output_type -> internal.rpc.proto.AddLinkBatchResponse + 9, // 14: internal.rpc.proto.Shortener.GetUserLinks:output_type -> internal.rpc.proto.GetUsersLinksResponse + 11, // 15: internal.rpc.proto.Shortener.DeleteUserLinksBatch:output_type -> internal.rpc.proto.DeleteUserLinksBatchResponse + 13, // 16: internal.rpc.proto.Shortener.GetStat:output_type -> internal.rpc.proto.GetStatResponse + 10, // [10:17] is the sub-list for method output_type + 3, // [3:10] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_internal_rpc_proto_shortener_proto_init() } +func file_internal_rpc_proto_shortener_proto_init() { + if File_internal_rpc_proto_shortener_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_internal_rpc_proto_shortener_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddLinkRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_rpc_proto_shortener_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddLinkResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_rpc_proto_shortener_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetLinkRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_rpc_proto_shortener_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetLinkResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_rpc_proto_shortener_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PingRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_rpc_proto_shortener_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PingResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_rpc_proto_shortener_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddLinkBatchRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_rpc_proto_shortener_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddLinkBatchResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_rpc_proto_shortener_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetUsersLinksRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_rpc_proto_shortener_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetUsersLinksResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_rpc_proto_shortener_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteUserLinksBatchRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_rpc_proto_shortener_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DeleteUserLinksBatchResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_rpc_proto_shortener_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetStatRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_rpc_proto_shortener_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetStatResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_rpc_proto_shortener_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddLinkBatchRequest_Item); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_rpc_proto_shortener_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*AddLinkBatchResponse_Item); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_internal_rpc_proto_shortener_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetUsersLinksResponse_Item); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_internal_rpc_proto_shortener_proto_rawDesc, + NumEnums: 0, + NumMessages: 17, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_internal_rpc_proto_shortener_proto_goTypes, + DependencyIndexes: file_internal_rpc_proto_shortener_proto_depIdxs, + MessageInfos: file_internal_rpc_proto_shortener_proto_msgTypes, + }.Build() + File_internal_rpc_proto_shortener_proto = out.File + file_internal_rpc_proto_shortener_proto_rawDesc = nil + file_internal_rpc_proto_shortener_proto_goTypes = nil + file_internal_rpc_proto_shortener_proto_depIdxs = nil +} diff --git a/internal/rpc/proto/shortener.proto b/internal/rpc/proto/shortener.proto new file mode 100644 index 0000000..0a7c9f9 --- /dev/null +++ b/internal/rpc/proto/shortener.proto @@ -0,0 +1,89 @@ +syntax = "proto3"; + +package internal.rpc.proto; + +option go_package = "internal/rpc/proto"; + +//to generate: +//protoc.exe --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative internal/rpc/proto/shortener.proto + +message AddLinkRequest { + string long_link = 1; +} + +message AddLinkResponse { + string short_link = 1; +} + +message GetLinkRequest { + string short_link = 1; +} + +message GetLinkResponse { + string long_link = 1; +} + +message PingRequest { + +} + +message PingResponse { + +} + +message AddLinkBatchRequest { + message Item { + string correlation_id = 1; + string long_url = 2; + } + repeated Item items = 1; +} + +message AddLinkBatchResponse { + message Item { + string correlation_id = 1; + string short_url = 2; + } + repeated Item items = 1; +} + +message GetUsersLinksRequest { + +} + +message GetUsersLinksResponse { + message Item { + string long_url = 1; + string short_url = 2; + } + repeated Item items = 1; +} + +message DeleteUserLinksBatchRequest { + repeated string items = 1; +} + +message DeleteUserLinksBatchResponse { + +} + +message GetStatRequest { + +} + +message GetStatResponse { + int32 urls_cont = 1; + int32 users_cont = 2; +} + +service Shortener { + rpc AddLink(AddLinkRequest) returns (AddLinkResponse); + rpc GetLink(GetLinkRequest) returns (GetLinkResponse); + rpc Ping(PingRequest) returns (PingResponse); + + rpc AddLinkBatch(AddLinkBatchRequest) returns (AddLinkBatchResponse); + rpc GetUserLinks(GetUsersLinksRequest) returns (GetUsersLinksResponse); + rpc DeleteUserLinksBatch(DeleteUserLinksBatchRequest) returns (DeleteUserLinksBatchResponse); + + rpc GetStat(GetStatRequest) returns (GetStatResponse); +} \ No newline at end of file diff --git a/internal/rpc/proto/shortener_grpc.pb.go b/internal/rpc/proto/shortener_grpc.pb.go new file mode 100644 index 0000000..9e547fe --- /dev/null +++ b/internal/rpc/proto/shortener_grpc.pb.go @@ -0,0 +1,321 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.21.5 +// source: internal/rpc/proto/shortener.proto + +package proto + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// ShortenerClient is the client API for Shortener service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type ShortenerClient interface { + AddLink(ctx context.Context, in *AddLinkRequest, opts ...grpc.CallOption) (*AddLinkResponse, error) + GetLink(ctx context.Context, in *GetLinkRequest, opts ...grpc.CallOption) (*GetLinkResponse, error) + Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) + AddLinkBatch(ctx context.Context, in *AddLinkBatchRequest, opts ...grpc.CallOption) (*AddLinkBatchResponse, error) + GetUserLinks(ctx context.Context, in *GetUsersLinksRequest, opts ...grpc.CallOption) (*GetUsersLinksResponse, error) + DeleteUserLinksBatch(ctx context.Context, in *DeleteUserLinksBatchRequest, opts ...grpc.CallOption) (*DeleteUserLinksBatchResponse, error) + GetStat(ctx context.Context, in *GetStatRequest, opts ...grpc.CallOption) (*GetStatResponse, error) +} + +type shortenerClient struct { + cc grpc.ClientConnInterface +} + +func NewShortenerClient(cc grpc.ClientConnInterface) ShortenerClient { + return &shortenerClient{cc} +} + +func (c *shortenerClient) AddLink(ctx context.Context, in *AddLinkRequest, opts ...grpc.CallOption) (*AddLinkResponse, error) { + out := new(AddLinkResponse) + err := c.cc.Invoke(ctx, "/internal.rpc.proto.Shortener/AddLink", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *shortenerClient) GetLink(ctx context.Context, in *GetLinkRequest, opts ...grpc.CallOption) (*GetLinkResponse, error) { + out := new(GetLinkResponse) + err := c.cc.Invoke(ctx, "/internal.rpc.proto.Shortener/GetLink", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *shortenerClient) Ping(ctx context.Context, in *PingRequest, opts ...grpc.CallOption) (*PingResponse, error) { + out := new(PingResponse) + err := c.cc.Invoke(ctx, "/internal.rpc.proto.Shortener/Ping", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *shortenerClient) AddLinkBatch(ctx context.Context, in *AddLinkBatchRequest, opts ...grpc.CallOption) (*AddLinkBatchResponse, error) { + out := new(AddLinkBatchResponse) + err := c.cc.Invoke(ctx, "/internal.rpc.proto.Shortener/AddLinkBatch", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *shortenerClient) GetUserLinks(ctx context.Context, in *GetUsersLinksRequest, opts ...grpc.CallOption) (*GetUsersLinksResponse, error) { + out := new(GetUsersLinksResponse) + err := c.cc.Invoke(ctx, "/internal.rpc.proto.Shortener/GetUserLinks", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *shortenerClient) DeleteUserLinksBatch(ctx context.Context, in *DeleteUserLinksBatchRequest, opts ...grpc.CallOption) (*DeleteUserLinksBatchResponse, error) { + out := new(DeleteUserLinksBatchResponse) + err := c.cc.Invoke(ctx, "/internal.rpc.proto.Shortener/DeleteUserLinksBatch", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *shortenerClient) GetStat(ctx context.Context, in *GetStatRequest, opts ...grpc.CallOption) (*GetStatResponse, error) { + out := new(GetStatResponse) + err := c.cc.Invoke(ctx, "/internal.rpc.proto.Shortener/GetStat", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// ShortenerServer is the server API for Shortener service. +// All implementations must embed UnimplementedShortenerServer +// for forward compatibility +type ShortenerServer interface { + AddLink(context.Context, *AddLinkRequest) (*AddLinkResponse, error) + GetLink(context.Context, *GetLinkRequest) (*GetLinkResponse, error) + Ping(context.Context, *PingRequest) (*PingResponse, error) + AddLinkBatch(context.Context, *AddLinkBatchRequest) (*AddLinkBatchResponse, error) + GetUserLinks(context.Context, *GetUsersLinksRequest) (*GetUsersLinksResponse, error) + DeleteUserLinksBatch(context.Context, *DeleteUserLinksBatchRequest) (*DeleteUserLinksBatchResponse, error) + GetStat(context.Context, *GetStatRequest) (*GetStatResponse, error) + mustEmbedUnimplementedShortenerServer() +} + +// UnimplementedShortenerServer must be embedded to have forward compatible implementations. +type UnimplementedShortenerServer struct { +} + +func (UnimplementedShortenerServer) AddLink(context.Context, *AddLinkRequest) (*AddLinkResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddLink not implemented") +} +func (UnimplementedShortenerServer) GetLink(context.Context, *GetLinkRequest) (*GetLinkResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetLink not implemented") +} +func (UnimplementedShortenerServer) Ping(context.Context, *PingRequest) (*PingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Ping not implemented") +} +func (UnimplementedShortenerServer) AddLinkBatch(context.Context, *AddLinkBatchRequest) (*AddLinkBatchResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method AddLinkBatch not implemented") +} +func (UnimplementedShortenerServer) GetUserLinks(context.Context, *GetUsersLinksRequest) (*GetUsersLinksResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetUserLinks not implemented") +} +func (UnimplementedShortenerServer) DeleteUserLinksBatch(context.Context, *DeleteUserLinksBatchRequest) (*DeleteUserLinksBatchResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DeleteUserLinksBatch not implemented") +} +func (UnimplementedShortenerServer) GetStat(context.Context, *GetStatRequest) (*GetStatResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetStat not implemented") +} +func (UnimplementedShortenerServer) mustEmbedUnimplementedShortenerServer() {} + +// UnsafeShortenerServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to ShortenerServer will +// result in compilation errors. +type UnsafeShortenerServer interface { + mustEmbedUnimplementedShortenerServer() +} + +func RegisterShortenerServer(s grpc.ServiceRegistrar, srv ShortenerServer) { + s.RegisterService(&Shortener_ServiceDesc, srv) +} + +func _Shortener_AddLink_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AddLinkRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ShortenerServer).AddLink(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/internal.rpc.proto.Shortener/AddLink", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ShortenerServer).AddLink(ctx, req.(*AddLinkRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Shortener_GetLink_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetLinkRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ShortenerServer).GetLink(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/internal.rpc.proto.Shortener/GetLink", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ShortenerServer).GetLink(ctx, req.(*GetLinkRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Shortener_Ping_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(PingRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ShortenerServer).Ping(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/internal.rpc.proto.Shortener/Ping", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ShortenerServer).Ping(ctx, req.(*PingRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Shortener_AddLinkBatch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(AddLinkBatchRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ShortenerServer).AddLinkBatch(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/internal.rpc.proto.Shortener/AddLinkBatch", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ShortenerServer).AddLinkBatch(ctx, req.(*AddLinkBatchRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Shortener_GetUserLinks_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetUsersLinksRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ShortenerServer).GetUserLinks(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/internal.rpc.proto.Shortener/GetUserLinks", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ShortenerServer).GetUserLinks(ctx, req.(*GetUsersLinksRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Shortener_DeleteUserLinksBatch_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(DeleteUserLinksBatchRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ShortenerServer).DeleteUserLinksBatch(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/internal.rpc.proto.Shortener/DeleteUserLinksBatch", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ShortenerServer).DeleteUserLinksBatch(ctx, req.(*DeleteUserLinksBatchRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Shortener_GetStat_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetStatRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ShortenerServer).GetStat(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/internal.rpc.proto.Shortener/GetStat", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ShortenerServer).GetStat(ctx, req.(*GetStatRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Shortener_ServiceDesc is the grpc.ServiceDesc for Shortener service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Shortener_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "internal.rpc.proto.Shortener", + HandlerType: (*ShortenerServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "AddLink", + Handler: _Shortener_AddLink_Handler, + }, + { + MethodName: "GetLink", + Handler: _Shortener_GetLink_Handler, + }, + { + MethodName: "Ping", + Handler: _Shortener_Ping_Handler, + }, + { + MethodName: "AddLinkBatch", + Handler: _Shortener_AddLinkBatch_Handler, + }, + { + MethodName: "GetUserLinks", + Handler: _Shortener_GetUserLinks_Handler, + }, + { + MethodName: "DeleteUserLinksBatch", + Handler: _Shortener_DeleteUserLinksBatch_Handler, + }, + { + MethodName: "GetStat", + Handler: _Shortener_GetStat_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "internal/rpc/proto/shortener.proto", +} diff --git a/internal/server/grpcserver.go b/internal/server/grpcserver.go new file mode 100644 index 0000000..91a7b86 --- /dev/null +++ b/internal/server/grpcserver.go @@ -0,0 +1,45 @@ +package server + +import ( + "github.com/zhel1/yandex-practicum-go/internal/config" + "github.com/zhel1/yandex-practicum-go/internal/rpc" + "github.com/zhel1/yandex-practicum-go/internal/rpc/interceptors" + pb "github.com/zhel1/yandex-practicum-go/internal/rpc/proto" + "github.com/zhel1/yandex-practicum-go/internal/service" + "google.golang.org/grpc" + "log" + "net" +) + +// GRPCServer struct +type GRPCServer struct { + grpcServer *grpc.Server + listener net.Listener + enableHTTPS bool +} + +func NewGRPCServer(cfg *config.Config, services *service.Services) *GRPCServer { + server := &GRPCServer{} + var err error + + //TODO Add addr in config + server.listener, err = net.Listen("tcp", ":3200") + if err != nil { + log.Fatal(err) + } + + i := interceptors.InitInterceptors(services) + + server.grpcServer = grpc.NewServer(grpc.UnaryInterceptor(i.UserIDInterceptor)) + pb.RegisterShortenerServer(server.grpcServer, rpc.NewBaseServer(services)) + + return server +} + +func (s *GRPCServer) Run() error { + return s.grpcServer.Serve(s.listener) +} + +func (s *GRPCServer) Stop() { + s.grpcServer.GracefulStop() +} diff --git a/internal/server/server.go b/internal/server/httpserver.go similarity index 74% rename from internal/server/server.go rename to internal/server/httpserver.go index 69384d6..ee62940 100644 --- a/internal/server/server.go +++ b/internal/server/httpserver.go @@ -11,14 +11,14 @@ import ( "net/http" ) -//Server struct -type Server struct { +// HttpServer struct +type HTTPServer struct { httpServer *http.Server enableHTTPS bool } -func NewServer(cfg *config.Config, handler http.Handler) *Server { - server := &Server{ +func NewHTTPServer(cfg *config.Config, handler http.Handler) *HTTPServer { + server := &HTTPServer{ enableHTTPS: cfg.EnableHTTPS, httpServer: &http.Server{ Addr: cfg.Addr, @@ -27,7 +27,7 @@ func NewServer(cfg *config.Config, handler http.Handler) *Server { } if cfg.EnableHTTPS { - cert, key := CreateServerCert() + cert, key := createServerCert() server.httpServer.TLSConfig = &tls.Config{ Certificates: []tls.Certificate{{ Certificate: [][]byte{cert.Raw}, @@ -40,7 +40,7 @@ func NewServer(cfg *config.Config, handler http.Handler) *Server { return server } -func (s *Server) Run() error { +func (s *HTTPServer) Run() error { if s.enableHTTPS { return s.httpServer.ListenAndServeTLS("", "") } else { @@ -48,11 +48,11 @@ func (s *Server) Run() error { } } -func (s *Server) Stop(ctx context.Context) error { +func (s *HTTPServer) Stop(ctx context.Context) error { return s.httpServer.Shutdown(ctx) } -func CreateServerCert() (*x509.Certificate, *rsa.PrivateKey) { +func createServerCert() (*x509.Certificate, *rsa.PrivateKey) { rootCert, _, rootPriv := certificates.GenCARoot() DCACert, _, DCAPriv := certificates.GenDCA(rootCert, rootPriv) serverCert, _, ServerPriv := certificates.GenServerCert(DCACert, DCAPriv) diff --git a/internal/service/internal.go b/internal/service/internal.go new file mode 100644 index 0000000..1cb0fc8 --- /dev/null +++ b/internal/service/internal.go @@ -0,0 +1,47 @@ +package service + +import ( + "context" + "github.com/zhel1/yandex-practicum-go/internal/dto" + "github.com/zhel1/yandex-practicum-go/internal/storage" +) + +// Check interface implementation +var ( + _ Internal = (*InternalService)(nil) +) + +type InternalService struct { + storage storage.Storage +} + +func NewInternalService(storage storage.Storage) *InternalService { + return &InternalService{ + storage: storage, + } +} + +func (s *InternalService) GetURLsCount(ctx context.Context) (int, error) { + return s.storage.GetURLsCount(ctx) +} + +func (s *InternalService) GetUsersCount(ctx context.Context) (int, error) { + return s.storage.GetUserCount(ctx) +} + +func (s *InternalService) GetStatistic(ctx context.Context) (dto.Statistic, error) { + urlsCount, err := s.GetURLsCount(ctx) + if err != nil { + return dto.Statistic{}, err + } + + usersCount, err := s.GetUsersCount(ctx) + if err != nil { + return dto.Statistic{}, err + } + + return dto.Statistic{ + URLsCount: urlsCount, + UsersCount: usersCount, + }, nil +} diff --git a/internal/service/security.go b/internal/service/security.go new file mode 100644 index 0000000..3d6b515 --- /dev/null +++ b/internal/service/security.go @@ -0,0 +1,33 @@ +package service + +import ( + "context" + "net" +) + +// Check interface implementation +var ( + _ Security = (*SecurityService)(nil) +) + +type SecurityService struct { + TrustedSubnet *net.IPNet +} + +func NewSecurityService(trustedSubnet *net.IPNet) *SecurityService { + return &SecurityService{ + TrustedSubnet: trustedSubnet, + } +} + +func (s *SecurityService) IsIpAddrTrusted(ctx context.Context, ipStr string) (bool, error) { + if s.TrustedSubnet == nil { + return true, nil + } + + ip, _, err := net.ParseCIDR(ipStr) + if err != nil { + return false, err + } + return s.TrustedSubnet.Contains(ip), nil +} diff --git a/internal/service/service.go b/internal/service/service.go index 0166538..355dcdc 100644 --- a/internal/service/service.go +++ b/internal/service/service.go @@ -6,6 +6,7 @@ import ( "github.com/zhel1/yandex-practicum-go/internal/auth" "github.com/zhel1/yandex-practicum-go/internal/dto" "github.com/zhel1/yandex-practicum-go/internal/storage" + "net" ) type User interface { @@ -22,20 +23,36 @@ type Shorten interface { ShortenBatchURL(ctx context.Context, userID string, URLs []dto.ModelOriginalURLBatch) ([]dto.ModelShortURLBatch, error) } +type Internal interface { + GetURLsCount(ctx context.Context) (int, error) + GetUsersCount(ctx context.Context) (int, error) + + GetStatistic(ctx context.Context) (dto.Statistic, error) +} + +type Security interface { + IsIpAddrTrusted(ctx context.Context, ipStr string) (bool, error) +} + type Services struct { - Users User - Shorten Shorten + Users User + Shorten Shorten + Internal Internal + Security Security } type Deps struct { - Storage storage.Storage - BaseURL string - TokenManager auth.TokenManager + Storage storage.Storage + BaseURL string + TokenManager auth.TokenManager + TrustedSubnet *net.IPNet } func NewServices(deps Deps) *Services { return &Services{ - Shorten: NewShortenService(deps.Storage, deps.BaseURL), - Users: NewUserService(deps.Storage, deps.BaseURL, deps.TokenManager), + Shorten: NewShortenService(deps.Storage, deps.BaseURL), + Users: NewUserService(deps.Storage, deps.BaseURL, deps.TokenManager), + Internal: NewInternalService(deps.Storage), + Security: NewSecurityService(deps.TrustedSubnet), } } diff --git a/internal/service/shorten.go b/internal/service/shorten.go index cec4dee..572293a 100644 --- a/internal/service/shorten.go +++ b/internal/service/shorten.go @@ -32,6 +32,10 @@ func (s *ShortenService) ShortenURL(ctx context.Context, userID string, URL dto. return dto.ModelShortURL{}, err } + if userID == "" { + return dto.ModelShortURL{}, dto.ErrInvalidArgument + } + shortIDLink := utils.MD5(URL.OriginalURL)[:8] response := dto.ModelShortURL{ @@ -50,6 +54,10 @@ func (s *ShortenService) ShortenURL(ctx context.Context, userID string, URL dto. } func (s *ShortenService) ShortenBatchURL(ctx context.Context, userID string, URLs []dto.ModelOriginalURLBatch) ([]dto.ModelShortURLBatch, error) { + if userID == "" || len(URLs) == 0 { + return nil, dto.ErrInvalidArgument + } + bResArr := make([]dto.ModelShortURLBatch, 0, len(URLs)) batchForDB := make(map[string]string, len(URLs)) diff --git a/internal/service/user.go b/internal/service/user.go index a886ddc..9e74b43 100644 --- a/internal/service/user.go +++ b/internal/service/user.go @@ -50,8 +50,12 @@ func (s *UserService) GetOriginalURLByShort(ctx context.Context, shortURL string return s.storage.Get(ctx, shortURL) } -func (s *UserService) GetURLsByUserID(ctx context.Context, UserID string) ([]dto.ModelURL, error) { - links, err := s.storage.GetUserLinks(ctx, UserID) +func (s *UserService) GetURLsByUserID(ctx context.Context, userID string) ([]dto.ModelURL, error) { + if userID == "" { + return nil, dto.ErrInvalidArgument + } + + links, err := s.storage.GetUserLinks(ctx, userID) if err != nil { return nil, err } @@ -69,6 +73,10 @@ func (s *UserService) GetURLsByUserID(ctx context.Context, UserID string) ([]dto } func (s *UserService) DeleteBatchURL(ctx context.Context, userID string, shortURLs []string) error { + if userID == "" { + return dto.ErrInvalidArgument + } + // perform asynchronous deletion return s.storage.Delete(ctx, shortURLs, userID) } diff --git a/internal/storage/infile/storage.go b/internal/storage/infile/storage.go index 3c89fa4..73ad9b0 100644 --- a/internal/storage/infile/storage.go +++ b/internal/storage/infile/storage.go @@ -83,6 +83,16 @@ func (s *Storage) Delete(ctx context.Context, shortURLs []string, userID string) return nil } +// GetURLsCount returns the mount of all urls in DB +func (s *Storage) GetURLsCount(ctx context.Context) (int, error) { + return s.cache.GetURLsCount(ctx) +} + +// GetURLsCount returns the mount of all users in DB +func (s *Storage) GetUserCount(ctx context.Context) (int, error) { + return s.cache.GetUserCount(ctx) +} + // Close removes cache and close thr file func (s *Storage) Close() error { s.cache = nil diff --git a/internal/storage/inmemory/storage.go b/internal/storage/inmemory/storage.go index bc75c89..e6c1b2f 100644 --- a/internal/storage/inmemory/storage.go +++ b/internal/storage/inmemory/storage.go @@ -94,6 +94,25 @@ func (s *Storage) Delete(ctx context.Context, shortURLs []string, userID string) return nil } +// GetURLsCount returns the mount of all urls in DB +func (s *Storage) GetURLsCount(ctx context.Context) (int, error) { + urlsCount := 0 + for _, userData := range s.m { + urlsCount = +len(userData.URLs) + } + return urlsCount, nil +} + +// GetURLsCount returns the mount of all users in DB +func (s *Storage) GetUserCount(ctx context.Context) (int, error) { + return len(s.m), nil +} + +//PingDB checks connection to DB +func (s *Storage) PingDB() error { + return nil +} + // Close clears the map with user data. func (s *Storage) Close() error { s.Lock() diff --git a/internal/storage/inpsql/storage.go b/internal/storage/inpsql/storage.go index 662c84e..9ea1b2a 100644 --- a/internal/storage/inpsql/storage.go +++ b/internal/storage/inpsql/storage.go @@ -417,6 +417,44 @@ func (s *Storage) Close() error { return nil } +func (s *Storage) GetURLsCount(ctx context.Context) (int, error) { + getURLsCountStmt, err := s.DB.PrepareContext(ctx, "SELECT COUNT(*) FROM urls;") + if err != nil { + return 0, &storageErrors.StatementPSQLError{Err: err} + } + defer getURLsCountStmt.Close() + + var count int + if err := getURLsCountStmt.QueryRowContext(ctx).Scan(&count); err != nil { + switch { + case errors.Is(err, sql.ErrNoRows): + return 0, &storageErrors.NotFoundError{Err: dto.ErrNotFound} + default: + return 0, &storageErrors.ExecutionPSQLError{Err: err} + } + } + return count, nil +} + +func (s *Storage) GetUserCount(ctx context.Context) (int, error) { + getUserCountStmt, err := s.DB.PrepareContext(ctx, "select COUNT(DISTINCT user_id) from users_url;") + if err != nil { + return 0, &storageErrors.StatementPSQLError{Err: err} + } + defer getUserCountStmt.Close() + + var count int + if err := getUserCountStmt.QueryRowContext(ctx).Scan(&count); err != nil { + switch { + case errors.Is(err, sql.ErrNoRows): + return 0, &storageErrors.NotFoundError{Err: dto.ErrNotFound} + default: + return 0, &storageErrors.ExecutionPSQLError{Err: err} + } + } + return count, nil +} + //********************************************************************************************************************** // ************************************ WAITING FOR A COMMENT FROM MENTORS ********************************************* //********************************************************************************************************************** diff --git a/internal/storage/storage.go b/internal/storage/storage.go index 757af2f..8a418c8 100644 --- a/internal/storage/storage.go +++ b/internal/storage/storage.go @@ -36,4 +36,7 @@ type Storage interface { PutBatch(ctx context.Context, userID string, batchForDB map[string]string) error Delete(ctx context.Context, shortURLs []string, userID string) error Close() error + + GetURLsCount(ctx context.Context) (int, error) + GetUserCount(ctx context.Context) (int, error) } diff --git a/internal/utils/utils.go b/internal/utils/utils.go index b44ab1c..39dfce2 100644 --- a/internal/utils/utils.go +++ b/internal/utils/utils.go @@ -2,8 +2,11 @@ package utils import ( + "context" "crypto/md5" + "errors" "fmt" + "github.com/zhel1/yandex-practicum-go/internal/dto" ) //MD5 generates a fixed length hash from a string @@ -11,3 +14,15 @@ func MD5(data string) string { h := md5.Sum([]byte(data)) return fmt.Sprintf("%x", h) } + +func ExtractValueFromContext(context context.Context, name interface{}) (string, error) { + value := "" + if id := context.Value(name); id != nil { + value = id.(string) + } + + if value == "" { + return "", errors.New("empty " + name.(dto.UserConst).String()) //TODO + } + return value, nil +}