diff --git a/cmd/likit.go b/cmd/likit.go index 3ebb499..5160cb8 100644 --- a/cmd/likit.go +++ b/cmd/likit.go @@ -2,6 +2,7 @@ package cmd import ( "github.com/CorrectRoadH/Likit/config" + "github.com/CorrectRoadH/Likit/internal/adapter/in/grpc" "github.com/CorrectRoadH/Likit/internal/adapter/in/restful" "github.com/CorrectRoadH/Likit/internal/adapter/in/restful/route" "github.com/CorrectRoadH/Likit/internal/adapter/out/admin" @@ -19,6 +20,9 @@ func Main() { route.NewAdminApiService, + grpc.NewGrpcServer, + grpc.NewVoteGRPCServer, + server.NewVoteServer, server.NewAdminServer, server.NewDatabaseServer, @@ -34,7 +38,7 @@ func Main() { database.NewRedisAdapter, database.NewPostgresAdapter, ), - fx.Invoke(func(s *restful.RESTfulServer) { + fx.Invoke(func(s *restful.RESTfulServer, g *grpc.GrpcServer) { s.Start() }), ).Run() diff --git a/go.mod b/go.mod index c59cdae..a5ae75c 100644 --- a/go.mod +++ b/go.mod @@ -3,13 +3,25 @@ module github.com/CorrectRoadH/Likit go 1.21.4 require ( + google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect + google.golang.org/grpc v1.58.2 + google.golang.org/protobuf v1.31.0 + +) + +require ( + connectrpc.com/connect v1.13.0 + github.com/deepmap/oapi-codegen v1.16.2 github.com/getkin/kin-openapi v0.122.0 + github.com/google/uuid v1.4.0 + github.com/jackc/pgx/v4 v4.18.1 github.com/labstack/echo/v4 v4.11.3 github.com/onsi/ginkgo/v2 v2.13.2 github.com/onsi/gomega v1.30.0 github.com/redis/go-redis/v9 v9.3.0 github.com/sourcegraph/conc v0.3.0 go.uber.org/fx v1.20.1 + google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb gorm.io/driver/postgres v1.5.4 gorm.io/gorm v1.25.5 ) @@ -25,7 +37,6 @@ require ( github.com/aymerick/douceur v0.2.0 // indirect github.com/bytedance/sonic v1.9.1 // indirect github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect - github.com/deepmap/oapi-codegen v1.16.2 // indirect github.com/fatih/structs v1.1.0 // indirect github.com/flosch/pongo2/v4 v4.0.2 // indirect github.com/gabriel-vasile/mimetype v1.4.2 // indirect @@ -35,9 +46,9 @@ require ( github.com/go-playground/universal-translator v0.18.1 // indirect github.com/go-playground/validator/v10 v10.14.0 // indirect github.com/goccy/go-json v0.10.2 // indirect + github.com/golang/protobuf v1.5.3 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/gomarkdown/markdown v0.0.0-20230716120725-531d2d74bc12 // indirect - github.com/google/uuid v1.4.0 // indirect github.com/gorilla/css v1.0.0 // indirect github.com/iris-contrib/schema v0.0.6 // indirect github.com/jackc/chunkreader/v2 v2.0.1 // indirect @@ -45,7 +56,6 @@ require ( github.com/jackc/pgio v1.0.0 // indirect github.com/jackc/pgproto3/v2 v2.3.2 // indirect github.com/jackc/pgtype v1.14.0 // indirect - github.com/jackc/pgx/v4 v4.18.1 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/kataras/blocks v0.0.7 // indirect github.com/kataras/golog v0.1.9 // indirect @@ -71,6 +81,7 @@ require ( github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect github.com/yosssi/ace v0.0.5 // indirect golang.org/x/arch v0.3.0 // indirect + google.golang.org/genproto v0.0.0-20230920204549-e6e6cdab5c13 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) @@ -112,6 +123,5 @@ require ( golang.org/x/text v0.13.0 // indirect golang.org/x/time v0.3.0 // indirect golang.org/x/tools v0.14.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index a807b43..e01ff9e 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +connectrpc.com/connect v1.13.0 h1:lGs5maZZzWOOD+PFFiOt5OncKmMsk9ZdPwpy5jcmaYg= +connectrpc.com/connect v1.13.0/go.mod h1:uHAFHtYgeSZJxXrkN1IunDpKghnTXhYbVh0wW4StPW0= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8= github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ= @@ -5,6 +7,7 @@ github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53 h1:sR+/8Yb4s github.com/CloudyKit/fastprinter v0.0.0-20200109182630-33d98a066a53/go.mod h1:+3IMCy2vIlbG1XG/0ggNQv0SvxCAIpPM5b1nCz56Xno= github.com/CloudyKit/jet/v6 v6.2.0 h1:EpcZ6SR9n28BUGtNJSvlBqf90IpjeFr36Tizxhn/oME= github.com/CloudyKit/jet/v6 v6.2.0/go.mod h1:d3ypHeIRNo2+XyqnGA8s+aphtcVpjP5hPwP/Lzo7Ro4= +github.com/Joker/hpp v1.0.0 h1:65+iuJYdRXv/XyN62C1uEmmOx3432rNG/rKlX6V7Kkc= github.com/Joker/hpp v1.0.0/go.mod h1:8x5n+M1Hp5hC0g8okX3sR3vFQwynaX/UgSOM9MeBKzY= github.com/Joker/jade v1.1.3 h1:Qbeh12Vq6BxURXT1qZBRHsDxeURB8ztcL6f3EXSGeHk= github.com/Joker/jade v1.1.3/go.mod h1:T+2WLyt7VH6Lp0TRxQrUYEs64nRc83wkMQrfeIQKduM= @@ -12,6 +15,8 @@ github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0 github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk= github.com/Shopify/goreferrer v0.0.0-20220729165902-8cddb4f5de06 h1:KkH3I3sJuOLP3TjA/dfr4NAY8bghDwnXiU7cTKxQqo0= github.com/Shopify/goreferrer v0.0.0-20220729165902-8cddb4f5de06/go.mod h1:7erjKLwalezA0k99cWs5L11HWOAPNjdUZ6RxH1BXbbM= +github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= +github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= github.com/andybalholm/brotli v1.0.5 h1:8uQZIdzKmjc/iuPu7O2ioW48L81FgatrcpfFmiq/cCs= github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ= @@ -36,6 +41,7 @@ github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583j github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I= 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= @@ -48,6 +54,8 @@ github.com/deepmap/oapi-codegen v1.16.2 h1:xGHx0dNqYfy9gE8a7AVgVM8Sd5oF9SEgePzP+ github.com/deepmap/oapi-codegen v1.16.2/go.mod h1:rdYoEA2GE+riuZ91DvpmBX9hJbQpuY9wchXpfQ3n+ho= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= +github.com/fatih/color v1.15.0 h1:kOqh6YHBtK8aywxGerMG2Eq3H6Qgoqeo13Bk2Mv/nBs= +github.com/fatih/color v1.15.0/go.mod h1:0h5ZqXfHYED7Bhv2ZJamyIOUej9KtShiJESRwBDUSsw= github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= github.com/flosch/pongo2/v4 v4.0.2 h1:gv+5Pe3vaSVmiJvh/BZa82b7/00YUGm0PIyVVLop0Hw= @@ -69,6 +77,8 @@ github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaL github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= github.com/go-openapi/swag v0.22.4 h1:QLMzNJnMGPRNDCbySlcj1x01tzU8/9LTTL9hZZZogBU= github.com/go-openapi/swag v0.22.4/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s= +github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA= github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY= github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= @@ -80,8 +90,11 @@ github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEe github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/go-test/deep v1.0.8 h1:TDsG77qcSprGbC6vTN8OuXp5g+J+b5Pcguhf7Zt61VM= github.com/go-test/deep v1.0.8/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE= +github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y= +github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8= github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU= github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw= github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM= github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= @@ -95,6 +108,8 @@ github.com/gomarkdown/markdown v0.0.0-20230716120725-531d2d74bc12/go.mod h1:JDGc github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8= +github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE= github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= @@ -103,12 +118,17 @@ github.com/google/uuid v1.4.0 h1:MtMxsa51/r9yyhkyLsVeVt0B+BGQZzpQiTQ4eHZ8bc4= github.com/google/uuid v1.4.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/css v1.0.0 h1:BQqNyPTi50JCFMTw/b67hByjMVXZRwGha6wxVGkeihY= github.com/gorilla/css v1.0.0/go.mod h1:Dn721qIggHpt4+EFCcTLTU/vk5ySda2ReITrtgBl60c= +github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc= +github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/imkira/go-interpol v1.1.0 h1:KIiKr0VSG2CUW1hl1jpiyuzuJeKUUpC8iM1AIE7N1Vk= +github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA= github.com/invopop/yaml v0.2.0 h1:7zky/qH+O0DwAyoobXUqvVBwgBFRxKoQ/3FjcVpjTMY= github.com/invopop/yaml v0.2.0/go.mod h1:2XuRLgs/ouIrW3XNzuNj7J3Nvu/Dig5MXvbCEdiBN3Q= +github.com/iris-contrib/httpexpect/v2 v2.15.2 h1:T9THsdP1woyAqKHwjkEsbCnMefsAFvk8iJJKokcJ3Go= +github.com/iris-contrib/httpexpect/v2 v2.15.2/go.mod h1:JLDgIqnFy5loDSUv1OA2j0mb6p/rDhiCqigP22Uq9xE= github.com/iris-contrib/schema v0.0.6 h1:CPSBLyx2e91H2yJzPuhGuifVRnZBBJ3pCOMbOvPZaTw= github.com/iris-contrib/schema v0.0.6/go.mod h1:iYszG0IOsuIsfzjymw1kMzTL8YQcCWlm65f3wX8J5iA= -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= @@ -125,10 +145,10 @@ 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 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc= 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= @@ -206,6 +226,7 @@ github.com/leodido/go-urn v1.2.4/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNa 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 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8= github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= github.com/mailgun/raymond/v2 v2.0.48 h1:5dmlB680ZkFG2RN/0lvTAghrSxIESeu9/2aeDqACtjw= github.com/mailgun/raymond/v2 v2.0.48/go.mod h1:lsgvL50kgt1ylcFJYZiULi5fjPBkkhNfj4KA0W54Z18= @@ -225,6 +246,8 @@ github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APP github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/microcosm-cc/bluemonday v1.0.25 h1:4NEwSfiJ+Wva0VxN5B8OwMicaJvD8r9tlJWm9rtloEg= github.com/microcosm-cc/bluemonday v1.0.25/go.mod h1:ZIOjCQp1OrzBBPIJmfX4qDYFuhU02nx4bn030ixfHLE= +github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0= +github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -257,10 +280,15 @@ github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA= github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA= +github.com/sanity-io/litter v1.5.5 h1:iE+sBxPBzoK6uaEP5Lt3fHNgpKcHXc/A2HGETy0uJQo= +github.com/sanity-io/litter v1.5.5/go.mod h1:9gzJgR2i4ZpjZHsKvUXIRQVk7P+yM3e+jAF7bU2UI5U= github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0= github.com/schollz/closestmatch v2.1.0+incompatible h1:Uel2GXEpJqOWBrlyI+oY9LTiyyjYS17cCYRqP13/SHk= github.com/schollz/closestmatch v2.1.0+incompatible/go.mod h1:RtP1ddjLong6gTkbtmuhtR2uUrrJOpYzYRvbcPAid+g= +github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ= +github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4= +github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ= 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= @@ -291,6 +319,7 @@ github.com/tdewolff/minify/v2 v2.12.9 h1:dvn5MtmuQ/DFMwqf5j8QhEVpPX6fi3WGImhv8RU github.com/tdewolff/minify/v2 v2.12.9/go.mod h1:qOqdlDfL+7v0/fyymB+OP497nIxJYSvX4MQWA8OoiXU= github.com/tdewolff/parse/v2 v2.6.8 h1:mhNZXYCx//xG7Yq2e/kVLNZw4YfYmeHbhx+Zc0OvFMA= github.com/tdewolff/parse/v2 v2.6.8/go.mod h1:XHDhaU6IBgsryfdnpzUXBlT6leW/l25yrFBTEb4eIyM= +github.com/tdewolff/test v1.0.9 h1:SswqJCmeN4B+9gEAi/5uqT0qpi1y2/2O47V/1hhGZT0= github.com/tdewolff/test v1.0.9/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE= github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI= github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08= @@ -305,8 +334,20 @@ github.com/vmihailenco/msgpack/v5 v5.3.5 h1:5gO0H1iULLWGhs2H5tbAHIZTV8/cYafcFOr9 github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/tagparser/v2 v2.0.0 h1:y09buUbR+b5aycVFQs/g70pqKVZNBmxwAhO7/IwNM9g= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= +github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY= +github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI= github.com/yosssi/ace v0.0.5 h1:tUkIP/BLdKqrlrPwcmH0shwEEhTRHoGnc1wFIWmaBUA= github.com/yosssi/ace v0.0.5/go.mod h1:ALfIzm2vT7t5ZE7uoIZqF3TQ7SAOyupFZnkrF5id+K0= +github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA= +github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg= +github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M= +github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM= 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= @@ -432,7 +473,16 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T 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/genproto v0.0.0-20230920204549-e6e6cdab5c13 h1:vlzZttNJGVqTsRFU9AmdnrcO1Znh8Ew9kCD//yjigk0= +google.golang.org/genproto v0.0.0-20230920204549-e6e6cdab5c13/go.mod h1:CCviP9RmpZ1mxVr8MUjCnSiY09IbAXZxhLE6EhHIdPU= +google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb h1:lK0oleSc7IQsUxO3U5TjL9DWlsxpEBemh+zpB7IqhWI= +google.golang.org/genproto/googleapis/api v0.0.0-20230913181813-007df8e322eb/go.mod h1:KjSP20unUpOx5kyQUFa7k4OJg0qeJ7DEZflGDu2p6Bk= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 h1:6GQBEOdGkX6MMTLT9V+TjtIRZCw9VPD5Z+yHY9wMgS0= +google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97/go.mod h1:v7nGkzlmW8P3n/bKmWBn2WpBjpOEx8Q6gMueudAmKfY= +google.golang.org/grpc v1.58.2 h1:SXUpjxeVF3FKrTYQI4f4KvbGD5u2xccdYdurwowix5I= +google.golang.org/grpc v1.58.2/go.mod h1:tgX3ZQDlNJGU96V6yHh1T/JeoBQ2TXdr43YbYSsCJk0= 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.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= @@ -445,6 +495,7 @@ gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:a gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= @@ -456,4 +507,6 @@ gorm.io/driver/postgres v1.5.4/go.mod h1:Bgo89+h0CRcdA33Y6frlaHHVuTdOf87pmyzwW9C gorm.io/gorm v1.25.5 h1:zR9lOiiYf09VNh5Q1gphfyia1JpiClIWG9hQaxB/mls= gorm.io/gorm v1.25.5/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8= honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +moul.io/http2curl/v2 v2.3.0 h1:9r3JfDzWPcbIklMOs2TnIFzDYvfAZvjeavG6EzP7jYs= +moul.io/http2curl/v2 v2.3.0/go.mod h1:RW4hyBjTWSYDOxapodpNEtX0g5Eb16sxklBqmd2RHcE= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= diff --git a/grpc/api/v1/vote.proto b/grpc/api/v1/vote.proto index 6f0acf9..3181efa 100644 --- a/grpc/api/v1/vote.proto +++ b/grpc/api/v1/vote.proto @@ -9,15 +9,11 @@ import "google/api/field_behavior.proto"; import "google/protobuf/timestamp.proto"; service VoteService { - rpc Vote(VoteRequest) returns (VoteResponse) { - option (google.api.http) = { get: "/v1/vote" }; - } - rpc UnVote(VoteRequest) returns (VoteResponse) { - option (google.api.http) = { get: "/v1/unvote" }; - } - rpc Count(CountRequest) returns (CountResponse) { - - } + rpc Vote(VoteRequest) returns (VoteResponse) {} + rpc UnVote(VoteRequest) returns (VoteResponse) {} + rpc Count(CountRequest) returns (CountResponse) {} + rpc IsVoted(IsVotedRequest) returns (IsVotedResponse) {} + rpc VotedUsers(VotedUsersRequest) returns (VotedUsersResponse) {} } @@ -40,3 +36,21 @@ message CountResponse { int64 count = 1; } +message IsVotedRequest { + string business_id = 1; + string message_id = 2; + string user_id = 3; +} + +message IsVotedResponse { + bool is_voted = 1; +} + +message VotedUsersRequest { + string business_id = 1; + string message_id = 2; +} + +message VotedUsersResponse { + repeated string user_ids = 1; +} diff --git a/grpc/buf.lock b/grpc/buf.lock new file mode 100644 index 0000000..03ad7be --- /dev/null +++ b/grpc/buf.lock @@ -0,0 +1,13 @@ +# Generated by buf. DO NOT EDIT. +version: v1 +deps: + - remote: buf.build + owner: googleapis + repository: googleapis + commit: b30c5775bfb3485d9da2e87b26590ac9 + digest: shake256:9d0caaf056949a0e1c883b9849d8a2fa66e22f18a2a48f867d1a8c700aa22abee50ad3ef0d8171637457cadc43c584998bdf3adac55da0f9e4614c72686b057d + - remote: buf.build + owner: grpc-ecosystem + repository: grpc-gateway + commit: 3f42134f4c564983838425bc43c7a65f + digest: shake256:3d11d4c0fe5e05fda0131afefbce233940e27f0c31c5d4e385686aea58ccd30f72053f61af432fa83f1fc11cda57f5f18ca3da26a29064f73c5a0d076bba8d92 diff --git a/grpc/buf.yaml b/grpc/buf.yaml index e69de29..15c41f4 100644 --- a/grpc/buf.yaml +++ b/grpc/buf.yaml @@ -0,0 +1,11 @@ +version: v1 +name: buf.build/likit/likit +breaking: + use: + - FILE +lint: + use: + - DEFAULT +deps: + - buf.build/googleapis/googleapis + - buf.build/grpc-ecosystem/grpc-gateway \ No newline at end of file diff --git a/grpc/gen/api/v1/apiv1connect/vote.connect.go b/grpc/gen/api/v1/apiv1connect/vote.connect.go new file mode 100644 index 0000000..4a9c689 --- /dev/null +++ b/grpc/gen/api/v1/apiv1connect/vote.connect.go @@ -0,0 +1,208 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: api/v1/vote.proto + +package apiv1connect + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + v1 "github.com/CorrectRoadH/Likit/grpc/gen/api/v1" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion0_1_0 + +const ( + // VoteServiceName is the fully-qualified name of the VoteService service. + VoteServiceName = "likit.api.v1.VoteService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // VoteServiceVoteProcedure is the fully-qualified name of the VoteService's Vote RPC. + VoteServiceVoteProcedure = "/likit.api.v1.VoteService/Vote" + // VoteServiceUnVoteProcedure is the fully-qualified name of the VoteService's UnVote RPC. + VoteServiceUnVoteProcedure = "/likit.api.v1.VoteService/UnVote" + // VoteServiceCountProcedure is the fully-qualified name of the VoteService's Count RPC. + VoteServiceCountProcedure = "/likit.api.v1.VoteService/Count" + // VoteServiceIsVotedProcedure is the fully-qualified name of the VoteService's IsVoted RPC. + VoteServiceIsVotedProcedure = "/likit.api.v1.VoteService/IsVoted" + // VoteServiceVotedUsersProcedure is the fully-qualified name of the VoteService's VotedUsers RPC. + VoteServiceVotedUsersProcedure = "/likit.api.v1.VoteService/VotedUsers" +) + +// VoteServiceClient is a client for the likit.api.v1.VoteService service. +type VoteServiceClient interface { + Vote(context.Context, *connect.Request[v1.VoteRequest]) (*connect.Response[v1.VoteResponse], error) + UnVote(context.Context, *connect.Request[v1.VoteRequest]) (*connect.Response[v1.VoteResponse], error) + Count(context.Context, *connect.Request[v1.CountRequest]) (*connect.Response[v1.CountResponse], error) + IsVoted(context.Context, *connect.Request[v1.IsVotedRequest]) (*connect.Response[v1.IsVotedResponse], error) + VotedUsers(context.Context, *connect.Request[v1.VotedUsersRequest]) (*connect.Response[v1.VotedUsersResponse], error) +} + +// NewVoteServiceClient constructs a client for the likit.api.v1.VoteService service. By default, it +// uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and sends +// uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() or +// connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewVoteServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) VoteServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &voteServiceClient{ + vote: connect.NewClient[v1.VoteRequest, v1.VoteResponse]( + httpClient, + baseURL+VoteServiceVoteProcedure, + opts..., + ), + unVote: connect.NewClient[v1.VoteRequest, v1.VoteResponse]( + httpClient, + baseURL+VoteServiceUnVoteProcedure, + opts..., + ), + count: connect.NewClient[v1.CountRequest, v1.CountResponse]( + httpClient, + baseURL+VoteServiceCountProcedure, + opts..., + ), + isVoted: connect.NewClient[v1.IsVotedRequest, v1.IsVotedResponse]( + httpClient, + baseURL+VoteServiceIsVotedProcedure, + opts..., + ), + votedUsers: connect.NewClient[v1.VotedUsersRequest, v1.VotedUsersResponse]( + httpClient, + baseURL+VoteServiceVotedUsersProcedure, + opts..., + ), + } +} + +// voteServiceClient implements VoteServiceClient. +type voteServiceClient struct { + vote *connect.Client[v1.VoteRequest, v1.VoteResponse] + unVote *connect.Client[v1.VoteRequest, v1.VoteResponse] + count *connect.Client[v1.CountRequest, v1.CountResponse] + isVoted *connect.Client[v1.IsVotedRequest, v1.IsVotedResponse] + votedUsers *connect.Client[v1.VotedUsersRequest, v1.VotedUsersResponse] +} + +// Vote calls likit.api.v1.VoteService.Vote. +func (c *voteServiceClient) Vote(ctx context.Context, req *connect.Request[v1.VoteRequest]) (*connect.Response[v1.VoteResponse], error) { + return c.vote.CallUnary(ctx, req) +} + +// UnVote calls likit.api.v1.VoteService.UnVote. +func (c *voteServiceClient) UnVote(ctx context.Context, req *connect.Request[v1.VoteRequest]) (*connect.Response[v1.VoteResponse], error) { + return c.unVote.CallUnary(ctx, req) +} + +// Count calls likit.api.v1.VoteService.Count. +func (c *voteServiceClient) Count(ctx context.Context, req *connect.Request[v1.CountRequest]) (*connect.Response[v1.CountResponse], error) { + return c.count.CallUnary(ctx, req) +} + +// IsVoted calls likit.api.v1.VoteService.IsVoted. +func (c *voteServiceClient) IsVoted(ctx context.Context, req *connect.Request[v1.IsVotedRequest]) (*connect.Response[v1.IsVotedResponse], error) { + return c.isVoted.CallUnary(ctx, req) +} + +// VotedUsers calls likit.api.v1.VoteService.VotedUsers. +func (c *voteServiceClient) VotedUsers(ctx context.Context, req *connect.Request[v1.VotedUsersRequest]) (*connect.Response[v1.VotedUsersResponse], error) { + return c.votedUsers.CallUnary(ctx, req) +} + +// VoteServiceHandler is an implementation of the likit.api.v1.VoteService service. +type VoteServiceHandler interface { + Vote(context.Context, *connect.Request[v1.VoteRequest]) (*connect.Response[v1.VoteResponse], error) + UnVote(context.Context, *connect.Request[v1.VoteRequest]) (*connect.Response[v1.VoteResponse], error) + Count(context.Context, *connect.Request[v1.CountRequest]) (*connect.Response[v1.CountResponse], error) + IsVoted(context.Context, *connect.Request[v1.IsVotedRequest]) (*connect.Response[v1.IsVotedResponse], error) + VotedUsers(context.Context, *connect.Request[v1.VotedUsersRequest]) (*connect.Response[v1.VotedUsersResponse], error) +} + +// NewVoteServiceHandler builds an HTTP handler from the service implementation. It returns the path +// on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewVoteServiceHandler(svc VoteServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + voteServiceVoteHandler := connect.NewUnaryHandler( + VoteServiceVoteProcedure, + svc.Vote, + opts..., + ) + voteServiceUnVoteHandler := connect.NewUnaryHandler( + VoteServiceUnVoteProcedure, + svc.UnVote, + opts..., + ) + voteServiceCountHandler := connect.NewUnaryHandler( + VoteServiceCountProcedure, + svc.Count, + opts..., + ) + voteServiceIsVotedHandler := connect.NewUnaryHandler( + VoteServiceIsVotedProcedure, + svc.IsVoted, + opts..., + ) + voteServiceVotedUsersHandler := connect.NewUnaryHandler( + VoteServiceVotedUsersProcedure, + svc.VotedUsers, + opts..., + ) + return "/likit.api.v1.VoteService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case VoteServiceVoteProcedure: + voteServiceVoteHandler.ServeHTTP(w, r) + case VoteServiceUnVoteProcedure: + voteServiceUnVoteHandler.ServeHTTP(w, r) + case VoteServiceCountProcedure: + voteServiceCountHandler.ServeHTTP(w, r) + case VoteServiceIsVotedProcedure: + voteServiceIsVotedHandler.ServeHTTP(w, r) + case VoteServiceVotedUsersProcedure: + voteServiceVotedUsersHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedVoteServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedVoteServiceHandler struct{} + +func (UnimplementedVoteServiceHandler) Vote(context.Context, *connect.Request[v1.VoteRequest]) (*connect.Response[v1.VoteResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("likit.api.v1.VoteService.Vote is not implemented")) +} + +func (UnimplementedVoteServiceHandler) UnVote(context.Context, *connect.Request[v1.VoteRequest]) (*connect.Response[v1.VoteResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("likit.api.v1.VoteService.UnVote is not implemented")) +} + +func (UnimplementedVoteServiceHandler) Count(context.Context, *connect.Request[v1.CountRequest]) (*connect.Response[v1.CountResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("likit.api.v1.VoteService.Count is not implemented")) +} + +func (UnimplementedVoteServiceHandler) IsVoted(context.Context, *connect.Request[v1.IsVotedRequest]) (*connect.Response[v1.IsVotedResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("likit.api.v1.VoteService.IsVoted is not implemented")) +} + +func (UnimplementedVoteServiceHandler) VotedUsers(context.Context, *connect.Request[v1.VotedUsersRequest]) (*connect.Response[v1.VotedUsersResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("likit.api.v1.VoteService.VotedUsers is not implemented")) +} diff --git a/grpc/gen/api/v1/vote.pb.go b/grpc/gen/api/v1/vote.pb.go new file mode 100644 index 0000000..cd82d79 --- /dev/null +++ b/grpc/gen/api/v1/vote.pb.go @@ -0,0 +1,698 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.31.0 +// protoc (unknown) +// source: api/v1/vote.proto + +package apiv1 + +import ( + _ "google.golang.org/genproto/googleapis/api/annotations" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + _ "google.golang.org/protobuf/types/known/fieldmaskpb" + _ "google.golang.org/protobuf/types/known/timestamppb" + 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 VoteRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BusinessId string `protobuf:"bytes,1,opt,name=business_id,json=businessId,proto3" json:"business_id,omitempty"` + MessageId string `protobuf:"bytes,2,opt,name=message_id,json=messageId,proto3" json:"message_id,omitempty"` + UserId string `protobuf:"bytes,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` +} + +func (x *VoteRequest) Reset() { + *x = VoteRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_api_v1_vote_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *VoteRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*VoteRequest) ProtoMessage() {} + +func (x *VoteRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_v1_vote_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 VoteRequest.ProtoReflect.Descriptor instead. +func (*VoteRequest) Descriptor() ([]byte, []int) { + return file_api_v1_vote_proto_rawDescGZIP(), []int{0} +} + +func (x *VoteRequest) GetBusinessId() string { + if x != nil { + return x.BusinessId + } + return "" +} + +func (x *VoteRequest) GetMessageId() string { + if x != nil { + return x.MessageId + } + return "" +} + +func (x *VoteRequest) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +type VoteResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Count int64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` +} + +func (x *VoteResponse) Reset() { + *x = VoteResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_api_v1_vote_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *VoteResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*VoteResponse) ProtoMessage() {} + +func (x *VoteResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_v1_vote_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 VoteResponse.ProtoReflect.Descriptor instead. +func (*VoteResponse) Descriptor() ([]byte, []int) { + return file_api_v1_vote_proto_rawDescGZIP(), []int{1} +} + +func (x *VoteResponse) GetCount() int64 { + if x != nil { + return x.Count + } + return 0 +} + +type CountRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BusinessId string `protobuf:"bytes,1,opt,name=business_id,json=businessId,proto3" json:"business_id,omitempty"` + MessageId string `protobuf:"bytes,2,opt,name=message_id,json=messageId,proto3" json:"message_id,omitempty"` +} + +func (x *CountRequest) Reset() { + *x = CountRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_api_v1_vote_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CountRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CountRequest) ProtoMessage() {} + +func (x *CountRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_v1_vote_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 CountRequest.ProtoReflect.Descriptor instead. +func (*CountRequest) Descriptor() ([]byte, []int) { + return file_api_v1_vote_proto_rawDescGZIP(), []int{2} +} + +func (x *CountRequest) GetBusinessId() string { + if x != nil { + return x.BusinessId + } + return "" +} + +func (x *CountRequest) GetMessageId() string { + if x != nil { + return x.MessageId + } + return "" +} + +type CountResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Count int64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` +} + +func (x *CountResponse) Reset() { + *x = CountResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_api_v1_vote_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *CountResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CountResponse) ProtoMessage() {} + +func (x *CountResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_v1_vote_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 CountResponse.ProtoReflect.Descriptor instead. +func (*CountResponse) Descriptor() ([]byte, []int) { + return file_api_v1_vote_proto_rawDescGZIP(), []int{3} +} + +func (x *CountResponse) GetCount() int64 { + if x != nil { + return x.Count + } + return 0 +} + +type IsVotedRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BusinessId string `protobuf:"bytes,1,opt,name=business_id,json=businessId,proto3" json:"business_id,omitempty"` + MessageId string `protobuf:"bytes,2,opt,name=message_id,json=messageId,proto3" json:"message_id,omitempty"` + UserId string `protobuf:"bytes,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"` +} + +func (x *IsVotedRequest) Reset() { + *x = IsVotedRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_api_v1_vote_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IsVotedRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IsVotedRequest) ProtoMessage() {} + +func (x *IsVotedRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_v1_vote_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 IsVotedRequest.ProtoReflect.Descriptor instead. +func (*IsVotedRequest) Descriptor() ([]byte, []int) { + return file_api_v1_vote_proto_rawDescGZIP(), []int{4} +} + +func (x *IsVotedRequest) GetBusinessId() string { + if x != nil { + return x.BusinessId + } + return "" +} + +func (x *IsVotedRequest) GetMessageId() string { + if x != nil { + return x.MessageId + } + return "" +} + +func (x *IsVotedRequest) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +type IsVotedResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + IsVoted bool `protobuf:"varint,1,opt,name=is_voted,json=isVoted,proto3" json:"is_voted,omitempty"` +} + +func (x *IsVotedResponse) Reset() { + *x = IsVotedResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_api_v1_vote_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *IsVotedResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IsVotedResponse) ProtoMessage() {} + +func (x *IsVotedResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_v1_vote_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 IsVotedResponse.ProtoReflect.Descriptor instead. +func (*IsVotedResponse) Descriptor() ([]byte, []int) { + return file_api_v1_vote_proto_rawDescGZIP(), []int{5} +} + +func (x *IsVotedResponse) GetIsVoted() bool { + if x != nil { + return x.IsVoted + } + return false +} + +type VotedUsersRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + BusinessId string `protobuf:"bytes,1,opt,name=business_id,json=businessId,proto3" json:"business_id,omitempty"` + MessageId string `protobuf:"bytes,2,opt,name=message_id,json=messageId,proto3" json:"message_id,omitempty"` +} + +func (x *VotedUsersRequest) Reset() { + *x = VotedUsersRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_api_v1_vote_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *VotedUsersRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*VotedUsersRequest) ProtoMessage() {} + +func (x *VotedUsersRequest) ProtoReflect() protoreflect.Message { + mi := &file_api_v1_vote_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 VotedUsersRequest.ProtoReflect.Descriptor instead. +func (*VotedUsersRequest) Descriptor() ([]byte, []int) { + return file_api_v1_vote_proto_rawDescGZIP(), []int{6} +} + +func (x *VotedUsersRequest) GetBusinessId() string { + if x != nil { + return x.BusinessId + } + return "" +} + +func (x *VotedUsersRequest) GetMessageId() string { + if x != nil { + return x.MessageId + } + return "" +} + +type VotedUsersResponse struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserIds []string `protobuf:"bytes,1,rep,name=user_ids,json=userIds,proto3" json:"user_ids,omitempty"` +} + +func (x *VotedUsersResponse) Reset() { + *x = VotedUsersResponse{} + if protoimpl.UnsafeEnabled { + mi := &file_api_v1_vote_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *VotedUsersResponse) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*VotedUsersResponse) ProtoMessage() {} + +func (x *VotedUsersResponse) ProtoReflect() protoreflect.Message { + mi := &file_api_v1_vote_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 VotedUsersResponse.ProtoReflect.Descriptor instead. +func (*VotedUsersResponse) Descriptor() ([]byte, []int) { + return file_api_v1_vote_proto_rawDescGZIP(), []int{7} +} + +func (x *VotedUsersResponse) GetUserIds() []string { + if x != nil { + return x.UserIds + } + return nil +} + +var File_api_v1_vote_proto protoreflect.FileDescriptor + +var file_api_v1_vote_proto_rawDesc = []byte{ + 0x0a, 0x11, 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x2f, 0x76, 0x6f, 0x74, 0x65, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x6c, 0x69, 0x6b, 0x69, 0x74, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, + 0x31, 0x1a, 0x1c, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x61, 0x6e, + 0x6e, 0x6f, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, + 0x17, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x63, 0x6c, 0x69, 0x65, + 0x6e, 0x74, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x20, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, + 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, + 0x6d, 0x61, 0x73, 0x6b, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, 0x67, + 0x6c, 0x65, 0x2f, 0x61, 0x70, 0x69, 0x2f, 0x66, 0x69, 0x65, 0x6c, 0x64, 0x5f, 0x62, 0x65, 0x68, + 0x61, 0x76, 0x69, 0x6f, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x1f, 0x67, 0x6f, 0x6f, + 0x67, 0x6c, 0x65, 0x2f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2f, 0x74, 0x69, 0x6d, + 0x65, 0x73, 0x74, 0x61, 0x6d, 0x70, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x66, 0x0a, 0x0b, + 0x56, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x62, + 0x75, 0x73, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0a, 0x62, 0x75, 0x73, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, + 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x09, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, + 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, + 0x65, 0x72, 0x49, 0x64, 0x22, 0x24, 0x0a, 0x0c, 0x56, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, + 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x4e, 0x0a, 0x0c, 0x43, 0x6f, + 0x75, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x75, + 0x73, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x0a, 0x62, 0x75, 0x73, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, + 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x09, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x64, 0x22, 0x25, 0x0a, 0x0d, 0x43, 0x6f, + 0x75, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x63, + 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x6f, 0x75, 0x6e, + 0x74, 0x22, 0x69, 0x0a, 0x0e, 0x49, 0x73, 0x56, 0x6f, 0x74, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x12, 0x1f, 0x0a, 0x0b, 0x62, 0x75, 0x73, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x5f, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x62, 0x75, 0x73, 0x69, 0x6e, 0x65, + 0x73, 0x73, 0x49, 0x64, 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, + 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, + 0x65, 0x49, 0x64, 0x12, 0x17, 0x0a, 0x07, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x2c, 0x0a, 0x0f, + 0x49, 0x73, 0x56, 0x6f, 0x74, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, + 0x19, 0x0a, 0x08, 0x69, 0x73, 0x5f, 0x76, 0x6f, 0x74, 0x65, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x08, 0x52, 0x07, 0x69, 0x73, 0x56, 0x6f, 0x74, 0x65, 0x64, 0x22, 0x53, 0x0a, 0x11, 0x56, 0x6f, + 0x74, 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, + 0x1f, 0x0a, 0x0b, 0x62, 0x75, 0x73, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x5f, 0x69, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x62, 0x75, 0x73, 0x69, 0x6e, 0x65, 0x73, 0x73, 0x49, 0x64, + 0x12, 0x1d, 0x0a, 0x0a, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x64, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x49, 0x64, 0x22, + 0x2f, 0x0a, 0x12, 0x56, 0x6f, 0x74, 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, + 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x69, 0x64, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x07, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x73, + 0x32, 0xf2, 0x02, 0x0a, 0x0b, 0x56, 0x6f, 0x74, 0x65, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, + 0x12, 0x3f, 0x0a, 0x04, 0x56, 0x6f, 0x74, 0x65, 0x12, 0x19, 0x2e, 0x6c, 0x69, 0x6b, 0x69, 0x74, + 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x6c, 0x69, 0x6b, 0x69, 0x74, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x31, 0x2e, 0x56, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, + 0x00, 0x12, 0x41, 0x0a, 0x06, 0x55, 0x6e, 0x56, 0x6f, 0x74, 0x65, 0x12, 0x19, 0x2e, 0x6c, 0x69, + 0x6b, 0x69, 0x74, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x6f, 0x74, 0x65, 0x52, + 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x6c, 0x69, 0x6b, 0x69, 0x74, 0x2e, 0x61, + 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x56, 0x6f, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, + 0x73, 0x65, 0x22, 0x00, 0x12, 0x42, 0x0a, 0x05, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x2e, + 0x6c, 0x69, 0x6b, 0x69, 0x74, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x75, + 0x6e, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1b, 0x2e, 0x6c, 0x69, 0x6b, 0x69, + 0x74, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x52, 0x65, + 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x07, 0x49, 0x73, 0x56, 0x6f, + 0x74, 0x65, 0x64, 0x12, 0x1c, 0x2e, 0x6c, 0x69, 0x6b, 0x69, 0x74, 0x2e, 0x61, 0x70, 0x69, 0x2e, + 0x76, 0x31, 0x2e, 0x49, 0x73, 0x56, 0x6f, 0x74, 0x65, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x1d, 0x2e, 0x6c, 0x69, 0x6b, 0x69, 0x74, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, + 0x2e, 0x49, 0x73, 0x56, 0x6f, 0x74, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, + 0x22, 0x00, 0x12, 0x51, 0x0a, 0x0a, 0x56, 0x6f, 0x74, 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, + 0x12, 0x1f, 0x2e, 0x6c, 0x69, 0x6b, 0x69, 0x74, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x2e, + 0x56, 0x6f, 0x74, 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x20, 0x2e, 0x6c, 0x69, 0x6b, 0x69, 0x74, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, + 0x2e, 0x56, 0x6f, 0x74, 0x65, 0x64, 0x55, 0x73, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, + 0x6e, 0x73, 0x65, 0x22, 0x00, 0x42, 0xa4, 0x01, 0x0a, 0x10, 0x63, 0x6f, 0x6d, 0x2e, 0x6c, 0x69, + 0x6b, 0x69, 0x74, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x31, 0x42, 0x09, 0x56, 0x6f, 0x74, 0x65, + 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, + 0x63, 0x6f, 0x6d, 0x2f, 0x43, 0x6f, 0x72, 0x72, 0x65, 0x63, 0x74, 0x52, 0x6f, 0x61, 0x64, 0x48, + 0x2f, 0x4c, 0x69, 0x6b, 0x69, 0x74, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x67, 0x65, 0x6e, 0x2f, + 0x61, 0x70, 0x69, 0x2f, 0x76, 0x31, 0x3b, 0x61, 0x70, 0x69, 0x76, 0x31, 0xa2, 0x02, 0x03, 0x4c, + 0x41, 0x58, 0xaa, 0x02, 0x0c, 0x4c, 0x69, 0x6b, 0x69, 0x74, 0x2e, 0x41, 0x70, 0x69, 0x2e, 0x56, + 0x31, 0xca, 0x02, 0x0c, 0x4c, 0x69, 0x6b, 0x69, 0x74, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, + 0xe2, 0x02, 0x18, 0x4c, 0x69, 0x6b, 0x69, 0x74, 0x5c, 0x41, 0x70, 0x69, 0x5c, 0x56, 0x31, 0x5c, + 0x47, 0x50, 0x42, 0x4d, 0x65, 0x74, 0x61, 0x64, 0x61, 0x74, 0x61, 0xea, 0x02, 0x0e, 0x4c, 0x69, + 0x6b, 0x69, 0x74, 0x3a, 0x3a, 0x41, 0x70, 0x69, 0x3a, 0x3a, 0x56, 0x31, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_api_v1_vote_proto_rawDescOnce sync.Once + file_api_v1_vote_proto_rawDescData = file_api_v1_vote_proto_rawDesc +) + +func file_api_v1_vote_proto_rawDescGZIP() []byte { + file_api_v1_vote_proto_rawDescOnce.Do(func() { + file_api_v1_vote_proto_rawDescData = protoimpl.X.CompressGZIP(file_api_v1_vote_proto_rawDescData) + }) + return file_api_v1_vote_proto_rawDescData +} + +var file_api_v1_vote_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_api_v1_vote_proto_goTypes = []interface{}{ + (*VoteRequest)(nil), // 0: likit.api.v1.VoteRequest + (*VoteResponse)(nil), // 1: likit.api.v1.VoteResponse + (*CountRequest)(nil), // 2: likit.api.v1.CountRequest + (*CountResponse)(nil), // 3: likit.api.v1.CountResponse + (*IsVotedRequest)(nil), // 4: likit.api.v1.IsVotedRequest + (*IsVotedResponse)(nil), // 5: likit.api.v1.IsVotedResponse + (*VotedUsersRequest)(nil), // 6: likit.api.v1.VotedUsersRequest + (*VotedUsersResponse)(nil), // 7: likit.api.v1.VotedUsersResponse +} +var file_api_v1_vote_proto_depIdxs = []int32{ + 0, // 0: likit.api.v1.VoteService.Vote:input_type -> likit.api.v1.VoteRequest + 0, // 1: likit.api.v1.VoteService.UnVote:input_type -> likit.api.v1.VoteRequest + 2, // 2: likit.api.v1.VoteService.Count:input_type -> likit.api.v1.CountRequest + 4, // 3: likit.api.v1.VoteService.IsVoted:input_type -> likit.api.v1.IsVotedRequest + 6, // 4: likit.api.v1.VoteService.VotedUsers:input_type -> likit.api.v1.VotedUsersRequest + 1, // 5: likit.api.v1.VoteService.Vote:output_type -> likit.api.v1.VoteResponse + 1, // 6: likit.api.v1.VoteService.UnVote:output_type -> likit.api.v1.VoteResponse + 3, // 7: likit.api.v1.VoteService.Count:output_type -> likit.api.v1.CountResponse + 5, // 8: likit.api.v1.VoteService.IsVoted:output_type -> likit.api.v1.IsVotedResponse + 7, // 9: likit.api.v1.VoteService.VotedUsers:output_type -> likit.api.v1.VotedUsersResponse + 5, // [5:10] is the sub-list for method output_type + 0, // [0:5] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_api_v1_vote_proto_init() } +func file_api_v1_vote_proto_init() { + if File_api_v1_vote_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_api_v1_vote_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*VoteRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_v1_vote_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*VoteResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_v1_vote_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CountRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_v1_vote_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*CountResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_v1_vote_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IsVotedRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_v1_vote_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*IsVotedResponse); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_v1_vote_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*VotedUsersRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_api_v1_vote_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*VotedUsersResponse); 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_api_v1_vote_proto_rawDesc, + NumEnums: 0, + NumMessages: 8, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_api_v1_vote_proto_goTypes, + DependencyIndexes: file_api_v1_vote_proto_depIdxs, + MessageInfos: file_api_v1_vote_proto_msgTypes, + }.Build() + File_api_v1_vote_proto = out.File + file_api_v1_vote_proto_rawDesc = nil + file_api_v1_vote_proto_goTypes = nil + file_api_v1_vote_proto_depIdxs = nil +} diff --git a/grpc/gen/api/v1/vote_grpc.pb.go b/grpc/gen/api/v1/vote_grpc.pb.go new file mode 100644 index 0000000..f90ebeb --- /dev/null +++ b/grpc/gen/api/v1/vote_grpc.pb.go @@ -0,0 +1,257 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc (unknown) +// source: api/v1/vote.proto + +package apiv1 + +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 + +const ( + VoteService_Vote_FullMethodName = "/likit.api.v1.VoteService/Vote" + VoteService_UnVote_FullMethodName = "/likit.api.v1.VoteService/UnVote" + VoteService_Count_FullMethodName = "/likit.api.v1.VoteService/Count" + VoteService_IsVoted_FullMethodName = "/likit.api.v1.VoteService/IsVoted" + VoteService_VotedUsers_FullMethodName = "/likit.api.v1.VoteService/VotedUsers" +) + +// VoteServiceClient is the client API for VoteService 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 VoteServiceClient interface { + Vote(ctx context.Context, in *VoteRequest, opts ...grpc.CallOption) (*VoteResponse, error) + UnVote(ctx context.Context, in *VoteRequest, opts ...grpc.CallOption) (*VoteResponse, error) + Count(ctx context.Context, in *CountRequest, opts ...grpc.CallOption) (*CountResponse, error) + IsVoted(ctx context.Context, in *IsVotedRequest, opts ...grpc.CallOption) (*IsVotedResponse, error) + VotedUsers(ctx context.Context, in *VotedUsersRequest, opts ...grpc.CallOption) (*VotedUsersResponse, error) +} + +type voteServiceClient struct { + cc grpc.ClientConnInterface +} + +func NewVoteServiceClient(cc grpc.ClientConnInterface) VoteServiceClient { + return &voteServiceClient{cc} +} + +func (c *voteServiceClient) Vote(ctx context.Context, in *VoteRequest, opts ...grpc.CallOption) (*VoteResponse, error) { + out := new(VoteResponse) + err := c.cc.Invoke(ctx, VoteService_Vote_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *voteServiceClient) UnVote(ctx context.Context, in *VoteRequest, opts ...grpc.CallOption) (*VoteResponse, error) { + out := new(VoteResponse) + err := c.cc.Invoke(ctx, VoteService_UnVote_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *voteServiceClient) Count(ctx context.Context, in *CountRequest, opts ...grpc.CallOption) (*CountResponse, error) { + out := new(CountResponse) + err := c.cc.Invoke(ctx, VoteService_Count_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *voteServiceClient) IsVoted(ctx context.Context, in *IsVotedRequest, opts ...grpc.CallOption) (*IsVotedResponse, error) { + out := new(IsVotedResponse) + err := c.cc.Invoke(ctx, VoteService_IsVoted_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *voteServiceClient) VotedUsers(ctx context.Context, in *VotedUsersRequest, opts ...grpc.CallOption) (*VotedUsersResponse, error) { + out := new(VotedUsersResponse) + err := c.cc.Invoke(ctx, VoteService_VotedUsers_FullMethodName, in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// VoteServiceServer is the server API for VoteService service. +// All implementations must embed UnimplementedVoteServiceServer +// for forward compatibility +type VoteServiceServer interface { + Vote(context.Context, *VoteRequest) (*VoteResponse, error) + UnVote(context.Context, *VoteRequest) (*VoteResponse, error) + Count(context.Context, *CountRequest) (*CountResponse, error) + IsVoted(context.Context, *IsVotedRequest) (*IsVotedResponse, error) + VotedUsers(context.Context, *VotedUsersRequest) (*VotedUsersResponse, error) + mustEmbedUnimplementedVoteServiceServer() +} + +// UnimplementedVoteServiceServer must be embedded to have forward compatible implementations. +type UnimplementedVoteServiceServer struct { +} + +func (UnimplementedVoteServiceServer) Vote(context.Context, *VoteRequest) (*VoteResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Vote not implemented") +} +func (UnimplementedVoteServiceServer) UnVote(context.Context, *VoteRequest) (*VoteResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UnVote not implemented") +} +func (UnimplementedVoteServiceServer) Count(context.Context, *CountRequest) (*CountResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method Count not implemented") +} +func (UnimplementedVoteServiceServer) IsVoted(context.Context, *IsVotedRequest) (*IsVotedResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method IsVoted not implemented") +} +func (UnimplementedVoteServiceServer) VotedUsers(context.Context, *VotedUsersRequest) (*VotedUsersResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method VotedUsers not implemented") +} +func (UnimplementedVoteServiceServer) mustEmbedUnimplementedVoteServiceServer() {} + +// UnsafeVoteServiceServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to VoteServiceServer will +// result in compilation errors. +type UnsafeVoteServiceServer interface { + mustEmbedUnimplementedVoteServiceServer() +} + +func RegisterVoteServiceServer(s grpc.ServiceRegistrar, srv VoteServiceServer) { + s.RegisterService(&VoteService_ServiceDesc, srv) +} + +func _VoteService_Vote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(VoteRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(VoteServiceServer).Vote(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: VoteService_Vote_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(VoteServiceServer).Vote(ctx, req.(*VoteRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _VoteService_UnVote_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(VoteRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(VoteServiceServer).UnVote(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: VoteService_UnVote_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(VoteServiceServer).UnVote(ctx, req.(*VoteRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _VoteService_Count_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CountRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(VoteServiceServer).Count(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: VoteService_Count_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(VoteServiceServer).Count(ctx, req.(*CountRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _VoteService_IsVoted_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(IsVotedRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(VoteServiceServer).IsVoted(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: VoteService_IsVoted_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(VoteServiceServer).IsVoted(ctx, req.(*IsVotedRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _VoteService_VotedUsers_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(VotedUsersRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(VoteServiceServer).VotedUsers(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: VoteService_VotedUsers_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(VoteServiceServer).VotedUsers(ctx, req.(*VotedUsersRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// VoteService_ServiceDesc is the grpc.ServiceDesc for VoteService service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var VoteService_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "likit.api.v1.VoteService", + HandlerType: (*VoteServiceServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Vote", + Handler: _VoteService_Vote_Handler, + }, + { + MethodName: "UnVote", + Handler: _VoteService_UnVote_Handler, + }, + { + MethodName: "Count", + Handler: _VoteService_Count_Handler, + }, + { + MethodName: "IsVoted", + Handler: _VoteService_IsVoted_Handler, + }, + { + MethodName: "VotedUsers", + Handler: _VoteService_VotedUsers_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "api/v1/vote.proto", +} diff --git a/internal/adapter/in/grpc/server.go b/internal/adapter/in/grpc/server.go new file mode 100644 index 0000000..1443956 --- /dev/null +++ b/internal/adapter/in/grpc/server.go @@ -0,0 +1,38 @@ +package grpc + +import ( + "log" + "net" + "os" + + apiv1 "github.com/CorrectRoadH/Likit/grpc/gen/api/v1" + "google.golang.org/grpc" +) + +type GrpcServer struct { + listener net.Listener + Server *grpc.Server +} + +func NewGrpcServer(voteGRPCServer *VoteGRPCServer) *GrpcServer { + port := os.Getenv("GRPC_PORT") + if port == "" { + port = "4778" + } + lis, err := net.Listen("tcp", ":"+port) + if err != nil { + log.Fatalln("Failed to listen:", err) + } else { + log.Println("GRPC Server is listening on port", port) + } + + // Create a gRPC server object + s := grpc.NewServer() + + apiv1.RegisterVoteServiceServer(s, voteGRPCServer) + + return &GrpcServer{ + Server: s, + listener: lis, + } +} diff --git a/internal/adapter/in/grpc/vote.go b/internal/adapter/in/grpc/vote.go new file mode 100644 index 0000000..3b80fea --- /dev/null +++ b/internal/adapter/in/grpc/vote.go @@ -0,0 +1,77 @@ +package grpc + +import ( + "context" + + apiv1 "github.com/CorrectRoadH/Likit/grpc/gen/api/v1" + "github.com/CorrectRoadH/Likit/internal/port/in" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +type VoteGRPCServer struct { + apiv1.UnimplementedVoteServiceServer + voteUseCase in.VoteUseCase +} + +func NewVoteGRPCServer(voteUseCase in.VoteUseCase) *VoteGRPCServer { + s := &VoteGRPCServer{ + voteUseCase: voteUseCase, + } + return s +} + +func (s *VoteGRPCServer) Vote(ctx context.Context, in *apiv1.VoteRequest) (*apiv1.VoteResponse, error) { + val, err := s.voteUseCase.Vote(ctx, in.BusinessId, in.MessageId, in.UserId) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &apiv1.VoteResponse{ + Count: val, + }, nil +} + +func (s *VoteGRPCServer) UnVote(ctx context.Context, in *apiv1.VoteRequest) (*apiv1.VoteResponse, error) { + val, err := s.voteUseCase.UnVote(ctx, in.BusinessId, in.MessageId, in.UserId) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &apiv1.VoteResponse{ + Count: val, + }, nil +} + +func (s *VoteGRPCServer) Count(ctx context.Context, in *apiv1.CountRequest) (*apiv1.CountResponse, error) { + val, err := s.voteUseCase.Count(ctx, in.BusinessId, in.MessageId) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &apiv1.CountResponse{ + Count: val, + }, nil +} + +func (s *VoteGRPCServer) IsVoted(ctx context.Context, in *apiv1.IsVotedRequest) (*apiv1.IsVotedResponse, error) { + val, err := s.voteUseCase.IsVoted(ctx, in.BusinessId, in.MessageId, in.UserId) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &apiv1.IsVotedResponse{ + IsVoted: val, + }, nil +} + +func (s *VoteGRPCServer) VotedUsers(ctx context.Context, in *apiv1.VotedUsersRequest) (*apiv1.VotedUsersResponse, error) { + val, err := s.voteUseCase.VotedUsers(ctx, in.BusinessId, in.MessageId) + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &apiv1.VotedUsersResponse{ + UserIds: val, + }, nil +}