From ff388e2ed72d7ff430504675c78e563d0e2750be Mon Sep 17 00:00:00 2001 From: demoasm Date: Thu, 9 Mar 2023 19:45:13 +0800 Subject: [PATCH 01/19] add sample_douyin --- sample_douyin/.gitignore | 11 + sample_douyin/README.md | 128 + sample_douyin/cmd/api/.gitignore | 37 + sample_douyin/cmd/api/.hz | 3 + sample_douyin/cmd/api/biz/apimodel/object.go | 199 + sample_douyin/cmd/api/biz/apimodel/request.go | 87 + .../cmd/api/biz/apimodel/response.go | 263 + .../cmd/api/biz/cache/favoritecache.go | 78 + sample_douyin/cmd/api/biz/cache/init.go | 16 + .../cmd/api/biz/cache/messagecache.go | 301 + .../cmd/api/biz/cache/messagequeue.go | 32 + .../api/biz/handler/douyinapi/api_service.go | 383 + .../cmd/api/biz/handler/douyinapi/handler.go | 30 + sample_douyin/cmd/api/biz/handler/ping.go | 29 + sample_douyin/cmd/api/biz/mw/jwt.go | 103 + sample_douyin/cmd/api/biz/mw/my_jwt.go | 886 +++ .../cmd/api/biz/router/douyinapi/api.go | 84 + .../api/biz/router/douyinapi/middleware.go | 115 + sample_douyin/cmd/api/biz/router/register.go | 14 + sample_douyin/cmd/api/biz/rpc/comment.go | 54 + sample_douyin/cmd/api/biz/rpc/favorite.go | 54 + sample_douyin/cmd/api/biz/rpc/init.go | 10 + sample_douyin/cmd/api/biz/rpc/message.go | 54 + sample_douyin/cmd/api/biz/rpc/relation.go | 101 + sample_douyin/cmd/api/biz/rpc/user.go | 54 + sample_douyin/cmd/api/biz/rpc/video.go | 66 + .../cmd/api/biz/service/comment_service.go | 117 + .../cmd/api/biz/service/favorite_service.go | 87 + .../cmd/api/biz/service/feed_service.go | 84 + .../cmd/api/biz/service/message_service.go | 88 + .../cmd/api/biz/service/publish_service.go | 64 + .../cmd/api/biz/service/relation_service.go | 232 + .../cmd/api/biz/service/user_service.go | 64 + .../cmd/api/biz/videoHandel/videohandel.go | 176 + sample_douyin/cmd/api/main.go | 45 + sample_douyin/cmd/api/router.go | 34 + sample_douyin/cmd/api/router_gen.go | 16 + sample_douyin/cmd/comment/build.sh | 12 + sample_douyin/cmd/comment/dal/db/comment.go | 67 + .../cmd/comment/dal/db/comment_video.go | 21 + sample_douyin/cmd/comment/dal/db/init.go | 38 + sample_douyin/cmd/comment/dal/init.go | 7 + sample_douyin/cmd/comment/handler.go | 55 + sample_douyin/cmd/comment/kitex.yaml | 3 + sample_douyin/cmd/comment/main.go | 61 + sample_douyin/cmd/comment/output/bootstrap.sh | 21 + sample_douyin/cmd/comment/pack/comment.go | 31 + sample_douyin/cmd/comment/pack/resp.go | 25 + sample_douyin/cmd/comment/script/bootstrap.sh | 21 + .../cmd/comment/service/create_comment.go | 27 + .../cmd/comment/service/delete_comment.go | 24 + .../cmd/comment/service/get_video_comments.go | 28 + sample_douyin/cmd/favorite/build.sh | 12 + sample_douyin/cmd/favorite/dal/db/favorite.go | 110 + sample_douyin/cmd/favorite/dal/db/init.go | 38 + sample_douyin/cmd/favorite/dal/db/user.go | 25 + sample_douyin/cmd/favorite/dal/db/video.go | 21 + sample_douyin/cmd/favorite/dal/init.go | 7 + sample_douyin/cmd/favorite/handler.go | 62 + sample_douyin/cmd/favorite/kitex.yaml | 3 + sample_douyin/cmd/favorite/main.go | 60 + .../cmd/favorite/output/bootstrap.sh | 21 + sample_douyin/cmd/favorite/pack/favorite.go | 39 + sample_douyin/cmd/favorite/pack/resp.go | 25 + .../cmd/favorite/script/bootstrap.sh | 21 + .../cmd/favorite/service/cancle_favorite.go | 24 + .../cmd/favorite/service/create_favorite.go | 24 + .../cmd/favorite/service/get_isfavorite.go | 21 + .../cmd/favorite/service/get_list.go | 26 + sample_douyin/cmd/message/build.sh | 12 + sample_douyin/cmd/message/dal/db/init.go | 38 + sample_douyin/cmd/message/dal/db/message.go | 112 + sample_douyin/cmd/message/dal/init.go | 7 + sample_douyin/cmd/message/handler.go | 61 + sample_douyin/cmd/message/kitex.yaml | 3 + sample_douyin/cmd/message/main.go | 61 + sample_douyin/cmd/message/output/bootstrap.sh | 21 + .../cmd/message/pack/firstmessage.go | 29 + sample_douyin/cmd/message/pack/message.go | 31 + sample_douyin/cmd/message/pack/resp.go | 25 + .../cmd/message/service/create_message.go | 25 + .../cmd/message/service/get_firstmessage.go | 26 + .../cmd/message/service/get_messagelist.go | 26 + sample_douyin/cmd/relation/build.sh | 12 + sample_douyin/cmd/relation/dal/db/init.go | 38 + sample_douyin/cmd/relation/dal/db/realtion.go | 89 + sample_douyin/cmd/relation/dal/db/user.go | 19 + sample_douyin/cmd/relation/dal/init.go | 7 + sample_douyin/cmd/relation/handler.go | 115 + sample_douyin/cmd/relation/kitex.yaml | 3 + sample_douyin/cmd/relation/main.go | 61 + .../cmd/relation/output/bootstrap.sh | 21 + sample_douyin/cmd/relation/pack/resp.go | 42 + .../cmd/relation/script/bootstrap.sh | 21 + .../cmd/relation/service/create_relation.go | 24 + .../cmd/relation/service/delete_relation.go | 21 + .../cmd/relation/service/get_follow.go | 26 + .../cmd/relation/service/get_follower.go | 26 + .../cmd/relation/service/get_friend.go | 21 + .../cmd/relation/service/valid_if_follow.go | 21 + sample_douyin/cmd/user/build.sh | 10 + sample_douyin/cmd/user/dal/db/init.go | 38 + sample_douyin/cmd/user/dal/db/user.go | 54 + sample_douyin/cmd/user/dal/init.go | 7 + sample_douyin/cmd/user/handler.go | 71 + sample_douyin/cmd/user/kitex.yaml | 3 + sample_douyin/cmd/user/main.go | 61 + sample_douyin/cmd/user/output/bootstrap.sh | 21 + sample_douyin/cmd/user/pack/resp.go | 25 + sample_douyin/cmd/user/pack/user.go | 36 + sample_douyin/cmd/user/service/check_user.go | 45 + sample_douyin/cmd/user/service/create_user.go | 44 + sample_douyin/cmd/user/service/mget_user.go | 28 + sample_douyin/cmd/video/build.sh | 12 + sample_douyin/cmd/video/dal/db/init.go | 38 + sample_douyin/cmd/video/dal/db/user.go | 25 + sample_douyin/cmd/video/dal/db/video.go | 88 + sample_douyin/cmd/video/dal/init.go | 7 + sample_douyin/cmd/video/handler.go | 95 + sample_douyin/cmd/video/kitex.yaml | 3 + sample_douyin/cmd/video/main.go | 61 + sample_douyin/cmd/video/output/bootstrap.sh | 21 + sample_douyin/cmd/video/pack/resp.go | 25 + sample_douyin/cmd/video/pack/video.go | 32 + sample_douyin/cmd/video/script/bootstrap.sh | 21 + .../cmd/video/service/create_video.go | 26 + .../cmd/video/service/delete_video.go | 2 + sample_douyin/cmd/video/service/get_feed.go | 44 + sample_douyin/cmd/video/service/get_list.go | 26 + sample_douyin/cmd/video/service/mget_video.go | 26 + .../cmd/video/service/time_videos.go | 24 + sample_douyin/cmd/video/test.go | 7 + sample_douyin/docker-compose.yaml | 88 + sample_douyin/go.mod | 135 + sample_douyin/go.sum | 1105 +++ sample_douyin/idl/api.thrift | 52 + sample_douyin/idl/comment.thrift | 50 + sample_douyin/idl/favorite.thrift | 48 + sample_douyin/idl/message.thrift | 64 + sample_douyin/idl/relation.thrift | 62 + sample_douyin/idl/user.thrift | 68 + sample_douyin/idl/video.thrift | 87 + sample_douyin/images/architecture.jpg | Bin 0 -> 220481 bytes sample_douyin/images/call-relation.jpg | Bin 0 -> 142794 bytes .../kitex_gen/douyincomment/comment.go | 3248 +++++++++ .../douyincomment/comment_validator.go | 30 + .../douyincomment/commentservice/client.go | 61 + .../commentservice/commentservice.go | 132 + .../douyincomment/commentservice/invoker.go | 24 + .../douyincomment/commentservice/server.go | 20 + .../kitex_gen/douyincomment/k-comment.go | 2356 +++++++ .../kitex_gen/douyincomment/k-consts.go | 4 + .../kitex_gen/douyinfavorite/favorite.go | 3125 ++++++++ .../douyinfavorite/favorite_validator.go | 29 + .../douyinfavorite/favoriteservice/client.go | 61 + .../favoriteservice/favoriteservice.go | 132 + .../douyinfavorite/favoriteservice/invoker.go | 24 + .../douyinfavorite/favoriteservice/server.go | 20 + .../kitex_gen/douyinfavorite/k-consts.go | 4 + .../kitex_gen/douyinfavorite/k-favorite.go | 2264 ++++++ .../kitex_gen/douyinuser/k-consts.go | 4 + sample_douyin/kitex_gen/douyinuser/k-user.go | 2862 ++++++++ sample_douyin/kitex_gen/douyinuser/user.go | 3929 +++++++++++ .../kitex_gen/douyinuser/user_validator.go | 82 + .../douyinuser/userservice/client.go | 61 + .../douyinuser/userservice/invoker.go | 24 + .../douyinuser/userservice/server.go | 20 + .../douyinuser/userservice/userservice.go | 132 + .../kitex_gen/douyinvideo/k-consts.go | 4 + .../kitex_gen/douyinvideo/k-video.go | 4571 ++++++++++++ sample_douyin/kitex_gen/douyinvideo/video.go | 6260 +++++++++++++++++ .../kitex_gen/douyinvideo/video_validator.go | 54 + .../douyinvideo/videoservice/client.go | 79 + .../douyinvideo/videoservice/invoker.go | 24 + .../douyinvideo/videoservice/server.go | 20 + .../douyinvideo/videoservice/videoservice.go | 219 + sample_douyin/kitex_gen/message/k-consts.go | 4 + sample_douyin/kitex_gen/message/k-message.go | 2823 ++++++++ sample_douyin/kitex_gen/message/message.go | 3818 ++++++++++ .../kitex_gen/message/message_validator.go | 44 + .../message/messageservice/client.go | 61 + .../message/messageservice/invoker.go | 24 + .../message/messageservice/messageservice.go | 132 + .../message/messageservice/server.go | 20 + sample_douyin/kitex_gen/relation/k-consts.go | 4 + .../kitex_gen/relation/k-relation.go | 3500 +++++++++ sample_douyin/kitex_gen/relation/relation.go | 4904 +++++++++++++ .../kitex_gen/relation/relation_validator.go | 44 + .../relation/relationservice/client.go | 79 + .../relation/relationservice/invoker.go | 24 + .../relationservice/relationservice.go | 219 + .../relation/relationservice/server.go | 20 + .../configs/otel/otel-collector-config.yaml | 37 + .../pkg/configs/prometheus/prometheus.yml | 30 + sample_douyin/pkg/configs/redis/redis.conf | 17 + sample_douyin/pkg/configs/sql/init.sql | 95 + sample_douyin/pkg/consts/consts.go | 58 + sample_douyin/pkg/errno/errno.go | 49 + sample_douyin/pkg/mw/client.go | 24 + sample_douyin/pkg/mw/common.go | 28 + sample_douyin/pkg/mw/server.go | 24 + sample_douyin/start_script/start_api.sh | 3 + sample_douyin/start_script/start_comment.sh | 5 + sample_douyin/start_script/start_favorite.sh | 5 + sample_douyin/start_script/start_message.sh | 5 + sample_douyin/start_script/start_relation.sh | 5 + sample_douyin/start_script/start_user.sh | 5 + sample_douyin/start_script/start_video.sh | 5 + 208 files changed, 55002 insertions(+) create mode 100644 sample_douyin/.gitignore create mode 100644 sample_douyin/README.md create mode 100644 sample_douyin/cmd/api/.gitignore create mode 100644 sample_douyin/cmd/api/.hz create mode 100644 sample_douyin/cmd/api/biz/apimodel/object.go create mode 100644 sample_douyin/cmd/api/biz/apimodel/request.go create mode 100644 sample_douyin/cmd/api/biz/apimodel/response.go create mode 100644 sample_douyin/cmd/api/biz/cache/favoritecache.go create mode 100644 sample_douyin/cmd/api/biz/cache/init.go create mode 100644 sample_douyin/cmd/api/biz/cache/messagecache.go create mode 100644 sample_douyin/cmd/api/biz/cache/messagequeue.go create mode 100644 sample_douyin/cmd/api/biz/handler/douyinapi/api_service.go create mode 100644 sample_douyin/cmd/api/biz/handler/douyinapi/handler.go create mode 100644 sample_douyin/cmd/api/biz/handler/ping.go create mode 100644 sample_douyin/cmd/api/biz/mw/jwt.go create mode 100644 sample_douyin/cmd/api/biz/mw/my_jwt.go create mode 100644 sample_douyin/cmd/api/biz/router/douyinapi/api.go create mode 100644 sample_douyin/cmd/api/biz/router/douyinapi/middleware.go create mode 100644 sample_douyin/cmd/api/biz/router/register.go create mode 100644 sample_douyin/cmd/api/biz/rpc/comment.go create mode 100644 sample_douyin/cmd/api/biz/rpc/favorite.go create mode 100644 sample_douyin/cmd/api/biz/rpc/init.go create mode 100644 sample_douyin/cmd/api/biz/rpc/message.go create mode 100644 sample_douyin/cmd/api/biz/rpc/relation.go create mode 100644 sample_douyin/cmd/api/biz/rpc/user.go create mode 100644 sample_douyin/cmd/api/biz/rpc/video.go create mode 100644 sample_douyin/cmd/api/biz/service/comment_service.go create mode 100644 sample_douyin/cmd/api/biz/service/favorite_service.go create mode 100644 sample_douyin/cmd/api/biz/service/feed_service.go create mode 100644 sample_douyin/cmd/api/biz/service/message_service.go create mode 100644 sample_douyin/cmd/api/biz/service/publish_service.go create mode 100644 sample_douyin/cmd/api/biz/service/relation_service.go create mode 100644 sample_douyin/cmd/api/biz/service/user_service.go create mode 100644 sample_douyin/cmd/api/biz/videoHandel/videohandel.go create mode 100644 sample_douyin/cmd/api/main.go create mode 100644 sample_douyin/cmd/api/router.go create mode 100644 sample_douyin/cmd/api/router_gen.go create mode 100644 sample_douyin/cmd/comment/build.sh create mode 100644 sample_douyin/cmd/comment/dal/db/comment.go create mode 100644 sample_douyin/cmd/comment/dal/db/comment_video.go create mode 100644 sample_douyin/cmd/comment/dal/db/init.go create mode 100644 sample_douyin/cmd/comment/dal/init.go create mode 100644 sample_douyin/cmd/comment/handler.go create mode 100644 sample_douyin/cmd/comment/kitex.yaml create mode 100644 sample_douyin/cmd/comment/main.go create mode 100644 sample_douyin/cmd/comment/output/bootstrap.sh create mode 100644 sample_douyin/cmd/comment/pack/comment.go create mode 100644 sample_douyin/cmd/comment/pack/resp.go create mode 100644 sample_douyin/cmd/comment/script/bootstrap.sh create mode 100644 sample_douyin/cmd/comment/service/create_comment.go create mode 100644 sample_douyin/cmd/comment/service/delete_comment.go create mode 100644 sample_douyin/cmd/comment/service/get_video_comments.go create mode 100644 sample_douyin/cmd/favorite/build.sh create mode 100644 sample_douyin/cmd/favorite/dal/db/favorite.go create mode 100644 sample_douyin/cmd/favorite/dal/db/init.go create mode 100644 sample_douyin/cmd/favorite/dal/db/user.go create mode 100644 sample_douyin/cmd/favorite/dal/db/video.go create mode 100644 sample_douyin/cmd/favorite/dal/init.go create mode 100644 sample_douyin/cmd/favorite/handler.go create mode 100644 sample_douyin/cmd/favorite/kitex.yaml create mode 100644 sample_douyin/cmd/favorite/main.go create mode 100644 sample_douyin/cmd/favorite/output/bootstrap.sh create mode 100644 sample_douyin/cmd/favorite/pack/favorite.go create mode 100644 sample_douyin/cmd/favorite/pack/resp.go create mode 100644 sample_douyin/cmd/favorite/script/bootstrap.sh create mode 100644 sample_douyin/cmd/favorite/service/cancle_favorite.go create mode 100644 sample_douyin/cmd/favorite/service/create_favorite.go create mode 100644 sample_douyin/cmd/favorite/service/get_isfavorite.go create mode 100644 sample_douyin/cmd/favorite/service/get_list.go create mode 100644 sample_douyin/cmd/message/build.sh create mode 100644 sample_douyin/cmd/message/dal/db/init.go create mode 100644 sample_douyin/cmd/message/dal/db/message.go create mode 100644 sample_douyin/cmd/message/dal/init.go create mode 100644 sample_douyin/cmd/message/handler.go create mode 100644 sample_douyin/cmd/message/kitex.yaml create mode 100644 sample_douyin/cmd/message/main.go create mode 100644 sample_douyin/cmd/message/output/bootstrap.sh create mode 100644 sample_douyin/cmd/message/pack/firstmessage.go create mode 100644 sample_douyin/cmd/message/pack/message.go create mode 100644 sample_douyin/cmd/message/pack/resp.go create mode 100644 sample_douyin/cmd/message/service/create_message.go create mode 100644 sample_douyin/cmd/message/service/get_firstmessage.go create mode 100644 sample_douyin/cmd/message/service/get_messagelist.go create mode 100644 sample_douyin/cmd/relation/build.sh create mode 100644 sample_douyin/cmd/relation/dal/db/init.go create mode 100644 sample_douyin/cmd/relation/dal/db/realtion.go create mode 100644 sample_douyin/cmd/relation/dal/db/user.go create mode 100644 sample_douyin/cmd/relation/dal/init.go create mode 100644 sample_douyin/cmd/relation/handler.go create mode 100644 sample_douyin/cmd/relation/kitex.yaml create mode 100644 sample_douyin/cmd/relation/main.go create mode 100644 sample_douyin/cmd/relation/output/bootstrap.sh create mode 100644 sample_douyin/cmd/relation/pack/resp.go create mode 100644 sample_douyin/cmd/relation/script/bootstrap.sh create mode 100644 sample_douyin/cmd/relation/service/create_relation.go create mode 100644 sample_douyin/cmd/relation/service/delete_relation.go create mode 100644 sample_douyin/cmd/relation/service/get_follow.go create mode 100644 sample_douyin/cmd/relation/service/get_follower.go create mode 100644 sample_douyin/cmd/relation/service/get_friend.go create mode 100644 sample_douyin/cmd/relation/service/valid_if_follow.go create mode 100644 sample_douyin/cmd/user/build.sh create mode 100644 sample_douyin/cmd/user/dal/db/init.go create mode 100644 sample_douyin/cmd/user/dal/db/user.go create mode 100644 sample_douyin/cmd/user/dal/init.go create mode 100644 sample_douyin/cmd/user/handler.go create mode 100644 sample_douyin/cmd/user/kitex.yaml create mode 100644 sample_douyin/cmd/user/main.go create mode 100644 sample_douyin/cmd/user/output/bootstrap.sh create mode 100644 sample_douyin/cmd/user/pack/resp.go create mode 100644 sample_douyin/cmd/user/pack/user.go create mode 100644 sample_douyin/cmd/user/service/check_user.go create mode 100644 sample_douyin/cmd/user/service/create_user.go create mode 100644 sample_douyin/cmd/user/service/mget_user.go create mode 100644 sample_douyin/cmd/video/build.sh create mode 100644 sample_douyin/cmd/video/dal/db/init.go create mode 100644 sample_douyin/cmd/video/dal/db/user.go create mode 100644 sample_douyin/cmd/video/dal/db/video.go create mode 100644 sample_douyin/cmd/video/dal/init.go create mode 100644 sample_douyin/cmd/video/handler.go create mode 100644 sample_douyin/cmd/video/kitex.yaml create mode 100644 sample_douyin/cmd/video/main.go create mode 100644 sample_douyin/cmd/video/output/bootstrap.sh create mode 100644 sample_douyin/cmd/video/pack/resp.go create mode 100644 sample_douyin/cmd/video/pack/video.go create mode 100644 sample_douyin/cmd/video/script/bootstrap.sh create mode 100644 sample_douyin/cmd/video/service/create_video.go create mode 100644 sample_douyin/cmd/video/service/delete_video.go create mode 100644 sample_douyin/cmd/video/service/get_feed.go create mode 100644 sample_douyin/cmd/video/service/get_list.go create mode 100644 sample_douyin/cmd/video/service/mget_video.go create mode 100644 sample_douyin/cmd/video/service/time_videos.go create mode 100644 sample_douyin/cmd/video/test.go create mode 100644 sample_douyin/docker-compose.yaml create mode 100644 sample_douyin/go.mod create mode 100644 sample_douyin/go.sum create mode 100644 sample_douyin/idl/api.thrift create mode 100644 sample_douyin/idl/comment.thrift create mode 100644 sample_douyin/idl/favorite.thrift create mode 100644 sample_douyin/idl/message.thrift create mode 100644 sample_douyin/idl/relation.thrift create mode 100644 sample_douyin/idl/user.thrift create mode 100644 sample_douyin/idl/video.thrift create mode 100644 sample_douyin/images/architecture.jpg create mode 100644 sample_douyin/images/call-relation.jpg create mode 100644 sample_douyin/kitex_gen/douyincomment/comment.go create mode 100644 sample_douyin/kitex_gen/douyincomment/comment_validator.go create mode 100644 sample_douyin/kitex_gen/douyincomment/commentservice/client.go create mode 100644 sample_douyin/kitex_gen/douyincomment/commentservice/commentservice.go create mode 100644 sample_douyin/kitex_gen/douyincomment/commentservice/invoker.go create mode 100644 sample_douyin/kitex_gen/douyincomment/commentservice/server.go create mode 100644 sample_douyin/kitex_gen/douyincomment/k-comment.go create mode 100644 sample_douyin/kitex_gen/douyincomment/k-consts.go create mode 100644 sample_douyin/kitex_gen/douyinfavorite/favorite.go create mode 100644 sample_douyin/kitex_gen/douyinfavorite/favorite_validator.go create mode 100644 sample_douyin/kitex_gen/douyinfavorite/favoriteservice/client.go create mode 100644 sample_douyin/kitex_gen/douyinfavorite/favoriteservice/favoriteservice.go create mode 100644 sample_douyin/kitex_gen/douyinfavorite/favoriteservice/invoker.go create mode 100644 sample_douyin/kitex_gen/douyinfavorite/favoriteservice/server.go create mode 100644 sample_douyin/kitex_gen/douyinfavorite/k-consts.go create mode 100644 sample_douyin/kitex_gen/douyinfavorite/k-favorite.go create mode 100644 sample_douyin/kitex_gen/douyinuser/k-consts.go create mode 100644 sample_douyin/kitex_gen/douyinuser/k-user.go create mode 100644 sample_douyin/kitex_gen/douyinuser/user.go create mode 100644 sample_douyin/kitex_gen/douyinuser/user_validator.go create mode 100644 sample_douyin/kitex_gen/douyinuser/userservice/client.go create mode 100644 sample_douyin/kitex_gen/douyinuser/userservice/invoker.go create mode 100644 sample_douyin/kitex_gen/douyinuser/userservice/server.go create mode 100644 sample_douyin/kitex_gen/douyinuser/userservice/userservice.go create mode 100644 sample_douyin/kitex_gen/douyinvideo/k-consts.go create mode 100644 sample_douyin/kitex_gen/douyinvideo/k-video.go create mode 100644 sample_douyin/kitex_gen/douyinvideo/video.go create mode 100644 sample_douyin/kitex_gen/douyinvideo/video_validator.go create mode 100644 sample_douyin/kitex_gen/douyinvideo/videoservice/client.go create mode 100644 sample_douyin/kitex_gen/douyinvideo/videoservice/invoker.go create mode 100644 sample_douyin/kitex_gen/douyinvideo/videoservice/server.go create mode 100644 sample_douyin/kitex_gen/douyinvideo/videoservice/videoservice.go create mode 100644 sample_douyin/kitex_gen/message/k-consts.go create mode 100644 sample_douyin/kitex_gen/message/k-message.go create mode 100644 sample_douyin/kitex_gen/message/message.go create mode 100644 sample_douyin/kitex_gen/message/message_validator.go create mode 100644 sample_douyin/kitex_gen/message/messageservice/client.go create mode 100644 sample_douyin/kitex_gen/message/messageservice/invoker.go create mode 100644 sample_douyin/kitex_gen/message/messageservice/messageservice.go create mode 100644 sample_douyin/kitex_gen/message/messageservice/server.go create mode 100644 sample_douyin/kitex_gen/relation/k-consts.go create mode 100644 sample_douyin/kitex_gen/relation/k-relation.go create mode 100644 sample_douyin/kitex_gen/relation/relation.go create mode 100644 sample_douyin/kitex_gen/relation/relation_validator.go create mode 100644 sample_douyin/kitex_gen/relation/relationservice/client.go create mode 100644 sample_douyin/kitex_gen/relation/relationservice/invoker.go create mode 100644 sample_douyin/kitex_gen/relation/relationservice/relationservice.go create mode 100644 sample_douyin/kitex_gen/relation/relationservice/server.go create mode 100644 sample_douyin/pkg/configs/otel/otel-collector-config.yaml create mode 100644 sample_douyin/pkg/configs/prometheus/prometheus.yml create mode 100644 sample_douyin/pkg/configs/redis/redis.conf create mode 100644 sample_douyin/pkg/configs/sql/init.sql create mode 100644 sample_douyin/pkg/consts/consts.go create mode 100644 sample_douyin/pkg/errno/errno.go create mode 100644 sample_douyin/pkg/mw/client.go create mode 100644 sample_douyin/pkg/mw/common.go create mode 100644 sample_douyin/pkg/mw/server.go create mode 100644 sample_douyin/start_script/start_api.sh create mode 100644 sample_douyin/start_script/start_comment.sh create mode 100644 sample_douyin/start_script/start_favorite.sh create mode 100644 sample_douyin/start_script/start_message.sh create mode 100644 sample_douyin/start_script/start_relation.sh create mode 100644 sample_douyin/start_script/start_user.sh create mode 100644 sample_douyin/start_script/start_video.sh diff --git a/sample_douyin/.gitignore b/sample_douyin/.gitignore new file mode 100644 index 00000000..53b36533 --- /dev/null +++ b/sample_douyin/.gitignore @@ -0,0 +1,11 @@ +*.mp4 +*.jpg +# *.sh +# pkg/consts/consts.go +.idea +cmd/user/output/bin/douyinuser +cmd/favorite/output/bin/favorite +cmd/comment/output/bin/comment +cmd/relation/output/bin/relation +cmd/user/output/bin/douyinuser +cmd/message/output/bin/message \ No newline at end of file diff --git a/sample_douyin/README.md b/sample_douyin/README.md new file mode 100644 index 00000000..1aa199be --- /dev/null +++ b/sample_douyin/README.md @@ -0,0 +1,128 @@ +# Sample Douyin + +## Introduction +A simple Douyin service built with `Kitex` and `Hertz` which is divided into seven microservices. + +| Service Name | Usage | Framework | protocol | Path | IDL | +|--------------|--------------------------|-------------|----------|--------------|---------------------| +| api | HTTP interface | kitex/hertz | http | cmd/api | idl/api.thrift | +| user | user data management | kitex/gorm | thrift | cmd/user | idl/user.thrift | +| video | video data management | kitex/gorm | thrift | cmd/video | idl/video.thrift | +| favorite | favorite data management | kitex/gorm | thrift | cmd/favorite | idl/favorite.thrift | +| comment | comment data management | kitex/gorm | thrift | cmd/comment | idl/comment.thrift | +| message | message data management | kitex/gorm | thrift | cmd/message | idl/message.thrift | +| relation | relation data management | kitex/gorm | thrift | cmd/relation | idl/relation.thrift | + +### Architecture + +![Architecture](./images/architecture.jpg) + +### Call Relations + +![Call Relations](./images/call-relation.jpg) + +### Basic Features + +- Hertz + - Use `thrift` IDL to define HTTP interface + - Use `Hertz` binding and validate + - Use `obs-opentelemetry` and `jarger` for `tracing`, `metrics`, `logging` + - Middleware + - Use `requestid`, `jwt`, `recovery`, `gzip` +- Kitex + - User `thrift` IDL to define `RPC` interface + - Use `kitex` to generate code + - Use `obs-opentelemetry` and `jarger` for `tracing`, `metrics`, `logging` + - Use `registry-etcd` for service discovery and register + +### Catalog Introduce + +| catalog | introduce | +|---------------|-------------------------| +| handler | HTTP handler | +| service | business logic | +| rpc | RPC call logic | +| dal | DB operation | +| pack | data pack | +| cache | Redis operation | +| videoHandler | Video stream processing | +| pkg/mw | RPC middleware | +| pkg/consts | constants | +| pkg/errno | customized error number | +| pkg/configs | SQL and Tracing configs | + +## Quick Start + +### Setup Basic Dependence + +```shell +docker-compose up -d +``` + +### Change config +Edit the following code block in pkg/consts/consts.go and replace it with your own Alibaba Cloud OSS AKID & AKS etc. +```go +Endpoint = "oss-c**************cs.com" +AKID = "LTAI****************92kxo" +AKS = "SmEa**************LuS9N3K9" +Bucket = "douy******************67" +CDNURL = "http://*************.cn/" +``` + +### Run User RPC Server + +```shell +sh ./start_script/start_user.sh +``` + +### Run Video RPC Server + +```shell +sh ./start_script/start_video.sh +``` + +### Run Relation RPC Server + +```shell +sh ./start_script/start_relation.sh +``` + +### Run Favorite RPC Server + +```shell +sh ./start_script/start_favorite.sh +``` + +### Run Comment RPC Server + +```shell +sh ./start_script/start_comment.sh +``` +### Run Message RPC Server + +```shell +sh ./start_script/start_message.sh +``` +### Run API Server + +```shell +sh ./start_script/start_api.sh +``` +### Jaeger + +Visit `http://127.0.0.1:16686/` on browser + +### Grafana + +Visit `http://127.0.0.1:3000/` on browser + +### APK + +[:memo:Sample Douyin APP Package Instructions](https://bytedance.feishu.cn/docs/doccnM9KkBAdyDhg8qaeGlIz7S7#quPkfu) + +##[:point_right: MORE](https://a6i0rzkzjm.feishu.cn/docx/Xa8sdTIGJopWrNxYgeVcrmxPnKe#doxcnPDVQrEZq14hwckf1K1Taqg) + + +### Demo + + diff --git a/sample_douyin/cmd/api/.gitignore b/sample_douyin/cmd/api/.gitignore new file mode 100644 index 00000000..101ea87c --- /dev/null +++ b/sample_douyin/cmd/api/.gitignore @@ -0,0 +1,37 @@ +*.o +*.a +*.so +_obj +_test +*.[568vq] +[568vq].out +*.cgo1.go +*.cgo2.c +_cgo_defun.c +_cgo_gotypes.go +_cgo_export.* +_testmain.go +*.exe +*.exe~ +*.test +*.prof +*.rar +*.zip +*.gz +*.psd +*.bmd +*.cfg +*.pptx +*.log +*nohup.out +*settings.pyc +*.sublime-project +*.sublime-workspace +!.gitkeep +.DS_Store +/.idea +/.vscode +/output +*.local.yml +dumped_hertz_remote_config.json + \ No newline at end of file diff --git a/sample_douyin/cmd/api/.hz b/sample_douyin/cmd/api/.hz new file mode 100644 index 00000000..9285a978 --- /dev/null +++ b/sample_douyin/cmd/api/.hz @@ -0,0 +1,3 @@ +// Code generated by hz. DO NOT EDIT. + +hz version: v0.5.1 diff --git a/sample_douyin/cmd/api/biz/apimodel/object.go b/sample_douyin/cmd/api/biz/apimodel/object.go new file mode 100644 index 00000000..7ba513d1 --- /dev/null +++ b/sample_douyin/cmd/api/biz/apimodel/object.go @@ -0,0 +1,199 @@ +package apimodel + +import ( + "context" + "mydouyin/cmd/api/biz/rpc" + "mydouyin/kitex_gen/douyincomment" + "mydouyin/kitex_gen/douyinfavorite" + "mydouyin/kitex_gen/douyinuser" + "mydouyin/kitex_gen/douyinvideo" + "mydouyin/kitex_gen/message" + "mydouyin/kitex_gen/relation" + "mydouyin/pkg/consts" + "mydouyin/pkg/errno" +) + +type User struct { + UserID int64 `form:"user_id" json:"id" query:"user_id"` + Username string `form:"name" json:"name" query:"name"` + FollowCount int64 `form:"follow_count" json:"follow_count" query:"follow_count"` + FollowerCount int64 `form:"follower_count" json:"follower_count" query:"follower_count"` + IsFollow bool `form:"is_follow" json:"is_follow" query:"is_follow"` + Avatar string `form:"avatar" json:"avatar" query:"avatar"` + BackgroundImage string `form:"background_image" json:"background_image" query:"background_image"` + Signature string `form:"signature" json:"signature" query:"signature"` + TotalFavorited int64 `form:"total_favorited" json:"total_favorited" query:"total_favoried"` + WorkCount int64 `form:"work_count" json:"work_count" query:"work_count"` + FavoriteCount int64 `form:"favorite_count" json:"favorite_count" query:"favorite_count"` +} + +func PackUser(douyin_user *douyinuser.User) *User { + return &User{ + UserID: douyin_user.UserId, + Username: douyin_user.Username, + FollowCount: douyin_user.FollowCount, + FollowerCount: douyin_user.FollowerCount, + Avatar: douyin_user.Avatar, + BackgroundImage: douyin_user.BackgroundImage, + Signature: douyin_user.Signature, + TotalFavorited: douyin_user.TotalFavorited, + WorkCount: douyin_user.WorkCount, + FavoriteCount: douyin_user.FavoriteCount, + IsFollow: false, + } +} + +func PackUserRelation(douyin_user *douyinuser.User, me int64) *User { + user := PackUser(douyin_user) + r, err := rpc.ValidIfFollowRequest(context.Background(), &relation.ValidIfFollowRequest{FollowId: user.UserID, FollowerId: me}) + if err != nil || r.BaseResp.StatusCode != 0 { + return user + } + user.IsFollow = r.IfFollow + return user +} + +type Video struct { + VideoID int64 `form:"id" json:"id" query:"id"` + Author User `form:"author" json:"author" query:"author"` + PlayUrl string `form:"play_url" json:"play_url" query:"play_url"` + CoverUrl string `form:"cover_url" json:"cover_url" query:"cover_url"` + FavoriteCount int `form:"favorite_count" json:"favorite_count" query:"favorite_count"` + CommentCount int `form:"comment_count" json:"comment_count" query:"comment_count"` + IsFavorite bool `form:"is_favorite" json:"is_favorite" query:"is_favorite"` + Title string `form:"title" json:"title" query:"title"` + UploadTime string `form:"upload_time" json:"upload_time" query:"upload_time"` +} + +func PackVideo(douyin_video *douyinvideo.Video) *Video { + return &Video{ + VideoID: douyin_video.VideoId, + // Author: douyin_video.Author, + PlayUrl: consts.CDNURL + douyin_video.PlayUrl, + CoverUrl: consts.CDNURL + douyin_video.CoverUrl, + FavoriteCount: int(douyin_video.FavoriteCount), + CommentCount: int(douyin_video.CommentCount), + IsFavorite: douyin_video.IsFavorite, + Title: douyin_video.Title, + UploadTime: douyin_video.UploadTime, + } +} + +func PackVideos(douyin_videos []*douyinvideo.Video) []*Video { + res := make([]*Video, 0, 30) + for _, douyin_video := range douyin_videos { + res = append(res, PackVideo(douyin_video)) + } + return res +} + +type FriendUser struct { + User + Message string `form:"message" json:"message" query:"message"` + MsgType int64 `form:"msgType" json:"msgType" query:"msgType"` +} + +func PackFriendUser(douyin_user *douyinuser.User) *FriendUser { + return &FriendUser{ + *PackUser(douyin_user), + "有新消息", + 1, + } +} + +func PackFriendUsers(douyin_users []*douyinuser.User, me int64) ([]*FriendUser, error) { + res := make([]*FriendUser, 0, len(douyin_users)) + friendIds := make([]int64, 0, len(douyin_users)) + for _, douyin_user := range douyin_users { + res = append(res, PackFriendUser(douyin_user)) + friendIds = append(friendIds, douyin_user.UserId) + } + rpc_resp, err := rpc.GetFirstMessage(context.Background(), &message.GetFirstMessageRequest{ + Id: me, + FriendIds: friendIds, + }) + if err != nil { + return nil, err + } + if rpc_resp.BaseResp.StatusCode != 0 { + return nil, errno.NewErrNo(rpc_resp.BaseResp.StatusCode, rpc_resp.BaseResp.StatusMessage) + } + if len(rpc_resp.FirstMessageList) != len(res) { + return nil, errno.QueryErr + } + for i, message := range rpc_resp.FirstMessageList { + if res[i].UserID == message.FriendId { + res[i].Message = message.Message + res[i].MsgType = message.MsgType + } + } + return res, nil +} + +type Comment struct { + CommentID int64 `form:"id" json:"id" query:"id"` + Commentor User `form:"user" json:"user" query:"user"` + Content string `form:"content" json:"content" query:"content"` + CreateDate string `form:"create_date" json:"create_date" query:"create_date"` +} + +func PackComment(douyin_comment *douyincomment.Comment) *Comment { + return &Comment{ + CommentID: douyin_comment.CommentId, + // User: douyin_comment.User + Content: douyin_comment.Content, + CreateDate: douyin_comment.CreateDate, + } +} + +type Favorite struct { + FavoriteID int64 `form:"id" json:"id" query:"id"` + UserID int64 `form:"user_id" json:"user_id" query:"user_id"` + VideoID int64 `form:"video_id" json:"video_id" query:"video_id"` +} + +func PackVFavorite(douyin_favorite *douyinfavorite.Favorite) *Favorite { + return &Favorite{ + FavoriteID: douyin_favorite.FavoriteId, + UserID: douyin_favorite.UserId, + VideoID: douyin_favorite.VideoId, + } +} + +type Message struct { + ID int64 `form:"id" json:"id" query:"id"` + ToUserId int64 `form:"to_user_id" json:"to_user_id" query:"to_user_id"` + FromUserId int64 `form:"from_user_id" json:"from_user_id" query:"from_user_id"` + Content string `form:"content" json:"content" query:"content"` + CreateTime int64 `form:"create_time" json:"create_time" query:"create_time"` +} + +type FristMessage struct { + FriendId int64 + MsgType int //0表示接收的 1表示发送的 -1表示为空 + Content string +} + +func PackMessages(rpc_message []*message.Message) []*Message { + res := make([]*Message, 0, 50) + for _, res_msg := range rpc_message { + res = append(res, &Message{ + ID: res_msg.Id, + ToUserId: res_msg.ToUserId, + FromUserId: res_msg.FromUserId, + Content: res_msg.Content, + CreateTime: res_msg.CreateTime, + }) + } + return res +} + +type MessageSorter []*Message + +func (s MessageSorter) Len() int { return len(s) } + +func (s MessageSorter) Less(i, j int) bool { return s[i].ID < s[j].ID } + +func (s MessageSorter) Swap(i, j int) { + s[i], s[j] = s[j], s[i] +} diff --git a/sample_douyin/cmd/api/biz/apimodel/request.go b/sample_douyin/cmd/api/biz/apimodel/request.go new file mode 100644 index 00000000..3c033478 --- /dev/null +++ b/sample_douyin/cmd/api/biz/apimodel/request.go @@ -0,0 +1,87 @@ +package apimodel + +import "mime/multipart" + +type RegistUserRequest struct { + Username string `json:"username" query:"username" vd:"len($) > 0"` + Password string `json:"password" query:"password" vd:"len($) > 0"` +} + +type CheckUserRequest struct { + Username string `json:"username" query:"username" vd:"len($) > 0"` + Password string `json:"password" query:"password" vd:"len($) > 0"` +} + +type GetUserRequest struct { + UserID string `json:"user_id" query:"user_id"` + Token string `json:"token" query:"token"` +} + +type GetFeedRequest struct { + LatestTime string `json:"latest_time" query:"latest_time"` + Token string `json:"token" query:"token"` +} + +type PublishVideoRequest struct { + Data *multipart.FileHeader `json:"data" form:"data"` + Token string `json:"token" form:"token"` + Title string `json:"title" form:"title"` +} + +type GetPublishListRequest struct { + Token string `json:"token" query:"token"` + UserId string `json:"user_id" query:"user_id"` +} + +type RelationActionRequest struct { + Token string `json:"token" query:"token"` + ToUserId string `json:"to_user_id" query:"to_user_id"` + ActionType string `json:"action_type" query:"action_type"` +} + +type FollowAndFollowerListRequest struct { + UserId string `json:"user_id" query:"user_id"` + Token string `json:"token" query:"token"` +} + +type FriendListRequest struct { + UserId int64 `json:"user_id" query:"user_id"` + Token string `json:"token" query:"token"` +} + +type FavoriteActionRequest struct { + Token string `json:"query" query:"token"` + VideoID string `json:"video_id" query:"video_id"` + ActionType string `json:"action_type" query:"action_type"` +} + +type GetFavoriteListRequest struct { + Token string `json:"query" query:"token"` + UserId string `json:"user_id" query:"user_id"` +} + +type CommentActionRequest struct { + Token string `json:"token" query:"token"` + VideoId string `json:"video_id" query:"video_id"` + ActionType string `json:"action_type" query:"action_type"` + CommentText string `json:"comment_text" query:"comment_text"` + CommentId string `json:"comment_id" query:"comment_id"` +} + +type CommentListRequest struct { + Token string `json:"token" query:"token"` + VideoId string `json:"video_id" query:"video_id"` +} + +type MessageChatRequest struct { + Token string `json:"token" query:"token"` + ToUserId int64 `json:"to_user_id" query:"to_user_id"` + PreMsgTime int64 `json:"pre_msg_time" query:"pre_msg_time"` +} + +type MessageActionRequest struct { + Token string `json:"token" query:"token"` + ToUserId int64 `json:"to_user_id" query:"to_user_id"` + ActionType int32 `json:"action_type" query:"action_type"` + Content string `json:"content" query:"content"` +} diff --git a/sample_douyin/cmd/api/biz/apimodel/response.go b/sample_douyin/cmd/api/biz/apimodel/response.go new file mode 100644 index 00000000..8a3cace2 --- /dev/null +++ b/sample_douyin/cmd/api/biz/apimodel/response.go @@ -0,0 +1,263 @@ +package apimodel + +import ( + "mydouyin/pkg/errno" + + "github.com/cloudwego/hertz/pkg/app" + "github.com/cloudwego/hertz/pkg/protocol/consts" +) + +type Response interface { + SetErr(err error) + Send(c *app.RequestContext) +} + +// @router /douyin/user/register [POST] Response +type RegistUserResponse struct { + StatusCode int64 `form:"status_code" json:"status_code" query:"status_code"` + StatusMsg string `form:"status_msg" json:"status_msg" query:"status_msg"` + UserId int64 `form:"user_id" json:"user_id" query:"user_id"` + Token string `form:"token" json:"token" query:"token"` +} + +func (res *RegistUserResponse) Send(c *app.RequestContext) { + c.JSON(consts.StatusOK, res) +} + +func (res *RegistUserResponse) SetErr(err error) { + Err := errno.ConvertErr(err) + res.StatusCode = Err.ErrCode + res.StatusMsg = Err.ErrMsg +} + +// @router /douyin/user/login [POST] Response +type CheckUserResponse struct { + StatusCode int64 `form:"status_code" json:"status_code" query:"status_code"` + StatusMsg string `form:"status_msg" json:"status_msg" query:"status_msg"` + UserId int64 `form:"user_id" json:"user_id" query:"user_id"` + Token string `form:"token" json:"token" query:"token"` +} + +func (res *CheckUserResponse) Send(c *app.RequestContext) { + c.JSON(consts.StatusOK, res) +} + +func (res *CheckUserResponse) SetErr(err error) { + Err := errno.ConvertErr(err) + res.StatusCode = Err.ErrCode + res.StatusMsg = Err.ErrMsg +} + +// @router /douyin/user/ [GET] +type GetUserResponse struct { + StatusCode int64 `form:"status_code" json:"status_code" query:"status_code"` + StatusMsg string `form:"status_msg" json:"status_msg" query:"status_msg"` + User User `form:"user" json:"user" query:"user"` +} + +func (res *GetUserResponse) Send(c *app.RequestContext) { + c.JSON(consts.StatusOK, res) +} + +func (res *GetUserResponse) SetErr(err error) { + Err := errno.ConvertErr(err) + res.StatusCode = Err.ErrCode + res.StatusMsg = Err.ErrMsg +} + +// @router /douyin/feed/ [GET] +type GetFeedResponse struct { + StatusCode int64 `form:"status_code" json:"status_code" query:"status_code"` + StatusMsg string `form:"status_msg" json:"status_msg" query:"status_msg"` + NextTime int64 `form:"next_time" json:"next_time" query:"next_time"` + VideoList []Video `form:"video_list" json:"video_list" query:"video_list"` +} + +func (res *GetFeedResponse) Send(c *app.RequestContext) { + c.JSON(consts.StatusOK, res) +} + +func (res *GetFeedResponse) SetErr(err error) { + Err := errno.ConvertErr(err) + res.StatusCode = Err.ErrCode + res.StatusMsg = Err.ErrMsg +} + +// @router /douyin/publish/action/ [POST] +type PublishVideoResponse struct { + StatusCode int64 `form:"status_code" json:"status_code" query:"status_code"` + StatusMsg string `form:"status_msg" json:"status_msg" query:"status_msg"` +} + +func (res *PublishVideoResponse) Send(c *app.RequestContext) { + c.JSON(consts.StatusOK, res) +} + +func (res *PublishVideoResponse) SetErr(err error) { + Err := errno.ConvertErr(err) + res.StatusCode = Err.ErrCode + res.StatusMsg = Err.ErrMsg +} + +// @router /douyin/publish/list/ [GET] +type GetPublishListResponse struct { + StatusCode int64 `form:"status_code" json:"status_code" query:"status_code"` + StatusMsg string `form:"status_msg" json:"status_msg" query:"status_msg"` + VideoList []Video `form:"video_list" json:"video_list" query:"video_list"` +} + +func (res *GetPublishListResponse) Send(c *app.RequestContext) { + c.JSON(consts.StatusOK, res) +} + +func (res *GetPublishListResponse) SetErr(err error) { + Err := errno.ConvertErr(err) + res.StatusCode = Err.ErrCode + res.StatusMsg = Err.ErrMsg +} + +// @router /douyin/comment/action/ [POST] +type CommentActionResponse struct { + StatusCode int64 `form:"status_code" json:"status_code" query:"status_code"` + StatusMsg string `form:"status_msg" json:"status_msg" query:"status_msg"` + Comment Comment `form:"comment" json:"comment" query:"comment"` +} + +func (res *CommentActionResponse) Send(c *app.RequestContext) { + c.JSON(consts.StatusOK, res) +} + +func (res *CommentActionResponse) SetErr(err error) { + Err := errno.ConvertErr(err) + res.StatusCode = Err.ErrCode + res.StatusMsg = Err.ErrMsg +} + +// @router /douyin/comment/list/ [GET] +type CommentListResponse struct { + StatusCode int64 `form:"status_code" json:"status_code" query:"status_code"` + StatusMsg string `form:"status_msg" json:"status_msg" query:"status_msg"` + CommentList []Comment `form:"comment_list" json:"comment_list" query:"comment_list"` +} + +func (res *CommentListResponse) Send(c *app.RequestContext) { + c.JSON(consts.StatusOK, res) +} + +func (res *CommentListResponse) SetErr(err error) { + Err := errno.ConvertErr(err) + res.StatusCode = Err.ErrCode + res.StatusMsg = Err.ErrMsg +} + +// @router /douyin/relation/action/ [POST] +type RelationActionResponse struct { + StatusCode int64 `form:"status_code" json:"status_code" query:"status_code"` + StatusMsg string `form:"status_msg" json:"status_msg" query:"status_msg"` +} + +func (res *RelationActionResponse) Send(c *app.RequestContext) { + c.JSON(consts.StatusOK, res) +} + +func (res *RelationActionResponse) SetErr(err error) { + Err := errno.ConvertErr(err) + res.StatusCode = Err.ErrCode + res.StatusMsg = Err.ErrMsg +} + +type FollowAndFollowerListReponse struct { + StatusCode int64 `form:"status_code" json:"status_code" query:"status_code"` + StatusMsg string `form:"status_msg" json:"status_msg" query:"status_msg"` + UserList []*User `form:"user_list" json:"user_list" query:"user_list"` +} + +func (res *FollowAndFollowerListReponse) Send(c *app.RequestContext) { + c.JSON(consts.StatusOK, res) +} + +func (res *FollowAndFollowerListReponse) SetErr(err error) { + Err := errno.ConvertErr(err) + res.StatusCode = Err.ErrCode + res.StatusMsg = Err.ErrMsg +} + +type FriendListReponse struct { + StatusCode int64 `form:"status_code" json:"status_code" query:"status_code"` + StatusMsg string `form:"status_msg" json:"status_msg" query:"status_msg"` + UserList []*FriendUser `form:"user_list" json:"user_list" query:"user_list"` +} + +func (res *FriendListReponse) Send(c *app.RequestContext) { + c.JSON(consts.StatusOK, res) +} + +func (res *FriendListReponse) SetErr(err error) { + Err := errno.ConvertErr(err) + res.StatusCode = Err.ErrCode + res.StatusMsg = Err.ErrMsg +} + +// @router /douyin/favorite/action/ [POST] +type FavoriteActionResponse struct { + StatusCode int64 `form:"status_code" json:"status_code" query:"status_code"` + StatusMsg string `form:"status_msg" json:"status_msg" query:"status_msg"` +} + +func (res *FavoriteActionResponse) Send(c *app.RequestContext) { + c.JSON(consts.StatusOK, res) +} + +func (res *FavoriteActionResponse) SetErr(err error) { + Err := errno.ConvertErr(err) + res.StatusCode = Err.ErrCode + res.StatusMsg = Err.ErrMsg +} + +// @router /douyin/favorite/list/ [GET] +type GetFavoriteListResponse struct { + StatusCode int64 `form:"status_code" json:"status_code" query:"status_code"` + StatusMsg string `form:"status_msg" json:"status_msg" query:"status_msg"` + VideoList []Video `form:"video_list" json:"video_list" query:"video_list"` +} + +func (res *GetFavoriteListResponse) Send(c *app.RequestContext) { + c.JSON(consts.StatusOK, res) +} + +func (res *GetFavoriteListResponse) SetErr(err error) { + Err := errno.ConvertErr(err) + res.StatusCode = Err.ErrCode + res.StatusMsg = Err.ErrMsg +} + +type MessageChatResponse struct { + StatusCode int64 `form:"status_code" json:"status_code" query:"status_code"` + StatusMsg string `form:"status_msg" json:"status_msg" query:"status_msg"` + MessageList []*Message `form:"message_list" json:"message_list" query:"message_list"` +} + +func (res *MessageChatResponse) Send(c *app.RequestContext) { + c.JSON(consts.StatusOK, res) +} + +func (res *MessageChatResponse) SetErr(err error) { + Err := errno.ConvertErr(err) + res.StatusCode = Err.ErrCode + res.StatusMsg = Err.ErrMsg +} + +type MessageActionResponse struct { + StatusCode int64 `form:"status_code" json:"status_code" query:"status_code"` + StatusMsg string `form:"status_msg" json:"status_msg" query:"status_msg"` +} + +func (res *MessageActionResponse) Send(c *app.RequestContext) { + c.JSON(consts.StatusOK, res) +} + +func (res *MessageActionResponse) SetErr(err error) { + Err := errno.ConvertErr(err) + res.StatusCode = Err.ErrCode + res.StatusMsg = Err.ErrMsg +} diff --git a/sample_douyin/cmd/api/biz/cache/favoritecache.go b/sample_douyin/cmd/api/biz/cache/favoritecache.go new file mode 100644 index 00000000..4893ef2f --- /dev/null +++ b/sample_douyin/cmd/api/biz/cache/favoritecache.go @@ -0,0 +1,78 @@ +package cache + +import ( + "context" + "encoding/json" + "log" + "mydouyin/cmd/api/biz/rpc" + "mydouyin/kitex_gen/douyinfavorite" + "mydouyin/pkg/errno" + "time" +) + +type FavoriteCache struct { + keyName string + mq *CommandQueue +} + +type FavoriteActionCommand struct { + UserId int64 + VideoId int64 + ActionType string +} + +var FC *FavoriteCache + +func initFavoriteCache() { + FC = new(FavoriteCache) + FC.keyName = "favorite_list" + FC.mq = NewCommandQueue(context.Background(), "favorite") + + go FC.listen() +} + +func (c *FavoriteCache) listen() { + for { + msg, err := c.mq.ConsumeMessage() + if err != nil { + continue + } + var cmd FavoriteActionCommand + json.Unmarshal(msg, &cmd) + log.Printf("[********FavoriteCache********] recover command:%v", cmd) + err = c.execCommand(&cmd) + if err != nil { + log.Printf("[********FavoriteCache********] command exec fail, error:%v", err) + data, _ := json.Marshal(cmd) + c.mq.ProductionMessage(data) + time.Sleep(time.Second * 10) + } else { + log.Printf("[********FavoriteCache********] command exec success!!!") + } + } +} + +func (c *FavoriteCache) execCommand(cmd *FavoriteActionCommand) error { + resp, err := rpc.FavoriteAction(c.mq.ctx, &douyinfavorite.FavoriteActionRequest{ + UserId: cmd.UserId, + VideoId: cmd.VideoId, + ActionType: cmd.ActionType, + }) + if err != nil { + return err + } + if resp.BaseResp.StatusCode != 0 { + return errno.NewErrNo(resp.BaseResp.StatusCode, resp.BaseResp.StatusMessage) + } + return nil +} + +func (c *FavoriteCache) CommitFavoriteActionCommand(user_id, video_id int64, action_type string) error { + cmd := FavoriteActionCommand{ + UserId: user_id, + VideoId: video_id, + ActionType: action_type, + } + data, _ := json.Marshal(cmd) + return c.mq.ProductionMessage(data) +} diff --git a/sample_douyin/cmd/api/biz/cache/init.go b/sample_douyin/cmd/api/biz/cache/init.go new file mode 100644 index 00000000..e33102f0 --- /dev/null +++ b/sample_douyin/cmd/api/biz/cache/init.go @@ -0,0 +1,16 @@ +package cache + +import "github.com/go-redis/redis/v8" + +var redisClient *redis.Client + +func Init() { + redisClient = redis.NewClient(&redis.Options{ + Addr: "localhost:6379", + Password: "", // no password set + DB: 0, // use default DB + }) + // initVideoCache() + initMessageCache() + initFavoriteCache() +} diff --git a/sample_douyin/cmd/api/biz/cache/messagecache.go b/sample_douyin/cmd/api/biz/cache/messagecache.go new file mode 100644 index 00000000..9cbd20b5 --- /dev/null +++ b/sample_douyin/cmd/api/biz/cache/messagecache.go @@ -0,0 +1,301 @@ +package cache + +import ( + "context" + "crypto/md5" + "encoding/json" + "errors" + "log" + "math" + "mydouyin/cmd/api/biz/apimodel" + "mydouyin/cmd/api/biz/rpc" + "mydouyin/kitex_gen/message" + "mydouyin/kitex_gen/relation" + "mydouyin/pkg/errno" + "strconv" + "sync" + "time" + + "github.com/go-redis/redis/v8" +) + +type MessageCache struct { + keyName string + mq *CommandQueue + lasted_time_map sync.Map +} + +type CreateMessageCommand struct { + FromUserId int64 + ToUserId int64 + Content string +} + +var MC *MessageCache + +func initMessageCache() { + MC = new(MessageCache) + MC.keyName = "message_list" + MC.mq = NewCommandQueue(context.Background(), "message") + + go MC.listen() +} + +// 获取from_user_id最新发给to_uer_id的消息 +func (c *MessageCache) GetLastedMsg(from_user_id, to_user_id int64) (lastedTime int64, err error) { + var msg interface{} + var ok bool = false + for !ok { + msg, ok = c.lasted_time_map.Load(strconv.FormatInt(from_user_id, 10) + strconv.FormatInt(to_user_id, 10)) + time.Sleep(50 * time.Millisecond) + } + lastedTime = msg.(*apimodel.Message).CreateTime + return +} + +func (c *MessageCache) PushLastedMsg(msg *apimodel.Message) { + c.lasted_time_map.Store(strconv.FormatInt(msg.FromUserId, 10)+strconv.FormatInt(msg.ToUserId, 10), msg) +} + +func (c *MessageCache) listen() { + for { + msg, err := c.mq.ConsumeMessage() + if err != nil { + continue + } + var cmd CreateMessageCommand + json.Unmarshal(msg, &cmd) + log.Printf("[********MessageCache********] recover command:%v", cmd) + err = c.execCommand(&cmd) + if err != nil { + log.Printf("[********MessageCache********] command exec fail, error:%v", err) + data, _ := json.Marshal(cmd) + c.mq.ProductionMessage(data) + time.Sleep(time.Second * 10) + } else { + log.Printf("[********MessageCache********] command exec success!!!") + } + } +} + +func (c *MessageCache) execCommand(cmd *CreateMessageCommand) error { + resp, err := rpc.CreateMessage(c.mq.ctx, &message.CreateMessageRequest{ + FromUserId: cmd.FromUserId, + ToUserId: cmd.ToUserId, + Content: cmd.Content, + }) + if err != nil { + return err + } + if resp.BaseResp.StatusCode != 0 { + return errno.NewErrNo(resp.BaseResp.StatusCode, resp.BaseResp.StatusMessage) + } + //上传成功,将新消息写入缓存 + msg := apimodel.Message{ + ID: resp.Id, + CreateTime: resp.CreateTime, + ToUserId: cmd.ToUserId, + FromUserId: cmd.FromUserId, + Content: cmd.Content, + } + err = c.SaveMessage([]*apimodel.Message{&msg}) + c.PushLastedMsg(&msg) + return err +} + +func (c *MessageCache) getMsgFromSet(from_id, to_id int64) (msg *apimodel.Message, err error) { + key := md5.Sum([]byte(strconv.FormatUint(c.hash_key(from_id, to_id), 10) + c.keyName)) + exist, err := redisClient.Exists(c.mq.ctx, string(key[:])).Result() + if err != nil { + return nil, err + } + if exist != 1 { + return nil, errors.New("key not exist") + } + result, err := redisClient.Get(c.mq.ctx, string(key[:])).Result() + defer redisClient.Expire(c.mq.ctx, string(key[:]), 12*time.Hour) + if err != nil { + return nil, err + } + msg = new(apimodel.Message) + json.Unmarshal([]byte(result), msg) + return msg, nil +} + +func (c *MessageCache) setMsgToSet(msg *apimodel.Message) error { + key := md5.Sum([]byte(strconv.FormatUint(c.hash_key(msg.FromUserId, msg.ToUserId), 10) + c.keyName)) + val, _ := json.Marshal(msg) + result, err := redisClient.Set(c.mq.ctx, string(key[:]), val, 12*time.Hour).Result() + if err != nil || result != "OK" { + return err + } + return nil +} + +func (c *MessageCache) hash_key(id1, id2 int64) uint64 { + if id1 > id2 { + return uint64(id2 | id1<<32) + } else { + return uint64(id1 | (id2 << 32)) + } +} + +func (c *MessageCache) CommitCreateMessageCommand(from_user_id, to_user_id int64, content string) error { + cmd := CreateMessageCommand{ + FromUserId: from_user_id, + ToUserId: to_user_id, + Content: content, + } + data, _ := json.Marshal(cmd) + return c.mq.ProductionMessage(data) +} + +func (c *MessageCache) CommitCreateMessageCommandV0(from_user_id, to_user_id int64, content string) error { + cmd := CreateMessageCommand{ + FromUserId: from_user_id, + ToUserId: to_user_id, + Content: content, + } + return c.execCommand(&cmd) + // return c.mq.ProductionMessage(data) +} + +func (c *MessageCache) GetFirstMessage(me int64, friendIds []int64) (frist_msg_list []*apimodel.FristMessage) { + frist_msg_list = make([]*apimodel.FristMessage, 0, len(friendIds)) + for _, friendId := range friendIds { + msg, err := c.getMsgFromSet(friendId, me) + if err != nil { + frist_msg_list = append(frist_msg_list, &apimodel.FristMessage{ + FriendId: friendId, + MsgType: -1, + }) + } else { + if msg.FromUserId == me { + frist_msg_list = append(frist_msg_list, &apimodel.FristMessage{ + FriendId: friendId, + Content: msg.Content, + MsgType: 1, + }) + } else { + frist_msg_list = append(frist_msg_list, &apimodel.FristMessage{ + FriendId: friendId, + Content: msg.Content, + MsgType: 0, + }) + } + } + } + return +} + +// 设置最新消息 +func (c *MessageCache) SetFirstMessage(msg *apimodel.Message) (err error) { + return c.setMsgToSet(msg) +} + +func (c *MessageCache) SaveMessage(messages []*apimodel.Message) error { + frist_msg := new(apimodel.Message) + for i := 0; i < len(messages); i++ { + if messages[i].CreateTime > frist_msg.CreateTime { + frist_msg = messages[i] + } + msgKey := strconv.FormatUint(c.hash_key(messages[i].FromUserId, messages[i].ToUserId), 10) + c.keyName + message, _ := json.Marshal(messages[i]) + // msgKey := md5.Sum([]byte(strconv.FormatInt(messages[i].ID, 10) + strconv.FormatInt(messages[i].ToUserId, 10) + c.keyname)) + _, err := redisClient.ZAdd(c.mq.ctx, msgKey, &redis.Z{Score: float64(messages[i].CreateTime), Member: message}).Result() + if err != nil { + return err + } + _, err1 := redisClient.Expire(c.mq.ctx, msgKey, time.Hour*12).Result() + if err1 != nil { + return err1 + } + } + //更新fristmessage缓存 + return c.SetFirstMessage(frist_msg) +} + +func (c *MessageCache) InitMessageFromDB(fromUserID int64) error { + resp, err := rpc.GetFriend(c.mq.ctx, &relation.GetFriendRequest{ + MeId: fromUserID, + }) + if err != nil { + return err + } + friendIds := resp.FriendIds + for i := 0; i < len(friendIds); i++ { + msgkey := strconv.FormatUint(c.hash_key(fromUserID, friendIds[i]), 10) + c.keyName + ex, err := redisClient.Exists(c.mq.ctx, msgkey).Result() + if err != nil { + return err + } + if ex == 0 { + messageList := make([]*apimodel.Message, 0) + // 从数据库拉取所有我发的消息 + resp, err := rpc.GetMessageList(c.mq.ctx, &message.GetMessageListRequest{ + FromUserId: fromUserID, + ToUserId: friendIds[i], + PreMsgTime: 0, + }) + if err != nil { + return err + } + messageList = append(messageList, apimodel.PackMessages(resp.MessageList)...) + // 从数据库拉取所有发给我的消息 + resp, err = rpc.GetMessageList(c.mq.ctx, &message.GetMessageListRequest{ + FromUserId: friendIds[i], + ToUserId: fromUserID, + PreMsgTime: time.Now().Unix(), + }) + if err != nil { + return err + } + messageList = append(messageList, apimodel.PackMessages(resp.MessageList)...) + // 存入缓存 + err = c.SaveMessage(messageList) + if err != nil { + return err + } + } + + } + return nil +} + +func (c *MessageCache) GetMessage(fromUserID int64, toUserID int64, preMsgTime int64) ([]*apimodel.Message, bool, error) { + messageList := make([]*apimodel.Message, 0) + msgkey := strconv.FormatUint(c.hash_key(fromUserID, toUserID), 10) + c.keyName + ex, err := redisClient.Exists(c.mq.ctx, msgkey).Result() + if err != nil { + return nil, false, err + } + if ex == 0 { + return nil, false, nil + } + _, err = redisClient.Expire(c.mq.ctx, msgkey, time.Hour*12).Result() + if err != nil { + return nil, false, err + } + values, err := redisClient.ZRangeByScore(c.mq.ctx, msgkey, &redis.ZRangeBy{ + Min: strconv.FormatInt(preMsgTime, 10), + Max: strconv.FormatInt(math.MaxInt64, 10), + }).Result() + // log.Println(values) + if err != nil { + return nil, false, err + } + + for i := 0; i < len(values); i++ { + message := new(apimodel.Message) + err = json.Unmarshal([]byte(values[i]), &message) + if err != nil { + continue + } + //由于要返回>preMsgTime的记录,因此需要剔除掉preMsgTime处的记录 + if message.CreateTime == preMsgTime { + continue + } + messageList = append(messageList, message) + } + return messageList, true, nil +} diff --git a/sample_douyin/cmd/api/biz/cache/messagequeue.go b/sample_douyin/cmd/api/biz/cache/messagequeue.go new file mode 100644 index 00000000..2fa312f7 --- /dev/null +++ b/sample_douyin/cmd/api/biz/cache/messagequeue.go @@ -0,0 +1,32 @@ +package cache + +import ( + "context" +) + +//消息队列,调用ProductionCommand将指令结构体放入redis的list中,另起一个线程调用ConsumeCommand接收消息,反序列化指令结构体交给自定义的handler函数执行 +//在videoHandel中有使用 +type CommandQueue struct { + ListName string + ctx context.Context +} + +func NewCommandQueue(ctx context.Context, listName string) *CommandQueue { + return &CommandQueue{ + ListName: listName, + ctx: ctx, + } +} + +func (cq *CommandQueue) ProductionMessage(command []byte) error { + _, err := redisClient.LPush(cq.ctx, cq.ListName, command).Result() + return err +} + +func (cq *CommandQueue) ConsumeMessage() ([]byte, error) { + item, err := redisClient.BRPop(cq.ctx, 0, cq.ListName).Result() + if err != nil { + return nil, err + } + return []byte(item[1]), err +} diff --git a/sample_douyin/cmd/api/biz/handler/douyinapi/api_service.go b/sample_douyin/cmd/api/biz/handler/douyinapi/api_service.go new file mode 100644 index 00000000..be5d7f19 --- /dev/null +++ b/sample_douyin/cmd/api/biz/handler/douyinapi/api_service.go @@ -0,0 +1,383 @@ +// Code generated by hertz generator. + +package douyinapi + +import ( + "context" + "mydouyin/cmd/api/biz/apimodel" + "mydouyin/cmd/api/biz/mw" + "mydouyin/cmd/api/biz/service" + "mydouyin/pkg/consts" + "mydouyin/pkg/errno" + + "github.com/cloudwego/hertz/pkg/app" +) + +// 基础接口 +// +// FavoriteAction +// @router /douyin/favorite/action/ [POST] +func FavoriteAction(ctx context.Context, c *app.RequestContext) { + user, exists := c.Get(consts.IdentityKey) + if !exists { + SendResponse(c, errno.AuthorizationFailedErr, nil) + return + } + var err error + var req apimodel.FavoriteActionRequest + err = c.BindAndValidate(&req) + if err != nil { + SendResponse(c, err, nil) + return + } + resp, err := service.NewFavoriteService(ctx).FavoriteAction(req, user.(*apimodel.User)) + if err != nil { + resp.SetErr(err) + resp.Send(c) + } + resp.SetErr(errno.Success) + resp.Send(c) +} + +// GetFavoriteList +// @router /douyin/favorite/list/ [GET] +func GetFavoriteList(ctx context.Context, c *app.RequestContext) { + + user, exists := c.Get(consts.IdentityKey) + if !exists { + SendResponse(c, errno.AuthorizationFailedErr, nil) + return + } + + var err error + var req apimodel.GetFavoriteListRequest + err = c.BindAndValidate(&req) + if err != nil { + // c.String(consts.StatusBadRequest, err.Error()) + SendResponse(c, err, nil) + return + } + + resp, err := service.NewFavoriteService(ctx).GetFavoriteList(req, user.(*apimodel.User)) + if err != nil { + resp.SetErr(errno.Success) + resp.Send(c) + } + resp.SetErr(errno.Success) + resp.Send(c) +} + +// GetFeed +// @router /douyin/feed/ [GET] +func GetFeed(ctx context.Context, c *app.RequestContext) { + user, exists := c.Get(consts.IdentityKey) + var userId int64 = -1 + if exists { + userId = user.(*apimodel.User).UserID + } + var err error + var req apimodel.GetFeedRequest + err = c.BindAndValidate(&req) + if err != nil { + // c.String(consts.StatusBadRequest, err.Error()) + SendResponse(c, err, nil) + return + } + + resp, err := service.NewFeedService(ctx).GetFeed(req, userId) + if err != nil { + resp.SetErr(err) + resp.Send(c) + return + } + resp.SetErr(errno.Success) + resp.Send(c) +} + +// GetPublishList +// @router /douyin/publish/list [GET] +func GetPublishList(ctx context.Context, c *app.RequestContext) { + user, exists := c.Get(consts.IdentityKey) + if !exists { + SendResponse(c, errno.AuthorizationFailedErr, nil) + return + } + + var err error + var req apimodel.GetPublishListRequest + + err = c.BindAndValidate(&req) + if err != nil { + // c.String(consts.StatusBadRequest, err.Error()) + SendResponse(c, err, nil) + return + } + + resp, err := service.NewPublishService(ctx).GetPublishList(req, user.(*apimodel.User)) + if err != nil { + resp.SetErr(err) + resp.Send(c) + } + resp.SetErr(errno.Success) + resp.Send(c) +} + +// Publish Video +// @router /douyin/publish/action/ [POST] +func PublishVideo(ctx context.Context, c *app.RequestContext) { + user, exists := c.Get(consts.IdentityKey) + if !exists { + SendResponse(c, errno.AuthorizationFailedErr, nil) + return + } + var err error + var req apimodel.PublishVideoRequest + err = c.BindAndValidate(&req) + if err != nil { + // c.String(consts.StatusBadRequest, err.Error()) + SendResponse(c, err, nil) + return + } + resp, err := service.NewPublishService(ctx).PublishVideo(req, user.(*apimodel.User)) + if err != nil { + resp.SetErr(err) + resp.Send(c) + return + } + resp.SetErr(errno.Success) + resp.Send(c) +} + +// CreateUser . +// @router /douyin/user/register/ [POST] +func RegistUser(ctx context.Context, c *app.RequestContext) { + var err error + var req apimodel.RegistUserRequest + err = c.BindAndValidate(&req) + if err != nil { + // c.String(consts.StatusBadRequest, err.Error()) + SendResponse(c, err, nil) + return + } + + resp, err := service.NewUserService(ctx).RegistUser(req) + if err != nil { + resp.SetErr(err) + resp.Send(c) + return + } + mw.JwtMiddleware.LoginHandler(ctx, c) +} + +// CheckUser . +// @router /douyin/user/login/ [POST] +func CheckUser(ctx context.Context, c *app.RequestContext) { + mw.JwtMiddleware.LoginHandler(ctx, c) + +} + +// GetUser . +// @router /douyin/user/ [GET] +func GetUser(ctx context.Context, c *app.RequestContext) { + var err error + var req apimodel.GetUserRequest + err = c.BindAndValidate(&req) + if err != nil { + SendResponse(c, err, nil) + return + } + resp, err := service.NewUserService(ctx).GetUser(req) + if err != nil { + resp.SetErr(err) + resp.Send(c) + } + + resp.SetErr(errno.Success) + resp.Send(c) +} + +// CommentAction . +// @router /douyin/comment/action [POST] +func CommentAction(ctx context.Context, c *app.RequestContext) { + user, exists := c.Get(consts.IdentityKey) + if !exists { + SendResponse(c, errno.AuthorizationFailedErr, nil) + return + } + var err error + var req apimodel.CommentActionRequest + err = c.BindAndValidate((&req)) + if err != nil { + SendResponse(c, err, nil) + return + } + + resp, err := service.NewCommentService(ctx).CommentAction(req, user.(*apimodel.User)) + if err != nil { + resp.SetErr(err) + resp.Send(c) + return + } + + resp.SetErr(errno.Success) + resp.Send(c) +} + +// @router /douyin/comment/list/ [GET] +func CommentList(ctx context.Context, c *app.RequestContext) { + var err error + var req apimodel.CommentListRequest + err = c.BindAndValidate(&req) + if err != nil { + SendResponse(c, err, nil) + return + } + resp, err := service.NewCommentService(ctx).CommentList(req) + if err != nil { + resp.SetErr(err) + resp.Send(c) + return + } + resp.SetErr(errno.Success) + resp.Send(c) +} + +// @router /douyin/relation/action/ [POST] +func RelationAction(ctx context.Context, c *app.RequestContext) { + var err error + var req apimodel.RelationActionRequest + err = c.BindAndValidate(&req) + if err != nil { + SendResponse(c, err, nil) + return + } + user, exists := c.Get(consts.IdentityKey) + if !exists { + SendResponse(c, errno.AuthorizationFailedErr, nil) + return + } + resp, err := service.NewRelationService(ctx).RelationAction(req, user.(*apimodel.User)) + if err != nil { + resp.SetErr(err) + resp.Send(c) + return + } + resp.SetErr(errno.Success) + resp.Send(c) +} + +// @router /douyin/relation/follow/list/ [GET] +func FollowList(ctx context.Context, c *app.RequestContext) { + var err error + var req apimodel.FollowAndFollowerListRequest + err = c.BindAndValidate(&req) + if err != nil { + SendResponse(c, err, nil) + return + } + user, exists := c.Get(consts.IdentityKey) + if !exists { + SendResponse(c, errno.AuthorizationFailedErr, nil) + return + } + resp, err := service.NewRelationService(ctx).FollowAndFollowerList(req, user.(*apimodel.User), 1) + if err != nil { + resp.SetErr(err) + resp.Send(c) + return + } + resp.SetErr(errno.Success) + resp.Send(c) +} + +// @router /douyin/relation/follower/list/ [GET] +func FollowerList(ctx context.Context, c *app.RequestContext) { + var err error + var req apimodel.FollowAndFollowerListRequest + err = c.BindAndValidate(&req) + if err != nil { + SendResponse(c, err, nil) + return + } + user, exists := c.Get(consts.IdentityKey) + if !exists { + SendResponse(c, errno.AuthorizationFailedErr, nil) + return + } + resp, err := service.NewRelationService(ctx).FollowAndFollowerList(req, user.(*apimodel.User), 2) + if err != nil { + resp.SetErr(err) + resp.Send(c) + return + } + resp.SetErr(errno.Success) + resp.Send(c) +} + +// @router /douyin/relation/friend/list/ [GET] +func FriendList(ctx context.Context, c *app.RequestContext) { + var err error + var req apimodel.FriendListRequest + err = c.BindAndValidate(&req) + if err != nil { + SendResponse(c, err, nil) + return + } + + resp, err := service.NewRelationService(ctx).FriendList(req) + if err != nil { + resp.SetErr(err) + resp.Send(c) + return + } + resp.SetErr(errno.Success) + resp.Send(c) +} + +// @router /douyin/message/chat/ [GET] +func MessageChat(ctx context.Context, c *app.RequestContext) { + var err error + var req apimodel.MessageChatRequest + err = c.BindAndValidate(&req) + if err != nil { + SendResponse(c, err, nil) + return + } + user, exists := c.Get(consts.IdentityKey) + if !exists { + SendResponse(c, errno.AuthorizationFailedErr, nil) + return + } + resp, err := service.NewMessageService(ctx).MessageChat(req, user.(*apimodel.User)) + if err != nil { + resp.SetErr(err) + resp.Send(c) + return + } + resp.SetErr(errno.Success) + resp.Send(c) +} + +// @router /douyin/message/action/ [POST] +func MessageAction(ctx context.Context, c *app.RequestContext) { + var err error + var req apimodel.MessageActionRequest + err = c.BindAndValidate(&req) + if err != nil { + SendResponse(c, err, nil) + return + } + user, exists := c.Get(consts.IdentityKey) + if !exists { + SendResponse(c, errno.AuthorizationFailedErr, nil) + return + } + resp, err := service.NewMessageService(ctx).MessageAction(req, user.(*apimodel.User)) + if err != nil { + resp.SetErr(err) + resp.Send(c) + return + } + resp.SetErr(errno.Success) + resp.Send(c) +} diff --git a/sample_douyin/cmd/api/biz/handler/douyinapi/handler.go b/sample_douyin/cmd/api/biz/handler/douyinapi/handler.go new file mode 100644 index 00000000..8c15ab30 --- /dev/null +++ b/sample_douyin/cmd/api/biz/handler/douyinapi/handler.go @@ -0,0 +1,30 @@ +package douyinapi + +import ( + "mydouyin/cmd/api/biz/apimodel" + "mydouyin/pkg/errno" + + "github.com/cloudwego/hertz/pkg/app" + "github.com/cloudwego/hertz/pkg/protocol/consts" +) + +type Response struct { + Code int64 `json:"status_code"` + Message string `json:"status_msg"` + Data interface{} `json:"data"` +} + +//SendResponse pack response +func SendResponse(c *app.RequestContext, err error, data interface{}) { + Err := errno.ConvertErr(err) + c.JSON(consts.StatusOK, Response{ + Code: Err.ErrCode, + Message: Err.ErrMsg, + Data: data, + }) +} + +func SendError(c *app.RequestContext, err error, res apimodel.Response) { + res.SetErr(err) + res.Send(c) +} diff --git a/sample_douyin/cmd/api/biz/handler/ping.go b/sample_douyin/cmd/api/biz/handler/ping.go new file mode 100644 index 00000000..c6bc5d7e --- /dev/null +++ b/sample_douyin/cmd/api/biz/handler/ping.go @@ -0,0 +1,29 @@ +// Code generated by hertz generator. + +package handler + +import ( + "context" + + myconsts "mydouyin/pkg/consts" + + "github.com/cloudwego/hertz/pkg/app" + "github.com/cloudwego/hertz/pkg/common/utils" + "github.com/cloudwego/hertz/pkg/protocol/consts" +) + +// Ping . +func Ping(ctx context.Context, c *app.RequestContext) { + userid, exists := c.Get(myconsts.IdentityKey) + if exists { + c.JSON(consts.StatusOK, utils.H{ + "message": "pong", + "user_id": userid, + }) + } else { + c.JSON(consts.StatusOK, utils.H{ + "message": "pong", + "user_id": "没登陆", + }) + } +} diff --git a/sample_douyin/cmd/api/biz/mw/jwt.go b/sample_douyin/cmd/api/biz/mw/jwt.go new file mode 100644 index 00000000..dd0e029e --- /dev/null +++ b/sample_douyin/cmd/api/biz/mw/jwt.go @@ -0,0 +1,103 @@ +package mw + +import ( + "context" + "mydouyin/cmd/api/biz/apimodel" + "mydouyin/cmd/api/biz/rpc" + "mydouyin/kitex_gen/douyinuser" + "mydouyin/pkg/consts" + "mydouyin/pkg/errno" + "net/http" + "time" + + "github.com/cloudwego/hertz/pkg/app" + "github.com/cloudwego/hertz/pkg/common/utils" + "github.com/hertz-contrib/jwt" +) + +var JwtMiddleware *HertzJWTMiddleware + +func InitJWT() { + JwtMiddleware, _ = New(&HertzJWTMiddleware{ + //用于设置签名密钥* + Key: []byte(consts.SecretKey), + //用于设置token的获取源,可选header、query、cookie、param、form 默认header: Authorization + TokenLookup: "header: Authorization, query: token, form: token, cookie: jwt", + //用于设置从header中获取token时的前缀,默认为Bearer + TokenHeadName: "Bearer", + //设置获取当前时间的函数 + TimeFunc: time.Now, + //token的过期时间 + Timeout: 24 * time.Hour, + //最大token刷新时间,允许客户端在tokenTime+MaxRefresh内刷新token的有效时间,追加一个timeout时长 + MaxRefresh: time.Hour, + //用于设置检索身份的键 默认indentity + IdentityKey: consts.IdentityKey, + //设置获取身份信息的函数,与PayloadFunc一致 + IdentityHandler: func(ctx context.Context, c *app.RequestContext) interface{} { + claims := ExtractClaims(ctx, c) + return &apimodel.User{ + UserID: int64(claims[consts.IdentityKey].(float64)), + } + }, + //登陆成功后为向token中添加自定义负载信息的函数,额外存储了用户id,如不设置则只存储token的过期时间和创建时间 + PayloadFunc: func(data interface{}) MapClaims { + if v, ok := data.(int64); ok { + return MapClaims{ + consts.IdentityKey: v, + } + } + return MapClaims{} + }, + //设置登陆时认证用户信息的函数** + Authenticator: func(ctx context.Context, c *app.RequestContext) (interface{}, error) { + var err error + var req apimodel.CheckUserRequest + if err = c.BindAndValidate(&req); err != nil { + return "", jwt.ErrMissingLoginValues + } + if len(req.Username) == 0 || len(req.Password) == 0 { + return "", jwt.ErrMissingLoginValues + } + resp, err := rpc.CheckUser(context.Background(), &douyinuser.CheckUserRequest{ + Username: req.Username, + Password: req.Password, + }) + if err != nil { + return 0, err + } + if resp.BaseResp.StatusCode != 0 { + return 0, errno.NewErrNo(resp.BaseResp.StatusCode, resp.BaseResp.StatusMessage) + } + return resp.UserId, nil + }, + //设置登陆的响应函数 + LoginResponse: func(ctx context.Context, c *app.RequestContext, code int, token string, expire time.Time, identity interface{}) { + res := &apimodel.CheckUserResponse{ + StatusCode: errno.Success.ErrCode, + StatusMsg: "", + UserId: identity.(int64), + Token: token, + } + res.Send(c) + }, + //验证流程失败的响应函数 + Unauthorized: func(ctx context.Context, c *app.RequestContext, code int, message string) { + c.JSON(http.StatusOK, utils.H{ + "status_code": errno.AuthorizationFailedErr.ErrCode, + "status_msg": message, + "token": nil, + "user_id": nil, + }) + }, + //设置jwt校验流程发生错误时相应所包含的错误信息 + HTTPStatusMessageFunc: func(e error, ctx context.Context, c *app.RequestContext) string { + switch t := e.(type) { + case errno.ErrNo: + return t.ErrMsg + default: + return t.Error() + } + }, + }) +} diff --git a/sample_douyin/cmd/api/biz/mw/my_jwt.go b/sample_douyin/cmd/api/biz/mw/my_jwt.go new file mode 100644 index 00000000..32e1d8e0 --- /dev/null +++ b/sample_douyin/cmd/api/biz/mw/my_jwt.go @@ -0,0 +1,886 @@ +// The MIT License (MIT) +// +// Copyright (c) 2016 Bo-Yi Wu +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +// +// This file may have been modified by CloudWeGo authors. All CloudWeGo +// Modifications are Copyright 2022 CloudWeGo Authors. + +package mw + +import ( + "context" + "crypto/rsa" + "encoding/json" + "errors" + "io/ioutil" + //"mydouyin/cmd/api/biz/cache" + "net/http" + //"strconv" + "strings" + "time" + + "github.com/cloudwego/hertz/pkg/app" + "github.com/cloudwego/hertz/pkg/protocol" + "github.com/golang-jwt/jwt/v4" +) + +// MapClaims type that uses the map[string]interface{} for JSON decoding +// This is the default claims type if you don't supply one +type MapClaims map[string]interface{} + +// HertzJWTMiddleware provides a Json-Web-Token authentication implementation. On failure, a 401 HTTP response +// is returned. On success, the wrapped middleware is called, and the userID is made available as +// c.Get("userID").(string). +// Users can get a token by posting a json request to LoginHandler. The token then needs to be passed in +// the Authentication header. Example: Authorization:Bearer XXX_TOKEN_XXX +type HertzJWTMiddleware struct { + // Realm name to display to the user. Required. + Realm string + + // signing algorithm - possible values are HS256, HS384, HS512, RS256, RS384 or RS512 + // Optional, default is HS256. + SigningAlgorithm string + + // Secret key used for signing. Required. + Key []byte + + // Callback to retrieve key used for signing. Setting KeyFunc will bypass + // all other key settings + KeyFunc func(token *jwt.Token) (interface{}, error) + + // Duration that a jwt token is valid. Optional, defaults to one hour. + Timeout time.Duration + + // This field allows clients to refresh their token until MaxRefresh has passed. + // Note that clients can refresh their token in the last moment of MaxRefresh. + // This means that the maximum validity timespan for a token is TokenTime + MaxRefresh. + // Optional, defaults to 0 meaning not refreshable. + MaxRefresh time.Duration + + // Callback function that should perform the authentication of the user based on login info. + // Must return user data as user identifier, it will be stored in Claim Array. Required. + // Check error (e) to determine the appropriate error message. + Authenticator func(ctx context.Context, c *app.RequestContext) (interface{}, error) + + // Callback function that should perform the authorization of the authenticated user. Called + // only after an authentication success. Must return true on success, false on failure. + // Optional, default to success. + Authorizator func(data interface{}, ctx context.Context, c *app.RequestContext) bool + + // Callback function that will be called during login. + // Using this function it is possible to add additional payload data to the webtoken. + // The data is then made available during requests via c.Get("JWT_PAYLOAD"). + // Note that the payload is not encrypted. + // The attributes mentioned on jwt.io can't be used as keys for the map. + // Optional, by default no additional data will be set. + PayloadFunc func(data interface{}) MapClaims + + // User can define own Unauthorized func. + Unauthorized func(ctx context.Context, c *app.RequestContext, code int, message string) + + // User can define own LoginResponse func. + LoginResponse func(ctx context.Context, c *app.RequestContext, code int, message string, time time.Time, identity interface{}) + + // User can define own LogoutResponse func. + LogoutResponse func(ctx context.Context, c *app.RequestContext, code int) + + // User can define own RefreshResponse func. + RefreshResponse func(ctx context.Context, c *app.RequestContext, code int, message string, time time.Time) + + // Set the identity handler function + IdentityHandler func(ctx context.Context, c *app.RequestContext) interface{} + + // Set the identity key + IdentityKey string + + // TokenLookup is a string in the form of ":" that is used + // to extract token from the request. + // Optional. Default value "header:Authorization". + // Possible values: + // - "header:" + // - "query:" + // - "cookie:" + // - "param:" + // - "form:" + TokenLookup string + + // TokenHeadName is a string in the header. Default value is "Bearer" + TokenHeadName string + + // WithoutDefaultTokenHeadName allow set empty TokenHeadName + WithoutDefaultTokenHeadName bool + + // TimeFunc provides the current time. You can override it to use another time value. This is useful for testing or if your server uses a different time zone than your tokens. + TimeFunc func() time.Time + + // HTTP Status messages for when something in the JWT middleware fails. + // Check error (e) to determine the appropriate error message. + HTTPStatusMessageFunc func(e error, ctx context.Context, c *app.RequestContext) string + + // Private key file for asymmetric algorithms + PrivKeyFile string + + // Private Key bytes for asymmetric algorithms + // + // Note: PrivKeyFile takes precedence over PrivKeyBytes if both are set + PrivKeyBytes []byte + + // Public key file for asymmetric algorithms + PubKeyFile string + + // Private key passphrase + PrivateKeyPassphrase string + + // Public key bytes for asymmetric algorithms. + // + // Note: PubKeyFile takes precedence over PubKeyBytes if both are set + PubKeyBytes []byte + + // Private key + privKey *rsa.PrivateKey + + // Public key + pubKey *rsa.PublicKey + + // Optionally return the token as a cookie + SendCookie bool + + // Duration that a cookie is valid. Optional, by default equals to Timeout value. + CookieMaxAge time.Duration + + // Allow insecure cookies for development over http + SecureCookie bool + + // Allow cookies to be accessed client side for development + CookieHTTPOnly bool + + // Allow cookie domain change for development + CookieDomain string + + // SendAuthorization allow return authorization header for every request + SendAuthorization bool + + // Disable abort() of context. + DisabledAbort bool + + // CookieName allow cookie name change for development + CookieName string + + // CookieSameSite allow use protocol.CookieSameSite cookie param + CookieSameSite protocol.CookieSameSite + + // ParseOptions allow to modify jwt's parser methods + ParseOptions []jwt.ParserOption +} + +var ( + // ErrMissingSecretKey indicates Secret key is required + ErrMissingSecretKey = errors.New("secret key is required") + + // ErrForbidden when HTTP status 403 is given + ErrForbidden = errors.New("you don't have permission to access this resource") + + // ErrMissingAuthenticatorFunc indicates Authenticator is required + ErrMissingAuthenticatorFunc = errors.New("HertzJWTMiddleware.Authenticator func is undefined") + + // ErrMissingLoginValues indicates a user tried to authenticate without username or password + ErrMissingLoginValues = errors.New("missing Username or Password") + + // ErrFailedAuthentication indicates authentication failed, could be faulty username or password + ErrFailedAuthentication = errors.New("incorrect Username or Password") + + // ErrFailedTokenCreation indicates JWT Token failed to create, reason unknown + ErrFailedTokenCreation = errors.New("failed to create JWT Token") + + // ErrExpiredToken indicates JWT token has expired. Can't refresh. + ErrExpiredToken = errors.New("token is expired") // in practice, this is generated from the jwt library not by us + + // ErrEmptyAuthHeader can be thrown if authing with a HTTP header, the Auth header needs to be set + ErrEmptyAuthHeader = errors.New("auth header is empty") + + // ErrMissingExpField missing exp field in token + ErrMissingExpField = errors.New("missing exp field") + + // ErrWrongFormatOfExp field must be float64 format + ErrWrongFormatOfExp = errors.New("exp must be float64 format") + + // ErrInvalidAuthHeader indicates auth header is invalid, could for example have the wrong Realm name + ErrInvalidAuthHeader = errors.New("auth header is invalid") + + // ErrEmptyQueryToken can be thrown if authing with URL Query, the query token variable is empty + ErrEmptyQueryToken = errors.New("query token is empty") + + // ErrEmptyCookieToken can be thrown if authing with a cookie, the token cookie is empty + ErrEmptyCookieToken = errors.New("cookie token is empty") + + // ErrEmptyParamToken can be thrown if authing with parameter in path, the parameter in path is empty + ErrEmptyParamToken = errors.New("parameter token is empty") + + // ErrEmptyFormToken can be thrown if authing with post form, the form token is empty + ErrEmptyFormToken = errors.New("form token is empty") + + // ErrInvalidSigningAlgorithm indicates signing algorithm is invalid, needs to be HS256, HS384, HS512, RS256, RS384 or RS512 + ErrInvalidSigningAlgorithm = errors.New("invalid signing algorithm") + + // ErrNoPrivKeyFile indicates that the given private key is unreadable + ErrNoPrivKeyFile = errors.New("private key file unreadable") + + // ErrNoPubKeyFile indicates that the given public key is unreadable + ErrNoPubKeyFile = errors.New("public key file unreadable") + + // ErrInvalidPrivKey indicates that the given private key is invalid + ErrInvalidPrivKey = errors.New("private key invalid") + + // ErrInvalidPubKey indicates the the given public key is invalid + ErrInvalidPubKey = errors.New("public key invalid") + + // IdentityKey default identity key + IdentityKey = "identity" +) + +// New for check error with HertzJWTMiddleware +func New(m *HertzJWTMiddleware) (*HertzJWTMiddleware, error) { + if err := m.MiddlewareInit(); err != nil { + return nil, err + } + + return m, nil +} + +func (mw *HertzJWTMiddleware) readKeys() error { + err := mw.privateKey() + if err != nil { + return err + } + err = mw.publicKey() + if err != nil { + return err + } + return nil +} + +func (mw *HertzJWTMiddleware) privateKey() error { + var keyData []byte + if mw.PrivKeyFile == "" { + keyData = mw.PrivKeyBytes + } else { + filecontent, err := ioutil.ReadFile(mw.PrivKeyFile) + if err != nil { + return ErrNoPrivKeyFile + } + keyData = filecontent + } + + if mw.PrivateKeyPassphrase != "" { + key, err := jwt.ParseRSAPrivateKeyFromPEMWithPassword(keyData, mw.PrivateKeyPassphrase) //lint:ignore SA1019 ignoreCheck + if err != nil { + return ErrInvalidPrivKey + } + mw.privKey = key + return nil + } + + key, err := jwt.ParseRSAPrivateKeyFromPEM(keyData) + if err != nil { + return ErrInvalidPrivKey + } + mw.privKey = key + return nil +} + +func (mw *HertzJWTMiddleware) publicKey() error { + var keyData []byte + if mw.PubKeyFile == "" { + keyData = mw.PubKeyBytes + } else { + filecontent, err := ioutil.ReadFile(mw.PubKeyFile) + if err != nil { + return ErrNoPubKeyFile + } + keyData = filecontent + } + + key, err := jwt.ParseRSAPublicKeyFromPEM(keyData) + if err != nil { + return ErrInvalidPubKey + } + mw.pubKey = key + return nil +} + +func (mw *HertzJWTMiddleware) usingPublicKeyAlgo() bool { + switch mw.SigningAlgorithm { + case "RS256", "RS512", "RS384": + return true + } + return false +} + +// MiddlewareInit initialize jwt configs. +func (mw *HertzJWTMiddleware) MiddlewareInit() error { + if mw.TokenLookup == "" { + mw.TokenLookup = "header:Authorization" + } + + if mw.SigningAlgorithm == "" { + mw.SigningAlgorithm = "HS256" + } + + if mw.Timeout == 0 { + mw.Timeout = time.Hour + } + + if mw.TimeFunc == nil { + mw.TimeFunc = time.Now + } + + mw.TokenHeadName = strings.TrimSpace(mw.TokenHeadName) + if len(mw.TokenHeadName) == 0 && !mw.WithoutDefaultTokenHeadName { + mw.TokenHeadName = "Bearer" + } + + if mw.Authorizator == nil { + mw.Authorizator = func(data interface{}, ctx context.Context, c *app.RequestContext) bool { + return true + } + } + + if mw.Unauthorized == nil { + mw.Unauthorized = func(ctx context.Context, c *app.RequestContext, code int, message string) { + c.JSON(code, map[string]interface{}{ + "code": code, + "message": message, + }) + } + } + + if mw.LoginResponse == nil { + mw.LoginResponse = func(ctx context.Context, c *app.RequestContext, code int, token string, expire time.Time, identity interface{}) { + c.JSON(http.StatusOK, map[string]interface{}{ + "code": http.StatusOK, + "token": token, + "expire": expire.Format(time.RFC3339), + IdentityKey: identity, + }) + } + } + + if mw.LogoutResponse == nil { + mw.LogoutResponse = func(ctx context.Context, c *app.RequestContext, code int) { + c.JSON(http.StatusOK, map[string]interface{}{ + "code": http.StatusOK, + }) + } + } + + if mw.RefreshResponse == nil { + mw.RefreshResponse = func(ctx context.Context, c *app.RequestContext, code int, token string, expire time.Time) { + c.JSON(http.StatusOK, map[string]interface{}{ + "code": http.StatusOK, + "token": token, + "expire": expire.Format(time.RFC3339), + }) + } + } + + if mw.IdentityKey == "" { + mw.IdentityKey = IdentityKey + } + + if mw.IdentityHandler == nil { + mw.IdentityHandler = func(ctx context.Context, c *app.RequestContext) interface{} { + claims := ExtractClaims(ctx, c) + return claims[mw.IdentityKey] + } + } + + if mw.HTTPStatusMessageFunc == nil { + mw.HTTPStatusMessageFunc = func(e error, ctx context.Context, c *app.RequestContext) string { + return e.Error() + } + } + + if mw.Realm == "" { + mw.Realm = "hertz jwt" + } + + if mw.CookieMaxAge == 0 { + mw.CookieMaxAge = mw.Timeout + } + + if mw.CookieName == "" { + mw.CookieName = "jwt" + } + + // bypass other key settings if KeyFunc is set + if mw.KeyFunc != nil { + return nil + } + + if mw.usingPublicKeyAlgo() { + return mw.readKeys() + } + + if mw.Key == nil { + return ErrMissingSecretKey + } + return nil +} + +// MiddlewareFunc makes HertzJWTMiddleware implement the Middleware interface. +func (mw *HertzJWTMiddleware) MiddlewareFunc() app.HandlerFunc { + return func(ctx context.Context, c *app.RequestContext) { + mw.middlewareImpl(ctx, c) + } +} + +func (mw *HertzJWTMiddleware) middlewareImpl(ctx context.Context, c *app.RequestContext) { + claims, err := mw.GetClaimsFromJWT(ctx, c) + if err != nil { + mw.unauthorized(ctx, c, http.StatusUnauthorized, mw.HTTPStatusMessageFunc(err, ctx, c)) + return + } + + switch v := claims["exp"].(type) { + case nil: + mw.unauthorized(ctx, c, http.StatusBadRequest, mw.HTTPStatusMessageFunc(ErrMissingExpField, ctx, c)) + return + case float64: + if int64(v) < mw.TimeFunc().Unix() { + mw.unauthorized(ctx, c, http.StatusUnauthorized, mw.HTTPStatusMessageFunc(ErrExpiredToken, ctx, c)) + return + } + case json.Number: + n, err := v.Int64() + if err != nil { + mw.unauthorized(ctx, c, http.StatusBadRequest, mw.HTTPStatusMessageFunc(ErrWrongFormatOfExp, ctx, c)) + return + } + if n < mw.TimeFunc().Unix() { + mw.unauthorized(ctx, c, http.StatusUnauthorized, mw.HTTPStatusMessageFunc(ErrExpiredToken, ctx, c)) + return + } + default: + mw.Unauthorized(ctx, c, http.StatusBadRequest, mw.HTTPStatusMessageFunc(ErrWrongFormatOfExp, ctx, c)) + } + + c.Set("JWT_PAYLOAD", claims) + identity := mw.IdentityHandler(ctx, c) + + if identity != nil { + c.Set(mw.IdentityKey, identity) + } + + if !mw.Authorizator(identity, ctx, c) { + mw.unauthorized(ctx, c, http.StatusForbidden, mw.HTTPStatusMessageFunc(ErrForbidden, ctx, c)) + return + } + + c.Next(ctx) +} + +func (mw *HertzJWTMiddleware) MyMiddlewareFunc() app.HandlerFunc { + return func(ctx context.Context, c *app.RequestContext) { + claims, err := mw.GetClaimsFromJWT(ctx, c) + defer c.Next(ctx) + if err != nil { + // mw.unauthorized(ctx, c, http.StatusUnauthorized, mw.HTTPStatusMessageFunc(err, ctx, c)) + return + } + + switch v := claims["exp"].(type) { + case nil: + // mw.unauthorized(ctx, c, http.StatusBadRequest, mw.HTTPStatusMessageFunc(ErrMissingExpField, ctx, c)) + return + case float64: + if int64(v) < mw.TimeFunc().Unix() { + // mw.unauthorized(ctx, c, http.StatusUnauthorized, mw.HTTPStatusMessageFunc(ErrExpiredToken, ctx, c)) + return + } + case json.Number: + n, err := v.Int64() + if err != nil { + // mw.unauthorized(ctx, c, http.StatusBadRequest, mw.HTTPStatusMessageFunc(ErrWrongFormatOfExp, ctx, c)) + return + } + if n < mw.TimeFunc().Unix() { + // mw.unauthorized(ctx, c, http.StatusUnauthorized, mw.HTTPStatusMessageFunc(ErrExpiredToken, ctx, c)) + return + } + default: + // mw.Unauthorized(ctx, c, http.StatusBadRequest, mw.HTTPStatusMessageFunc(ErrWrongFormatOfExp, ctx, c)) + } + + c.Set("JWT_PAYLOAD", claims) + identity := mw.IdentityHandler(ctx, c) + + if identity != nil { + c.Set(mw.IdentityKey, identity) + } + + c.Next(ctx) + } +} + +// GetClaimsFromJWT get claims from JWT token +func (mw *HertzJWTMiddleware) GetClaimsFromJWT(ctx context.Context, c *app.RequestContext) (MapClaims, error) { + token, err := mw.ParseToken(ctx, c) + if err != nil { + return nil, err + } + + if mw.SendAuthorization { + if v, ok := c.Get("JWT_TOKEN"); ok { + c.Header("Authorization", mw.TokenHeadName+" "+v.(string)) + } + } + + claims := MapClaims{} + for key, value := range token.Claims.(jwt.MapClaims) { + claims[key] = value + } + + return claims, nil +} + +// LoginHandler can be used by clients to get a jwt token. +// Payload needs to be json in the form of {"username": "USERNAME", "password": "PASSWORD"}. +// Reply will be of the form {"token": "TOKEN"}. +func (mw *HertzJWTMiddleware) LoginHandler(ctx context.Context, c *app.RequestContext) { + if mw.Authenticator == nil { + mw.unauthorized(ctx, c, http.StatusInternalServerError, mw.HTTPStatusMessageFunc(ErrMissingAuthenticatorFunc, ctx, c)) + return + } + + data, err := mw.Authenticator(ctx, c) + if err != nil { + mw.unauthorized(ctx, c, http.StatusUnauthorized, mw.HTTPStatusMessageFunc(err, ctx, c)) + return + } + + // Create the token + token := jwt.New(jwt.GetSigningMethod(mw.SigningAlgorithm)) + claims := token.Claims.(jwt.MapClaims) + + if mw.PayloadFunc != nil { + for key, value := range mw.PayloadFunc(data) { + claims[key] = value + } + } + + expire := mw.TimeFunc().Add(mw.Timeout) + claims["exp"] = expire.Unix() + claims["orig_iat"] = mw.TimeFunc().Unix() + tokenString, err := mw.signedString(token) + if err != nil { + mw.unauthorized(ctx, c, http.StatusUnauthorized, mw.HTTPStatusMessageFunc(ErrFailedTokenCreation, ctx, c)) + return + } + + // set cookie + if mw.SendCookie { + expireCookie := mw.TimeFunc().Add(mw.CookieMaxAge) + maxage := int(expireCookie.Unix() - mw.TimeFunc().Unix()) + c.SetCookie(mw.CookieName, tokenString, maxage, "/", mw.CookieDomain, mw.CookieSameSite, mw.SecureCookie, mw.CookieHTTPOnly) + } + //log.Println(claims[mw.IdentityKey]) + + + + mw.LoginResponse(ctx, c, http.StatusOK, tokenString, expire, claims[mw.IdentityKey]) +} + +// LogoutHandler can be used by clients to remove the jwt cookie (if set) +func (mw *HertzJWTMiddleware) LogoutHandler(ctx context.Context, c *app.RequestContext) { + // delete auth cookie + if mw.SendCookie { + c.SetCookie(mw.CookieName, "", -1, "/", mw.CookieDomain, mw.CookieSameSite, mw.SecureCookie, mw.CookieHTTPOnly) + } + + mw.LogoutResponse(ctx, c, http.StatusOK) +} + +func (mw *HertzJWTMiddleware) signedString(token *jwt.Token) (string, error) { + var tokenString string + var err error + if mw.usingPublicKeyAlgo() { + tokenString, err = token.SignedString(mw.privKey) + } else { + tokenString, err = token.SignedString(mw.Key) + } + return tokenString, err +} + +// RefreshHandler can be used to refresh a token. The token still needs to be valid on refresh. +// Shall be put under an endpoint that is using the HertzJWTMiddleware. +// Reply will be of the form {"token": "TOKEN"}. +func (mw *HertzJWTMiddleware) RefreshHandler(ctx context.Context, c *app.RequestContext) { + tokenString, expire, err := mw.RefreshToken(ctx, c) + if err != nil { + mw.unauthorized(ctx, c, http.StatusUnauthorized, mw.HTTPStatusMessageFunc(err, ctx, c)) + return + } + + mw.RefreshResponse(ctx, c, http.StatusOK, tokenString, expire) +} + +// RefreshToken refresh token and check if token is expired +func (mw *HertzJWTMiddleware) RefreshToken(ctx context.Context, c *app.RequestContext) (string, time.Time, error) { + claims, err := mw.CheckIfTokenExpire(ctx, c) + if err != nil { + return "", time.Now(), err + } + + // Create the token + newToken := jwt.New(jwt.GetSigningMethod(mw.SigningAlgorithm)) + newClaims := newToken.Claims.(jwt.MapClaims) + + for key := range claims { + newClaims[key] = claims[key] + } + + expire := mw.TimeFunc().Add(mw.Timeout) + newClaims["exp"] = expire.Unix() + newClaims["orig_iat"] = mw.TimeFunc().Unix() + tokenString, err := mw.signedString(newToken) + if err != nil { + return "", time.Now(), err + } + + // set cookie + if mw.SendCookie { + expireCookie := mw.TimeFunc().Add(mw.CookieMaxAge) + maxage := int(expireCookie.Unix() - time.Now().Unix()) + c.SetCookie(mw.CookieName, tokenString, maxage, "/", mw.CookieDomain, mw.CookieSameSite, mw.SecureCookie, mw.CookieHTTPOnly) + } + + return tokenString, expire, nil +} + +// CheckIfTokenExpire check if token expire +func (mw *HertzJWTMiddleware) CheckIfTokenExpire(ctx context.Context, c *app.RequestContext) (jwt.MapClaims, error) { + token, err := mw.ParseToken(ctx, c) + if err != nil { + validationErr, ok := err.(*jwt.ValidationError) + if !ok || validationErr.Errors != jwt.ValidationErrorExpired { + return nil, err + } + } + + claims := token.Claims.(jwt.MapClaims) + + origIat := int64(claims["orig_iat"].(float64)) + + if origIat < mw.TimeFunc().Add(-mw.MaxRefresh).Unix() { + return nil, ErrExpiredToken + } + + return claims, nil +} + +// TokenGenerator method that clients can use to get a jwt token. +func (mw *HertzJWTMiddleware) TokenGenerator(data interface{}) (string, time.Time, error) { + token := jwt.New(jwt.GetSigningMethod(mw.SigningAlgorithm)) + claims := token.Claims.(jwt.MapClaims) + + if mw.PayloadFunc != nil { + for key, value := range mw.PayloadFunc(data) { + claims[key] = value + } + } + + expire := mw.TimeFunc().UTC().Add(mw.Timeout) + claims["exp"] = expire.Unix() + claims["orig_iat"] = mw.TimeFunc().Unix() + tokenString, err := mw.signedString(token) + if err != nil { + return "", time.Time{}, err + } + + return tokenString, expire, nil +} + +func (mw *HertzJWTMiddleware) jwtFromHeader(_ context.Context, c *app.RequestContext, key string) (string, error) { + authHeader := c.Request.Header.Get(key) + + if authHeader == "" { + return "", ErrEmptyAuthHeader + } + + parts := strings.SplitN(authHeader, " ", 2) + if !((len(parts) == 1 && mw.WithoutDefaultTokenHeadName && mw.TokenHeadName == "") || + (len(parts) == 2 && parts[0] == mw.TokenHeadName)) { + return "", ErrInvalidAuthHeader + } + + return parts[len(parts)-1], nil +} + +func (mw *HertzJWTMiddleware) jwtFromQuery(_ context.Context, c *app.RequestContext, key string) (string, error) { + token := c.Query(key) + + if token == "" { + return "", ErrEmptyQueryToken + } + + return token, nil +} + +func (mw *HertzJWTMiddleware) jwtFromCookie(_ context.Context, c *app.RequestContext, key string) (string, error) { + cookie := string(c.Cookie(key)) + + if cookie == "" { + return "", ErrEmptyCookieToken + } + + return cookie, nil +} + +func (mw *HertzJWTMiddleware) jwtFromParam(_ context.Context, c *app.RequestContext, key string) (string, error) { + token := c.Param(key) + + if token == "" { + return "", ErrEmptyParamToken + } + + return token, nil +} + +func (mw *HertzJWTMiddleware) jwtFromForm(_ context.Context, c *app.RequestContext, key string) (string, error) { + token := c.PostForm(key) + + if token == "" { + return "", ErrEmptyFormToken + } + + return token, nil +} + +// ParseToken parse jwt token from hertz context +func (mw *HertzJWTMiddleware) ParseToken(ctx context.Context, c *app.RequestContext) (*jwt.Token, error) { + var token string + var err error + + methods := strings.Split(mw.TokenLookup, ",") + for _, method := range methods { + if len(token) > 0 { + break + } + parts := strings.Split(strings.TrimSpace(method), ":") + k := strings.TrimSpace(parts[0]) + v := strings.TrimSpace(parts[1]) + switch k { + case "header": + token, err = mw.jwtFromHeader(ctx, c, v) + case "query": + token, err = mw.jwtFromQuery(ctx, c, v) + case "cookie": + token, err = mw.jwtFromCookie(ctx, c, v) + case "param": + token, err = mw.jwtFromParam(ctx, c, v) + case "form": + token, err = mw.jwtFromForm(ctx, c, v) + } + } + + if err != nil { + return nil, err + } + + if mw.KeyFunc != nil { + return jwt.Parse(token, mw.KeyFunc, mw.ParseOptions...) + } + + return jwt.Parse(token, func(t *jwt.Token) (interface{}, error) { + if jwt.GetSigningMethod(mw.SigningAlgorithm) != t.Method { + return nil, ErrInvalidSigningAlgorithm + } + if mw.usingPublicKeyAlgo() { + return mw.pubKey, nil + } + + // save token string if valid + c.Set("JWT_TOKEN", token) + + return mw.Key, nil + }, mw.ParseOptions...) +} + +// ParseTokenString parse jwt token string +func (mw *HertzJWTMiddleware) ParseTokenString(token string) (*jwt.Token, error) { + if mw.KeyFunc != nil { + return jwt.Parse(token, mw.KeyFunc, mw.ParseOptions...) + } + + return jwt.Parse(token, func(t *jwt.Token) (interface{}, error) { + if jwt.GetSigningMethod(mw.SigningAlgorithm) != t.Method { + return nil, ErrInvalidSigningAlgorithm + } + if mw.usingPublicKeyAlgo() { + return mw.pubKey, nil + } + + return mw.Key, nil + }, mw.ParseOptions...) +} + +func (mw *HertzJWTMiddleware) unauthorized(ctx context.Context, c *app.RequestContext, code int, message string) { + c.Header("WWW-Authenticate", "JWT realm="+mw.Realm) + if !mw.DisabledAbort { + c.Abort() + } + + mw.Unauthorized(ctx, c, code, message) +} + +// ExtractClaims help to extract the JWT claims +func ExtractClaims(ctx context.Context, c *app.RequestContext) MapClaims { + claims, exists := c.Get("JWT_PAYLOAD") + if !exists { + return make(MapClaims) + } + + return claims.(MapClaims) +} + +// ExtractClaimsFromToken help to extract the JWT claims from token +func ExtractClaimsFromToken(token *jwt.Token) MapClaims { + if token == nil { + return make(MapClaims) + } + + claims := MapClaims{} + for key, value := range token.Claims.(jwt.MapClaims) { + claims[key] = value + } + + return claims +} + +// GetToken help to get the JWT token string +func GetToken(ctx context.Context, c *app.RequestContext) string { + token, exists := c.Get("JWT_TOKEN") + if !exists { + return "" + } + + return token.(string) +} diff --git a/sample_douyin/cmd/api/biz/router/douyinapi/api.go b/sample_douyin/cmd/api/biz/router/douyinapi/api.go new file mode 100644 index 00000000..905de01b --- /dev/null +++ b/sample_douyin/cmd/api/biz/router/douyinapi/api.go @@ -0,0 +1,84 @@ +// Code generated by hertz generator. DO NOT EDIT. + +package Douyinapi + +import ( + douyinapi "mydouyin/cmd/api/biz/handler/douyinapi" + + "github.com/cloudwego/hertz/pkg/app/server" +) + +/* + This file will register all the routes of the services in the master idl. + And it will update automatically when you use the "update" command for the idl. + So don't modify the contents of the file, or your code will be deleted when it is updated. +*/ + +// Register register routes based on the IDL 'api.${HTTP Method}' annotation. +func Register(r *server.Hertz) { + root := r.Group("/", rootMw()...) + { + _douyin := root.Group("/douyin", _douyinMw()...) + { + { + _feed := _douyin.Group("/feed", _feedMw()...) + _feed.GET("/", douyinapi.GetFeed) + } + _publish := _douyin.Group("/publish", _publishMw()...) + { + _list := _publish.Group("/list") + _list.GET("/", douyinapi.GetPublishList) + } + { + _action := _publish.Group("/action") + _action.POST("/", douyinapi.PublishVideo) + } + _favorite := _douyin.Group("/favorite", _favoriteMw()...) + { + _action := _favorite.Group("/action") + _action.POST("/", douyinapi.FavoriteAction) + } + { + _list := _favorite.Group("/list") + _list.GET("/", douyinapi.GetFavoriteList) + } + _user := _douyin.Group("/user", _userMw()...) + _user.GET("/", append(_getuserMw(), douyinapi.GetUser)...) + { + _login := _user.Group("/login", _loginMw()...) + _login.POST("/", append(_checkuserMw(), douyinapi.CheckUser)...) + } + { + _register := _user.Group("/register", _registerMw()...) + _register.POST("/", append(_createuserMw(), douyinapi.RegistUser)...) + } + _comment := _douyin.Group("/comment") + { + _caction := _comment.Group("/action", _actionMw()...) + _caction.POST("/", douyinapi.CommentAction) + } + { + _clist := _comment.Group("/list") + _clist.GET("/", douyinapi.CommentList) + } + _relation := _douyin.Group("/relation", _relationMw()...) + { + _action := _relation.Group("/action") + _action.POST("/", douyinapi.RelationAction) + } + { + _follow := _relation.Group("/follow") + _follow.GET("/list/", douyinapi.FollowList) + _follower := _relation.Group("/follower") + _follower.GET("/list/", douyinapi.FollowerList) + _friend := _relation.Group("/friend") + _friend.GET("/list/",douyinapi.FriendList) + } + _message := _douyin.Group("/message", _messageMw()...) + { + _message.GET("/chat/", douyinapi.MessageChat) + _message.POST("/action/", douyinapi.MessageAction) + } + } + } +} diff --git a/sample_douyin/cmd/api/biz/router/douyinapi/middleware.go b/sample_douyin/cmd/api/biz/router/douyinapi/middleware.go new file mode 100644 index 00000000..b968121e --- /dev/null +++ b/sample_douyin/cmd/api/biz/router/douyinapi/middleware.go @@ -0,0 +1,115 @@ +// Code generated by hertz generator. + +package Douyinapi + +import ( + "context" + "fmt" + "mydouyin/cmd/api/biz/mw" + "mydouyin/pkg/errno" + + "github.com/cloudwego/hertz/pkg/app" + "github.com/cloudwego/hertz/pkg/app/middlewares/server/recovery" + "github.com/cloudwego/hertz/pkg/common/hlog" + "github.com/cloudwego/hertz/pkg/common/utils" + "github.com/cloudwego/hertz/pkg/protocol/consts" + "github.com/hertz-contrib/gzip" + "github.com/hertz-contrib/requestid" + "go.opentelemetry.io/otel/trace" +) + +func rootMw() []app.HandlerFunc { + // your code... + return []app.HandlerFunc{ + // use recovery mw + recovery.Recovery(recovery.WithRecoveryHandler( + func(ctx context.Context, c *app.RequestContext, err interface{}, stack []byte) { + hlog.SystemLogger().CtxErrorf(ctx, "[Recovery] err=%v\nstack=%s", err, stack) + c.JSON(consts.StatusInternalServerError, utils.H{ + "code": errno.ServiceErr.ErrCode, + "message": fmt.Sprintf("[Recovery] err=%v\nstack=%s", err, stack), + }) + }, + )), + // use requestid mw + requestid.New( + requestid.WithGenerator(func(ctx context.Context, c *app.RequestContext) string { + traceID := trace.SpanFromContext(ctx).SpanContext().TraceID().String() + return traceID + }), + ), + // use gzip mw + gzip.Gzip(gzip.DefaultCompression), + } +} + +func _feedMw() []app.HandlerFunc { + return []app.HandlerFunc{ + mw.JwtMiddleware.MyMiddlewareFunc(), + } +} + +func _douyinMw() []app.HandlerFunc { + // your code... + return nil +} + +func _userMw() []app.HandlerFunc { + // your code... + return nil +} + +func _getuserMw() []app.HandlerFunc { + // your code... + return nil +} + +func _loginMw() []app.HandlerFunc { + // your code... + return nil +} + +func _checkuserMw() []app.HandlerFunc { + // your code... + return nil +} + +func _registerMw() []app.HandlerFunc { + // your code... + return nil +} + +func _createuserMw() []app.HandlerFunc { + // your code... + return nil +} + +func _favoriteMw() []app.HandlerFunc { + return []app.HandlerFunc{ + mw.JwtMiddleware.MiddlewareFunc(), + } +} + +func _publishMw() []app.HandlerFunc { + return []app.HandlerFunc{ + mw.JwtMiddleware.MiddlewareFunc(), + } +} + +func _actionMw() []app.HandlerFunc { + return []app.HandlerFunc{ + mw.JwtMiddleware.MiddlewareFunc(), + } +} + +func _relationMw() []app.HandlerFunc { + return []app.HandlerFunc{ + mw.JwtMiddleware.MiddlewareFunc(), + } +} + +func _messageMw() []app.HandlerFunc { + return []app.HandlerFunc{ + mw.JwtMiddleware.MiddlewareFunc(), + } +} diff --git a/sample_douyin/cmd/api/biz/router/register.go b/sample_douyin/cmd/api/biz/router/register.go new file mode 100644 index 00000000..67252bd6 --- /dev/null +++ b/sample_douyin/cmd/api/biz/router/register.go @@ -0,0 +1,14 @@ +// Code generated by hertz generator. DO NOT EDIT. + +package router + +import ( + "github.com/cloudwego/hertz/pkg/app/server" + douyinapi "mydouyin/cmd/api/biz/router/douyinapi" +) + +// GeneratedRegister registers routers generated by IDL. +func GeneratedRegister(r *server.Hertz) { + //INSERT_POINT: DO NOT DELETE THIS LINE! + douyinapi.Register(r) +} diff --git a/sample_douyin/cmd/api/biz/rpc/comment.go b/sample_douyin/cmd/api/biz/rpc/comment.go new file mode 100644 index 00000000..ac4a5dc5 --- /dev/null +++ b/sample_douyin/cmd/api/biz/rpc/comment.go @@ -0,0 +1,54 @@ +package rpc + +import ( + "context" + "mydouyin/kitex_gen/douyincomment" + "mydouyin/kitex_gen/douyincomment/commentservice" + "mydouyin/pkg/consts" + "mydouyin/pkg/mw" + + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/kitex-contrib/obs-opentelemetry/provider" + "github.com/kitex-contrib/obs-opentelemetry/tracing" + etcd "github.com/kitex-contrib/registry-etcd" +) + +var commentClient commentservice.Client + +func initComment() { + r, err := etcd.NewEtcdResolver([]string{consts.ETCDAddress}) + if err != nil { + panic(err) + } + provider.NewOpenTelemetryProvider( + provider.WithServiceName(consts.ApiServiceName), + provider.WithExportEndpoint(consts.ExportEndpoint), + provider.WithInsecure(), + ) + c, err := commentservice.NewClient( + consts.CommentServiceName, + client.WithResolver(r), + client.WithMuxConnection(1), + client.WithMiddleware(mw.CommonMiddleware), + client.WithInstanceMW(mw.ClientMiddleware), + client.WithSuite(tracing.NewClientSuite()), + client.WithClientBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: consts.ApiServiceName}), + ) + if err != nil { + panic(err) + } + commentClient = c +} + +func CreateComment(ctx context.Context, req *douyincomment.CreateCommentRequest) (r *douyincomment.CreateCommentResponse, err error) { + return commentClient.CreateComment(ctx, req) +} + +func DeleteComment(ctx context.Context, req *douyincomment.DeleteCommentRequest) (r *douyincomment.DeleteCommentResponse, err error) { + return commentClient.DeleteComment(ctx, req) +} + +func GetVideoComments(ctx context.Context, req *douyincomment.GetVideoCommentsRequest) (r *douyincomment.GetVideoCommentsResponse, err error) { + return commentClient.GetVideoComments(ctx, req) +} diff --git a/sample_douyin/cmd/api/biz/rpc/favorite.go b/sample_douyin/cmd/api/biz/rpc/favorite.go new file mode 100644 index 00000000..abf29e5f --- /dev/null +++ b/sample_douyin/cmd/api/biz/rpc/favorite.go @@ -0,0 +1,54 @@ +package rpc + +import ( + "context" + "mydouyin/kitex_gen/douyinfavorite" + "mydouyin/kitex_gen/douyinfavorite/favoriteservice" + "mydouyin/pkg/consts" + "mydouyin/pkg/mw" + + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/kitex-contrib/obs-opentelemetry/provider" + "github.com/kitex-contrib/obs-opentelemetry/tracing" + etcd "github.com/kitex-contrib/registry-etcd" +) + +var favoriteClient favoriteservice.Client + +func initFavorite() { + r, err := etcd.NewEtcdResolver([]string{consts.ETCDAddress}) + if err != nil { + panic(err) + } + provider.NewOpenTelemetryProvider( + provider.WithServiceName(consts.ApiServiceName), + provider.WithExportEndpoint(consts.ExportEndpoint), + provider.WithInsecure(), + ) + c, err := favoriteservice.NewClient( + consts.FavoriteServiceName, + client.WithResolver(r), + client.WithMuxConnection(1), + client.WithMiddleware(mw.CommonMiddleware), + client.WithInstanceMW(mw.ClientMiddleware), + client.WithSuite(tracing.NewClientSuite()), + client.WithClientBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: consts.ApiServiceName}), + ) + if err != nil { + panic(err) + } + favoriteClient = c +} + +func FavoriteAction(ctx context.Context, req *douyinfavorite.FavoriteActionRequest) (r *douyinfavorite.FavoriteActionResponse, err error) { + return favoriteClient.FavoriteAction(ctx, req) +} + +func GetFavouriteList(ctx context.Context, req *douyinfavorite.GetListRequest) (r *douyinfavorite.GetListResponse, err error) { + return favoriteClient.GetList(ctx, req) +} + +func GetIsFavorite(ctx context.Context, req *douyinfavorite.GetIsFavoriteRequest) (r *douyinfavorite.GetIsFavoriteResponse, err error) { + return favoriteClient.GetIsFavorite(ctx, req) +} diff --git a/sample_douyin/cmd/api/biz/rpc/init.go b/sample_douyin/cmd/api/biz/rpc/init.go new file mode 100644 index 00000000..de2904e3 --- /dev/null +++ b/sample_douyin/cmd/api/biz/rpc/init.go @@ -0,0 +1,10 @@ +package rpc + +func Init() { + initUser() + initVideo() + initComment() + initRelation() + initFavorite() + initMessage() +} diff --git a/sample_douyin/cmd/api/biz/rpc/message.go b/sample_douyin/cmd/api/biz/rpc/message.go new file mode 100644 index 00000000..41e7fac7 --- /dev/null +++ b/sample_douyin/cmd/api/biz/rpc/message.go @@ -0,0 +1,54 @@ +package rpc + +import ( + "context" + "mydouyin/kitex_gen/message" + "mydouyin/kitex_gen/message/messageservice" + "mydouyin/pkg/consts" + "mydouyin/pkg/mw" + + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/kitex-contrib/obs-opentelemetry/provider" + "github.com/kitex-contrib/obs-opentelemetry/tracing" + etcd "github.com/kitex-contrib/registry-etcd" +) + +var messageClient messageservice.Client + +func initMessage() { + r, err := etcd.NewEtcdResolver([]string{consts.ETCDAddress}) + if err != nil { + panic(err) + } + provider.NewOpenTelemetryProvider( + provider.WithServiceName(consts.ApiServiceName), + provider.WithExportEndpoint(consts.ExportEndpoint), + provider.WithInsecure(), + ) + c, err := messageservice.NewClient( + consts.MessageServiceName, + client.WithResolver(r), + client.WithMuxConnection(1), + client.WithMiddleware(mw.CommonMiddleware), + client.WithInstanceMW(mw.ClientMiddleware), + client.WithSuite(tracing.NewClientSuite()), + client.WithClientBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: consts.ApiServiceName}), + ) + if err != nil { + panic(err) + } + messageClient = c +} + +func CreateMessage(ctx context.Context, req *message.CreateMessageRequest) (r *message.CreateMessageResponse, err error) { + return messageClient.CreateMessage(ctx, req) +} + +func GetMessageList(ctx context.Context, req *message.GetMessageListRequest) (r *message.GetMessageListResponse, err error) { + return messageClient.GetMessageList(ctx, req) +} + +func GetFirstMessage(ctx context.Context, req *message.GetFirstMessageRequest) (r *message.GetFirstMessageResponse, err error) { + return messageClient.GetFirstMessage(ctx, req) +} diff --git a/sample_douyin/cmd/api/biz/rpc/relation.go b/sample_douyin/cmd/api/biz/rpc/relation.go new file mode 100644 index 00000000..410c51ad --- /dev/null +++ b/sample_douyin/cmd/api/biz/rpc/relation.go @@ -0,0 +1,101 @@ +package rpc + +import ( + "context" + "mydouyin/kitex_gen/relation" + "mydouyin/kitex_gen/relation/relationservice" + "mydouyin/pkg/consts" + "mydouyin/pkg/mw" + + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/kitex-contrib/obs-opentelemetry/provider" + "github.com/kitex-contrib/obs-opentelemetry/tracing" + etcd "github.com/kitex-contrib/registry-etcd" +) + +var relationClient relationservice.Client + +func initRelation() { + r, err := etcd.NewEtcdResolver([]string{consts.ETCDAddress}) + if err != nil { + panic(err) + } + provider.NewOpenTelemetryProvider( + provider.WithServiceName(consts.ApiServiceName), + provider.WithExportEndpoint(consts.ExportEndpoint), + provider.WithInsecure(), + ) + c, err := relationservice.NewClient( + consts.RelationServiceName, + client.WithResolver(r), + client.WithMuxConnection(1), + client.WithMiddleware(mw.CommonMiddleware), + client.WithInstanceMW(mw.ClientMiddleware), + client.WithSuite(tracing.NewClientSuite()), + client.WithClientBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: consts.ApiServiceName}), + ) + if err != nil { + panic(err) + } + relationClient = c +} + +func CreateRelation(ctx context.Context, req *relation.CreateRelationRequest) (r *relation.BaseResp, err error) { + return relationClient.CreateRelation(ctx, req) +} + +func DeleteRelation(ctx context.Context, req *relation.DeleteRelationRequest) (r *relation.BaseResp, err error) { + return relationClient.DeleteRelation(ctx, req) +} + +func GetFollower(ctx context.Context, req *relation.GetFollowerListRequest) (r *relation.GetFollowerListResponse, err error) { + return relationClient.GetFollower(ctx, req) +} + +func GetFollow(ctx context.Context, req *relation.GetFollowListRequest) (r *relation.GetFollowListResponse, err error) { + return relationClient.GetFollow(ctx, req) +} + +func ValidIfFollowRequest(ctx context.Context, req *relation.ValidIfFollowRequest) (r *relation.ValidIfFollowResponse, err error) { + return relationClient.ValidIfFollowRequest(ctx, req) +} + +// func GetFriendList(ctx context.Context, req *relation.GetFollowerListRequest) ([]*apimodel.FriendUser, error) { +// // resp, err := relationClient.GetFollower(ctx, req) +// // if err != nil { +// // return nil, err +// // } +// // if resp.BaseResp.StatusCode != 0 { +// // return nil, errno.NewErrNo(resp.BaseResp.StatusCode, resp.BaseResp.StatusMessage) +// // } +// // if len(resp.FollowerIds) < 1 { +// // return []*apimodel.FriendUser{}, nil +// // } +// // ur, err := userClient.MGetUser(ctx, &douyinuser.MGetUserRequest{ +// // UserIds: resp.FollowerIds, +// // }) +// // if err != nil { +// // return nil, err +// // } +// // if ur.BaseResp.StatusCode != 0 { +// // return nil, errno.NewErrNo(ur.BaseResp.StatusCode, ur.BaseResp.StatusMessage) +// // } +// // res := make([]*apimodel.FriendUser, 0, 30) +// // for _, rpc_user := range ur.Users { +// // user := apimodel.PackFriendUser(rpc_user) +// // r, err := relationClient.ValidIfFollowRequest(ctx, &relation.ValidIfFollowRequest{ +// // FollowId: user.UserID, +// // FollowerId: req.FollowId, +// // }) +// // if err != nil || r.BaseResp.StatusCode != 0 { +// // continue +// // } +// // user.IsFollow = r.IfFollow +// // res = append(res, user) +// // } +// return res, nil +// } +func GetFriend(ctx context.Context, req *relation.GetFriendRequest) (r *relation.GetFriendResponse, err error) { + return relationClient.GetFriend(ctx, req) +} diff --git a/sample_douyin/cmd/api/biz/rpc/user.go b/sample_douyin/cmd/api/biz/rpc/user.go new file mode 100644 index 00000000..0b4fa170 --- /dev/null +++ b/sample_douyin/cmd/api/biz/rpc/user.go @@ -0,0 +1,54 @@ +package rpc + +import ( + "context" + "mydouyin/kitex_gen/douyinuser" + "mydouyin/kitex_gen/douyinuser/userservice" + "mydouyin/pkg/consts" + "mydouyin/pkg/mw" + + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/kitex-contrib/obs-opentelemetry/provider" + "github.com/kitex-contrib/obs-opentelemetry/tracing" + etcd "github.com/kitex-contrib/registry-etcd" +) + +var userClient userservice.Client + +func initUser() { + r, err := etcd.NewEtcdResolver([]string{consts.ETCDAddress}) + if err != nil { + panic(err) + } + provider.NewOpenTelemetryProvider( + provider.WithServiceName(consts.ApiServiceName), + provider.WithExportEndpoint(consts.ExportEndpoint), + provider.WithInsecure(), + ) + c, err := userservice.NewClient( + consts.UserServiceName, + client.WithResolver(r), + client.WithMuxConnection(1), + client.WithMiddleware(mw.CommonMiddleware), + client.WithInstanceMW(mw.ClientMiddleware), + client.WithSuite(tracing.NewClientSuite()), + client.WithClientBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: consts.ApiServiceName}), + ) + if err != nil { + panic(err) + } + userClient = c +} + +func CreateUser(ctx context.Context, req *douyinuser.CreateUserRequest) (r *douyinuser.CreateUserResponse, err error) { + return userClient.CreateUser(ctx, req) +} + +func CheckUser(ctx context.Context, req *douyinuser.CheckUserRequest) (r *douyinuser.CheckUserResponse, err error) { + return userClient.CheckUser(ctx, req) +} + +func MGetUser(ctx context.Context, req *douyinuser.MGetUserRequest) (r *douyinuser.MGetUserResponse, err error) { + return userClient.MGetUser(ctx, req) +} diff --git a/sample_douyin/cmd/api/biz/rpc/video.go b/sample_douyin/cmd/api/biz/rpc/video.go new file mode 100644 index 00000000..82407da8 --- /dev/null +++ b/sample_douyin/cmd/api/biz/rpc/video.go @@ -0,0 +1,66 @@ +package rpc + +import ( + "context" + "mydouyin/kitex_gen/douyinvideo" + "mydouyin/kitex_gen/douyinvideo/videoservice" + "mydouyin/pkg/consts" + "mydouyin/pkg/mw" + + "github.com/cloudwego/kitex/client" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/kitex-contrib/obs-opentelemetry/provider" + "github.com/kitex-contrib/obs-opentelemetry/tracing" + etcd "github.com/kitex-contrib/registry-etcd" +) + +var videoClient videoservice.Client + +func initVideo() { + r, err := etcd.NewEtcdResolver([]string{consts.ETCDAddress}) + if err != nil { + panic(err) + } + provider.NewOpenTelemetryProvider( + provider.WithServiceName(consts.ApiServiceName), + provider.WithExportEndpoint(consts.ExportEndpoint), + provider.WithInsecure(), + ) + c, err := videoservice.NewClient( + consts.VideoServiceName, + client.WithResolver(r), + client.WithMuxConnection(1), + client.WithMiddleware(mw.CommonMiddleware), + client.WithInstanceMW(mw.ClientMiddleware), + client.WithSuite(tracing.NewClientSuite()), + client.WithClientBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: consts.ApiServiceName}), + ) + if err != nil { + panic(err) + } + videoClient = c +} + +func CreateVideo(ctx context.Context, req *douyinvideo.CreateVideoRequest) (r *douyinvideo.CreateVideoResponse, err error) { + return videoClient.CreateVideo(ctx, req) +} + +func GetFeed(ctx context.Context, req *douyinvideo.GetFeedRequest) (r *douyinvideo.GetFeedResponse, err error) { + return videoClient.GetFeed(ctx, req) +} + +func GetList(ctx context.Context, req *douyinvideo.GetListRequest) (r *douyinvideo.GetListResponse, err error) { + return videoClient.GetList(ctx, req) +} + +func MGetVideo(ctx context.Context, req *douyinvideo.MGetVideoRequest) (r *douyinvideo.MGetVideoResponse, err error) { + return videoClient.MGetVideoUser(ctx, req) +} + +func DeleteVideo(ctx context.Context, req *douyinvideo.DeleteVideoRequest) (r *douyinvideo.DeleteVideoResponse, err error) { + return videoClient.DeleteVideo(ctx, req) +} + +func GetTimeVideos(ctx context.Context, req *douyinvideo.GetTimeVideosRequest) (r *douyinvideo.GetTimeVideosResponse, err error) { + return videoClient.GetTimeVideos(ctx, req) +} diff --git a/sample_douyin/cmd/api/biz/service/comment_service.go b/sample_douyin/cmd/api/biz/service/comment_service.go new file mode 100644 index 00000000..07e6a6c4 --- /dev/null +++ b/sample_douyin/cmd/api/biz/service/comment_service.go @@ -0,0 +1,117 @@ +package service + +import ( + "context" + "mydouyin/cmd/api/biz/apimodel" + "mydouyin/cmd/api/biz/rpc" + "mydouyin/kitex_gen/douyincomment" + "mydouyin/kitex_gen/douyinuser" + "mydouyin/pkg/errno" + "strconv" + "strings" + "time" +) + +type CommentService struct { + ctx context.Context +} + +func NewCommentService(ctx context.Context) *CommentService { + return &CommentService{ + ctx: ctx, + } +} + +func (s *CommentService) CommentAction(req apimodel.CommentActionRequest, user *apimodel.User) (*apimodel.CommentActionResponse, error) { + resp := new(apimodel.CommentActionResponse) + actionType, err := strconv.Atoi(req.ActionType) + if err != nil { + return resp, err + } + switch actionType { + case 1: + // create the date + getMonth := time.Now().Format("01") + getDay := time.Now().Format("02") + var build strings.Builder + build.WriteString(getMonth) + build.WriteString("-") + build.WriteString(getDay) + date := build.String() + // create the VideoID + videoID, err := strconv.ParseInt(req.VideoId, 10, 64) + if err != nil { + return resp, err + } + + rpc_resp, err := rpc.CreateComment(s.ctx, &douyincomment.CreateCommentRequest{ + Video: videoID, + User: user.UserID, + Content: req.CommentText, + CreateDate: date, + }) + if err != nil { + return resp, err + } + + if rpc_resp.BaseResp.StatusCode != 0 { + return resp, errno.NewErrNo(rpc_resp.BaseResp.StatusCode, rpc_resp.BaseResp.StatusMessage) + } + + resp.Comment = apimodel.Comment{ + CommentID: rpc_resp.CommentId, + Commentor: *user, + Content: req.CommentText, + CreateDate: date, + } + case 2: + // delete the date + commentID, err := strconv.ParseInt(req.CommentId, 10, 64) + if err != nil { + return resp, err + } + rpc_resp, err := rpc.DeleteComment(s.ctx, &douyincomment.DeleteCommentRequest{ + CommentId: commentID, + }) + if err != nil { + return resp, err + } + if rpc_resp.BaseResp.StatusCode != 0 { + return resp, errno.NewErrNo(rpc_resp.BaseResp.StatusCode, rpc_resp.BaseResp.StatusMessage) + } + default: + return nil, errno.ParamErr + } + return resp, nil +} + +func (s *CommentService) CommentList(req apimodel.CommentListRequest) (*apimodel.CommentListResponse, error) { + resp := new(apimodel.CommentListResponse) + // get the VideoID + videoID, err := strconv.ParseInt(req.VideoId, 10, 64) + if err != nil { + return resp, err + } + + rpc_resp, err := rpc.GetVideoComments(s.ctx, &douyincomment.GetVideoCommentsRequest{ + Video: videoID, + }) + if err != nil { + return resp, err + } + if rpc_resp.BaseResp.StatusCode != 0 { + return resp, errno.NewErrNo(rpc_resp.BaseResp.StatusCode, rpc_resp.BaseResp.StatusMessage) + } + resp.CommentList = make([]apimodel.Comment, 0, 50) + for _, rpc_comment := range rpc_resp.Comments { + r, err := rpc.MGetUser(s.ctx, &douyinuser.MGetUserRequest{UserIds: []int64{rpc_comment.User}}) + if err != nil || r.BaseResp.StatusCode != 0 || len(r.Users) < 1 { + continue + } + user := apimodel.PackUser(r.Users[0]) + comment := apimodel.PackComment(rpc_comment) + comment.Commentor = *user + resp.CommentList = append(resp.CommentList, *comment) + } + return resp, nil +} diff --git a/sample_douyin/cmd/api/biz/service/favorite_service.go b/sample_douyin/cmd/api/biz/service/favorite_service.go new file mode 100644 index 00000000..766c460b --- /dev/null +++ b/sample_douyin/cmd/api/biz/service/favorite_service.go @@ -0,0 +1,87 @@ +package service + +import ( + "context" + "mydouyin/cmd/api/biz/apimodel" + "mydouyin/cmd/api/biz/cache" + "mydouyin/cmd/api/biz/rpc" + "mydouyin/kitex_gen/douyinfavorite" + "mydouyin/kitex_gen/douyinuser" + "mydouyin/kitex_gen/douyinvideo" + "mydouyin/pkg/errno" + "strconv" +) + +type FavoriteService struct { + ctx context.Context +} + +func NewFavoriteService(ctx context.Context) *FavoriteService { + return &FavoriteService{ + ctx: ctx, + } +} + +func (s *FavoriteService) FavoriteAction(req apimodel.FavoriteActionRequest, user *apimodel.User) (*apimodel.FavoriteActionResponse, error) { + resp := new(apimodel.FavoriteActionResponse) + videoId, err := strconv.Atoi(req.VideoID) + if err != nil { + return resp, err + } + //异步处理 + err = cache.FC.CommitFavoriteActionCommand( + user.UserID, + int64(videoId), + req.ActionType, + ) + //同步处理 + // rpc_resp, err := rpc.FavoriteAction(s.ctx, &douyinfavorite.FavoriteActionRequest{ + // UserId: user.UserID, + // VideoId: int64(videoId), + // ActionType: req.ActionType, + // }) + if err != nil { + return resp, err + } + // if rpc_resp.BaseResp.StatusCode != 0 { + // return resp, errno.NewErrNo(rpc_resp.BaseResp.StatusCode, rpc_resp.BaseResp.StatusMessage) + // } + return resp, nil +} + +func (s *FavoriteService) GetFavoriteList(req apimodel.GetFavoriteListRequest, user *apimodel.User) (*apimodel.GetFavoriteListResponse, error) { + resp := new(apimodel.GetFavoriteListResponse) + var err error + userId, err := strconv.Atoi(req.UserId) + if err != nil { + return resp, err + } + vids, err := rpc.GetFavouriteList(s.ctx, &douyinfavorite.GetListRequest{ + UserId: int64(userId), + }) + if err != nil { + return nil, err + } + if vids.BaseResp.StatusCode != 0 { + return nil, errno.NewErrNo(vids.BaseResp.StatusCode, vids.BaseResp.StatusMessage) + } + resp.VideoList = make([]apimodel.Video, 0, 50) + videos, err := rpc.MGetVideo(s.ctx, &douyinvideo.MGetVideoRequest{VideoIds: vids.VideoIds}) + if err != nil { + return nil, err + } + if len(videos.Videos) < 1 { + return resp, nil + } + for _, rpc_video := range videos.Videos { + r, err := rpc.MGetUser(s.ctx, &douyinuser.MGetUserRequest{UserIds: []int64{rpc_video.Author}}) + if err != nil || r.BaseResp.StatusCode != 0 || len(r.Users) < 1 { + continue + } + author := apimodel.PackUser(r.Users[0]) + video := apimodel.PackVideo(rpc_video) + video.Author = *author + resp.VideoList = append(resp.VideoList, *video) + } + return resp, nil +} diff --git a/sample_douyin/cmd/api/biz/service/feed_service.go b/sample_douyin/cmd/api/biz/service/feed_service.go new file mode 100644 index 00000000..297566d6 --- /dev/null +++ b/sample_douyin/cmd/api/biz/service/feed_service.go @@ -0,0 +1,84 @@ +package service + +import ( + "context" + "mydouyin/cmd/api/biz/apimodel" + "mydouyin/cmd/api/biz/rpc" + "mydouyin/kitex_gen/douyinfavorite" + "mydouyin/kitex_gen/douyinuser" + "mydouyin/kitex_gen/douyinvideo" + "mydouyin/pkg/errno" + "strconv" + "time" +) + +type FeedService struct { + ctx context.Context +} + +func NewFeedService(ctx context.Context) *FeedService { + return &FeedService{ + ctx: ctx, + } +} + +func (s *FeedService) GetFeed(req apimodel.GetFeedRequest, userId int64) (*apimodel.GetFeedResponse, error) { + resp := new(apimodel.GetFeedResponse) + var err error + if req.LatestTime == "" { + req.LatestTime = strconv.FormatInt(time.Now().Unix(), 10) + } + if len(req.LatestTime) > 10 { + req.LatestTime = string([]rune(req.LatestTime[0 : len(req.LatestTime)-3])) + } + rpcResp, err := rpc.GetFeed(s.ctx, &douyinvideo.GetFeedRequest{ + LatestTime: req.LatestTime, + UserId: userId, + }) + if err != nil { + resp.NextTime = time.Now().Unix() + return resp, err + } + if rpcResp.BaseResp.StatusCode != 0 { + resp.NextTime = time.Now().Unix() + return resp, errno.NewErrNo(rpcResp.BaseResp.StatusCode, rpcResp.BaseResp.StatusMessage) + } + resp.VideoList = make([]apimodel.Video, 0, 30) + favorites := make([]*douyinfavorite.Favorite, 0) + for _, rpcVideo := range rpcResp.VideoList { + favorite := new(douyinfavorite.Favorite) + favorite.UserId = userId + favorite.VideoId = rpcVideo.VideoId + favorites = append(favorites, favorite) + } + isFavorites, err := rpc.GetIsFavorite(s.ctx, &douyinfavorite.GetIsFavoriteRequest{FavoriteList: favorites}) + + if err != nil { + resp.NextTime = time.Now().Unix() + return resp, err + } + + if len(rpcResp.VideoList) != len(isFavorites.IsFavorites) { + resp.NextTime = time.Now().Unix() + return resp, errno.ServiceErr + } + + for i := 0; i < len(rpcResp.VideoList); i++ { + r, err := rpc.MGetUser(s.ctx, &douyinuser.MGetUserRequest{UserIds: []int64{rpcResp.VideoList[i].Author}}) + if err != nil || r.BaseResp.StatusCode != 0 || len(r.Users) < 1 { + continue + } + var author *apimodel.User + if userId != -1 { + author = apimodel.PackUserRelation(r.Users[0], userId) + } else { + author = apimodel.PackUser(r.Users[0]) + } + video := apimodel.PackVideo(rpcResp.VideoList[i]) + video.Author = *author + video.IsFavorite = isFavorites.IsFavorites[i] + resp.VideoList = append(resp.VideoList, *video) + } + resp.NextTime = rpcResp.NextTime + return resp, nil +} diff --git a/sample_douyin/cmd/api/biz/service/message_service.go b/sample_douyin/cmd/api/biz/service/message_service.go new file mode 100644 index 00000000..d4de5c40 --- /dev/null +++ b/sample_douyin/cmd/api/biz/service/message_service.go @@ -0,0 +1,88 @@ +package service + +import ( + "context" + "mydouyin/cmd/api/biz/apimodel" + "mydouyin/cmd/api/biz/cache" + "mydouyin/cmd/api/biz/rpc" + "mydouyin/kitex_gen/message" + "mydouyin/pkg/errno" + "sort" + "time" + //"time" +) + +type MessageService struct { + ctx context.Context +} + +func NewMessageService(ctx context.Context) *MessageService { + return &MessageService{ + ctx: ctx, + } +} + +func (s *MessageService) MessageAction(req apimodel.MessageActionRequest, user *apimodel.User) (resp *apimodel.MessageActionResponse, err error) { + resp = new(apimodel.MessageActionResponse) + err = cache.MC.CommitCreateMessageCommand(user.UserID, req.ToUserId, req.Content) + //err = cache.MC.CommitCreateMessageCommandV0(user.UserID, req.ToUserId, req.Content) + if err != nil { + return resp, err + } + return resp, nil +} + +func (s *MessageService) MessageChat(req apimodel.MessageChatRequest, user *apimodel.User) (resp *apimodel.MessageChatResponse, err error) { + resp = new(apimodel.MessageChatResponse) + if time.Now().Unix() < req.PreMsgTime { + //客户端返回的毫秒级时间戳,需要转化成秒级 + // req.PreMsgTime = req.PreMsgTime / 1e3 + req.PreMsgTime, err = cache.MC.GetLastedMsg(user.UserID, req.ToUserId) + // log.Println(req.PreMsgTime, err) + if err != nil { + return + } + } + // log.Println(req.PreMsgTime, time.Now().Unix() > req.PreMsgTime) + messageList, hit, err := cache.MC.GetMessage(user.UserID, req.ToUserId, req.PreMsgTime) + if err != nil { + return + } + if hit { + resp.MessageList = messageList + return + } + rpc_resp_from, err := rpc.GetMessageList(s.ctx, &message.GetMessageListRequest{ + FromUserId: user.UserID, + ToUserId: req.ToUserId, + PreMsgTime: req.PreMsgTime, + }) + if err != nil { + return resp, err + } + if rpc_resp_from.BaseResp.StatusCode != 0 { + return nil, errno.NewErrNo(rpc_resp_from.BaseResp.StatusCode, rpc_resp_from.BaseResp.StatusMessage) + } + message_list_from := apimodel.PackMessages(rpc_resp_from.MessageList) + rpc_resp_to, err := rpc.GetMessageList(s.ctx, &message.GetMessageListRequest{ + FromUserId: req.ToUserId, + ToUserId: user.UserID, + PreMsgTime: req.PreMsgTime, + }) + if err != nil { + return resp, err + } + if rpc_resp_to.BaseResp.StatusCode != 0 { + return nil, errno.NewErrNo(rpc_resp_to.BaseResp.StatusCode, rpc_resp_to.BaseResp.StatusMessage) + } + message_list_to := apimodel.PackMessages(rpc_resp_to.MessageList) + resp.MessageList = append(message_list_from, message_list_to...) + sort.Sort(apimodel.MessageSorter(resp.MessageList)) + if len(resp.MessageList) == 0 { + //表示两个用户之间第一次聊天,没有消息记录,向对应kv缓存中加一条空消息,防止service轮询rpc接口 + cache.MC.SaveMessage(append([]*apimodel.Message{}, &apimodel.Message{FromUserId: user.UserID, ToUserId: req.ToUserId, CreateTime: 0})) + } else { + cache.MC.SaveMessage(resp.MessageList) + } + return +} diff --git a/sample_douyin/cmd/api/biz/service/publish_service.go b/sample_douyin/cmd/api/biz/service/publish_service.go new file mode 100644 index 00000000..f9d94c3f --- /dev/null +++ b/sample_douyin/cmd/api/biz/service/publish_service.go @@ -0,0 +1,64 @@ +package service + +import ( + "context" + "mydouyin/cmd/api/biz/apimodel" + "mydouyin/cmd/api/biz/rpc" + videohandel "mydouyin/cmd/api/biz/videoHandel" + "mydouyin/kitex_gen/douyinuser" + "mydouyin/kitex_gen/douyinvideo" + "mydouyin/pkg/errno" + "strconv" +) + +type PublishService struct { + ctx context.Context +} + +func NewPublishService(ctx context.Context) *PublishService { + return &PublishService{ + ctx: ctx, + } +} + +func (s *PublishService) PublishVideo(req apimodel.PublishVideoRequest, user *apimodel.User) (*apimodel.PublishVideoResponse, error) { + resp := new(apimodel.PublishVideoResponse) + //err := videohandel.VH.UpLoadVideoV0(req.Data, user.UserID, req.Title) + videoName, err := videohandel.VH.UpLoadVideo(req.Data) + if err != nil { + return resp, err + } + + go videohandel.VH.CommitCommand(videoName, user.UserID, req.Title) + + return resp, err +} + +func (s *PublishService) GetPublishList(req apimodel.GetPublishListRequest, user *apimodel.User) (*apimodel.GetPublishListResponse, error) { + resp := new(apimodel.GetPublishListResponse) + userId, err := strconv.Atoi(req.UserId) + if err != nil { + return resp, err + } + rpc_resp, err := rpc.GetList(s.ctx, &douyinvideo.GetListRequest{ + UserId: int64(userId), + }) + if err != nil { + return nil, err + } + if rpc_resp.BaseResp.StatusCode != 0 { + return nil, errno.NewErrNo(rpc_resp.BaseResp.StatusCode, rpc_resp.BaseResp.StatusMessage) + } + resp.VideoList = make([]apimodel.Video, 0, 50) + for _, rpc_video := range rpc_resp.VideoList { + r, err := rpc.MGetUser(s.ctx, &douyinuser.MGetUserRequest{UserIds: []int64{rpc_video.Author}}) + if err != nil || r.BaseResp.StatusCode != 0 || len(r.Users) < 1 { + continue + } + author := apimodel.PackUser(r.Users[0]) + video := apimodel.PackVideo(rpc_video) + video.Author = *author + resp.VideoList = append(resp.VideoList, *video) + } + return resp, nil +} diff --git a/sample_douyin/cmd/api/biz/service/relation_service.go b/sample_douyin/cmd/api/biz/service/relation_service.go new file mode 100644 index 00000000..100145db --- /dev/null +++ b/sample_douyin/cmd/api/biz/service/relation_service.go @@ -0,0 +1,232 @@ +package service + +import ( + "context" + "mydouyin/cmd/api/biz/apimodel" + "mydouyin/cmd/api/biz/cache" + "mydouyin/cmd/api/biz/rpc" + "mydouyin/kitex_gen/douyinuser" + "mydouyin/kitex_gen/message" + "mydouyin/kitex_gen/relation" + "mydouyin/pkg/errno" + "strconv" +) + +type RelationService struct { + ctx context.Context +} + +func NewRelationService(ctx context.Context) *RelationService { + return &RelationService{ + ctx: ctx, + } +} + +func (s *RelationService) RelationAction(req apimodel.RelationActionRequest, user *apimodel.User) (*apimodel.RelationActionResponse, error) { + resp := new(apimodel.RelationActionResponse) + userId := user.UserID + to_user_id, err := strconv.Atoi(req.ToUserId) + if err != nil { + return resp, errno.ParamErr + } + + switch req.ActionType { + case "1": + rpc_resp, err := rpc.CreateRelation(s.ctx, &relation.CreateRelationRequest{ + FollowId: int64(to_user_id), + FollowerId: userId, + }) + if err != nil { + return resp, err + } + if rpc_resp.StatusCode != 0 { + return resp, errno.NewErrNo(rpc_resp.StatusCode, rpc_resp.StatusMessage) + } + case "2": + rpc_resp, err := rpc.DeleteRelation(s.ctx, &relation.DeleteRelationRequest{ + FollowId: int64(to_user_id), + FollowerId: userId, + }) + if err != nil { + return resp, err + } + if rpc_resp.StatusCode != 0 { + return resp, errno.NewErrNo(rpc_resp.StatusCode, rpc_resp.StatusMessage) + } + default: + err = errno.ParamErr + return resp, err + } + return resp, nil +} + +//获取关注或粉丝列表,option表示操作类型(1:关注列表,2:粉丝列表) +func (s *RelationService) FollowAndFollowerList(req apimodel.FollowAndFollowerListRequest, user *apimodel.User, option int) (*apimodel.FollowAndFollowerListReponse, error) { + resp := new(apimodel.FollowAndFollowerListReponse) + var err error + // users := make([]*apimodel.User, 0) + userIds := make([]int64, 0) + userId, err := strconv.Atoi(req.UserId) + if err != nil { + return resp, err + } + switch option { + case 1: + rpc_resp, err := rpc.GetFollow(s.ctx, &relation.GetFollowListRequest{FollowerId: int64(userId)}) + if err != nil { + return resp, err + } + if rpc_resp.BaseResp.StatusCode != 0 { + return resp, errno.NewErrNo(rpc_resp.BaseResp.StatusCode, rpc_resp.BaseResp.StatusMessage) + } + if len(rpc_resp.FollowIds) < 1 { + return resp, nil + } + userIds = rpc_resp.FollowIds + case 2: + rpc_resp, err := rpc.GetFollower(s.ctx, &relation.GetFollowerListRequest{FollowId: int64(userId)}) + if err != nil { + return resp, err + } + if rpc_resp.BaseResp.StatusCode != 0 { + return resp, errno.NewErrNo(rpc_resp.BaseResp.StatusCode, rpc_resp.BaseResp.StatusMessage) + } + if len(rpc_resp.FollowerIds) < 1 { + return resp, nil + } + userIds = rpc_resp.FollowerIds + } + ur, err := rpc.MGetUser(s.ctx, &douyinuser.MGetUserRequest{ + UserIds: userIds, + }) + if err != nil { + return nil, err + } + if ur.BaseResp.StatusCode != 0 { + return nil, errno.NewErrNo(ur.BaseResp.StatusCode, ur.BaseResp.StatusMessage) + } + for _, rpc_user := range ur.Users { + switch option { + case 1: + if user.UserID == int64(userId) { + //看的自己的关注列表,IsFollow肯定都是true + u := apimodel.PackUser(rpc_user) + u.IsFollow = true + resp.UserList = append(resp.UserList, u) + } else { + //看的别人的关注列表,需要掉rpc查IsFollow + u := apimodel.PackUserRelation(rpc_user, int64(user.UserID)) + resp.UserList = append(resp.UserList, u) + } + case 2: + u := apimodel.PackUserRelation(rpc_user, int64(user.UserID)) + resp.UserList = append(resp.UserList, u) + } + } + // resp.UserList = users + return resp, errno.Success +} + +func (s *RelationService) FriendList(req apimodel.FriendListRequest) (*apimodel.FriendListReponse, error) { + resp := new(apimodel.FriendListReponse) + var err error + // users := make([]*apimodel.User, 0) + rpc_resp, err := rpc.GetFriend(s.ctx, &relation.GetFriendRequest{ + MeId: req.UserId, + }) + if err != nil { + return resp, err + } + if rpc_resp.BaseResp.StatusCode != 0 { + return resp, errno.NewErrNo(rpc_resp.BaseResp.StatusCode, rpc_resp.BaseResp.StatusMessage) + } + if len(rpc_resp.FriendIds) == 0 { + resp.UserList = make([]*apimodel.FriendUser, 0) + return resp, nil + } + ur, err := rpc.MGetUser(s.ctx, &douyinuser.MGetUserRequest{ + UserIds: rpc_resp.FriendIds, + }) + if err != nil { + return resp, err + } + if ur.BaseResp.StatusCode != 0 { + return resp, errno.NewErrNo(ur.BaseResp.StatusCode, ur.BaseResp.StatusMessage) + } + friend_map := make(map[int64]*apimodel.FriendUser, 0) + for _, rpc_user := range ur.Users { + u := apimodel.PackFriendUser(rpc_user) + u.IsFollow = true + resp.UserList = append(resp.UserList, u) + friend_map[u.UserID] = u + } + + //先走缓存,从缓存中查看能不能得到friendlist + frist_msg_list := cache.MC.GetFirstMessage(req.UserId, rpc_resp.FriendIds) + missFriendId := make([]int64, 0) + missFriend := make(map[int64]*apimodel.FriendUser, 0) + // log.Println("cache中查到的fristlist:") + for _, frist_msg := range frist_msg_list { + if frist_msg.MsgType == -1 { + //miss了 + missFriendId = append(missFriendId, frist_msg.FriendId) + missFriend[frist_msg.FriendId] = friend_map[frist_msg.FriendId] + } else { + friend_map[frist_msg.FriendId].Message = frist_msg.Content + friend_map[frist_msg.FriendId].MsgType = int64(frist_msg.MsgType) + // resp.UserList[i].Message = frist_msg.Content + // resp.UserList[i].MsgType = int64(frist_msg.MsgType) + } + } + // log.Println("miss的friendId", missFriendId) + if len(missFriend) != 0 { + //调RPC方法走MySql数据库 + gfm_resp, err := rpc.GetFirstMessage(s.ctx, &message.GetFirstMessageRequest{ + Id: req.UserId, + FriendIds: missFriendId, + }) + if err != nil { + return resp, err + } + if gfm_resp.BaseResp.StatusCode != 0 { + return resp, errno.NewErrNo(gfm_resp.BaseResp.StatusCode, gfm_resp.BaseResp.StatusMessage) + } + if len(gfm_resp.FirstMessageList) != len(missFriend) { + return resp, errno.QueryErr + } + for _, message := range gfm_resp.FirstMessageList { + // log.Printf("%v:%v\n", *missFriend[message.FriendId], *message) + if missFriend[message.FriendId].UserID == message.FriendId { + if message.MsgType == -1 { + missFriend[message.FriendId].Message = "" + } else { + missFriend[message.FriendId].Message = message.Message + } + missFriend[message.FriendId].MsgType = message.MsgType + } + //miss了就更新缓存 + // log.Println("miss了,更新redis缓存", missFriendId) + if message.MsgType == 1 { + cache.MC.SetFirstMessage(&apimodel.Message{ + ToUserId: message.FriendId, + FromUserId: req.UserId, + Content: message.Message, + }) + } else if message.MsgType == 0 { + cache.MC.SetFirstMessage(&apimodel.Message{ + ToUserId: req.UserId, + FromUserId: message.FriendId, + Content: message.Message, + }) + } else { + cache.MC.SetFirstMessage(&apimodel.Message{ + ToUserId: req.UserId, + FromUserId: message.FriendId, + Content: "", + }) + } + } + } + + return resp, nil +} diff --git a/sample_douyin/cmd/api/biz/service/user_service.go b/sample_douyin/cmd/api/biz/service/user_service.go new file mode 100644 index 00000000..6c276f59 --- /dev/null +++ b/sample_douyin/cmd/api/biz/service/user_service.go @@ -0,0 +1,64 @@ +package service + +import ( + "context" + "math/rand" + "mydouyin/cmd/api/biz/apimodel" + + //"mydouyin/cmd/api/biz/cache" + "mydouyin/cmd/api/biz/rpc" + "mydouyin/kitex_gen/douyinuser" + "mydouyin/pkg/consts" + "mydouyin/pkg/errno" + "strconv" +) + +type UserService struct { + ctx context.Context +} + +func NewUserService(ctx context.Context) *UserService { + return &UserService{ + ctx: ctx, + } +} + +func (s *UserService) RegistUser(req apimodel.RegistUserRequest) (*apimodel.RegistUserResponse, error) { + resp := new(apimodel.RegistUserResponse) + rpc_resp, err := rpc.CreateUser(context.Background(), &douyinuser.CreateUserRequest{ + Username: req.Username, + Password: req.Password, + Avatar: consts.AvatarList[rand.Intn(len(consts.AvatarList))], + BackgroundImage: consts.BackgroundList[rand.Intn(len(consts.BackgroundList))], + Signature: "Hello World!", + }) + if err != nil { + return resp, err + } + if rpc_resp.BaseResp.StatusCode != 0 { + return resp, errno.NewErrNo(rpc_resp.BaseResp.StatusCode, rpc_resp.BaseResp.StatusMessage) + } + return resp, nil +} + +func (s *UserService) GetUser(req apimodel.GetUserRequest) (*apimodel.GetUserResponse, error) { + resp := new(apimodel.GetUserResponse) + id, err := strconv.Atoi(req.UserID) + if err != nil { + err = errno.ParamErr + return resp, err + } + + rpc_resp, err := rpc.MGetUser(s.ctx, &douyinuser.MGetUserRequest{UserIds: []int64{int64(id)}}) + if err != nil { + return nil, err + } + if rpc_resp.BaseResp.StatusCode != 0 { + return nil, errno.NewErrNo(rpc_resp.BaseResp.StatusCode, rpc_resp.BaseResp.StatusMessage) + } + if len(rpc_resp.Users) < 1 { + return nil, errno.QueryErr + } + resp.User = *apimodel.PackUser(rpc_resp.Users[0]) + return resp, nil +} diff --git a/sample_douyin/cmd/api/biz/videoHandel/videohandel.go b/sample_douyin/cmd/api/biz/videoHandel/videohandel.go new file mode 100644 index 00000000..559e37d0 --- /dev/null +++ b/sample_douyin/cmd/api/biz/videoHandel/videohandel.go @@ -0,0 +1,176 @@ +package videohandel + +import ( + "context" + "encoding/base64" + "encoding/json" + "fmt" + "log" + "mime/multipart" + "mydouyin/cmd/api/biz/cache" + "mydouyin/cmd/api/biz/rpc" + "mydouyin/kitex_gen/douyinvideo" + "mydouyin/pkg/consts" + "mydouyin/pkg/errno" + "time" + + "github.com/aliyun/aliyun-oss-go-sdk/oss" +) + +type VideoHandel struct { + CommandQueue *cache.CommandQueue + client *oss.Client + bucket *oss.Bucket +} + +type commandState int + +const ( + begin commandState = iota + finishCoverUpLoad + allFinish +) + +type Command struct { + VideoName string + UserID int64 + Title string + State commandState +} + +var VH *VideoHandel + +func Init() { + VH = new(VideoHandel) + VH.CommandQueue = cache.NewCommandQueue(context.Background(), "upload_command") + // 初始化OSS + var err error + VH.client, err = oss.New(consts.Endpoint, consts.AKID, consts.AKS) + if err != nil { + panic(fmt.Sprintf("init videohandler error:%v", err)) + } + + // 填写存储空间名称 + VH.bucket, err = VH.client.Bucket(consts.Bucket) + if err != nil { + panic(fmt.Sprintf("init videohandler error:%v", err)) + } + go VH.listen() +} + +func (vh *VideoHandel) CommitCommand(VideoName string, UserID int64, Title string) { + data, _ := json.Marshal(Command{ + VideoName: VideoName, + UserID: UserID, + Title: Title, + State: begin, + }) + vh.CommandQueue.ProductionMessage(data) +} + +func (vh *VideoHandel) listen() { + for { + msg, err := vh.CommandQueue.ConsumeMessage() + if err != nil { + continue + } + var cmd Command + json.Unmarshal(msg, &cmd) + log.Printf("[********VideoHandler********] recover command:%v", cmd) + err = vh.execCommand(&cmd) + if err != nil || cmd.State != allFinish { + log.Printf("[********VideoHandler********] command exec fail, error:%v", err) + data, _ := json.Marshal(cmd) + vh.CommandQueue.ProductionMessage(data) + } else { + log.Printf("[********VideoHandler********] command exec success!!!") + } + } +} + +// 执行指令,视频上传成功后service提交指令给videohandler,handler只执行生成封面、入库等操作 +func (vh *VideoHandel) execCommand(cmd *Command) error { + //执行指令,生成封面 + // 截图格式 + cover_name := "cover/" + time.Now().Format("2006-01-02-15:04:05") + ".jpg" + switch cmd.State { + case begin: + style := "video/snapshot,t_1000,f_jpg,w_0,h_0,m_fast" + // 根据视频名直接获取截图url + process := fmt.Sprintf("%s|sys/saveas,o_%v,b_%v", style, base64.URLEncoding.EncodeToString([]byte(cover_name)), base64.URLEncoding.EncodeToString([]byte(consts.Bucket))) + result, err := VH.bucket.ProcessObject(cmd.VideoName, process) + if err != nil { + return err + } + log.Println(result.Status) + cmd.State = finishCoverUpLoad + fallthrough + case finishCoverUpLoad: + //调rpc写库 + resp, err := rpc.CreateVideo(context.Background(), &douyinvideo.CreateVideoRequest{ + Author: cmd.UserID, + PlayUrl: cmd.VideoName, + CoverUrl: cover_name, + Title: cmd.Title, + }) + if err != nil { + return err + } + if resp.BaseResp.StatusCode != 0 { + return errno.NewErrNo(resp.BaseResp.StatusCode, resp.BaseResp.StatusMessage) + } + cmd.State = allFinish + } + return nil +} + +func (vh *VideoHandel) UpLoadVideo(data *multipart.FileHeader) (videoName string, err error) { + // 获取文件流 + // 视频文件object名称 + var filepoint multipart.File + filepoint, err = data.Open() + if err != nil { + return + } + defer filepoint.Close() + // 上传视频 + videoName = "videos/" + time.Now().Format("2006-01-02-15:04:05") + ".mp4" + err = vh.bucket.PutObject(videoName, filepoint) + return +} + +func (vh *VideoHandel) UpLoadVideoV0(data *multipart.FileHeader, userID int64, title string) (err error) { + var filepoint multipart.File + filepoint, err = data.Open() + if err != nil { + return + } + defer filepoint.Close() + // 上传视频 + videoName := "videos/" + time.Now().Format("2006-01-02-15:04:05") + ".mp4" + err = vh.bucket.PutObject(videoName, filepoint) + + cover_name := "cover/" + time.Now().Format("2006-01-02-15:04:05") + ".jpg" + style := "video/snapshot,t_1000,f_jpg,w_0,h_0,m_fast" + // 根据视频名直接获取截图url + process := fmt.Sprintf("%s|sys/saveas,o_%v,b_%v", style, base64.URLEncoding.EncodeToString([]byte(cover_name)), base64.URLEncoding.EncodeToString([]byte(consts.Bucket))) + result, err := VH.bucket.ProcessObject(videoName, process) + log.Println(result.Status) + if err != nil { + return err + } + //调rpc写库 + resp, err := rpc.CreateVideo(context.Background(), &douyinvideo.CreateVideoRequest{ + Author: userID, + PlayUrl: videoName, + CoverUrl: cover_name, + Title: title, + }) + if err != nil { + return err + } + if resp.BaseResp.StatusCode != 0 { + return errno.NewErrNo(resp.BaseResp.StatusCode, resp.BaseResp.StatusMessage) + } + return nil +} diff --git a/sample_douyin/cmd/api/main.go b/sample_douyin/cmd/api/main.go new file mode 100644 index 00000000..8beb2dbd --- /dev/null +++ b/sample_douyin/cmd/api/main.go @@ -0,0 +1,45 @@ +// Code generated by hertz generator. + +package main + +import ( + "mydouyin/cmd/api/biz/cache" + "mydouyin/cmd/api/biz/mw" + "mydouyin/cmd/api/biz/rpc" + videohandel "mydouyin/cmd/api/biz/videoHandel" + + "github.com/cloudwego/hertz/pkg/app/server" + "github.com/cloudwego/hertz/pkg/common/hlog" + "github.com/cloudwego/hertz/pkg/network/standard" + hertzlogrus "github.com/hertz-contrib/obs-opentelemetry/logging/logrus" + "github.com/hertz-contrib/obs-opentelemetry/tracing" + "github.com/hertz-contrib/pprof" +) + +func Init() { + mw.InitJWT() + rpc.Init() + cache.Init() + videohandel.Init() + //hlog init + hlog.SetLogger(hertzlogrus.NewLogger()) + hlog.SetLevel(hlog.LevelInfo) +} + +func main() { + Init() + tracer, cfg := tracing.NewServerTracer() + h := server.New( + server.WithHostPorts(":8080"), + server.WithStreamBody(true), + server.WithTransport(standard.NewTransporter), + server.WithHandleMethodNotAllowed(true), + tracer, + ) + //use pprof mw + pprof.Register(h) + //user otel mw + h.Use(tracing.ServerMiddleware(cfg)) + register(h) + h.Spin() +} diff --git a/sample_douyin/cmd/api/router.go b/sample_douyin/cmd/api/router.go new file mode 100644 index 00000000..aea56376 --- /dev/null +++ b/sample_douyin/cmd/api/router.go @@ -0,0 +1,34 @@ +// Code generated by hertz generator. + +package main + +import ( + "context" + handler "mydouyin/cmd/api/biz/handler" + "mydouyin/cmd/api/biz/handler/douyinapi" + "mydouyin/cmd/api/biz/mw" + "mydouyin/pkg/errno" + + "github.com/cloudwego/hertz/pkg/app" + "github.com/cloudwego/hertz/pkg/app/server" +) + +// customizeRegister registers customize routers. +func customizedRegister(r *server.Hertz) { + r.GET("/ping", append(_testMw(), handler.Ping)...) + + // your code ... + r.NoRoute(func(ctx context.Context, c *app.RequestContext) { // used for HTTP 404 + douyinapi.SendResponse(c, errno.ServiceErr, nil) + }) + r.NoMethod(func(ctx context.Context, c *app.RequestContext) { // used for HTTP 405 + douyinapi.SendResponse(c, errno.ServiceErr, nil) + }) +} + +func _testMw() []app.HandlerFunc { + // your code... + return []app.HandlerFunc{ + mw.JwtMiddleware.MiddlewareFunc(), + } +} diff --git a/sample_douyin/cmd/api/router_gen.go b/sample_douyin/cmd/api/router_gen.go new file mode 100644 index 00000000..f2b24772 --- /dev/null +++ b/sample_douyin/cmd/api/router_gen.go @@ -0,0 +1,16 @@ +// Code generated by hertz generator. DO NOT EDIT. + +package main + +import ( + "github.com/cloudwego/hertz/pkg/app/server" + router "mydouyin/cmd/api/biz/router" +) + +// register registers all routers. +func register(r *server.Hertz) { + + router.GeneratedRegister(r) + + customizedRegister(r) +} diff --git a/sample_douyin/cmd/comment/build.sh b/sample_douyin/cmd/comment/build.sh new file mode 100644 index 00000000..6a8940db --- /dev/null +++ b/sample_douyin/cmd/comment/build.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +RUN_NAME="comment" + +mkdir -p output/bin +cp script/* output/ +chmod +x output/bootstrap.sh + +if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then + go build -o output/bin/${RUN_NAME} +else + go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... +fi diff --git a/sample_douyin/cmd/comment/dal/db/comment.go b/sample_douyin/cmd/comment/dal/db/comment.go new file mode 100644 index 00000000..44a52b6d --- /dev/null +++ b/sample_douyin/cmd/comment/dal/db/comment.go @@ -0,0 +1,67 @@ +package db + +import ( + "context" + "mydouyin/pkg/consts" + + "gorm.io/gorm" +) + +type Comment struct { + gorm.Model + Video int64 `json:"video"` + User int64 `json:"user"` + Content string `json:"content"` + Date string `json:"date"` +} + +func (v *Comment) TableName() string { + return consts.CommentTableName +} + +// create a comment +func CreateComment(ctx context.Context, comment *Comment) (int64, error) { + result := DB.WithContext(ctx).Transaction(func(tx *gorm.DB) error { + // 在事务中执行一些 db 操作(从这里开始,您应该使用 'tx' 而不是 'db') + if err := tx.Create(comment).Error; err != nil { + // 返回任何错误都会回滚事务 + return err + } + // update the comment number of the video + if err := tx.Model(&Video{}).Where("id = ?", comment.Video).Update("comment_count", gorm.Expr("comment_count + ?", 1)).Error; err != nil { + return err + } + // 返回 nil 提交事务 + return nil + }) + return int64(comment.ID), result +} + +// delete a comment +func DeleteComment(ctx context.Context, comment_id int64) error { + return DB.WithContext(ctx).Transaction(func(tx *gorm.DB) error { + var comment Comment + if err := tx.First(&comment, comment_id).Error; err != nil { + return err + } + // 在事务中执行一些 db 操作(从这里开始,您应该使用 'tx' 而不是 'db') + if err := tx.Delete(&Comment{}, comment_id).Error; err != nil { + return err + } + if err := tx.Model(&Video{}).Where("id = ?", comment.Video).Update("comment_count", gorm.Expr("comment_count - ?", 1)).Error; err != nil { + return err + } + // 返回 nil 提交事务 + return nil + }) +} + +// get a comment list of a video +func GetVideoComments(ctx context.Context, video_id int64) ([]*Comment, error) { + res := make([]*Comment, 0) + // it will search the context that didn't be deleted + if err := DB.WithContext(ctx).Where("video = ?", video_id).Order("id desc").Find(&res).Error; err != nil { + return nil, err + } + return res, nil +} diff --git a/sample_douyin/cmd/comment/dal/db/comment_video.go b/sample_douyin/cmd/comment/dal/db/comment_video.go new file mode 100644 index 00000000..76cba5de --- /dev/null +++ b/sample_douyin/cmd/comment/dal/db/comment_video.go @@ -0,0 +1,21 @@ +package db + +import ( + "mydouyin/pkg/consts" + + "gorm.io/gorm" +) + +type Video struct { + gorm.Model + Author int64 `json:"author"` + PlayUrl string `json:"play_url"` + CoverUrl string `json:"cover_url"` + Title string `json:"title"` + FavoriteCount int `json:"favorite_count"` + CommentCount int `json:"comment_count"` +} + +func (v *Video) TableName() string { + return consts.VideoTableName +} diff --git a/sample_douyin/cmd/comment/dal/db/init.go b/sample_douyin/cmd/comment/dal/db/init.go new file mode 100644 index 00000000..d0001c46 --- /dev/null +++ b/sample_douyin/cmd/comment/dal/db/init.go @@ -0,0 +1,38 @@ +package db + +import ( + "mydouyin/pkg/consts" + "time" + + "gorm.io/driver/mysql" + "gorm.io/gorm" + "gorm.io/gorm/logger" + "gorm.io/plugin/opentelemetry/logging/logrus" + "gorm.io/plugin/opentelemetry/tracing" +) + +var DB *gorm.DB + +func Init() { + var err error + gormlogrus := logger.New( + logrus.NewWriter(), + logger.Config{ + SlowThreshold: time.Millisecond, + Colorful: false, + LogLevel: logger.Info, + }, + ) + DB, err = gorm.Open(mysql.Open(consts.MySQLDefaultDSN), + &gorm.Config{ + PrepareStmt: true, + Logger: gormlogrus, + }, + ) + if err != nil { + panic(err) + } + if err := DB.Use(tracing.NewPlugin()); err != nil { + panic(err) + } +} diff --git a/sample_douyin/cmd/comment/dal/init.go b/sample_douyin/cmd/comment/dal/init.go new file mode 100644 index 00000000..47a349ac --- /dev/null +++ b/sample_douyin/cmd/comment/dal/init.go @@ -0,0 +1,7 @@ +package dal + +import "mydouyin/cmd/comment/dal/db" + +func Init() { + db.Init() +} diff --git a/sample_douyin/cmd/comment/handler.go b/sample_douyin/cmd/comment/handler.go new file mode 100644 index 00000000..6caa7b34 --- /dev/null +++ b/sample_douyin/cmd/comment/handler.go @@ -0,0 +1,55 @@ +package main + +import ( + "context" + "mydouyin/cmd/comment/pack" + "mydouyin/cmd/comment/service" + douyincomment "mydouyin/kitex_gen/douyincomment" + "mydouyin/pkg/errno" +) + +// CommentServiceImpl implements the last service interface defined in the IDL. +type CommentServiceImpl struct{} + +// CreateComment implements the CommentServiceImpl interface. +func (s *CommentServiceImpl) CreateComment(ctx context.Context, req *douyincomment.CreateCommentRequest) (resp *douyincomment.CreateCommentResponse, err error) { + resp = new(douyincomment.CreateCommentResponse) + if err = req.IsValid(); err != nil { + resp.BaseResp = pack.BuildBaseResp(errno.ParamErr) + return resp, nil + } + id, err := service.NewCreateCommentService(ctx).CreateComment(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + resp.BaseResp = pack.BuildBaseResp(errno.Success) + resp.CommentId = id + return resp, nil +} + +// DeleteComment implements the CommentServiceImpl interface. +func (s *CommentServiceImpl) DeleteComment(ctx context.Context, req *douyincomment.DeleteCommentRequest) (resp *douyincomment.DeleteCommentResponse, err error) { + resp = new(douyincomment.DeleteCommentResponse) + err = service.NewDeleteCommentService(ctx).DeleteComment(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return resp, nil +} + +// GetVideoComments implements the CommentServiceImpl interface. +func (s *CommentServiceImpl) GetVideoComments(ctx context.Context, req *douyincomment.GetVideoCommentsRequest) (resp *douyincomment.GetVideoCommentsResponse, err error) { + resp = new(douyincomment.GetVideoCommentsResponse) + var comments []*douyincomment.Comment + comments, err = service.NewGetVideoCommentsService(ctx).GetVideoComments(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + resp.Comments = comments + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return resp, nil +} diff --git a/sample_douyin/cmd/comment/kitex.yaml b/sample_douyin/cmd/comment/kitex.yaml new file mode 100644 index 00000000..d9d24288 --- /dev/null +++ b/sample_douyin/cmd/comment/kitex.yaml @@ -0,0 +1,3 @@ +kitexinfo: + ServiceName: 'comment' + ToolVersion: 'v0.4.4' diff --git a/sample_douyin/cmd/comment/main.go b/sample_douyin/cmd/comment/main.go new file mode 100644 index 00000000..efc92674 --- /dev/null +++ b/sample_douyin/cmd/comment/main.go @@ -0,0 +1,61 @@ +package main + +import ( + "mydouyin/cmd/comment/dal" + douyincomment "mydouyin/kitex_gen/douyincomment/commentservice" + "mydouyin/pkg/consts" + "mydouyin/pkg/mw" + "net" + + "github.com/cloudwego/kitex/pkg/klog" + "github.com/cloudwego/kitex/pkg/limit" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/cloudwego/kitex/server" + kitexlogrus "github.com/kitex-contrib/obs-opentelemetry/logging/logrus" + "github.com/kitex-contrib/obs-opentelemetry/provider" + "github.com/kitex-contrib/obs-opentelemetry/tracing" + etcd "github.com/kitex-contrib/registry-etcd" +) + +func Init() { + dal.Init() + //klog init + klog.SetLogger(kitexlogrus.NewLogger()) + klog.SetLevel(klog.LevelInfo) +} + +func main() { + r, err := etcd.NewEtcdRegistry([]string{consts.ETCDAddress}) + if err != nil { + panic(err) + } + addr, err := net.ResolveTCPAddr(consts.TCP, consts.CommentServiceAddr) + if err != nil { + panic(err) + } + Init() + provider.NewOpenTelemetryProvider( + provider.WithServiceName(consts.CommentServiceName), + provider.WithExportEndpoint(consts.ExportEndpoint), + provider.WithInsecure(), + ) + svr := douyincomment.NewServer(new(CommentServiceImpl), + server.WithServiceAddr(addr), + server.WithRegistry(r), + //限流 + server.WithLimit(&limit.Option{MaxConnections: 1000, MaxQPS: 100}), + //启用多路复用 + server.WithMuxTransport(), + //启用中间件 + server.WithMiddleware(mw.CommonMiddleware), + server.WithMiddleware(mw.ServerMiddleware), + //链路追踪 + server.WithSuite(tracing.NewServerSuite()), + server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: consts.CommentServiceName}), + ) + + err = svr.Run() + if err != nil { + klog.Fatal(err) + } +} diff --git a/sample_douyin/cmd/comment/output/bootstrap.sh b/sample_douyin/cmd/comment/output/bootstrap.sh new file mode 100644 index 00000000..294cb6e7 --- /dev/null +++ b/sample_douyin/cmd/comment/output/bootstrap.sh @@ -0,0 +1,21 @@ +#! /usr/bin/env bash +CURDIR=$(cd $(dirname $0); pwd) + +if [ "X$1" != "X" ]; then + RUNTIME_ROOT=$1 +else + RUNTIME_ROOT=${CURDIR} +fi + +export KITEX_RUNTIME_ROOT=$RUNTIME_ROOT +export KITEX_LOG_DIR="$RUNTIME_ROOT/log" + +if [ ! -d "$KITEX_LOG_DIR/app" ]; then + mkdir -p "$KITEX_LOG_DIR/app" +fi + +if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then + mkdir -p "$KITEX_LOG_DIR/rpc" +fi + +exec "$CURDIR/bin/comment" diff --git a/sample_douyin/cmd/comment/pack/comment.go b/sample_douyin/cmd/comment/pack/comment.go new file mode 100644 index 00000000..5eee69d5 --- /dev/null +++ b/sample_douyin/cmd/comment/pack/comment.go @@ -0,0 +1,31 @@ +package pack + +import ( + "mydouyin/cmd/comment/dal/db" + "mydouyin/kitex_gen/douyincomment" +) + +// object : change DB pattern to RPC pattern +func Comment(c *db.Comment) *douyincomment.Comment { + if c == nil { + return nil + } + return &douyincomment.Comment{ + CommentId: int64(c.ID), + Video: c.Video, + User: c.User, + Content: c.Content, + CreateDate: c.Date, + } +} + +// list : change DB pattern to RPC pattern +func Comments(c []*db.Comment) []*douyincomment.Comment { + comments := make([]*douyincomment.Comment, 0) + for _, v := range c { + if temp := Comment(v); temp != nil { + comments = append(comments, temp) + } + } + return comments +} \ No newline at end of file diff --git a/sample_douyin/cmd/comment/pack/resp.go b/sample_douyin/cmd/comment/pack/resp.go new file mode 100644 index 00000000..fedaa91e --- /dev/null +++ b/sample_douyin/cmd/comment/pack/resp.go @@ -0,0 +1,25 @@ +package pack + +import ( + "errors" + "mydouyin/kitex_gen/douyincomment" + "mydouyin/pkg/errno" +) + +// BuildBaseResp build baseResp from error +func BuildBaseResp(err error) *douyincomment.BaseResp { + if err == nil { + return baseResp(errno.Success) + } + e := errno.ErrNo{} + if errors.As(err, &e) { + return baseResp(e) + } + + s := errno.ServiceErr.WithMessage(err.Error()) + return baseResp(s) +} + +func baseResp(err errno.ErrNo) *douyincomment.BaseResp { + return &douyincomment.BaseResp{StatusCode: err.ErrCode, StatusMessage: err.ErrMsg} +} diff --git a/sample_douyin/cmd/comment/script/bootstrap.sh b/sample_douyin/cmd/comment/script/bootstrap.sh new file mode 100644 index 00000000..294cb6e7 --- /dev/null +++ b/sample_douyin/cmd/comment/script/bootstrap.sh @@ -0,0 +1,21 @@ +#! /usr/bin/env bash +CURDIR=$(cd $(dirname $0); pwd) + +if [ "X$1" != "X" ]; then + RUNTIME_ROOT=$1 +else + RUNTIME_ROOT=${CURDIR} +fi + +export KITEX_RUNTIME_ROOT=$RUNTIME_ROOT +export KITEX_LOG_DIR="$RUNTIME_ROOT/log" + +if [ ! -d "$KITEX_LOG_DIR/app" ]; then + mkdir -p "$KITEX_LOG_DIR/app" +fi + +if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then + mkdir -p "$KITEX_LOG_DIR/rpc" +fi + +exec "$CURDIR/bin/comment" diff --git a/sample_douyin/cmd/comment/service/create_comment.go b/sample_douyin/cmd/comment/service/create_comment.go new file mode 100644 index 00000000..75a8ab9b --- /dev/null +++ b/sample_douyin/cmd/comment/service/create_comment.go @@ -0,0 +1,27 @@ +package service + +import ( + "context" + "mydouyin/cmd/comment/dal/db" + "mydouyin/kitex_gen/douyincomment" +) + +type CreateCommentService struct { + ctx context.Context +} + +func NewCreateCommentService(ctx context.Context) *CreateCommentService { + return &CreateCommentService{ + ctx: ctx, + } +} + +// create user +func (c *CreateCommentService) CreateComment(req *douyincomment.CreateCommentRequest) (int64, error) { + return db.CreateComment(c.ctx, &db.Comment{ + Video: req.Video, + User: req.User, + Content: req.Content, + Date: req.CreateDate, + }) +} diff --git a/sample_douyin/cmd/comment/service/delete_comment.go b/sample_douyin/cmd/comment/service/delete_comment.go new file mode 100644 index 00000000..bfcc8763 --- /dev/null +++ b/sample_douyin/cmd/comment/service/delete_comment.go @@ -0,0 +1,24 @@ +package service + +import ( + "context" + "mydouyin/cmd/comment/dal/db" + "mydouyin/kitex_gen/douyincomment" +) + +type DeleteCommentService struct { + ctx context.Context +} + +// get service +func NewDeleteCommentService(ctx context.Context) *DeleteCommentService { + return &DeleteCommentService{ + ctx: ctx, + } +} + +// Delete the comment service +func (d *DeleteCommentService) DeleteComment(req *douyincomment.DeleteCommentRequest) error { + err := db.DeleteComment(d.ctx, req.CommentId) + return err +} diff --git a/sample_douyin/cmd/comment/service/get_video_comments.go b/sample_douyin/cmd/comment/service/get_video_comments.go new file mode 100644 index 00000000..5d25a8a6 --- /dev/null +++ b/sample_douyin/cmd/comment/service/get_video_comments.go @@ -0,0 +1,28 @@ +package service + +import ( + "context" + "mydouyin/cmd/comment/dal/db" + "mydouyin/cmd/comment/pack" + "mydouyin/kitex_gen/douyincomment" +) + +type GetVideoCommentsService struct { + ctx context.Context +} + +// +func NewGetVideoCommentsService(ctx context.Context) *GetVideoCommentsService{ + return &GetVideoCommentsService{ + ctx: ctx, + } +} + +// Get the list of comments of a video +func (s *GetVideoCommentsService) GetVideoComments(req *douyincomment.GetVideoCommentsRequest) ([]*douyincomment.Comment, error) { + comments, err := db.GetVideoComments(s.ctx, req.Video) + if err != nil { + return nil, err + } + return pack.Comments(comments), nil +} diff --git a/sample_douyin/cmd/favorite/build.sh b/sample_douyin/cmd/favorite/build.sh new file mode 100644 index 00000000..c4cd2b98 --- /dev/null +++ b/sample_douyin/cmd/favorite/build.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +RUN_NAME="favorite" + +mkdir -p output/bin +cp script/* output/ +chmod +x output/bootstrap.sh + +if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then + go build -o output/bin/${RUN_NAME} +else + go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... +fi diff --git a/sample_douyin/cmd/favorite/dal/db/favorite.go b/sample_douyin/cmd/favorite/dal/db/favorite.go new file mode 100644 index 00000000..ea51d369 --- /dev/null +++ b/sample_douyin/cmd/favorite/dal/db/favorite.go @@ -0,0 +1,110 @@ +package db + +import ( + "context" + "mydouyin/cmd/video/dal/db" + "mydouyin/pkg/consts" + "mydouyin/pkg/errno" + "time" + + "gorm.io/gorm" +) + +type Favorite struct { + ID uint `gorm:"primarykey"` + CreatedAt time.Time + UpdatedAt time.Time + UserId int64 `json:"user_id"` + VideoId int64 `json:"video_id"` +} + +func (f *Favorite) TableName() string { + return consts.FavoriteTableName +} + +// CreateVideo create video info +func CreateFavorite(ctx context.Context, favorites []*Favorite) error { + err := DB.WithContext(ctx).Transaction(func(tx *gorm.DB) error { + if err := tx.WithContext(ctx).Create(favorites).Error; err != nil { + return err + } + for _, f := range favorites { + if err := tx.WithContext(ctx).Model(&Video{}).Where("id = ?", f.VideoId).Update("favorite_count", gorm.Expr("favorite_count + ?", 1)).Error; err != nil { + return err + } + if err := tx.WithContext(ctx).Model(&User{}).Where("id = ?", f.UserId).Update("favorite_count", gorm.Expr("favorite_count + ?", 1)).Error; err != nil { + return err + } + videos := make([]*db.Video, 0) + if err := tx.WithContext(ctx).Model(&Video{}).Where("id = ?", f.VideoId).Find(&videos).Error; err != nil{ + return err + } + for _,v := range videos{ + if err := tx.WithContext(ctx).Model(&User{}).Where("id = ?", v.Author).Update("total_favorited", gorm.Expr("total_favorited + ?", 1)).Error; err != nil { + return err + } + } + } + // 返回 nil 提交事务 + return nil + }) + return err +} + +func CancleFavorite(ctx context.Context, favorites []*Favorite) error { + err := DB.WithContext(ctx).Transaction(func(tx *gorm.DB) error { + for _, f := range favorites { + var favorite Favorite + if err := tx.Where("user_id = ? and video_id = ?", f.UserId, f.VideoId).Delete(&favorite).Error; err != nil { + return err + } + } + for _, f := range favorites { + if err := tx.WithContext(ctx).Model(&Video{}).Where("id = ?", f.VideoId).Update("favorite_count", gorm.Expr("favorite_count - ?", 1)).Error; err != nil { + return err + } + if err := tx.WithContext(ctx).Model(&User{}).Where("id = ?", f.UserId).Update("favorite_count", gorm.Expr("favorite_count - ?", 1)).Error; err != nil { + return err + } + videos := make([]*db.Video, 0) + if err := tx.WithContext(ctx).Model(&Video{}).Where("id = ?", f.VideoId).Find(&videos).Error; err != nil{ + return err + } + for _,v := range videos{ + if err := tx.WithContext(ctx).Model(&User{}).Where("id = ?", v.Author).Update("total_favorited", gorm.Expr("total_favorited - ?", 1)).Error; err != nil { + return err + } + } + } + // 返回 nil 提交事务 + return nil + }) + return err +} + +func QueryFavoriteById(ctx context.Context, favorites []*Favorite) ([]bool, error) { + res := make([]bool, 0) + for _, favorite := range favorites { + find := make([]*Favorite, 0) + if err := DB.WithContext(ctx).Where("user_id = ? and video_id = ?", favorite.UserId, favorite.VideoId).Find(&find).Error; err != nil { + return res, err + } + if len(find) > 0 { + res = append(res, true) + } else { + res = append(res, false) + } + } + if len(res) != len(favorites) { + return res, errno.NewErrNo(0000000, "something wrong") + } + return res, nil +} + +func GetFavoriteList(ctx context.Context, userID int64) ([]*Favorite, error) { + res := make([]*Favorite, 0) + if err := DB.WithContext(ctx).Where("user_id = ?", userID).Find(&res).Error; err != nil { + return nil, err + } + return res, nil +} diff --git a/sample_douyin/cmd/favorite/dal/db/init.go b/sample_douyin/cmd/favorite/dal/db/init.go new file mode 100644 index 00000000..5f11ba7b --- /dev/null +++ b/sample_douyin/cmd/favorite/dal/db/init.go @@ -0,0 +1,38 @@ +package db + +import ( + "mydouyin/pkg/consts" + "time" + + "gorm.io/driver/mysql" + "gorm.io/gorm" + "gorm.io/gorm/logger" + "gorm.io/plugin/opentelemetry/logging/logrus" + "gorm.io/plugin/opentelemetry/tracing" +) + +var DB *gorm.DB + +func Init() { + var err error + gormlogrus := logger.New( + logrus.NewWriter(), + logger.Config{ + SlowThreshold: time.Millisecond, + Colorful: false, + LogLevel: logger.Info, + }, + ) + DB, err = gorm.Open(mysql.Open(consts.MySQLDefaultDSN), + &gorm.Config{ + PrepareStmt: true, + Logger: gormlogrus, + }, + ) + if err != nil { + panic(err) + } + if err := DB.Use(tracing.NewPlugin()); err != nil { + panic(err) + } +} \ No newline at end of file diff --git a/sample_douyin/cmd/favorite/dal/db/user.go b/sample_douyin/cmd/favorite/dal/db/user.go new file mode 100644 index 00000000..a5dc2790 --- /dev/null +++ b/sample_douyin/cmd/favorite/dal/db/user.go @@ -0,0 +1,25 @@ +package db + +import ( + "mydouyin/pkg/consts" + + "gorm.io/gorm" +) + +type User struct { + gorm.Model + Username string `json:"username"` + Password string `json:"password"` + FollowCount int `json:"follow_count"` + FollowerCount int `json:"follower_count"` + FavoriteCount int `json:"favorite_count"` + WorkCount int `json:"work_count"` + TotalFavorited int `json:"total_favorited"` + BackgroundImage string `json:"background_image"` + Avatar string `json:"avatar"` + Signature string `json:"signature"` +} + +func (u *User) TableName() string { + return consts.UserTableName +} diff --git a/sample_douyin/cmd/favorite/dal/db/video.go b/sample_douyin/cmd/favorite/dal/db/video.go new file mode 100644 index 00000000..b1a88a56 --- /dev/null +++ b/sample_douyin/cmd/favorite/dal/db/video.go @@ -0,0 +1,21 @@ +package db + +import ( + "mydouyin/pkg/consts" + "gorm.io/gorm" +) + +type Video struct { + gorm.Model + Author int64 `json:"author"` + PlayUrl string `json:"play_url"` + CoverUrl string `json:"cover_url"` + Title string `json:"title"` + FavoriteCount int `json:"favorite_count"` + CommentCount int `json:"comment_count"` +} + +func (v *Video) TableName() string { + return consts.VideoTableName +} + diff --git a/sample_douyin/cmd/favorite/dal/init.go b/sample_douyin/cmd/favorite/dal/init.go new file mode 100644 index 00000000..7a4de48b --- /dev/null +++ b/sample_douyin/cmd/favorite/dal/init.go @@ -0,0 +1,7 @@ +package dal + +import "mydouyin/cmd/favorite/dal/db" + +func Init() { + db.Init() +} diff --git a/sample_douyin/cmd/favorite/handler.go b/sample_douyin/cmd/favorite/handler.go new file mode 100644 index 00000000..1af6f3cf --- /dev/null +++ b/sample_douyin/cmd/favorite/handler.go @@ -0,0 +1,62 @@ +package main + +import ( + "context" + "mydouyin/cmd/favorite/pack" + "mydouyin/cmd/favorite/service" + douyinfavorite "mydouyin/kitex_gen/douyinfavorite" + "mydouyin/pkg/errno" +) + +// FavoriteServiceImpl implements the last service interface defined in the IDL. +type FavoriteServiceImpl struct{} + +// FavoriteAction implements the FavoriteServiceImpl interface. +func (s *FavoriteServiceImpl) FavoriteAction(ctx context.Context, req *douyinfavorite.FavoriteActionRequest) (resp *douyinfavorite.FavoriteActionResponse, err error) { + resp = new(douyinfavorite.FavoriteActionResponse) + if req.ActionType == "2" { + err = service.NewCancleFavoriteService(ctx).CancleFavorite(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return resp, nil + } else { + err = service.NewCreateFavoriteService(ctx).CreateFavorite(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return resp, nil + } +} + +// GetList implements the FavoriteServiceImpl interface. +func (s *FavoriteServiceImpl) GetList(ctx context.Context, req *douyinfavorite.GetListRequest) (resp *douyinfavorite.GetListResponse, err error) { + resp = new(douyinfavorite.GetListResponse) + var vids []int64 + vids, err = service.NewGetListService(ctx).GetList(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + resp.VideoIds = vids + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return resp, nil +} + +// GetIsFavorite implements the FavoriteServiceImpl interface. +func (s *FavoriteServiceImpl) GetIsFavorite(ctx context.Context, req *douyinfavorite.GetIsFavoriteRequest) (resp *douyinfavorite.GetIsFavoriteResponse, err error) { + resp = new(douyinfavorite.GetIsFavoriteResponse) + var isfavorites []bool + isfavorites, err = service.NewGetIsFavoriteService(ctx).GetIsFavorite(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + resp.IsFavorites = isfavorites + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return resp, nil +} diff --git a/sample_douyin/cmd/favorite/kitex.yaml b/sample_douyin/cmd/favorite/kitex.yaml new file mode 100644 index 00000000..185432f4 --- /dev/null +++ b/sample_douyin/cmd/favorite/kitex.yaml @@ -0,0 +1,3 @@ +kitexinfo: + ServiceName: 'favorite' + ToolVersion: 'v0.4.4' diff --git a/sample_douyin/cmd/favorite/main.go b/sample_douyin/cmd/favorite/main.go new file mode 100644 index 00000000..20442291 --- /dev/null +++ b/sample_douyin/cmd/favorite/main.go @@ -0,0 +1,60 @@ +package main +import ( + "mydouyin/cmd/favorite/dal" + douyinvideo "mydouyin/kitex_gen/douyinfavorite/favoriteservice" + "mydouyin/pkg/consts" + "mydouyin/pkg/mw" + "net" + + "github.com/cloudwego/kitex/pkg/klog" + "github.com/cloudwego/kitex/pkg/limit" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/cloudwego/kitex/server" + kitexlogrus "github.com/kitex-contrib/obs-opentelemetry/logging/logrus" + "github.com/kitex-contrib/obs-opentelemetry/provider" + "github.com/kitex-contrib/obs-opentelemetry/tracing" + etcd "github.com/kitex-contrib/registry-etcd" +) + +func Init() { + dal.Init() + //klog init + klog.SetLogger(kitexlogrus.NewLogger()) + klog.SetLevel(klog.LevelInfo) +} + +func main() { + r, err := etcd.NewEtcdRegistry([]string{consts.ETCDAddress}) + if err != nil { + panic(err) + } + addr, err := net.ResolveTCPAddr(consts.TCP, consts.FavoriteServiceAddr) + if err != nil { + panic(err) + } + Init() + provider.NewOpenTelemetryProvider( + provider.WithServiceName(consts.FavoriteServiceName), + provider.WithExportEndpoint(consts.ExportEndpoint), + provider.WithInsecure(), + ) + svr := douyinvideo.NewServer(new(FavoriteServiceImpl), + server.WithServiceAddr(addr), + server.WithRegistry(r), + //限流 + server.WithLimit(&limit.Option{MaxConnections: 1000, MaxQPS: 100}), + //启用多路复用 + server.WithMuxTransport(), + //启用中间件 + server.WithMiddleware(mw.CommonMiddleware), + server.WithMiddleware(mw.ServerMiddleware), + //链路追踪 + server.WithSuite(tracing.NewServerSuite()), + server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: consts.FavoriteServiceName}), + ) + + err = svr.Run() + if err != nil { + klog.Fatal(err) + } +} \ No newline at end of file diff --git a/sample_douyin/cmd/favorite/output/bootstrap.sh b/sample_douyin/cmd/favorite/output/bootstrap.sh new file mode 100644 index 00000000..023030b2 --- /dev/null +++ b/sample_douyin/cmd/favorite/output/bootstrap.sh @@ -0,0 +1,21 @@ +#! /usr/bin/env bash +CURDIR=$(cd $(dirname $0); pwd) + +if [ "X$1" != "X" ]; then + RUNTIME_ROOT=$1 +else + RUNTIME_ROOT=${CURDIR} +fi + +export KITEX_RUNTIME_ROOT=$RUNTIME_ROOT +export KITEX_LOG_DIR="$RUNTIME_ROOT/log" + +if [ ! -d "$KITEX_LOG_DIR/app" ]; then + mkdir -p "$KITEX_LOG_DIR/app" +fi + +if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then + mkdir -p "$KITEX_LOG_DIR/rpc" +fi + +exec "$CURDIR/bin/favorite" diff --git a/sample_douyin/cmd/favorite/pack/favorite.go b/sample_douyin/cmd/favorite/pack/favorite.go new file mode 100644 index 00000000..15bfd632 --- /dev/null +++ b/sample_douyin/cmd/favorite/pack/favorite.go @@ -0,0 +1,39 @@ +package pack + +import ( + "mydouyin/cmd/favorite/dal/db" + "mydouyin/kitex_gen/douyinfavorite" +) + +// Favorite pack video info +func Favorite(f *douyinfavorite.Favorite) *db.Favorite{ + if f == nil { + return nil + } + return &db.Favorite{ + UserId: int64(f.UserId), + VideoId: int64(f.VideoId), + } +} + +func Favorites(fs []*douyinfavorite.Favorite) []*db.Favorite{ + favorites := make([]*db.Favorite, 0) + for _, f := range fs { + if temp := Favorite(f); temp != nil { + favorites = append(favorites, temp) + } + } + return favorites +} + + +func FavoriteToVideoids(favorites []*db.Favorite) []int64 { + vids := make([]int64, 0) + for i:= 0 ;i < len(favorites); i++{ + if temp := int64(favorites[i].VideoId); temp != 0 { + vids = append(vids, temp) + } + } + return vids +} + diff --git a/sample_douyin/cmd/favorite/pack/resp.go b/sample_douyin/cmd/favorite/pack/resp.go new file mode 100644 index 00000000..fbcbbab7 --- /dev/null +++ b/sample_douyin/cmd/favorite/pack/resp.go @@ -0,0 +1,25 @@ +package pack + +import ( + "errors" + "mydouyin/kitex_gen/douyinfavorite" + "mydouyin/pkg/errno" +) + +// BuildBaseResp build baseResp from error +func BuildBaseResp(err error) *douyinfavorite.BaseResp { + if err == nil { + return baseResp(errno.Success) + } + e := errno.ErrNo{} + if errors.As(err, &e) { + return baseResp(e) + } + + s := errno.ServiceErr.WithMessage(err.Error()) + return baseResp(s) +} + +func baseResp(err errno.ErrNo) *douyinfavorite.BaseResp { + return &douyinfavorite.BaseResp{StatusCode: err.ErrCode, StatusMessage: err.ErrMsg} +} diff --git a/sample_douyin/cmd/favorite/script/bootstrap.sh b/sample_douyin/cmd/favorite/script/bootstrap.sh new file mode 100644 index 00000000..023030b2 --- /dev/null +++ b/sample_douyin/cmd/favorite/script/bootstrap.sh @@ -0,0 +1,21 @@ +#! /usr/bin/env bash +CURDIR=$(cd $(dirname $0); pwd) + +if [ "X$1" != "X" ]; then + RUNTIME_ROOT=$1 +else + RUNTIME_ROOT=${CURDIR} +fi + +export KITEX_RUNTIME_ROOT=$RUNTIME_ROOT +export KITEX_LOG_DIR="$RUNTIME_ROOT/log" + +if [ ! -d "$KITEX_LOG_DIR/app" ]; then + mkdir -p "$KITEX_LOG_DIR/app" +fi + +if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then + mkdir -p "$KITEX_LOG_DIR/rpc" +fi + +exec "$CURDIR/bin/favorite" diff --git a/sample_douyin/cmd/favorite/service/cancle_favorite.go b/sample_douyin/cmd/favorite/service/cancle_favorite.go new file mode 100644 index 00000000..6a9af04e --- /dev/null +++ b/sample_douyin/cmd/favorite/service/cancle_favorite.go @@ -0,0 +1,24 @@ +package service + +import ( + "context" + "mydouyin/cmd/favorite/dal/db" + "mydouyin/kitex_gen/douyinfavorite" +) + +type CancleFavoriteService struct { + ctx context.Context +} + +// NewCrceateVideoService new CreateVideoService +func NewCancleFavoriteService(ctx context.Context) *CancleFavoriteService { + return &CancleFavoriteService{ctx: ctx} +} + +// CreateVideo create video info. +func (s *CancleFavoriteService) CancleFavorite(req *douyinfavorite.FavoriteActionRequest) error { + return db.CancleFavorite(s.ctx, []*db.Favorite{{ + UserId: req.UserId, + VideoId: req.VideoId, + }}) +} diff --git a/sample_douyin/cmd/favorite/service/create_favorite.go b/sample_douyin/cmd/favorite/service/create_favorite.go new file mode 100644 index 00000000..bf7c5ba0 --- /dev/null +++ b/sample_douyin/cmd/favorite/service/create_favorite.go @@ -0,0 +1,24 @@ +package service + +import ( + "context" + "mydouyin/cmd/favorite/dal/db" + "mydouyin/kitex_gen/douyinfavorite" +) + +type CreateFavoriteService struct { + ctx context.Context +} + +// NewCreateVideoService new CreateVideoService +func NewCreateFavoriteService(ctx context.Context) *CreateFavoriteService { + return &CreateFavoriteService{ctx: ctx} +} + +// CreateVideo create video info. +func (s *CreateFavoriteService) CreateFavorite(req *douyinfavorite.FavoriteActionRequest) error { + return db.CreateFavorite(s.ctx, []*db.Favorite{{ + UserId: req.UserId, + VideoId: req.VideoId, + }}) +} diff --git a/sample_douyin/cmd/favorite/service/get_isfavorite.go b/sample_douyin/cmd/favorite/service/get_isfavorite.go new file mode 100644 index 00000000..5e17d215 --- /dev/null +++ b/sample_douyin/cmd/favorite/service/get_isfavorite.go @@ -0,0 +1,21 @@ +package service +import ( + "context" + "mydouyin/cmd/favorite/dal/db" + "mydouyin/cmd/favorite/pack" + "mydouyin/kitex_gen/douyinfavorite" +) + +type GetIsFavoriteService struct { + ctx context.Context +} + +// NewGetFeedService new GetFeedService +func NewGetIsFavoriteService(ctx context.Context) *GetIsFavoriteService { + return &GetIsFavoriteService{ctx: ctx} +} + +// GetFeedService. +func (s *GetIsFavoriteService) GetIsFavorite(req *douyinfavorite.GetIsFavoriteRequest) ([]bool, error) { + return db.QueryFavoriteById(s.ctx, pack.Favorites(req.FavoriteList)) +} diff --git a/sample_douyin/cmd/favorite/service/get_list.go b/sample_douyin/cmd/favorite/service/get_list.go new file mode 100644 index 00000000..bdf4d7ef --- /dev/null +++ b/sample_douyin/cmd/favorite/service/get_list.go @@ -0,0 +1,26 @@ +package service + +import ( + "context" + "mydouyin/cmd/favorite/dal/db" + "mydouyin/cmd/favorite/pack" + "mydouyin/kitex_gen/douyinfavorite" +) + +type GetListService struct { + ctx context.Context +} + +// NewGetFeedService new GetFeedService +func NewGetListService(ctx context.Context) *GetListService { + return &GetListService{ctx: ctx} +} + +// GetFeedService. +func (s *GetListService) GetList(req *douyinfavorite.GetListRequest) ([]int64, error) { + favorites, err := db.GetFavoriteList(s.ctx, req.UserId) + if err != nil { + return nil, err + } + return pack.FavoriteToVideoids(favorites) ,nil +} diff --git a/sample_douyin/cmd/message/build.sh b/sample_douyin/cmd/message/build.sh new file mode 100644 index 00000000..2e28b6ae --- /dev/null +++ b/sample_douyin/cmd/message/build.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +RUN_NAME="message" + +mkdir -p output/bin +cp script/* output/ +chmod +x output/bootstrap.sh + +if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then + go build -o output/bin/${RUN_NAME} +else + go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... +fi diff --git a/sample_douyin/cmd/message/dal/db/init.go b/sample_douyin/cmd/message/dal/db/init.go new file mode 100644 index 00000000..d0001c46 --- /dev/null +++ b/sample_douyin/cmd/message/dal/db/init.go @@ -0,0 +1,38 @@ +package db + +import ( + "mydouyin/pkg/consts" + "time" + + "gorm.io/driver/mysql" + "gorm.io/gorm" + "gorm.io/gorm/logger" + "gorm.io/plugin/opentelemetry/logging/logrus" + "gorm.io/plugin/opentelemetry/tracing" +) + +var DB *gorm.DB + +func Init() { + var err error + gormlogrus := logger.New( + logrus.NewWriter(), + logger.Config{ + SlowThreshold: time.Millisecond, + Colorful: false, + LogLevel: logger.Info, + }, + ) + DB, err = gorm.Open(mysql.Open(consts.MySQLDefaultDSN), + &gorm.Config{ + PrepareStmt: true, + Logger: gormlogrus, + }, + ) + if err != nil { + panic(err) + } + if err := DB.Use(tracing.NewPlugin()); err != nil { + panic(err) + } +} diff --git a/sample_douyin/cmd/message/dal/db/message.go b/sample_douyin/cmd/message/dal/db/message.go new file mode 100644 index 00000000..b1517816 --- /dev/null +++ b/sample_douyin/cmd/message/dal/db/message.go @@ -0,0 +1,112 @@ +package db + +import ( + "context" + "log" + "mydouyin/pkg/consts" + "time" +) + +type Message struct { + ID uint `gorm:"primarykey"` + CreatedAt time.Time + FromUserID int `json:"from_user_id"` + ToUserID int `json:"to_user_id"` + Content string `json:"content"` +} + +type FirstMessage struct { + Message string `json:"message"` + MsgType int64 `json:"msgtype"` + FirendID int64 `json:"friend_id"` +} + +func (u *Message) TableName() string { + return consts.MessageTableName +} + +// CreateMessage create message info +func CreateMessage(ctx context.Context, messages []*Message) (id, create_time int64, err error) { + log.Println(messages[0].Content) + result := DB.WithContext(ctx).Create(messages) + if result.Error != nil { + err = result.Error + return + } + return int64(messages[0].ID), messages[0].CreatedAt.Unix(), err +} + +// QueryUser query list of user info +func QueryMessage(ctx context.Context, fromUserID int64, toUserID int64, preMsgTime int64) ([]*Message, error) { + res := make([]*Message, 0) + if err := DB.WithContext(ctx).Where("from_user_id = ? AND to_user_id = ? AND created_at > ?", fromUserID, toUserID, time.Unix(preMsgTime, 0).Format("2006-01-02 15:04:05")).Find(&res).Error; err != nil { + return nil, err + } + return res, nil +} + +// +func MGetFirstMessage(ctx context.Context, userID int64, friendIDs []int64) ([]*FirstMessage, error) { + res := make([]*FirstMessage, len(friendIDs)) + tx := DB.WithContext(ctx) + msg1 := make([]*Message, 0) // userID 发送的最近消息 + msg2 := make([]*Message, 0) // userID 接收的最近消息 + + if err := tx.Select("to_user_id,max(created_at) as created_at").Where("from_user_id = ? AND to_user_id in ?", userID, friendIDs).Group("to_user_id").Find(&msg1).Error; err != nil { + return nil, err + } + // log.Println(len(msg1), msg1[0].CreatedAt, msg1[0].ToUserID) + if err := tx.Select("from_user_id,max(created_at) as created_at").Where("to_user_id = ? AND from_user_id in ?", userID, friendIDs).Group("from_user_id").Find(&msg2).Error; err != nil { + return nil, err + } + // log.Println(msg2[0].CreatedAt, msg2[0].FromUserID) + // if len(msg1) == 0 && len(msg2) == 0 { + // return + // } + msg1_map, msg2_map := make(map[int64]time.Time, 0), make(map[int64]time.Time, 0) + for _, m := range msg1 { + msg1_map[int64(m.ToUserID)] = m.CreatedAt + } + + for _, m := range msg2 { + msg2_map[int64(m.FromUserID)] = m.CreatedAt + } + + for _, friend_id := range friendIDs { + first_message := make([]*FirstMessage, 0, 1) + time1, ok1 := msg1_map[friend_id] + time2, ok2 := msg2_map[friend_id] + if (!ok1) && (!ok2) { + res = append(res, &FirstMessage{FirendID: friend_id, MsgType: -1}) + } else if ok1 && (!ok2) { + if err := tx.Model(&Message{}).Select("to_user_id as friend_id,content as message").Where("created_at = ?", time1).Find(&first_message).Error; err != nil { + return nil, err + } + first_message[0].MsgType = 1 + first_message[0].FirendID = friend_id + res = append(res, append([]*FirstMessage{}, first_message[0])...) + } else if (!ok1) && ok2 { + if err := tx.Model(&Message{}).Select("from_user_id as friend_id,content as message").Where("created_at = ?", time2).Find(&first_message).Error; err != nil { + return nil, err + } + first_message[0].MsgType = 0 + first_message[0].FirendID = friend_id + res = append(res, append([]*FirstMessage{}, first_message[0])...) + } else { + if time1.Unix() > time2.Unix() { + if err := tx.Model(&Message{}).Select("to_user_id as friend_id,content as message").Where("created_at = ?", time1).Find(&first_message).Error; err != nil { + return nil, err + } + first_message[0].MsgType = 1 + } else { + if err := tx.Model(&Message{}).Select("from_user_id as friend_id,content as message").Where("created_at = ?", time2).Find(&first_message).Error; err != nil { + return nil, err + } + first_message[0].MsgType = 0 + } + first_message[0].FirendID = friend_id + res = append(res, append([]*FirstMessage{}, first_message[0])...) + } + } + return res, nil +} diff --git a/sample_douyin/cmd/message/dal/init.go b/sample_douyin/cmd/message/dal/init.go new file mode 100644 index 00000000..9a1f9216 --- /dev/null +++ b/sample_douyin/cmd/message/dal/init.go @@ -0,0 +1,7 @@ +package dal + +import "mydouyin/cmd/message/dal/db" + +func Init() { + db.Init() +} diff --git a/sample_douyin/cmd/message/handler.go b/sample_douyin/cmd/message/handler.go new file mode 100644 index 00000000..1e2aeb74 --- /dev/null +++ b/sample_douyin/cmd/message/handler.go @@ -0,0 +1,61 @@ +package main + +import ( + "context" + "mydouyin/cmd/message/pack" + "mydouyin/cmd/message/service" + message "mydouyin/kitex_gen/message" + "mydouyin/pkg/errno" +) + +// MessageServiceImpl implements the last service interface defined in the IDL. +type MessageServiceImpl struct{} + +// CreateMessage implements the MessageServiceImpl interface. +func (s *MessageServiceImpl) CreateMessage(ctx context.Context, req *message.CreateMessageRequest) (resp *message.CreateMessageResponse, err error) { + // TODO: Your code here... + resp = new(message.CreateMessageResponse) + if err = req.IsValid(); err != nil { + resp.BaseResp = pack.BuildBaseResp(errno.ParamErr) + return resp, nil + } + id, create_time, err := service.NewCreateMessageService(ctx).CreateMessage(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + resp.BaseResp = pack.BuildBaseResp(errno.Success) + resp.CreateTime = create_time + resp.Id = id + return resp, nil +} + +// GetMessageList implements the MessageServiceImpl interface. +func (s *MessageServiceImpl) GetMessageList(ctx context.Context, req *message.GetMessageListRequest) (resp *message.GetMessageListResponse, err error) { + // TODO: Your code here... + resp = new(message.GetMessageListResponse) + var messages []*message.Message + messages, err = service.NewGetMessageListService(ctx).GetMessageList(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + resp.MessageList = messages + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return resp, nil +} + +// GetFirstMessage implements the MessageServiceImpl interface. +func (s *MessageServiceImpl) GetFirstMessage(ctx context.Context, req *message.GetFirstMessageRequest) (resp *message.GetFirstMessageResponse, err error) { + // TODO: Your code here... + resp = new(message.GetFirstMessageResponse) + var firstmessages []*message.FirstMessage + firstmessages, err = service.NewGetFirstMessageService(ctx).GetFirstMessage(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + resp.FirstMessageList = firstmessages + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return resp, nil +} diff --git a/sample_douyin/cmd/message/kitex.yaml b/sample_douyin/cmd/message/kitex.yaml new file mode 100644 index 00000000..0160b4ba --- /dev/null +++ b/sample_douyin/cmd/message/kitex.yaml @@ -0,0 +1,3 @@ +kitexinfo: + ServiceName: 'message' + ToolVersion: 'v0.4.4' diff --git a/sample_douyin/cmd/message/main.go b/sample_douyin/cmd/message/main.go new file mode 100644 index 00000000..fb2d11da --- /dev/null +++ b/sample_douyin/cmd/message/main.go @@ -0,0 +1,61 @@ +package main + +import ( + "mydouyin/cmd/message/dal" + message "mydouyin/kitex_gen/message/messageservice" + "mydouyin/pkg/consts" + "mydouyin/pkg/mw" + "net" + + "github.com/cloudwego/kitex/pkg/klog" + "github.com/cloudwego/kitex/pkg/limit" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/cloudwego/kitex/server" + kitexlogrus "github.com/kitex-contrib/obs-opentelemetry/logging/logrus" + "github.com/kitex-contrib/obs-opentelemetry/provider" + "github.com/kitex-contrib/obs-opentelemetry/tracing" + etcd "github.com/kitex-contrib/registry-etcd" +) + +func Init() { + dal.Init() + //klog init + klog.SetLogger(kitexlogrus.NewLogger()) + klog.SetLevel(klog.LevelInfo) +} + +func main() { + r, err := etcd.NewEtcdRegistry([]string{consts.ETCDAddress}) + if err != nil { + panic(err) + } + addr, err := net.ResolveTCPAddr(consts.TCP, consts.MessageServiceAddr) + if err != nil { + panic(err) + } + Init() + provider.NewOpenTelemetryProvider( + provider.WithServiceName(consts.MessageServiceName), + provider.WithExportEndpoint(consts.ExportEndpoint), + provider.WithInsecure(), + ) + svr := message.NewServer(new(MessageServiceImpl), + server.WithServiceAddr(addr), + server.WithRegistry(r), + //限流 + server.WithLimit(&limit.Option{MaxConnections: 1000, MaxQPS: 100}), + //启用多路复用 + server.WithMuxTransport(), + //启用中间件 + server.WithMiddleware(mw.CommonMiddleware), + server.WithMiddleware(mw.ServerMiddleware), + //链路追踪 + server.WithSuite(tracing.NewServerSuite()), + server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: consts.MessageServiceName}), + ) + + err = svr.Run() + if err != nil { + klog.Fatal(err) + } +} diff --git a/sample_douyin/cmd/message/output/bootstrap.sh b/sample_douyin/cmd/message/output/bootstrap.sh new file mode 100644 index 00000000..4084d2e5 --- /dev/null +++ b/sample_douyin/cmd/message/output/bootstrap.sh @@ -0,0 +1,21 @@ +#! /usr/bin/env bash +CURDIR=$(cd $(dirname $0); pwd) + +if [ "X$1" != "X" ]; then + RUNTIME_ROOT=$1 +else + RUNTIME_ROOT=${CURDIR} +fi + +export KITEX_RUNTIME_ROOT=$RUNTIME_ROOT +export KITEX_LOG_DIR="$RUNTIME_ROOT/log" + +if [ ! -d "$KITEX_LOG_DIR/app" ]; then + mkdir -p "$KITEX_LOG_DIR/app" +fi + +if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then + mkdir -p "$KITEX_LOG_DIR/rpc" +fi + +exec "$CURDIR/bin/message" \ No newline at end of file diff --git a/sample_douyin/cmd/message/pack/firstmessage.go b/sample_douyin/cmd/message/pack/firstmessage.go new file mode 100644 index 00000000..47844706 --- /dev/null +++ b/sample_douyin/cmd/message/pack/firstmessage.go @@ -0,0 +1,29 @@ +package pack + +import ( + "mydouyin/cmd/message/dal/db" + "mydouyin/kitex_gen/message" +) + +// User pack user info +func FirstMessage(u *db.FirstMessage) *message.FirstMessage { + if u == nil { + return nil + } + + return &message.FirstMessage{ + Message: u.Message, + MsgType: int64(u.MsgType), + FriendId: int64(u.FirendID), + } +} + +func FirstMessages(us []*db.FirstMessage) []*message.FirstMessage { + firstmessages := make([]*message.FirstMessage, 0) + for _, m := range us { + if temp := FirstMessage(m); temp != nil { + firstmessages = append(firstmessages, temp) + } + } + return firstmessages +} diff --git a/sample_douyin/cmd/message/pack/message.go b/sample_douyin/cmd/message/pack/message.go new file mode 100644 index 00000000..97471d97 --- /dev/null +++ b/sample_douyin/cmd/message/pack/message.go @@ -0,0 +1,31 @@ +package pack + +import ( + "mydouyin/cmd/message/dal/db" + "mydouyin/kitex_gen/message" +) + +// User pack user info +func Message(u *db.Message) *message.Message { + if u == nil { + return nil + } + + return &message.Message{ + Id: int64(u.ID), + ToUserId: int64(u.ToUserID), + FromUserId: int64(u.FromUserID), + Content: u.Content, + CreateTime: u.CreatedAt.Unix(), + } +} + +func Messages(us []*db.Message) []*message.Message { + messages := make([]*message.Message, 0) + for _, m := range us { + if temp := Message(m); temp != nil { + messages = append(messages, temp) + } + } + return messages +} diff --git a/sample_douyin/cmd/message/pack/resp.go b/sample_douyin/cmd/message/pack/resp.go new file mode 100644 index 00000000..4a11bf47 --- /dev/null +++ b/sample_douyin/cmd/message/pack/resp.go @@ -0,0 +1,25 @@ +package pack + +import ( + "errors" + "mydouyin/kitex_gen/message" + "mydouyin/pkg/errno" +) + +// BuildBaseResp build baseResp from error +func BuildBaseResp(err error) *message.BaseResp { + if err == nil { + return baseResp(errno.Success) + } + e := errno.ErrNo{} + if errors.As(err, &e) { + return baseResp(e) + } + + s := errno.ServiceErr.WithMessage(err.Error()) + return baseResp(s) +} + +func baseResp(err errno.ErrNo) *message.BaseResp { + return &message.BaseResp{StatusCode: err.ErrCode, StatusMessage: err.ErrMsg} +} diff --git a/sample_douyin/cmd/message/service/create_message.go b/sample_douyin/cmd/message/service/create_message.go new file mode 100644 index 00000000..5f96223c --- /dev/null +++ b/sample_douyin/cmd/message/service/create_message.go @@ -0,0 +1,25 @@ +package service + +import ( + "context" + "mydouyin/cmd/message/dal/db" + "mydouyin/kitex_gen/message" +) + +type CreateMessageService struct { + ctx context.Context +} + +// NewCreateMessageService new CreateMessageService +func NewCreateMessageService(ctx context.Context) *CreateMessageService { + return &CreateMessageService{ctx: ctx} +} + +// CreateMessage create message info. +func (s *CreateMessageService) CreateMessage(req *message.CreateMessageRequest) (id, create_time int64, err error) { + return db.CreateMessage(s.ctx, []*db.Message{{ + FromUserID: int(req.FromUserId), + ToUserID: int(req.ToUserId), + Content: req.Content, + }}) +} diff --git a/sample_douyin/cmd/message/service/get_firstmessage.go b/sample_douyin/cmd/message/service/get_firstmessage.go new file mode 100644 index 00000000..a6856cac --- /dev/null +++ b/sample_douyin/cmd/message/service/get_firstmessage.go @@ -0,0 +1,26 @@ +package service + +import ( + "context" + "mydouyin/cmd/message/dal/db" + "mydouyin/cmd/message/pack" + "mydouyin/kitex_gen/message" +) + +type GetFirstMessageService struct { + ctx context.Context +} + +// NewGetFeedService new GetFeedService +func NewGetFirstMessageService(ctx context.Context) *GetFirstMessageService { + return &GetFirstMessageService{ctx: ctx} +} + +// GetFeedService. +func (s *GetFirstMessageService) GetFirstMessage(req *message.GetFirstMessageRequest) ([]*message.FirstMessage, error) { + firstmessages, err := db.MGetFirstMessage(s.ctx, req.Id, req.FriendIds) + if err != nil { + return nil, err + } + return pack.FirstMessages(firstmessages), nil +} diff --git a/sample_douyin/cmd/message/service/get_messagelist.go b/sample_douyin/cmd/message/service/get_messagelist.go new file mode 100644 index 00000000..2498ed24 --- /dev/null +++ b/sample_douyin/cmd/message/service/get_messagelist.go @@ -0,0 +1,26 @@ +package service + +import ( + "context" + "mydouyin/cmd/message/dal/db" + "mydouyin/cmd/message/pack" + "mydouyin/kitex_gen/message" +) + +type GetMessageListService struct { + ctx context.Context +} + +// NewGetFeedService new GetFeedService +func NewGetMessageListService(ctx context.Context) *GetMessageListService { + return &GetMessageListService{ctx: ctx} +} + +// GetFeedService. +func (s *GetMessageListService) GetMessageList(req *message.GetMessageListRequest) ([]*message.Message, error) { + messages, err := db.QueryMessage(s.ctx, req.FromUserId, req.ToUserId, req.PreMsgTime) + if err != nil { + return nil, err + } + return pack.Messages(messages), nil +} diff --git a/sample_douyin/cmd/relation/build.sh b/sample_douyin/cmd/relation/build.sh new file mode 100644 index 00000000..f9a96957 --- /dev/null +++ b/sample_douyin/cmd/relation/build.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +RUN_NAME="relation" + +mkdir -p output/bin +cp script/* output/ +chmod +x output/bootstrap.sh + +if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then + go build -o output/bin/${RUN_NAME} +else + go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... +fi diff --git a/sample_douyin/cmd/relation/dal/db/init.go b/sample_douyin/cmd/relation/dal/db/init.go new file mode 100644 index 00000000..d0001c46 --- /dev/null +++ b/sample_douyin/cmd/relation/dal/db/init.go @@ -0,0 +1,38 @@ +package db + +import ( + "mydouyin/pkg/consts" + "time" + + "gorm.io/driver/mysql" + "gorm.io/gorm" + "gorm.io/gorm/logger" + "gorm.io/plugin/opentelemetry/logging/logrus" + "gorm.io/plugin/opentelemetry/tracing" +) + +var DB *gorm.DB + +func Init() { + var err error + gormlogrus := logger.New( + logrus.NewWriter(), + logger.Config{ + SlowThreshold: time.Millisecond, + Colorful: false, + LogLevel: logger.Info, + }, + ) + DB, err = gorm.Open(mysql.Open(consts.MySQLDefaultDSN), + &gorm.Config{ + PrepareStmt: true, + Logger: gormlogrus, + }, + ) + if err != nil { + panic(err) + } + if err := DB.Use(tracing.NewPlugin()); err != nil { + panic(err) + } +} diff --git a/sample_douyin/cmd/relation/dal/db/realtion.go b/sample_douyin/cmd/relation/dal/db/realtion.go new file mode 100644 index 00000000..fe9f3b87 --- /dev/null +++ b/sample_douyin/cmd/relation/dal/db/realtion.go @@ -0,0 +1,89 @@ +package db + +import ( + "context" + "mydouyin/pkg/consts" + "time" + + "gorm.io/gorm" +) + +type Relation struct { + ID uint `gorm:"primarykey"` + CreatedAt time.Time + UpdatedAt time.Time + FollowId int64 `json:"follow_id"` + FollowerId int64 `json:"follower_id"` +} + +func (u *Relation) TableName() string { + return consts.RelationTableName +} + +func CreateRelation(ctx context.Context, realtion *Relation) error { + return DB.Transaction(func(tx *gorm.DB) error { + if err := tx.WithContext(ctx).Create(realtion).Error; err != nil { + return err + } + if err := tx.WithContext(ctx).Model(&User{}).Where("id = ?", realtion.FollowId).UpdateColumn("follower_count", gorm.Expr("follower_count + ?", 1)).Error; err != nil { + return err + } + if err := tx.WithContext(ctx).Model(&User{}).Where("id = ?", realtion.FollowerId).UpdateColumn("follow_count", gorm.Expr("follow_count + ?", 1)).Error; err != nil { + return err + } + return nil + }) +} + +func DeleteRelation(ctx context.Context, follow_id, follower_id int64) error { + return DB.Transaction(func(tx *gorm.DB) error { + if err := tx.WithContext(ctx).Where("follow_id = ? AND follower_id = ?", follow_id, follower_id).Delete(&Relation{}).Error; err != nil { + return err + } + if err := tx.WithContext(ctx).Model(&User{}).Where("id = ?", follow_id).Update("follower_count", gorm.Expr("follower_count - ?", 1)).Error; err != nil { + tx.Rollback() + return err + } + if err := tx.WithContext(ctx).Model(&User{}).Where("id = ?", follower_id).Update("follow_count", gorm.Expr("follow_count - ?", 1)).Error; err != nil { + tx.Rollback() + return err + } + return nil + }) +} + +func ValidRelationIfExist(ctx context.Context, follow_id, follower_id int64) (bool, error) { + res := make([]*Relation, 0) + if err := DB.WithContext(ctx).Model(&Relation{}).Where("follow_id = ? AND follower_id = ?", follow_id, follower_id).Find(&res).Error; err != nil { + return false, err + } + return len(res) > 0, nil +} + +// 通过FollowId查询所有FollowerId +func GetFollowersByFollow(ctx context.Context, follow_id int64) ([]*Relation, error) { + res := make([]*Relation, 0) + if err := DB.WithContext(ctx).Where("follow_id = ?", follow_id).Select("follower_id").Find(&res).Error; err != nil { + return nil, err + } + return res, nil +} + +// 通过FollowerId查询所有FollowId +func GetFollowsByFollower(ctx context.Context, follower_id int64) ([]*Relation, error) { + res := make([]*Relation, 0) + if err := DB.WithContext(ctx).Where("follower_id = ?", follower_id).Select("follow_id").Find(&res).Error; err != nil { + return nil, err + } + return res, nil +} + +func GetFriend(ctx context.Context, me int64) ([]int64, error) { + res := make([]int64, 0) + if err := DB.WithContext(ctx).Table("relation as a").Distinct("a.follow_id as friend_id"). + Joins("inner join relation as b on a.follower_id = ? and b.follow_id = ?", me, me). + Find(&res).Error; err != nil { + return nil, err + } + return res, nil +} diff --git a/sample_douyin/cmd/relation/dal/db/user.go b/sample_douyin/cmd/relation/dal/db/user.go new file mode 100644 index 00000000..ed9a482c --- /dev/null +++ b/sample_douyin/cmd/relation/dal/db/user.go @@ -0,0 +1,19 @@ +package db + +import ( + "mydouyin/pkg/consts" + + "gorm.io/gorm" +) + +type User struct { + gorm.Model + Username string `json:"username"` + Password string `json:"password"` + FollowCount int `json:"follow_count"` + FollowerCount int `json:"follower_count"` +} + +func (u *User) TableName() string { + return consts.UserTableName +} diff --git a/sample_douyin/cmd/relation/dal/init.go b/sample_douyin/cmd/relation/dal/init.go new file mode 100644 index 00000000..5b6e3064 --- /dev/null +++ b/sample_douyin/cmd/relation/dal/init.go @@ -0,0 +1,7 @@ +package dal + +import "mydouyin/cmd/relation/dal/db" + +func Init() { + db.Init() +} diff --git a/sample_douyin/cmd/relation/handler.go b/sample_douyin/cmd/relation/handler.go new file mode 100644 index 00000000..6d11bd4a --- /dev/null +++ b/sample_douyin/cmd/relation/handler.go @@ -0,0 +1,115 @@ +package main + +import ( + "context" + + "mydouyin/cmd/relation/pack" + "mydouyin/cmd/relation/service" + + relation "mydouyin/kitex_gen/relation" + "mydouyin/pkg/errno" +) + +// RelationServiceImpl implements the last service interface defined in the IDL. +type RelationServiceImpl struct{} + +// CreateRelation implements the RelationServiceImpl interface. +func (s *RelationServiceImpl) CreateRelation(ctx context.Context, req *relation.CreateRelationRequest) (resp *relation.BaseResp, err error) { + // TODO: Your code here... + if err = req.IsValid(); err != nil { + resp = pack.BuildBaseResp(errno.ParamErr) + return resp, nil + } + err = service.NewCreateRelationService(ctx).CreateRelation(req) + if err != nil { + resp = pack.BuildBaseResp(err) + return resp, nil + } + + resp = pack.BuildBaseResp(errno.Success) + return resp, nil +} + +// DeleteRelation implements the RelationServiceImpl interface. +func (s *RelationServiceImpl) DeleteRelation(ctx context.Context, req *relation.DeleteRelationRequest) (resp *relation.BaseResp, err error) { + // TODO: Your code here... + if err = req.IsValid(); err != nil { + resp = pack.BuildBaseResp(errno.ParamErr) + return resp, nil + } + err = service.NewDeleteRelationService(ctx).DeleteRelation(req) + if err != nil { + resp = pack.BuildBaseResp(err) + return resp, nil + } + + resp = pack.BuildBaseResp(errno.Success) + return resp, nil +} + +// GetFollow implements the RelationServiceImpl interface. +func (s *RelationServiceImpl) GetFollow(ctx context.Context, req *relation.GetFollowListRequest) (resp *relation.GetFollowListResponse, err error) { + // TODO: Your code here... + resp = new(relation.GetFollowListResponse) + if err = req.IsValid(); err != nil { + resp.BaseResp = pack.BuildBaseResp(errno.ParamErr) + return resp, nil + } + resp.FollowIds, err = service.NewGetFollowService(ctx).GetFollow(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return resp, nil +} + +// GetFollower implements the RelationServiceImpl interface. +func (s *RelationServiceImpl) GetFollower(ctx context.Context, req *relation.GetFollowerListRequest) (resp *relation.GetFollowerListResponse, err error) { + // TODO: Your code here... + resp = new(relation.GetFollowerListResponse) + if err = req.IsValid(); err != nil { + resp.BaseResp = pack.BuildBaseResp(errno.ParamErr) + return resp, nil + } + resp.FollowerIds, err = service.NewGetFollowerService(ctx).GetFollower(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return resp, nil +} + +// ValidIfFollowRequest implements the RelationServiceImpl interface. +func (s *RelationServiceImpl) ValidIfFollowRequest(ctx context.Context, req *relation.ValidIfFollowRequest) (resp *relation.ValidIfFollowResponse, err error) { + // TODO: Your code here... + resp = new(relation.ValidIfFollowResponse) + if err = req.IsValid(); err != nil { + resp.BaseResp = pack.BuildBaseResp(errno.ParamErr) + return resp, nil + } + resp.IfFollow, err = service.NewValidIfFollowService(ctx).ValidIfFollowFollower(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return resp, nil +} + +// GetFriend implements the RelationServiceImpl interface. +func (s *RelationServiceImpl) GetFriend(ctx context.Context, req *relation.GetFriendRequest) (resp *relation.GetFriendResponse, err error) { + // TODO: Your code here... + resp = new(relation.GetFriendResponse) + resp.FriendIds, err = service.NewGetFriendService(ctx).GetFriend(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, err + } + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return resp, nil +} diff --git a/sample_douyin/cmd/relation/kitex.yaml b/sample_douyin/cmd/relation/kitex.yaml new file mode 100644 index 00000000..50eace17 --- /dev/null +++ b/sample_douyin/cmd/relation/kitex.yaml @@ -0,0 +1,3 @@ +kitexinfo: + ServiceName: 'relation' + ToolVersion: 'v0.4.4' diff --git a/sample_douyin/cmd/relation/main.go b/sample_douyin/cmd/relation/main.go new file mode 100644 index 00000000..a615a417 --- /dev/null +++ b/sample_douyin/cmd/relation/main.go @@ -0,0 +1,61 @@ +package main + +import ( + "mydouyin/cmd/relation/dal" + relation "mydouyin/kitex_gen/relation/relationservice" + "mydouyin/pkg/consts" + "mydouyin/pkg/mw" + "net" + + "github.com/cloudwego/kitex/pkg/klog" + "github.com/cloudwego/kitex/pkg/limit" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/cloudwego/kitex/server" + kitexlogrus "github.com/kitex-contrib/obs-opentelemetry/logging/logrus" + "github.com/kitex-contrib/obs-opentelemetry/provider" + "github.com/kitex-contrib/obs-opentelemetry/tracing" + etcd "github.com/kitex-contrib/registry-etcd" +) + +func Init() { + dal.Init() + //klog init + klog.SetLogger(kitexlogrus.NewLogger()) + klog.SetLevel(klog.LevelInfo) +} + +func main() { + r, err := etcd.NewEtcdRegistry([]string{consts.ETCDAddress}) + if err != nil { + panic(err) + } + addr, err := net.ResolveTCPAddr(consts.TCP, consts.RelationServiceAddr) + if err != nil { + panic(err) + } + Init() + provider.NewOpenTelemetryProvider( + provider.WithServiceName(consts.RelationServiceName), + provider.WithExportEndpoint(consts.ExportEndpoint), + provider.WithInsecure(), + ) + svr := relation.NewServer(new(RelationServiceImpl), + server.WithServiceAddr(addr), + server.WithRegistry(r), + //限流 + server.WithLimit(&limit.Option{MaxConnections: 1000, MaxQPS: 100}), + //启用多路复用 + server.WithMuxTransport(), + //启用中间件 + server.WithMiddleware(mw.CommonMiddleware), + server.WithMiddleware(mw.ServerMiddleware), + //链路追踪 + server.WithSuite(tracing.NewServerSuite()), + server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: consts.RelationServiceName}), + ) + + err = svr.Run() + if err != nil { + klog.Fatal(err) + } +} diff --git a/sample_douyin/cmd/relation/output/bootstrap.sh b/sample_douyin/cmd/relation/output/bootstrap.sh new file mode 100644 index 00000000..b8af1494 --- /dev/null +++ b/sample_douyin/cmd/relation/output/bootstrap.sh @@ -0,0 +1,21 @@ +#! /usr/bin/env bash +CURDIR=$(cd $(dirname $0); pwd) + +if [ "X$1" != "X" ]; then + RUNTIME_ROOT=$1 +else + RUNTIME_ROOT=${CURDIR} +fi + +export KITEX_RUNTIME_ROOT=$RUNTIME_ROOT +export KITEX_LOG_DIR="$RUNTIME_ROOT/log" + +if [ ! -d "$KITEX_LOG_DIR/app" ]; then + mkdir -p "$KITEX_LOG_DIR/app" +fi + +if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then + mkdir -p "$KITEX_LOG_DIR/rpc" +fi + +exec "$CURDIR/bin/relation" diff --git a/sample_douyin/cmd/relation/pack/resp.go b/sample_douyin/cmd/relation/pack/resp.go new file mode 100644 index 00000000..d7712d6c --- /dev/null +++ b/sample_douyin/cmd/relation/pack/resp.go @@ -0,0 +1,42 @@ +package pack + +import ( + "errors" + "mydouyin/cmd/relation/dal/db" + "mydouyin/kitex_gen/relation" + "mydouyin/pkg/errno" +) + +// BuildBaseResp build baseResp from error +func BuildBaseResp(err error) *relation.BaseResp { + if err == nil { + return baseResp(errno.Success) + } + e := errno.ErrNo{} + if errors.As(err, &e) { + return baseResp(e) + } + + s := errno.ServiceErr.WithMessage(err.Error()) + return baseResp(s) +} + +func baseResp(err errno.ErrNo) *relation.BaseResp { + return &relation.BaseResp{StatusCode: err.ErrCode, StatusMessage: err.ErrMsg} +} + +func Relation2Follow(relations []*db.Relation) []int64 { + res := make([]int64, 0, len(relations)) + for _, relation := range relations { + res = append(res, relation.FollowId) + } + return res +} + +func Relation2Follower(relations []*db.Relation) []int64 { + res := make([]int64, 0, len(relations)) + for _, relation := range relations { + res = append(res, relation.FollowerId) + } + return res +} diff --git a/sample_douyin/cmd/relation/script/bootstrap.sh b/sample_douyin/cmd/relation/script/bootstrap.sh new file mode 100644 index 00000000..b8af1494 --- /dev/null +++ b/sample_douyin/cmd/relation/script/bootstrap.sh @@ -0,0 +1,21 @@ +#! /usr/bin/env bash +CURDIR=$(cd $(dirname $0); pwd) + +if [ "X$1" != "X" ]; then + RUNTIME_ROOT=$1 +else + RUNTIME_ROOT=${CURDIR} +fi + +export KITEX_RUNTIME_ROOT=$RUNTIME_ROOT +export KITEX_LOG_DIR="$RUNTIME_ROOT/log" + +if [ ! -d "$KITEX_LOG_DIR/app" ]; then + mkdir -p "$KITEX_LOG_DIR/app" +fi + +if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then + mkdir -p "$KITEX_LOG_DIR/rpc" +fi + +exec "$CURDIR/bin/relation" diff --git a/sample_douyin/cmd/relation/service/create_relation.go b/sample_douyin/cmd/relation/service/create_relation.go new file mode 100644 index 00000000..14ef4097 --- /dev/null +++ b/sample_douyin/cmd/relation/service/create_relation.go @@ -0,0 +1,24 @@ +package service + +import ( + "context" + "mydouyin/cmd/relation/dal/db" + "mydouyin/kitex_gen/relation" +) + +type CreateRelationService struct { + ctx context.Context +} + +func NewCreateRelationService(ctx context.Context) *CreateRelationService { + return &CreateRelationService{ + ctx: ctx, + } +} + +func (s *CreateRelationService) CreateRelation(req *relation.CreateRelationRequest) error { + return db.CreateRelation(s.ctx, &db.Relation{ + FollowId: req.FollowId, + FollowerId: req.FollowerId, + }) +} diff --git a/sample_douyin/cmd/relation/service/delete_relation.go b/sample_douyin/cmd/relation/service/delete_relation.go new file mode 100644 index 00000000..e55e6da9 --- /dev/null +++ b/sample_douyin/cmd/relation/service/delete_relation.go @@ -0,0 +1,21 @@ +package service + +import ( + "context" + "mydouyin/cmd/relation/dal/db" + "mydouyin/kitex_gen/relation" +) + +type DeleteRelationService struct { + ctx context.Context +} + +func NewDeleteRelationService(ctx context.Context) *DeleteRelationService { + return &DeleteRelationService{ + ctx: ctx, + } +} + +func (s *DeleteRelationService) DeleteRelation(req *relation.DeleteRelationRequest) error { + return db.DeleteRelation(s.ctx, req.FollowId, req.FollowerId) +} diff --git a/sample_douyin/cmd/relation/service/get_follow.go b/sample_douyin/cmd/relation/service/get_follow.go new file mode 100644 index 00000000..532ddc48 --- /dev/null +++ b/sample_douyin/cmd/relation/service/get_follow.go @@ -0,0 +1,26 @@ +package service + +import ( + "context" + "mydouyin/cmd/relation/dal/db" + "mydouyin/cmd/relation/pack" + "mydouyin/kitex_gen/relation" +) + +type GetFollowService struct { + ctx context.Context +} + +func NewGetFollowService(ctx context.Context) *GetFollowService { + return &GetFollowService{ + ctx: ctx, + } +} + +func (s *GetFollowService) GetFollow(req *relation.GetFollowListRequest) ([]int64, error) { + relations, err := db.GetFollowsByFollower(s.ctx, req.FollowerId) + if err != nil { + return nil, err + } + return pack.Relation2Follow(relations), nil +} diff --git a/sample_douyin/cmd/relation/service/get_follower.go b/sample_douyin/cmd/relation/service/get_follower.go new file mode 100644 index 00000000..521a6f87 --- /dev/null +++ b/sample_douyin/cmd/relation/service/get_follower.go @@ -0,0 +1,26 @@ +package service + +import ( + "context" + "mydouyin/cmd/relation/dal/db" + "mydouyin/cmd/relation/pack" + "mydouyin/kitex_gen/relation" +) + +type GetFollowerService struct { + ctx context.Context +} + +func NewGetFollowerService(ctx context.Context) *GetFollowerService { + return &GetFollowerService{ + ctx: ctx, + } +} + +func (s *GetFollowerService) GetFollower(req *relation.GetFollowerListRequest) ([]int64, error) { + relations, err := db.GetFollowersByFollow(s.ctx, req.FollowId) + if err != nil { + return nil, err + } + return pack.Relation2Follower(relations), nil +} diff --git a/sample_douyin/cmd/relation/service/get_friend.go b/sample_douyin/cmd/relation/service/get_friend.go new file mode 100644 index 00000000..6ee95aac --- /dev/null +++ b/sample_douyin/cmd/relation/service/get_friend.go @@ -0,0 +1,21 @@ +package service + +import ( + "context" + "mydouyin/cmd/relation/dal/db" + "mydouyin/kitex_gen/relation" +) + +type GetFriendService struct { + ctx context.Context +} + +func NewGetFriendService(ctx context.Context) *GetFriendService { + return &GetFriendService{ + ctx: ctx, + } +} + +func (s *GetFriendService) GetFriend(req *relation.GetFriendRequest) ([]int64, error) { + return db.GetFriend(s.ctx, req.MeId) +} diff --git a/sample_douyin/cmd/relation/service/valid_if_follow.go b/sample_douyin/cmd/relation/service/valid_if_follow.go new file mode 100644 index 00000000..96e75f05 --- /dev/null +++ b/sample_douyin/cmd/relation/service/valid_if_follow.go @@ -0,0 +1,21 @@ +package service + +import ( + "context" + "mydouyin/cmd/relation/dal/db" + "mydouyin/kitex_gen/relation" +) + +type ValidIfFollowService struct { + ctx context.Context +} + +func NewValidIfFollowService(ctx context.Context) *ValidIfFollowService { + return &ValidIfFollowService{ + ctx: ctx, + } +} + +func (s *ValidIfFollowService) ValidIfFollowFollower(req *relation.ValidIfFollowRequest) (bool, error) { + return db.ValidRelationIfExist(s.ctx, req.FollowId, req.FollowerId) +} diff --git a/sample_douyin/cmd/user/build.sh b/sample_douyin/cmd/user/build.sh new file mode 100644 index 00000000..803a9fbc --- /dev/null +++ b/sample_douyin/cmd/user/build.sh @@ -0,0 +1,10 @@ +#!/usr/bin/env bash +RUN_NAME="douyinuser" +mkdir -p output/bin +cp script/* output/ +chmod +x output/bootstrap.sh +if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then + go build -o output/bin/${RUN_NAME} +else + go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... +fi diff --git a/sample_douyin/cmd/user/dal/db/init.go b/sample_douyin/cmd/user/dal/db/init.go new file mode 100644 index 00000000..d0001c46 --- /dev/null +++ b/sample_douyin/cmd/user/dal/db/init.go @@ -0,0 +1,38 @@ +package db + +import ( + "mydouyin/pkg/consts" + "time" + + "gorm.io/driver/mysql" + "gorm.io/gorm" + "gorm.io/gorm/logger" + "gorm.io/plugin/opentelemetry/logging/logrus" + "gorm.io/plugin/opentelemetry/tracing" +) + +var DB *gorm.DB + +func Init() { + var err error + gormlogrus := logger.New( + logrus.NewWriter(), + logger.Config{ + SlowThreshold: time.Millisecond, + Colorful: false, + LogLevel: logger.Info, + }, + ) + DB, err = gorm.Open(mysql.Open(consts.MySQLDefaultDSN), + &gorm.Config{ + PrepareStmt: true, + Logger: gormlogrus, + }, + ) + if err != nil { + panic(err) + } + if err := DB.Use(tracing.NewPlugin()); err != nil { + panic(err) + } +} diff --git a/sample_douyin/cmd/user/dal/db/user.go b/sample_douyin/cmd/user/dal/db/user.go new file mode 100644 index 00000000..f8fd4d9c --- /dev/null +++ b/sample_douyin/cmd/user/dal/db/user.go @@ -0,0 +1,54 @@ +package db + +import ( + "context" + "mydouyin/pkg/consts" + + "gorm.io/gorm" +) + +type User struct { + gorm.Model + Username string `json:"username"` + Password string `json:"password"` + FollowCount int `json:"follow_count"` + FollowerCount int `json:"follower_count"` + FavoriteCount int `json:"favorite_count"` + WorkCount int `json:"work_count"` + TotalFavorited int `json:"total_favorited"` + BackgroundImage string `json:"background_image"` + Avatar string `json:"avatar"` + Signature string `json:"signature"` + +} + +func (u *User) TableName() string { + return consts.UserTableName +} + +// CreateUser create user info +func CreateUser(ctx context.Context, users []*User) error { + return DB.WithContext(ctx).Create(users).Error +} + +// QueryUser query list of user info +func QueryUser(ctx context.Context, userName string) ([]*User, error) { + res := make([]*User, 0) + if err := DB.WithContext(ctx).Where("username = ?", userName).Find(&res).Error; err != nil { + return nil, err + } + return res, nil +} + +// MGetUsers multiple get list of user info +func MGetUSers(ctx context.Context, userIDs []int64) ([]*User, error) { + res := make([]*User, 0) + if len(userIDs) == 0 { + return res, nil + } + + if err := DB.WithContext(ctx).Where("id in ?", userIDs).Find(&res).Error; err != nil { + return nil, err + } + return res, nil +} diff --git a/sample_douyin/cmd/user/dal/init.go b/sample_douyin/cmd/user/dal/init.go new file mode 100644 index 00000000..bbb45593 --- /dev/null +++ b/sample_douyin/cmd/user/dal/init.go @@ -0,0 +1,7 @@ +package dal + +import "mydouyin/cmd/user/dal/db" + +func Init() { + db.Init() +} diff --git a/sample_douyin/cmd/user/handler.go b/sample_douyin/cmd/user/handler.go new file mode 100644 index 00000000..0129f4d5 --- /dev/null +++ b/sample_douyin/cmd/user/handler.go @@ -0,0 +1,71 @@ +package main + +import ( + "context" + "mydouyin/cmd/user/pack" + "mydouyin/cmd/user/service" + douyinuser "mydouyin/kitex_gen/douyinuser" + "mydouyin/pkg/errno" +) + +// UserServiceImpl implements the last service interface defined in the IDL. +type UserServiceImpl struct{} + +// CreateUser implements the UserServiceImpl interface. +func (s *UserServiceImpl) CreateUser(ctx context.Context, req *douyinuser.CreateUserRequest) (resp *douyinuser.CreateUserResponse, err error) { + // TODO: Your code here... + resp = new(douyinuser.CreateUserResponse) + if err = req.IsValid(); err != nil { + resp.BaseResp = pack.BuildBaseResp(errno.ParamErr) + return resp, nil + } + err = service.NewCreateUserService(ctx).CreateUser(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return resp, nil +} + +// CheckUser implements the UserServiceImpl interface. +func (s *UserServiceImpl) CheckUser(ctx context.Context, req *douyinuser.CheckUserRequest) (resp *douyinuser.CheckUserResponse, err error) { + // TODO: Your code here... + resp = new(douyinuser.CheckUserResponse) + + if err = req.IsValid(); err != nil { + resp.BaseResp = pack.BuildBaseResp(errno.ParamErr) + return resp, nil + } + uid, err := service.NewCheckUserService(ctx).CheckUser(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + + resp.UserId = uid + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return +} + +// CheckUser implements the UserServiceImpl interface. +func (s *UserServiceImpl) MGetUser(ctx context.Context, req *douyinuser.MGetUserRequest) (resp *douyinuser.MGetUserResponse, err error) { + // TODO: Your code here... + resp = new(douyinuser.MGetUserResponse) + + if err = req.IsValid(); err != nil { + resp.BaseResp = pack.BuildBaseResp(errno.ParamErr) + return resp, nil + } + var users []*douyinuser.User + users, err = service.NewMGetUserService(ctx).GetUsers(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + resp.Users = users + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return +} + diff --git a/sample_douyin/cmd/user/kitex.yaml b/sample_douyin/cmd/user/kitex.yaml new file mode 100644 index 00000000..045ed493 --- /dev/null +++ b/sample_douyin/cmd/user/kitex.yaml @@ -0,0 +1,3 @@ +kitexinfo: + ServiceName: 'douyinuser' + ToolVersion: 'v0.4.4' diff --git a/sample_douyin/cmd/user/main.go b/sample_douyin/cmd/user/main.go new file mode 100644 index 00000000..83fd7c46 --- /dev/null +++ b/sample_douyin/cmd/user/main.go @@ -0,0 +1,61 @@ +package main + +import ( + "mydouyin/cmd/user/dal" + douyinuser "mydouyin/kitex_gen/douyinuser/userservice" + "mydouyin/pkg/consts" + "mydouyin/pkg/mw" + "net" + + "github.com/cloudwego/kitex/pkg/klog" + "github.com/cloudwego/kitex/pkg/limit" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/cloudwego/kitex/server" + kitexlogrus "github.com/kitex-contrib/obs-opentelemetry/logging/logrus" + "github.com/kitex-contrib/obs-opentelemetry/provider" + "github.com/kitex-contrib/obs-opentelemetry/tracing" + etcd "github.com/kitex-contrib/registry-etcd" +) + +func Init() { + dal.Init() + //klog init + klog.SetLogger(kitexlogrus.NewLogger()) + klog.SetLevel(klog.LevelInfo) +} + +func main() { + r, err := etcd.NewEtcdRegistry([]string{consts.ETCDAddress}) + if err != nil { + panic(err) + } + addr, err := net.ResolveTCPAddr(consts.TCP, consts.UserServiceAddr) + if err != nil { + panic(err) + } + Init() + provider.NewOpenTelemetryProvider( + provider.WithServiceName(consts.UserServiceName), + provider.WithExportEndpoint(consts.ExportEndpoint), + provider.WithInsecure(), + ) + svr := douyinuser.NewServer(new(UserServiceImpl), + server.WithServiceAddr(addr), + server.WithRegistry(r), + //限流 + server.WithLimit(&limit.Option{MaxConnections: 1000, MaxQPS: 100}), + //启用多路复用 + server.WithMuxTransport(), + //启用中间件 + server.WithMiddleware(mw.CommonMiddleware), + server.WithMiddleware(mw.ServerMiddleware), + //链路追踪 + server.WithSuite(tracing.NewServerSuite()), + server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: consts.UserServiceName}), + ) + + err = svr.Run() + if err != nil { + klog.Fatal(err) + } +} diff --git a/sample_douyin/cmd/user/output/bootstrap.sh b/sample_douyin/cmd/user/output/bootstrap.sh new file mode 100644 index 00000000..6a153647 --- /dev/null +++ b/sample_douyin/cmd/user/output/bootstrap.sh @@ -0,0 +1,21 @@ +#! /usr/bin/env bash +CURDIR=$(cd $(dirname $0); pwd) + +if [ "X$1" != "X" ]; then + RUNTIME_ROOT=$1 +else + RUNTIME_ROOT=${CURDIR} +fi + +export KITEX_RUNTIME_ROOT=$RUNTIME_ROOT +export KITEX_LOG_DIR="$RUNTIME_ROOT/log" + +if [ ! -d "$KITEX_LOG_DIR/app" ]; then + mkdir -p "$KITEX_LOG_DIR/app" +fi + +if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then + mkdir -p "$KITEX_LOG_DIR/rpc" +fi + +exec "$CURDIR/bin/douyinuser" diff --git a/sample_douyin/cmd/user/pack/resp.go b/sample_douyin/cmd/user/pack/resp.go new file mode 100644 index 00000000..63752552 --- /dev/null +++ b/sample_douyin/cmd/user/pack/resp.go @@ -0,0 +1,25 @@ +package pack + +import ( + "errors" + "mydouyin/kitex_gen/douyinuser" + "mydouyin/pkg/errno" +) + +// BuildBaseResp build baseResp from error +func BuildBaseResp(err error) *douyinuser.BaseResp { + if err == nil { + return baseResp(errno.Success) + } + e := errno.ErrNo{} + if errors.As(err, &e) { + return baseResp(e) + } + + s := errno.ServiceErr.WithMessage(err.Error()) + return baseResp(s) +} + +func baseResp(err errno.ErrNo) *douyinuser.BaseResp { + return &douyinuser.BaseResp{StatusCode: err.ErrCode, StatusMessage: err.ErrMsg} +} diff --git a/sample_douyin/cmd/user/pack/user.go b/sample_douyin/cmd/user/pack/user.go new file mode 100644 index 00000000..150536f4 --- /dev/null +++ b/sample_douyin/cmd/user/pack/user.go @@ -0,0 +1,36 @@ +package pack + +import ( + "mydouyin/cmd/user/dal/db" + "mydouyin/kitex_gen/douyinuser" +) + +// User pack user info +func User(u *db.User) *douyinuser.User { + if u == nil { + return nil + } + + return &douyinuser.User{ + UserId: int64(u.ID), + Username: u.Username, + FollowCount: int64(u.FollowCount), + FollowerCount: int64(u.FollowerCount), + TotalFavorited: int64(u.TotalFavorited), + FavoriteCount: int64(u.FavoriteCount), + WorkCount: int64(u.WorkCount), + Avatar: u.Avatar, + Signature: u.Signature, + BackgroundImage: u.BackgroundImage, + } +} + +func Users(us []*db.User) []*douyinuser.User { + users := make([]*douyinuser.User, 0) + for _, u := range us { + if temp := User(u); temp != nil { + users = append(users, temp) + } + } + return users +} diff --git a/sample_douyin/cmd/user/service/check_user.go b/sample_douyin/cmd/user/service/check_user.go new file mode 100644 index 00000000..0691b9bd --- /dev/null +++ b/sample_douyin/cmd/user/service/check_user.go @@ -0,0 +1,45 @@ +package service + +import ( + "context" + "crypto/md5" + "fmt" + "io" + "mydouyin/cmd/user/dal/db" + "mydouyin/kitex_gen/douyinuser" + "mydouyin/pkg/errno" +) + +type CheckUserService struct { + ctx context.Context +} + +// NewCheckUserService new CheckUserService +func NewCheckUserService(ctx context.Context) *CheckUserService { + return &CheckUserService{ + ctx: ctx, + } +} + +// CheckUser check user info +func (s *CheckUserService) CheckUser(req *douyinuser.CheckUserRequest) (int64, error) { + h := md5.New() + if _, err := io.WriteString(h, req.Password); err != nil { + return 0, err + } + passWord := fmt.Sprintf("%x", h.Sum(nil)) + + userName := req.Username + users, err := db.QueryUser(s.ctx, userName) + if err != nil { + return 0, err + } + if len(users) == 0 { + return 0, errno.AuthorizationFailedErr + } + u := users[0] + if u.Password != passWord { + return 0, errno.AuthorizationFailedErr + } + return int64(u.ID), nil +} diff --git a/sample_douyin/cmd/user/service/create_user.go b/sample_douyin/cmd/user/service/create_user.go new file mode 100644 index 00000000..5cac6330 --- /dev/null +++ b/sample_douyin/cmd/user/service/create_user.go @@ -0,0 +1,44 @@ +package service + +import ( + "context" + "crypto/md5" + "fmt" + "io" + "mydouyin/cmd/user/dal/db" + "mydouyin/kitex_gen/douyinuser" + "mydouyin/pkg/errno" +) + +type CreateUserService struct { + ctx context.Context +} + +// NewCreateUserService new CreateUserService +func NewCreateUserService(ctx context.Context) *CreateUserService { + return &CreateUserService{ctx: ctx} +} + +// CreateUser create user info. +func (s *CreateUserService) CreateUser(req *douyinuser.CreateUserRequest) error { + users, err := db.QueryUser(s.ctx, req.Username) + if err != nil { + return err + } + if len(users) != 0 { + return errno.UserAlreadyExistErr + } + + h := md5.New() + if _, err := io.WriteString(h, req.Password); err != nil { + return err + } + passWord := fmt.Sprintf("%x", h.Sum(nil)) + return db.CreateUser(s.ctx, []*db.User{{ + Username: req.Username, + Password: passWord, + Avatar: req.Avatar, + Signature: req.Signature, + BackgroundImage: req.BackgroundImage, + }}) +} diff --git a/sample_douyin/cmd/user/service/mget_user.go b/sample_douyin/cmd/user/service/mget_user.go new file mode 100644 index 00000000..d779fc67 --- /dev/null +++ b/sample_douyin/cmd/user/service/mget_user.go @@ -0,0 +1,28 @@ +package service + +import ( + "context" + "mydouyin/cmd/user/dal/db" + "mydouyin/cmd/user/pack" + "mydouyin/kitex_gen/douyinuser" +) + +type MGetUserService struct { + ctx context.Context +} + +// NewMGetUserService new CheckUserService +func NewMGetUserService(ctx context.Context) *MGetUserService { + return &MGetUserService{ + ctx: ctx, + } +} + +// CreateUser create user info. +func (s *MGetUserService) GetUsers(req *douyinuser.MGetUserRequest) ([]*douyinuser.User, error) { + users, err := db.MGetUSers(s.ctx, req.UserIds) + if err != nil { + return nil, err + } + return pack.Users(users), nil +} diff --git a/sample_douyin/cmd/video/build.sh b/sample_douyin/cmd/video/build.sh new file mode 100644 index 00000000..271a46a6 --- /dev/null +++ b/sample_douyin/cmd/video/build.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +RUN_NAME="douyinvideo" + +mkdir -p output/bin +cp script/* output/ +chmod +x output/bootstrap.sh + +if [ "$IS_SYSTEM_TEST_ENV" != "1" ]; then + go build -o output/bin/${RUN_NAME} +else + go test -c -covermode=set -o output/bin/${RUN_NAME} -coverpkg=./... +fi diff --git a/sample_douyin/cmd/video/dal/db/init.go b/sample_douyin/cmd/video/dal/db/init.go new file mode 100644 index 00000000..d0001c46 --- /dev/null +++ b/sample_douyin/cmd/video/dal/db/init.go @@ -0,0 +1,38 @@ +package db + +import ( + "mydouyin/pkg/consts" + "time" + + "gorm.io/driver/mysql" + "gorm.io/gorm" + "gorm.io/gorm/logger" + "gorm.io/plugin/opentelemetry/logging/logrus" + "gorm.io/plugin/opentelemetry/tracing" +) + +var DB *gorm.DB + +func Init() { + var err error + gormlogrus := logger.New( + logrus.NewWriter(), + logger.Config{ + SlowThreshold: time.Millisecond, + Colorful: false, + LogLevel: logger.Info, + }, + ) + DB, err = gorm.Open(mysql.Open(consts.MySQLDefaultDSN), + &gorm.Config{ + PrepareStmt: true, + Logger: gormlogrus, + }, + ) + if err != nil { + panic(err) + } + if err := DB.Use(tracing.NewPlugin()); err != nil { + panic(err) + } +} diff --git a/sample_douyin/cmd/video/dal/db/user.go b/sample_douyin/cmd/video/dal/db/user.go new file mode 100644 index 00000000..efc508bb --- /dev/null +++ b/sample_douyin/cmd/video/dal/db/user.go @@ -0,0 +1,25 @@ +package db + +import ( + "mydouyin/pkg/consts" + + "gorm.io/gorm" +) + +type User struct { + gorm.Model + Username string `json:"username"` + Password string `json:"password"` + FollowCount int `json:"follow_count"` + FollowerCount int `json:"follower_count"` + FavoriteCount int `json:"favorite_count"` + WorkCount int `json:"work_count"` + TotalFavorited int `json:"total_favorited"` + BackgroundImage string `json:"background_image"` + Avatar string `json:"avatar"` + Signature string `json:"signature"` +} + +func (u *User) TableName() string { + return consts.UserTableName +} diff --git a/sample_douyin/cmd/video/dal/db/video.go b/sample_douyin/cmd/video/dal/db/video.go new file mode 100644 index 00000000..614f99c6 --- /dev/null +++ b/sample_douyin/cmd/video/dal/db/video.go @@ -0,0 +1,88 @@ +package db + +import ( + "context" + "mydouyin/pkg/consts" + + "gorm.io/gorm" +) + +type Video struct { + gorm.Model + Author int64 `json:"author"` + PlayUrl string `json:"play_url"` + CoverUrl string `json:"cover_url"` + Title string `json:"title"` + FavoriteCount int `json:"favorite_count"` + CommentCount int `json:"comment_count"` +} + +func (v *Video) TableName() string { + return consts.VideoTableName +} + +// CreateVideo create video info +func CreateVideo(ctx context.Context, videos []*Video) ([]int64, error) { + idList := make([]int64, 0) + err := DB.WithContext(ctx).Transaction(func(tx *gorm.DB) error { + if err := tx.WithContext(ctx).Create(videos).Error; err != nil{ + return err + } + for _, i := range videos { + idList = append(idList, int64(i.ID)) + if err := tx.WithContext(ctx).Model(&User{}).Where("id = ?", i.Author).Update("work_count", gorm.Expr("work_count + ?", 1)).Error; err != nil { + return err + } + } + // 返回 nil 提交事务 + return nil + }) + return idList, err +} + +// MGetVideos multiple get list of video info +func MGetVideos(ctx context.Context, videoIDs []int64) ([]*Video, error) { + res := make([]*Video, 0) + if len(videoIDs) == 0 { + return res, nil + } + if err := DB.WithContext(ctx).Where("id in ?", videoIDs).Find(&res).Error; err != nil { + return nil, err + } + return res, nil +} + +// GetFeed multiple get list of video info +func GetFeed(ctx context.Context, latest_time string) ([]*Video, error) { + res := make([]*Video, 0) + if err := DB.WithContext(ctx).Where("created_at < ?", latest_time).Limit(30).Order("id desc").Find(&res).Error; err != nil { + return nil, err + } + return res, nil +} + +// GetVideosFromTime +func GetVideosFromTime(ctx context.Context, start, end string) ([]*Video, error) { + res := make([]*Video, 0) + if err := DB.WithContext(ctx).Where("created_at > ? AND created_at < ?", start, end).Limit(30).Order("id desc").Find(&res).Error; err != nil { + return nil, err + } + return res, nil +} + +// MGetVideos multiple get list of video info +func MGetVideosbyAuthor(ctx context.Context, authorID int64) ([]*Video, error) { + res := make([]*Video, 0) + if err := DB.WithContext(ctx).Where("author = ?", authorID).Find(&res).Error; err != nil { + return nil, err + } + return res, nil +} + +// Delete the video +func DeleteVideo(ctx context.Context, video_id int64) error { + if err := DB.WithContext(ctx).Delete(&Video{}, video_id).Error; err != nil { + return nil + } + return nil +} diff --git a/sample_douyin/cmd/video/dal/init.go b/sample_douyin/cmd/video/dal/init.go new file mode 100644 index 00000000..3197168e --- /dev/null +++ b/sample_douyin/cmd/video/dal/init.go @@ -0,0 +1,7 @@ +package dal + +import "mydouyin/cmd/video/dal/db" + +func Init() { + db.Init() +} diff --git a/sample_douyin/cmd/video/handler.go b/sample_douyin/cmd/video/handler.go new file mode 100644 index 00000000..1e0960f4 --- /dev/null +++ b/sample_douyin/cmd/video/handler.go @@ -0,0 +1,95 @@ +package main + +import ( + "context" + "mydouyin/cmd/video/pack" + "mydouyin/cmd/video/service" + douyinvideo "mydouyin/kitex_gen/douyinvideo" + "mydouyin/pkg/errno" +) + +// VideoServiceImpl implements the last service interface defined in the IDL. +type VideoServiceImpl struct{} + +// CreateVideo implements the VideoServiceImpl interface. +func (s *VideoServiceImpl) CreateVideo(ctx context.Context, req *douyinvideo.CreateVideoRequest) (resp *douyinvideo.CreateVideoResponse, err error) { + // TODO: Your code here... + resp = new(douyinvideo.CreateVideoResponse) + if err = req.IsValid(); err != nil { + resp.BaseResp = pack.BuildBaseResp(errno.ParamErr) + return resp, nil + } + var idList []int64 + idList, err = service.NewCreateVideoService(ctx).CreateVideo(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + resp.BaseResp = pack.BuildBaseResp(errno.Success) + resp.VideoIds = idList + return resp, nil +} + +// GetFeed implements the VideoServiceImpl interface. +func (s *VideoServiceImpl) GetFeed(ctx context.Context, req *douyinvideo.GetFeedRequest) (resp *douyinvideo.GetFeedResponse, err error) { + resp = new(douyinvideo.GetFeedResponse) + var videos []*douyinvideo.Video + var nextTime int64 + nextTime, videos, err = service.NewGetFeedService(ctx).GetFeed(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + resp.NextTime = nextTime + resp.VideoList = videos + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return resp, nil +} + +// GetList implements the VideoServiceImpl interface. +func (s *VideoServiceImpl) GetList(ctx context.Context, req *douyinvideo.GetListRequest) (resp *douyinvideo.GetListResponse, err error) { + resp = new(douyinvideo.GetListResponse) + var videos []*douyinvideo.Video + videos, err = service.NewGetListService(ctx).GetList(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + resp.VideoList = videos + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return resp, nil +} + +// MGetVideoUser implements the VideoServiceImpl interface. +func (s *VideoServiceImpl) MGetVideoUser(ctx context.Context, req *douyinvideo.MGetVideoRequest) (resp *douyinvideo.MGetVideoResponse, err error) { + resp = new(douyinvideo.MGetVideoResponse) + var videos []*douyinvideo.Video + videos, err = service.NewMGetVideoService(ctx).MGetVideo(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + resp.Videos = videos + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return resp, nil +} + +// DeleteVideo implements the VideoServiceImpl interface. +func (s *VideoServiceImpl) DeleteVideo(ctx context.Context, req *douyinvideo.DeleteVideoRequest) (resp *douyinvideo.DeleteVideoResponse, err error) { + // TODO: Your code here... + return +} + +// GetTimeVideos implements the VideoServiceImpl interface. +func (s *VideoServiceImpl) GetTimeVideos(ctx context.Context, req *douyinvideo.GetTimeVideosRequest) (resp *douyinvideo.GetTimeVideosResponse, err error) { + resp = new(douyinvideo.GetTimeVideosResponse) + var videos []*douyinvideo.Video + videos, err = service.NewGetTimeVideosService(ctx).GetTimeVideos(req) + if err != nil { + resp.BaseResp = pack.BuildBaseResp(err) + return resp, nil + } + resp.VideoList = videos + resp.BaseResp = pack.BuildBaseResp(errno.Success) + return resp, nil +} diff --git a/sample_douyin/cmd/video/kitex.yaml b/sample_douyin/cmd/video/kitex.yaml new file mode 100644 index 00000000..6df9e475 --- /dev/null +++ b/sample_douyin/cmd/video/kitex.yaml @@ -0,0 +1,3 @@ +kitexinfo: + ServiceName: 'douyinvideo' + ToolVersion: 'v0.4.4' diff --git a/sample_douyin/cmd/video/main.go b/sample_douyin/cmd/video/main.go new file mode 100644 index 00000000..12adad57 --- /dev/null +++ b/sample_douyin/cmd/video/main.go @@ -0,0 +1,61 @@ +package main + +import ( + "mydouyin/cmd/video/dal" + douyinvideo "mydouyin/kitex_gen/douyinvideo/videoservice" + "mydouyin/pkg/consts" + "mydouyin/pkg/mw" + "net" + + "github.com/cloudwego/kitex/pkg/klog" + "github.com/cloudwego/kitex/pkg/limit" + "github.com/cloudwego/kitex/pkg/rpcinfo" + "github.com/cloudwego/kitex/server" + kitexlogrus "github.com/kitex-contrib/obs-opentelemetry/logging/logrus" + "github.com/kitex-contrib/obs-opentelemetry/provider" + "github.com/kitex-contrib/obs-opentelemetry/tracing" + etcd "github.com/kitex-contrib/registry-etcd" +) + +func Init() { + dal.Init() + //klog init + klog.SetLogger(kitexlogrus.NewLogger()) + klog.SetLevel(klog.LevelInfo) +} + +func main() { + r, err := etcd.NewEtcdRegistry([]string{consts.ETCDAddress}) + if err != nil { + panic(err) + } + addr, err := net.ResolveTCPAddr(consts.TCP, consts.VideoServiceAddr) + if err != nil { + panic(err) + } + Init() + provider.NewOpenTelemetryProvider( + provider.WithServiceName(consts.VideoServiceName), + provider.WithExportEndpoint(consts.ExportEndpoint), + provider.WithInsecure(), + ) + svr := douyinvideo.NewServer(new(VideoServiceImpl), + server.WithServiceAddr(addr), + server.WithRegistry(r), + //限流 + server.WithLimit(&limit.Option{MaxConnections: 1000, MaxQPS: 100}), + //启用多路复用 + server.WithMuxTransport(), + //启用中间件 + server.WithMiddleware(mw.CommonMiddleware), + server.WithMiddleware(mw.ServerMiddleware), + //链路追踪 + server.WithSuite(tracing.NewServerSuite()), + server.WithServerBasicInfo(&rpcinfo.EndpointBasicInfo{ServiceName: consts.VideoServiceName}), + ) + + err = svr.Run() + if err != nil { + klog.Fatal(err) + } +} diff --git a/sample_douyin/cmd/video/output/bootstrap.sh b/sample_douyin/cmd/video/output/bootstrap.sh new file mode 100644 index 00000000..86ed79a6 --- /dev/null +++ b/sample_douyin/cmd/video/output/bootstrap.sh @@ -0,0 +1,21 @@ +#! /usr/bin/env bash +CURDIR=$(cd $(dirname $0); pwd) + +if [ "X$1" != "X" ]; then + RUNTIME_ROOT=$1 +else + RUNTIME_ROOT=${CURDIR} +fi + +export KITEX_RUNTIME_ROOT=$RUNTIME_ROOT +export KITEX_LOG_DIR="$RUNTIME_ROOT/log" + +if [ ! -d "$KITEX_LOG_DIR/app" ]; then + mkdir -p "$KITEX_LOG_DIR/app" +fi + +if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then + mkdir -p "$KITEX_LOG_DIR/rpc" +fi + +exec "$CURDIR/bin/douyinvideo" diff --git a/sample_douyin/cmd/video/pack/resp.go b/sample_douyin/cmd/video/pack/resp.go new file mode 100644 index 00000000..2f153b86 --- /dev/null +++ b/sample_douyin/cmd/video/pack/resp.go @@ -0,0 +1,25 @@ +package pack + +import ( + "errors" + "mydouyin/kitex_gen/douyinvideo" + "mydouyin/pkg/errno" +) + +// BuildBaseResp build baseResp from error +func BuildBaseResp(err error) *douyinvideo.BaseResp { + if err == nil { + return baseResp(errno.Success) + } + e := errno.ErrNo{} + if errors.As(err, &e) { + return baseResp(e) + } + + s := errno.ServiceErr.WithMessage(err.Error()) + return baseResp(s) +} + +func baseResp(err errno.ErrNo) *douyinvideo.BaseResp { + return &douyinvideo.BaseResp{StatusCode: err.ErrCode, StatusMessage: err.ErrMsg} +} diff --git a/sample_douyin/cmd/video/pack/video.go b/sample_douyin/cmd/video/pack/video.go new file mode 100644 index 00000000..7cf875b2 --- /dev/null +++ b/sample_douyin/cmd/video/pack/video.go @@ -0,0 +1,32 @@ +package pack + +import ( + "mydouyin/cmd/video/dal/db" + "mydouyin/kitex_gen/douyinvideo" +) + +// Video pack video info +func Video(v *db.Video) *douyinvideo.Video { + if v == nil { + return nil + } + return &douyinvideo.Video{ + VideoId: int64(v.ID), + Author: int64(v.Author), + PlayUrl: v.PlayUrl, + CoverUrl: v.CoverUrl, + Title: v.Title, + FavoriteCount: int64(v.FavoriteCount), + CommentCount: int64(v.CommentCount), + UploadTime: v.CreatedAt.Format("20060102.150405"), + } +} +func Videos(vs []*db.Video) []*douyinvideo.Video { + videos := make([]*douyinvideo.Video, 0) + for _, v := range vs { + if temp := Video(v); temp != nil { + videos = append(videos, temp) + } + } + return videos +} diff --git a/sample_douyin/cmd/video/script/bootstrap.sh b/sample_douyin/cmd/video/script/bootstrap.sh new file mode 100644 index 00000000..86ed79a6 --- /dev/null +++ b/sample_douyin/cmd/video/script/bootstrap.sh @@ -0,0 +1,21 @@ +#! /usr/bin/env bash +CURDIR=$(cd $(dirname $0); pwd) + +if [ "X$1" != "X" ]; then + RUNTIME_ROOT=$1 +else + RUNTIME_ROOT=${CURDIR} +fi + +export KITEX_RUNTIME_ROOT=$RUNTIME_ROOT +export KITEX_LOG_DIR="$RUNTIME_ROOT/log" + +if [ ! -d "$KITEX_LOG_DIR/app" ]; then + mkdir -p "$KITEX_LOG_DIR/app" +fi + +if [ ! -d "$KITEX_LOG_DIR/rpc" ]; then + mkdir -p "$KITEX_LOG_DIR/rpc" +fi + +exec "$CURDIR/bin/douyinvideo" diff --git a/sample_douyin/cmd/video/service/create_video.go b/sample_douyin/cmd/video/service/create_video.go new file mode 100644 index 00000000..a2053cdf --- /dev/null +++ b/sample_douyin/cmd/video/service/create_video.go @@ -0,0 +1,26 @@ +package service + +import ( + "context" + "mydouyin/cmd/video/dal/db" + "mydouyin/kitex_gen/douyinvideo" +) + +type CreateVideoService struct { + ctx context.Context +} + +// NewCreateVideoService new CreateVideoService +func NewCreateVideoService(ctx context.Context) *CreateVideoService { + return &CreateVideoService{ctx: ctx} +} + +// CreateVideo create video info. +func (s *CreateVideoService) CreateVideo(req *douyinvideo.CreateVideoRequest) ([]int64,error) { + return db.CreateVideo(s.ctx, []*db.Video{{ + Author: req.Author, + PlayUrl: req.PlayUrl, + CoverUrl: req.CoverUrl, + Title: req.Title, + }}) +} diff --git a/sample_douyin/cmd/video/service/delete_video.go b/sample_douyin/cmd/video/service/delete_video.go new file mode 100644 index 00000000..344e88cb --- /dev/null +++ b/sample_douyin/cmd/video/service/delete_video.go @@ -0,0 +1,2 @@ +package service + diff --git a/sample_douyin/cmd/video/service/get_feed.go b/sample_douyin/cmd/video/service/get_feed.go new file mode 100644 index 00000000..bf0a0926 --- /dev/null +++ b/sample_douyin/cmd/video/service/get_feed.go @@ -0,0 +1,44 @@ +package service + +import ( + "context" + "fmt" + "log" + "mydouyin/cmd/video/dal/db" + "mydouyin/cmd/video/pack" + "mydouyin/kitex_gen/douyinvideo" + "strconv" + "time" + + "github.com/cloudwego/kitex/pkg/klog" +) + +type GetFeedService struct { + ctx context.Context +} + +// NewGetFeedService new GetFeedService +func NewGetFeedService(ctx context.Context) *GetFeedService { + return &GetFeedService{ctx: ctx} +} + +// GetFeedService. +func (s *GetFeedService) GetFeed(req *douyinvideo.GetFeedRequest) (int64, []*douyinvideo.Video, error) { + fmt.Printf("video") + log.Println(req.LatestTime) + latestTime, err := strconv.Atoi(req.LatestTime) + if err != nil { + return time.Now().Unix(), nil, err + } + latestTimeStr := time.Unix(int64(latestTime), 0).Format("2006-01-02 15:04:05") + videos, err := db.GetFeed(s.ctx, latestTimeStr) + klog.Infof("请求时间:%v", req.LatestTime) + if err != nil { + return time.Now().Unix(), nil, err + } + if len(videos) < 1 { + return time.Now().Unix(), nil, nil + } + var index int = len(videos) - 1 + return videos[index].CreatedAt.Unix(), pack.Videos(videos), nil +} diff --git a/sample_douyin/cmd/video/service/get_list.go b/sample_douyin/cmd/video/service/get_list.go new file mode 100644 index 00000000..6cc26493 --- /dev/null +++ b/sample_douyin/cmd/video/service/get_list.go @@ -0,0 +1,26 @@ +package service + +import ( + "context" + "mydouyin/cmd/video/dal/db" + "mydouyin/cmd/video/pack" + "mydouyin/kitex_gen/douyinvideo" +) + +type GetListService struct { + ctx context.Context +} + +// NewGetFeedService new GetFeedService +func NewGetListService(ctx context.Context) *GetListService { + return &GetListService{ctx: ctx} +} + +// GetFeedService. +func (s *GetListService) GetList(req *douyinvideo.GetListRequest) ([]*douyinvideo.Video, error) { + videos, err := db.MGetVideosbyAuthor(s.ctx, req.UserId) + if err != nil { + return nil, err + } + return pack.Videos(videos) ,nil +} diff --git a/sample_douyin/cmd/video/service/mget_video.go b/sample_douyin/cmd/video/service/mget_video.go new file mode 100644 index 00000000..95197d3d --- /dev/null +++ b/sample_douyin/cmd/video/service/mget_video.go @@ -0,0 +1,26 @@ +package service + +import ( + "context" + "mydouyin/cmd/video/dal/db" + "mydouyin/kitex_gen/douyinvideo" + "mydouyin/cmd/video/pack" +) + +type MGetVideoService struct { + ctx context.Context +} + +// MGetVideoService new MGetVideoService +func NewMGetVideoService(ctx context.Context) *MGetVideoService { + return &MGetVideoService{ctx: ctx} +} + +// MGetVideo. +func (s *MGetVideoService) MGetVideo(req *douyinvideo.MGetVideoRequest) ([]*douyinvideo.Video, error) { + videos, err := db.MGetVideos(s.ctx, req.VideoIds) + if err != nil { + return nil, err + } + return pack.Videos(videos) ,nil +} diff --git a/sample_douyin/cmd/video/service/time_videos.go b/sample_douyin/cmd/video/service/time_videos.go new file mode 100644 index 00000000..d7b040de --- /dev/null +++ b/sample_douyin/cmd/video/service/time_videos.go @@ -0,0 +1,24 @@ +package service + +import ( + "context" + "mydouyin/cmd/video/dal/db" + "mydouyin/cmd/video/pack" + "mydouyin/kitex_gen/douyinvideo" +) + +type GetTimeVideosService struct { + ctx context.Context +} + +func NewGetTimeVideosService(ctx context.Context) *GetTimeVideosService { + return &GetTimeVideosService{ctx: ctx} +} + +func (s *GetTimeVideosService) GetTimeVideos(req *douyinvideo.GetTimeVideosRequest) ([]*douyinvideo.Video, error) { + videos, err := db.GetVideosFromTime(s.ctx, req.Start, req.End) + if err != nil { + return nil, err + } + return pack.Videos(videos), nil +} diff --git a/sample_douyin/cmd/video/test.go b/sample_douyin/cmd/video/test.go new file mode 100644 index 00000000..019e6773 --- /dev/null +++ b/sample_douyin/cmd/video/test.go @@ -0,0 +1,7 @@ +package main + +import "github.com/gogo/protobuf/test" + +func TestClient(t *test.T) { + +} \ No newline at end of file diff --git a/sample_douyin/docker-compose.yaml b/sample_douyin/docker-compose.yaml new file mode 100644 index 00000000..eebf2c87 --- /dev/null +++ b/sample_douyin/docker-compose.yaml @@ -0,0 +1,88 @@ +version: "3.7" +services: + # MySQL + mysql: + image: mysql:latest + volumes: + - ./pkg/configs/sql:/docker-entrypoint-initdb.d + ports: + - "3306:3306" + environment: + - MYSQL_DATABASE=douyin + - MYSQL_USER=douyin + - MYSQL_PASSWORD=douyin + - MYSQL_RANDOM_ROOT_PASSWORD="yes" + + # redis + redis: + image: redis:latest + ports: + - "6379:6379" + volumes: + - ./pkg/configs/redis/redis.conf:/etc/redis/redis.conf + + # ETCD + Etcd: + image: 'bitnami/etcd:latest' + environment: + - ALLOW_NONE_AUTHENTICATION=yes + - ETCD_ADVERTISE_CLIENT_URLS=http://etcd:10079 + ports: + - "10079:2379" + - "10080:2380" + + # Collector + otel-collector: + image: otel/opentelemetry-collector-contrib-dev:latest + command: [ "--config=/etc/otel-collector-config.yaml", "${OTELCOL_ARGS}" ] + volumes: + - ./pkg/configs/otel/otel-collector-config.yaml:/etc/otel-collector-config.yaml + ports: + - "1888:1888" # pprof extension + - "8888" # Prometheus metrics exposed by the collector + - "8889:8889" # Prometheus exporter metrics + - "13133:13133" # health_check extension + - "4317:4317" # OTLP gRPC receiver + - "55679" # zpages extension + depends_on: + - jaeger-all-in-one + + # Jaeger + jaeger-all-in-one: + image: jaegertracing/all-in-one:latest + environment: + - COLLECTOR_OTLP_ENABLED=true + ports: + - "16686:16686" + - "14268" + - "14250:14250" + - "6831:6831" + + # VictoriaMetrics + victoriametrics: + container_name: victoriametrics + image: victoriametrics/victoria-metrics + ports: + - "8428:8428" + - "8089:8089" + - "8089:8089/udp" + - "2003:2003" + - "2003:2003/udp" + - "4242:4242" + command: + - '--storageDataPath=/storage' + - '--graphiteListenAddr=:2003' + - '--opentsdbListenAddr=:4242' + - '--httpListenAddr=:8428' + - '--influxListenAddr=:8089' + restart: always + + # Grafana + grafana: + image: grafana/grafana:latest + environment: + - GF_AUTH_ANONYMOUS_ENABLED=true + - GF_AUTH_ANONYMOUS_ORG_ROLE=Admin + - GF_AUTH_DISABLE_LOGIN_FORM=true + ports: + - "3000:3000" \ No newline at end of file diff --git a/sample_douyin/go.mod b/sample_douyin/go.mod new file mode 100644 index 00000000..d71cee38 --- /dev/null +++ b/sample_douyin/go.mod @@ -0,0 +1,135 @@ +module mydouyin + +go 1.18 + +replace github.com/apache/thrift => github.com/apache/thrift v0.13.0 + +require ( + github.com/RaymondCode/simple-demo v0.0.0-20230221080337-89b8c9434e04 + github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible + github.com/apache/thrift v0.13.0 + github.com/cloudwego/hertz v0.5.1 + github.com/cloudwego/kitex v0.4.4 + github.com/gavv/httpexpect/v2 v2.12.0 + github.com/go-redis/redis/v8 v8.11.5 + github.com/gogo/protobuf v1.3.2 + github.com/golang-jwt/jwt/v4 v4.4.1 + github.com/hertz-contrib/gzip v0.0.1 + github.com/hertz-contrib/jwt v1.0.2 + github.com/hertz-contrib/obs-opentelemetry/logging/logrus v0.1.1 + github.com/hertz-contrib/obs-opentelemetry/tracing v0.1.1 + github.com/hertz-contrib/pprof v0.1.0 + github.com/hertz-contrib/requestid v1.1.0 + github.com/kitex-contrib/obs-opentelemetry v0.1.0 + github.com/kitex-contrib/obs-opentelemetry/logging/logrus v0.0.0-20221109071748-a433b0b57972 + github.com/kitex-contrib/registry-etcd v0.1.0 + github.com/stretchr/testify v1.8.0 + go.opentelemetry.io/otel/trace v1.9.0 + gorm.io/driver/mysql v1.4.5 + gorm.io/gorm v1.24.3 + gorm.io/plugin/opentelemetry v0.1.0 +) + +require ( + github.com/ajg/form v1.5.1 // indirect + github.com/andybalholm/brotli v1.0.4 // indirect + github.com/bytedance/go-tagexpr/v2 v2.9.2 // indirect + github.com/bytedance/gopkg v0.0.0-20220623074550-9d6d3df70991 // indirect + github.com/bytedance/sonic v1.5.0 // indirect + github.com/cenkalti/backoff/v4 v4.1.3 // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06 // indirect + github.com/chenzhuoyu/iasm v0.0.0-20220818063314-28c361dae733 // indirect + github.com/choleraehyq/pid v0.0.15 // indirect + github.com/cloudwego/fastpb v0.0.3 // indirect + github.com/cloudwego/frugal v0.1.3 // indirect + github.com/cloudwego/netpoll v0.3.1 // indirect + github.com/cloudwego/thriftgo v0.2.4 // indirect + github.com/coreos/go-semver v0.3.0 // indirect + github.com/coreos/go-systemd/v22 v22.3.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect + github.com/fatih/structs v1.1.0 // indirect + github.com/fsnotify/fsnotify v1.5.4 // indirect + github.com/gin-contrib/sse v0.1.0 // indirect + github.com/gin-gonic/gin v1.7.7 // indirect + github.com/go-logr/logr v1.2.3 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/go-playground/locales v0.14.0 // indirect + github.com/go-playground/universal-translator v0.18.0 // indirect + github.com/go-playground/validator/v10 v10.11.0 // indirect + github.com/go-sql-driver/mysql v1.7.0 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/go-querystring v1.1.0 // indirect + github.com/google/pprof v0.0.0-20220608213341-c488b8fa1db3 // indirect + github.com/google/uuid v1.3.0 // indirect + github.com/gorilla/websocket v1.4.2 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 // indirect + github.com/henrylee2cn/ameda v1.4.10 // indirect + github.com/henrylee2cn/goutil v0.0.0-20210127050712-89660552f6f8 // indirect + github.com/imkira/go-interpol v1.1.0 // indirect + github.com/jhump/protoreflect v1.8.2 // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/compress v1.15.0 // indirect + github.com/klauspost/cpuid/v2 v2.1.0 // indirect + github.com/leodido/go-urn v1.2.1 // indirect + github.com/mattn/go-isatty v0.0.14 // indirect + github.com/mitchellh/go-wordwrap v1.0.1 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/nyaruka/phonenumbers v1.0.55 // indirect + github.com/oleiade/lane v1.0.1 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect + github.com/prometheus/client_golang v1.14.0 // indirect + github.com/sanity-io/litter v1.5.5 // indirect + github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d // indirect + github.com/sergi/go-diff v1.0.0 // indirect + github.com/sirupsen/logrus v1.8.1 // indirect + github.com/tidwall/gjson v1.14.3 // indirect + github.com/tidwall/match v1.1.1 // indirect + github.com/tidwall/pretty v1.2.0 // indirect + github.com/twitchyliquid64/golang-asm v0.15.1 // indirect + github.com/ugorji/go/codec v1.2.7 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/valyala/fasthttp v1.34.0 // indirect + github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect + github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect + github.com/xeipuuv/gojsonschema v1.2.0 // indirect + github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect + github.com/yudai/gojsondiff v1.0.0 // indirect + github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect + go.etcd.io/etcd/api/v3 v3.5.5 // indirect + go.etcd.io/etcd/client/pkg/v3 v3.5.5 // indirect + go.etcd.io/etcd/client/v3 v3.5.5 // indirect + go.opentelemetry.io/contrib/instrumentation/runtime v0.33.0 // indirect + go.opentelemetry.io/contrib/propagators/b3 v1.9.0 // indirect + go.opentelemetry.io/contrib/propagators/ot v1.9.0 // indirect + go.opentelemetry.io/otel v1.9.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.9.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.31.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.31.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.9.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.9.0 // indirect + go.opentelemetry.io/otel/metric v0.31.0 // indirect + go.opentelemetry.io/otel/sdk v1.9.0 // indirect + go.opentelemetry.io/otel/sdk/metric v0.31.0 // indirect + go.opentelemetry.io/proto/otlp v0.18.0 // indirect + go.uber.org/atomic v1.8.0 // indirect + go.uber.org/multierr v1.8.0 // indirect + go.uber.org/zap v1.17.0 // indirect + golang.org/x/arch v0.0.0-20220722155209-00200b7164a7 // indirect + golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f // indirect + golang.org/x/net v0.0.0-20220225172249-27dd8689420f // indirect + golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f // indirect + golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2 // indirect + golang.org/x/text v0.3.7 // indirect + golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba // indirect + google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1 // indirect + google.golang.org/grpc v1.46.2 // indirect + google.golang.org/protobuf v1.28.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + moul.io/http2curl/v2 v2.3.0 // indirect +) diff --git a/sample_douyin/go.sum b/sample_douyin/go.sum new file mode 100644 index 00000000..33bf816a --- /dev/null +++ b/sample_douyin/go.sum @@ -0,0 +1,1105 @@ +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= +cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= +cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= +cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= +cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= +cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= +cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= +cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= +cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= +cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= +cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= +cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= +cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= +cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= +cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= +cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= +cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= +cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= +cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= +cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= +cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= +cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= +cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= +cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= +cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= +cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= +cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= +cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= +cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= +cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= +cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= +cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= +dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= +github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/RaymondCode/simple-demo v0.0.0-20230221080337-89b8c9434e04 h1:wAAJBgu81T41+EKxp43/nqljufNg55rh7QVrxOa2l14= +github.com/RaymondCode/simple-demo v0.0.0-20230221080337-89b8c9434e04/go.mod h1:XMO1NCRwu+8CnhAGPnCR+YgZPzl1kHER/d69V564Af0= +github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU= +github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY= +github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= +github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible h1:KXeJoM1wo9I/6xPTyt6qCxoSZnmASiAjlrr0dyTUKt8= +github.com/aliyun/aliyun-oss-go-sdk v2.2.6+incompatible/go.mod h1:T/Aws4fEfogEE9v+HPhhw+CntffsBHJ8nXQCwKr0/g8= +github.com/andybalholm/brotli v1.0.2/go.mod h1:loMXtMfwqflxFJPmdbJO0a3KNoPuLBgiu3qAvBg8x/Y= +github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY= +github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/apache/thrift v0.13.0 h1:5hryIiq9gtn+MiLVn0wP37kb/uTeRZgN08WoCsAhIhI= +github.com/apache/thrift v0.13.0/go.mod h1:cp2SuWMxlEZw2r+iP2GNCdIi4C1qmUzdZFSVb+bacwQ= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/benbjohnson/clock v1.3.0 h1:ip6w0uFQkncKQ979AypyG0ER7mqUSBdKLOgAle/AT8A= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/bketelsen/crypt v0.0.3-0.20200106085610-5cbc8cc4026c/go.mod h1:MKsuJmJgSg28kpZDP6UIiPt0e0Oz0kqKNGyRaWEPv84= +github.com/brianvoe/gofakeit/v6 v6.16.0/go.mod h1:Ow6qC71xtwm79anlwKRlWZW6zVq9D2XHE4QSSMP/rU8= +github.com/bytedance/go-tagexpr/v2 v2.9.2 h1:QySJaAIQgOEDQBLS3x9BxOWrnhqu5sQ+f6HaZIxD39I= +github.com/bytedance/go-tagexpr/v2 v2.9.2/go.mod h1:5qsx05dYOiUXOUgnQ7w3Oz8BYs2qtM/bJokdLb79wRM= +github.com/bytedance/gopkg v0.0.0-20210705062217-74c74ebadcae/go.mod h1:birsdqRCbwnckJbdAvcSao+AzOyibVEoWB55MjpYpB8= +github.com/bytedance/gopkg v0.0.0-20210709064845-3c00f9323f09/go.mod h1:birsdqRCbwnckJbdAvcSao+AzOyibVEoWB55MjpYpB8= +github.com/bytedance/gopkg v0.0.0-20210716082555-acbf5a2aa7e2/go.mod h1:birsdqRCbwnckJbdAvcSao+AzOyibVEoWB55MjpYpB8= +github.com/bytedance/gopkg v0.0.0-20210910103821-e4efae9c17c3/go.mod h1:birsdqRCbwnckJbdAvcSao+AzOyibVEoWB55MjpYpB8= +github.com/bytedance/gopkg v0.0.0-20220413063733-65bf48ffb3a7/go.mod h1:2ZlV9BaUH4+NXIBF0aMdKKAnHTzqH+iMU4KUjAbL23Q= +github.com/bytedance/gopkg v0.0.0-20220509134931-d1878f638986/go.mod h1:2ZlV9BaUH4+NXIBF0aMdKKAnHTzqH+iMU4KUjAbL23Q= +github.com/bytedance/gopkg v0.0.0-20220531084716-665b4f21126f/go.mod h1:2ZlV9BaUH4+NXIBF0aMdKKAnHTzqH+iMU4KUjAbL23Q= +github.com/bytedance/gopkg v0.0.0-20220623074550-9d6d3df70991 h1:UX3f692HP+gmMtNiXFUyEq1t9h4D2HOoinlDpdWMU6M= +github.com/bytedance/gopkg v0.0.0-20220623074550-9d6d3df70991/go.mod h1:2ZlV9BaUH4+NXIBF0aMdKKAnHTzqH+iMU4KUjAbL23Q= +github.com/bytedance/sonic v1.3.0/go.mod h1:V973WhNhGmvHxW6nQmsHEfHaoU9F3zTF+93rH03hcUQ= +github.com/bytedance/sonic v1.3.5/go.mod h1:V973WhNhGmvHxW6nQmsHEfHaoU9F3zTF+93rH03hcUQ= +github.com/bytedance/sonic v1.5.0 h1:XWdTi8bwPgxIML+eNV1IwNuTROK6EUrQ65ey8yd6fRQ= +github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM= +github.com/cenkalti/backoff/v4 v4.1.1/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +github.com/cenkalti/backoff/v4 v4.1.3 h1:cFAlzYUlVYDysBEH2T5hyJZMh3+5+WCBvSnK6Q8UtC4= +github.com/cenkalti/backoff/v4 v4.1.3/go.mod h1:scbssz8iZGpm3xbr14ovlUdkxfGXNInqkPWOWmG2CLw= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +github.com/certifi/gocertifi v0.0.0-20191021191039-0944d244cd40/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= +github.com/certifi/gocertifi v0.0.0-20200922220541-2c3bb06c6054/go.mod h1:sGbDF6GwGcLpkNXPUTkMRoywsNa/ol15pxFe6ERfguA= +github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE= +github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06 h1:1sDoSuDPWzhkdzNVxCxtIaKiAe96ESVPv8coGwc1gZ4= +github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY= +github.com/chenzhuoyu/iasm v0.0.0-20220818063314-28c361dae733 h1:Hx6Jxqln+bHRrtjUdgrehhF3gtWVJ2S7bjO/YTNn8Fg= +github.com/chenzhuoyu/iasm v0.0.0-20220818063314-28c361dae733/go.mod h1:wOQ0nsbeOLa2awv8bUYFW/EHXbjQMlZ10fAlXDB2sz8= +github.com/choleraehyq/pid v0.0.12/go.mod h1:uhzeFgxJZWQsZulelVQZwdASxQ9TIPZYL4TPkQMtL/U= +github.com/choleraehyq/pid v0.0.13/go.mod h1:uhzeFgxJZWQsZulelVQZwdASxQ9TIPZYL4TPkQMtL/U= +github.com/choleraehyq/pid v0.0.15 h1:PejhUZowqxxssjwyaw4OZURRFjnvftZfeEWK9UoWPXU= +github.com/choleraehyq/pid v0.0.15/go.mod h1:uhzeFgxJZWQsZulelVQZwdASxQ9TIPZYL4TPkQMtL/U= +github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= +github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY= +github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= +github.com/chzyer/readline v1.5.0/go.mod h1:x22KAscuvRqlLoK9CsoYsmxoXZMMFVyOl86cAH8qUic= +github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cloudwego/fastpb v0.0.3 h1:GZE0WzlnjQFE3+vkYFZd964PGT9AXOuvir+JGzuBSPM= +github.com/cloudwego/fastpb v0.0.3/go.mod h1:/V13XFTq2TUkxj2qWReV8MwfPC4NnPcy6FsrojnsSG0= +github.com/cloudwego/frugal v0.1.3 h1:tw3+hh4YMmtHFHRue3OGYjAnkxnZRHqeAyG18+7z5aI= +github.com/cloudwego/frugal v0.1.3/go.mod h1:b981ViPYdhI56aFYsoMjl9kv6yeqYSO+iEz2jrhkCgI= +github.com/cloudwego/hertz v0.2.1/go.mod h1:prTyExvsH/UmDkvfU3dp3EHsZFQISfT8R7BirvpTKdo= +github.com/cloudwego/hertz v0.3.2/go.mod h1:hnv3B7eZ6kMv7CKFHT2OC4LU0mA4s5XPyu/SbixLcrU= +github.com/cloudwego/hertz v0.4.2/go.mod h1:K1U0RlU07CDeBINfHNbafH/3j9uSgIW8otbjUys3OPY= +github.com/cloudwego/hertz v0.5.1 h1:Jpnq5pdO8ARnPEGFZLEL8g3jCQcagOst0Iq1YXyBIJI= +github.com/cloudwego/hertz v0.5.1/go.mod h1:K1U0RlU07CDeBINfHNbafH/3j9uSgIW8otbjUys3OPY= +github.com/cloudwego/kitex v0.0.4/go.mod h1:EIjPJ4Dom2ornk7xDCdKpUpOnf4Tulevimh4Tn05OGc= +github.com/cloudwego/kitex v0.0.5/go.mod h1:sDiWpxbadYE5wFYj7MrSzm2Tle7TFZdcSezIErMsvp8= +github.com/cloudwego/kitex v0.2.0/go.mod h1:1p4rtGIIiFZMOePYbSPgLkIhdhdfhEtVOJSti/k9vK4= +github.com/cloudwego/kitex v0.3.2/go.mod h1:/XD07VpUD9VQWmmoepASgZ6iw//vgWikVA9MpzLC5i0= +github.com/cloudwego/kitex v0.4.4 h1:/oInvgh0Nz8OpzXBrXkD3qVBkiQmCCdCVLdIpktj6q0= +github.com/cloudwego/kitex v0.4.4/go.mod h1:3FcH5h9Qw+dhRljSzuGSpWuThttA8DvK0BsL7HUYydo= +github.com/cloudwego/kitex-examples v0.0.0-20211019030300-7fd73f66ff4d/go.mod h1:YYForGqNLFhxmRJe3dZx61vJxJ4nxKURQBa3rBzXUJU= +github.com/cloudwego/netpoll v0.0.2/go.mod h1:rZOiNI0FYjuvNybXKKhAPUja03loJi/cdv2F55AE6E8= +github.com/cloudwego/netpoll v0.0.3/go.mod h1:rZOiNI0FYjuvNybXKKhAPUja03loJi/cdv2F55AE6E8= +github.com/cloudwego/netpoll v0.0.4/go.mod h1:rZOiNI0FYjuvNybXKKhAPUja03loJi/cdv2F55AE6E8= +github.com/cloudwego/netpoll v0.1.0/go.mod h1:rZOiNI0FYjuvNybXKKhAPUja03loJi/cdv2F55AE6E8= +github.com/cloudwego/netpoll v0.2.0/go.mod h1:rZOiNI0FYjuvNybXKKhAPUja03loJi/cdv2F55AE6E8= +github.com/cloudwego/netpoll v0.2.4/go.mod h1:1T2WVuQ+MQw6h6DpE45MohSvDTKdy2DlzCx2KsnPI4E= +github.com/cloudwego/netpoll v0.2.6/go.mod h1:1T2WVuQ+MQw6h6DpE45MohSvDTKdy2DlzCx2KsnPI4E= +github.com/cloudwego/netpoll v0.3.1 h1:xByoORmCLIyKZ8gS+da06WDo3j+jvmhaqS2KeKejtBk= +github.com/cloudwego/netpoll v0.3.1/go.mod h1:1T2WVuQ+MQw6h6DpE45MohSvDTKdy2DlzCx2KsnPI4E= +github.com/cloudwego/netpoll-http2 v0.0.4/go.mod h1:iFr5SzJCXIYgBg0ubL0fZiCQ6W36s9p0KjXpV04lmoY= +github.com/cloudwego/netpoll-http2 v0.0.6/go.mod h1:+bjPyu2Cd4GDzKa0IegPgp1hjMjpZ6/kXTsSjIsmUk8= +github.com/cloudwego/thriftgo v0.1.2/go.mod h1:LzeafuLSiHA9JTiWC8TIMIq64iadeObgRUhmVG1OC/w= +github.com/cloudwego/thriftgo v0.2.4 h1:o3JTSygQXaNHmggZYqAkfCBdPGWuKH1Q8XCflCvsSIY= +github.com/cloudwego/thriftgo v0.2.4/go.mod h1:8i9AF5uDdWHGqzUhXDlubCjx4MEfKvWXGQlMWyR0tM4= +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-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= +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/cockroachdb/datadriven v0.0.0-20200714090401-bf6692d28da5/go.mod h1:h6jFvWxBdQXxjopDMZyH2UVceIRfR84bdzbkoKrsWNo= +github.com/cockroachdb/errors v1.2.4/go.mod h1:rQD95gz6FARkaKkQXUksEje/d9a6wBJoCr5oaCLELYA= +github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f/go.mod h1:i/u985jwjWRlyHXQbwatDASoW0RMlZ/3i9yJHE2xLkI= +github.com/coreos/bbolt v1.3.2/go.mod h1:iRUV2dpdMOn7Bo10OQBFzIJO9kkE559Wcmn+qkEiiKk= +github.com/coreos/etcd v3.3.13+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= +github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= +github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= +github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= +github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= +github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/creack/pty v1.1.11/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= +github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= +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/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no= +github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo= +github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= +github.com/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.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= +github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= +github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= +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/fasthttp/websocket v1.4.3-rc.6 h1:omHqsl8j+KXpmzRjF8bmzOSYJ8GnS0E3efi1wYT+niY= +github.com/fasthttp/websocket v1.4.3-rc.6/go.mod h1:43W9OM2T8FeXpCWMsBd9Cb7nE2CACNqNvCqQCoty/Lc= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo= +github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M= +github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= +github.com/form3tech-oss/jwt-go v3.2.3+incompatible h1:7ZaBxOI7TMoYBfyA3cQHErNNyAWIKUMIwqxEtgHOs5c= +github.com/form3tech-oss/jwt-go v3.2.3+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k= +github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= +github.com/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= +github.com/gavv/httpexpect/v2 v2.12.0 h1:ibQT8ktEbPlkcsYKdh/QB7UgAjU5574O2jpwwgsrh6g= +github.com/gavv/httpexpect/v2 v2.12.0/go.mod h1:ra5Uy9iyQe0CljXH6LQJ00u8aeY1SKN2f4I6jPiD4Ng= +github.com/getsentry/raven-go v0.2.0/go.mod h1:KungGk8q33+aIAZUIVWZDr2OfAEBsO49PX4NzFV5kcQ= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= +github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI= +github.com/gin-gonic/gin v1.7.7 h1:3DoBmSbJbZAWqXJC3SLjAPfutPJJRN1U5pALB7EeTTs= +github.com/gin-gonic/gin v1.7.7/go.mod h1:axIBovoeJpVj8S3BwE0uPMTeReE4+AfFtqpqaZ1qq1U= +github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= +github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.2.3 h1:2DntVwHkVopvECVRSlL5PSo9eG+cAkDCuckLubN+rq0= +github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-playground/assert/v2 v2.0.1 h1:MsBgLAaY856+nPRTKrp3/OZK38U/wa0CcBYNjji3q3A= +github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= +github.com/go-playground/locales v0.13.0/go.mod h1:taPMhCMXrRLJO55olJkUXHZBHCxTMfnGwq/HNwmWNS8= +github.com/go-playground/locales v0.14.0 h1:u50s323jtVGugKlcYeyzC0etD1HifMjqmJqb8WugfUU= +github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= +github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA= +github.com/go-playground/universal-translator v0.18.0 h1:82dyy6p4OuJq4/CByFNOn/jYrnRPArHwAcmLoJZxyho= +github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA= +github.com/go-playground/validator/v10 v10.4.1/go.mod h1:nlOn6nFhuKACm19sB/8EGNn9GlaMV7XkbRSipzJ0Ii4= +github.com/go-playground/validator/v10 v10.11.0 h1:0W+xRM511GY47Yy3bZUbJVitCNg2BOGlCyvTqsp/xIw= +github.com/go-playground/validator/v10 v10.11.0/go.mod h1:i+3WkQ1FvaUjjxh1kSvIA4dMGDBiPU55YFDl0WbKdWU= +github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI= +github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo= +github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc= +github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/goccy/go-json v0.9.4/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= +github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/gogo/protobuf v1.2.1/go.mod h1:hp+jE20tsWTFYpLwKvXlhS1hjn+gTNwPg2I6zVXpSg4= +github.com/gogo/protobuf v1.3.1/go.mod h1:SlYgWuQ5SjCEi6WLHjHCa1yvBfUnHcTbrrZtXPKa29o= +github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= +github.com/golang-jwt/jwt/v4 v4.4.1 h1:pC5DB52sCeK48Wlb9oPcdhnjkz1TKt1D/P7WKJ0kUcQ= +github.com/golang-jwt/jwt/v4 v4.4.1/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/glog v1.0.0 h1:nfP3RFugxnNRyKgeWd4oI1nYvXpxrx8ck8ZrcizshdQ= +github.com/golang/glog v1.0.0/go.mod h1:EWib/APOK0SL3dFbYqvxE3UYd8E6s1ouQ7iEp/0LWV4= +github.com/golang/groupcache v0.0.0-20190129154638-5b532d6fd5ef/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= +github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= +github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= +github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/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.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= +github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= +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.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= +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/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= +github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= +github.com/google/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.4.1/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.1/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.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= +github.com/google/go-cmp v0.5.8 h1:e6P7q2lk1O+qJJb4BtCQXlK8vWEO8V1ZeuEdJNOqZyg= +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/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= +github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= +github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= +github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= +github.com/google/pprof v0.0.0-20220608213341-c488b8fa1db3 h1:mpL/HvfIgIejhVwAfxBQkwEjlhP5o0O9RAeTAjpwzxc= +github.com/google/pprof v0.0.0-20220608213341-c488b8fa1db3/go.mod h1:gSuNB+gJaOiQKLEZ+q+PK9Mq3SOzhRcw2GsGS/FhYDk= +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.2.0/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/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= +github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= +github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= +github.com/gordonklaus/ineffassign v0.0.0-20200309095847-7953dde2c7bf/go.mod h1:cuNKsD1zp2v6XfE/orVX2QE1LC+i254ceGcVeDT3pTU= +github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= +github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grpc-ecosystem/go-grpc-middleware v1.0.0/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= +github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 h1:+9834+KizmvFV7pXQGSXQTsaWhq2GjuNUt0aUU0YBYw= +github.com/grpc-ecosystem/go-grpc-middleware v1.3.0/go.mod h1:z0ButlSOZa5vEBq9m2m2hlwIgKw+rp3sdCBRoJY+30Y= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 h1:Ovs26xHkKqVztRpIrF/92BcuyuQ/YW4NSIpoGtfXNho= +github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= +github.com/grpc-ecosystem/grpc-gateway v1.9.0/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= +github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0 h1:BZHcxBETFHIdVyhyEfOvn/RdU/QGdLI4y34qQGjGWO0= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0/go.mod h1:hgWBS7lorOAVIJEQMi4ZsPv9hVvWI6+ch50m39Pf2Ks= +github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= +github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= +github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= +github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= +github.com/henrylee2cn/ameda v1.4.8/go.mod h1:liZulR8DgHxdK+MEwvZIylGnmcjzQ6N6f2PlWe7nEO4= +github.com/henrylee2cn/ameda v1.4.10 h1:JdvI2Ekq7tapdPsuhrc4CaFiqw6QXFvZIULWJgQyCAk= +github.com/henrylee2cn/ameda v1.4.10/go.mod h1:liZulR8DgHxdK+MEwvZIylGnmcjzQ6N6f2PlWe7nEO4= +github.com/henrylee2cn/goutil v0.0.0-20210127050712-89660552f6f8 h1:yE9ULgp02BhYIrO6sdV/FPe0xQM6fNHkVQW2IAymfM0= +github.com/henrylee2cn/goutil v0.0.0-20210127050712-89660552f6f8/go.mod h1:Nhe/DM3671a5udlv2AdV2ni/MZzgfv2qrPL5nIi3EGQ= +github.com/hertz-contrib/gzip v0.0.1 h1:fPCnSZIDT4Gd8ZTuoCCJXek0opUsN89T2djdEW7Awr4= +github.com/hertz-contrib/gzip v0.0.1/go.mod h1:Fom/vnPMLA3UJ/P8fsZO8izjWG82m53BGO48lW1U1l8= +github.com/hertz-contrib/jwt v1.0.2 h1:sAW3wqgBDsbPKr5JWJRObY61jg1NqYkUCg+o8UXLsaI= +github.com/hertz-contrib/jwt v1.0.2/go.mod h1:3zUSK+44dcw/9z/89JZ+mA0FoyhmVN7Hx+f46ucVV4I= +github.com/hertz-contrib/obs-opentelemetry/logging/logrus v0.1.1 h1:4KR/JoIc8PSbVucOzsLSJOtVgDowwNG6/C/GkrpPXHI= +github.com/hertz-contrib/obs-opentelemetry/logging/logrus v0.1.1/go.mod h1:dLQsSFKUVF4pya7kLlF6l1T69+mOPObotXGJO8ptbho= +github.com/hertz-contrib/obs-opentelemetry/tracing v0.1.1 h1:Ua/ImpcbYt8ohRolat3Ua7BEmeI7V4INRIbFKZJUndc= +github.com/hertz-contrib/obs-opentelemetry/tracing v0.1.1/go.mod h1:dhvPLrGU5FKUpzv4qYOO4Wgo/D4ldPyw+LwIvcDTKP8= +github.com/hertz-contrib/pprof v0.1.0 h1:yES6PQ5AJZRKiUQem1cpXU2gskO4cHdPMiXu9qSGS7E= +github.com/hertz-contrib/pprof v0.1.0/go.mod h1:4vgREcobBOExepQdEt/EMD/Nc1u01rpXXaQa2TNjA4A= +github.com/hertz-contrib/requestid v1.1.0 h1:+y1cuNlNX2KUoEC1SnBJ6M55/TlMTx3M9yxkqi0oTkk= +github.com/hertz-contrib/requestid v1.1.0/go.mod h1:+l5CbZl//cSUoos421fnDFKQ6YYlVHcYc3Ri7AS8DUA= +github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= +github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= +github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w= +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/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jhump/protoreflect v1.8.2 h1:k2xE7wcUomeqwY0LDCYA16y4WWfyTcMx5mKhk0d4ua0= +github.com/jhump/protoreflect v1.8.2/go.mod h1:7GcYQDdMU/O/BBrl/cX6PNHpXh6cenjd8pneu5yW7Tg= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= +github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= +github.com/jonboulle/clockwork v0.2.2 h1:UOGuzwb1PwsrDAObMuhUnj0p5ULPj8V/xJ7Kx9qUBdQ= +github.com/jonboulle/clockwork v0.2.2/go.mod h1:Pkfl5aHPm1nk2H9h0bjmnJD/BcgbGXUBGnn1kMkgxc8= +github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= +github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= +github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= +github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= +github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k= +github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q= +github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00= +github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= +github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kitex-contrib/obs-opentelemetry v0.1.0 h1:A8DUzKSujPb21ORn+DuFM2jLdsrQ/fM3o4r8yXLd5k4= +github.com/kitex-contrib/obs-opentelemetry v0.1.0/go.mod h1:l5Opsj8BtfHrsRJCw9PRKiidwWvOtGumijm+9odf2E8= +github.com/kitex-contrib/obs-opentelemetry/logging/logrus v0.0.0-20221109071748-a433b0b57972 h1:TcPpmJiIFB9hybZA8Aa4SC5KMj2bmjjPsYDlxJglfxw= +github.com/kitex-contrib/obs-opentelemetry/logging/logrus v0.0.0-20221109071748-a433b0b57972/go.mod h1:Eml/0Z+CqgGIPf9JXzLGu+N9NJoy2x5pqypN+hmKArE= +github.com/kitex-contrib/registry-etcd v0.1.0 h1:D+bg70S9+syTx2+m3I71vO8fhbKT/MO9GeKLzqXSkuc= +github.com/kitex-contrib/registry-etcd v0.1.0/go.mod h1:+/RTa3y+zSX4+HIlrowJYt2w4FQiQbQsrKTVsQ4ueIs= +github.com/kitex-contrib/tracer-opentracing v0.0.2/go.mod h1:mprt5pxqywFQxlHb7ugfiMdKbABTLI9YrBYs9WmlK5Q= +github.com/klauspost/compress v1.12.2/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg= +github.com/klauspost/compress v1.15.0 h1:xqfchp4whNFxn5A4XFyyYtitiWI8Hy5EW59jEwcyL6U= +github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk= +github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg= +github.com/klauspost/cpuid/v2 v2.1.0 h1:eyi1Ad2aNJMW95zcSbmGg7Cg6cq3ADwLpMAP96d8rF0= +github.com/klauspost/cpuid/v2 v2.1.0/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY= +github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M= +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.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0= +github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= +github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII= +github.com/leodido/go-urn v1.2.1 h1:BqpAaACuzVSgi/VLzGZIobT2z4v53pjosyNd9Yv6n/w= +github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY= +github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= +github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= +github.com/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU= +github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.13/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-sqlite3 v1.14.12 h1:TJ1bhYJPV44phC+IMu1u2K/i5RriLTPe+yc68XDJ1Z0= +github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= +github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= +github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= +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/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= +github.com/nishanths/predeclared v0.0.0-20200524104333-86fad755b4d3/go.mod h1:nt3d53pc1VYcphSCIaYAJtnPYnr3Zyn8fMq2wvPGPso= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/nyaruka/phonenumbers v1.0.55 h1:bj0nTO88Y68KeUQ/n3Lo2KgK7lM1hF7L9NFuwcCl3yg= +github.com/nyaruka/phonenumbers v1.0.55/go.mod h1:sDaTZ/KPX5f8qyV9qN+hIm+4ZBARJrupC6LuhshJq1U= +github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= +github.com/oleiade/lane v1.0.1 h1:hXofkn7GEOubzTwNpeL9MaNy8WxolCYb9cInAIeqShU= +github.com/oleiade/lane v1.0.1/go.mod h1:IyTkraa4maLfjq/GmHR+Dxb4kCMtEGeb+qmhlrQ5Mk4= +github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.10.1/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= +github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE= +github.com/opentracing/opentracing-go v1.1.0/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o= +github.com/opentracing/opentracing-go v1.2.0/go.mod h1:GxEUsuufX4nBwe+T+Wl9TAgYrxe9dPLANfrWvHYVTgc= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= +github.com/pkg/diff v0.0.0-20200914180035-5b29258ca4f7/go.mod h1:zO8QMzTeZd5cpnIkz/Gn6iK0jDfGicM1nynOkkPIl28= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +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/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= +github.com/prometheus/client_golang v1.11.1/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= +github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= +github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= +github.com/prometheus/common v0.0.0-20181113130724-41aa239b4cce/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= +github.com/prometheus/common v0.4.0/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= +github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= +github.com/prometheus/common v0.37.0 h1:ccBbHCgIiT9uSoFY0vX8H3zsNR5eLt17/RQLUvn8pXE= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.0-20190507164030-5867b95ac084/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= +github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.8.0 h1:ODq8ZFEaYeCaZOJlZZdJA2AbQR98dSHSM1KW/You5mo= +github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= +github.com/rogpeppe/fastuuid v0.0.0-20150106093220-6724a57986af/go.mod h1:XWv6SoW27p1b0cqNHllgS5HIMJraePCO15w5zCzIWYg= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= +github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc= +github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8= +github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE= +github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +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/savsgio/gotils v0.0.0-20210617111740-97865ed5a873/go.mod h1:dmPawKuiAeG/aFYVs2i+Dyosoo7FNcm+Pi8iK6ZUrX8= +github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d h1:Q+gqLBOPkFGHyCJxXMRqtUgUbTjI8/Ze8vu8GGyNFwo= +github.com/savsgio/gotils v0.0.0-20220530130905-52f3993e8d6d/go.mod h1:Gy+0tqhJvgGlqnTF8CVGP0AaGRjwBtXs/a5PA0Y3+A4= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +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/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= +github.com/sirupsen/logrus v1.7.0/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE= +github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0= +github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= +github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= +github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM= +github.com/soheilhy/cmux v0.1.5 h1:jjzc5WVemNEDTLwv9tlmemhC73tI08BNOIGwBOo10Js= +github.com/soheilhy/cmux v0.1.5/go.mod h1:T7TcVDs9LWfQgPlPsdngu6I6QIoyIFZDDC6sNE1GqG0= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ= +github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= +github.com/spf13/cobra v1.1.3/go.mod h1:pGADOWyqRD/YMrPZigI/zbliZ2wVD/23d+is3pSWzOo= +github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo= +github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4= +github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= +github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= +github.com/spf13/viper v1.7.0/go.mod h1:8WkrPz2fc9jxqZNCJI/76HCieCp4Q8HaLFoCha5qpdg= +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.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +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.0/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk= +github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= +github.com/tailscale/depaware v0.0.0-20210622194025-720c4b409502/go.mod h1:p9lPsd+cx33L3H9nNoecRRxPssFKUwwI50I3pZ0yT+8= +github.com/tidwall/gjson v1.8.0/go.mod h1:5/xDoumyyDNerp2U36lyolv46b3uF/9Bu6OfyQ9GImk= +github.com/tidwall/gjson v1.9.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.12.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.13.0/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/gjson v1.14.3 h1:9jvXn7olKEHU1S9vwoMGliaT8jq1vJ7IH/n9zD9Dnlw= +github.com/tidwall/gjson v1.14.3/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.0.3/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= +github.com/tidwall/pretty v1.1.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= +github.com/tidwall/sjson v1.2.4/go.mod h1:098SZ494YoMWPmMO6ct4dcFnqxwj9r/gF0Etp19pSNM= +github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802 h1:uruHq4dN7GR16kFc5fp3d1RIYzJW5onx8Ybykw2YQFA= +github.com/tmc/grpc-websocket-proxy v0.0.0-20201229170055-e5319fda7802/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= +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= +github.com/uber/jaeger-client-go v2.29.1+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= +github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= +github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw= +github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M= +github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY= +github.com/ugorji/go/codec v1.2.7 h1:YPXUKf7fYbp/y8xloBqZOw2qaVggbfwMlI8WM3wZUJ0= +github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasthttp v1.27.0/go.mod h1:cmWIqlu99AO/RKcp1HWaViTqc57FswJOfYYdPJBl8BA= +github.com/valyala/fasthttp v1.34.0 h1:d3AAQJ2DRcxJYHm7OXNXtXt2as1vMDfxeIcFvhmGGm4= +github.com/valyala/fasthttp v1.34.0/go.mod h1:epZA5N+7pY6ZaEKRmstzOuYJx9HI8DI1oaCGZpdH4h0= +github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo= +github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/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/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 h1:eY9dn8+vbi4tKz5Qo6v2eYzo7kUS51QINcR5jNpbZS8= +github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= +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/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/yudai/pp v2.0.1+incompatible h1:Q4//iY4pNF6yPLZIigmvcl7k/bPgrcTPIFIcmawg5bI= +github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc= +github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +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.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU= +go.etcd.io/bbolt v1.3.6 h1:/ecaJf0sk1l4l6V4awd65v2C3ILy7MSj+s/x1ADCIMU= +go.etcd.io/bbolt v1.3.6/go.mod h1:qXsaaIqmgQH0T+OPdb99Bf+PKfBBQVAdyD6TY9G8XM4= +go.etcd.io/etcd/api/v3 v3.5.5 h1:BX4JIbQ7hl7+jL+g+2j5UAr0o1bctCm6/Ct+ArBGkf0= +go.etcd.io/etcd/api/v3 v3.5.5/go.mod h1:KFtNaxGDw4Yx/BA4iPPwevUTAuqcsPxzyX8PHydchN8= +go.etcd.io/etcd/client/pkg/v3 v3.5.5 h1:9S0JUVvmrVl7wCF39iTQthdaaNIiAaQbmK75ogO6GU8= +go.etcd.io/etcd/client/pkg/v3 v3.5.5/go.mod h1:ggrwbk069qxpKPq8/FKkQ3Xq9y39kbFR4LnKszpRXeQ= +go.etcd.io/etcd/client/v2 v2.305.5 h1:DktRP60//JJpnPC0VBymAN/7V71GHMdjDCBt4ZPXDjI= +go.etcd.io/etcd/client/v2 v2.305.5/go.mod h1:zQjKllfqfBVyVStbt4FaosoX2iYd8fV/GRy/PbowgP4= +go.etcd.io/etcd/client/v3 v3.5.5 h1:q++2WTJbUgpQu4B6hCuT7VkdwaTP7Qz6Daak3WzbrlI= +go.etcd.io/etcd/client/v3 v3.5.5/go.mod h1:aApjR4WGlSumpnJ2kloS75h6aHUmAyaPLjHMxpc7E7c= +go.etcd.io/etcd/pkg/v3 v3.5.5 h1:Ablg7T7OkR+AeeeU32kdVhw/AGDsitkKPl7aW73ssjU= +go.etcd.io/etcd/pkg/v3 v3.5.5/go.mod h1:6ksYFxttiUGzC2uxyqiyOEvhAiD0tuIqSZkX3TyPdaE= +go.etcd.io/etcd/raft/v3 v3.5.5 h1:Ibz6XyZ60OYyRopu73lLM/P+qco3YtlZMOhnXNS051I= +go.etcd.io/etcd/raft/v3 v3.5.5/go.mod h1:76TA48q03g1y1VpTue92jZLr9lIHKUNcYdZOOGyx8rI= +go.etcd.io/etcd/server/v3 v3.5.5 h1:jNjYm/9s+f9A9r6+SC4RvNaz6AqixpOvhrFdT0PvIj0= +go.etcd.io/etcd/server/v3 v3.5.5/go.mod h1:rZ95vDw/jrvsbj9XpTqPrTAB9/kzchVdhRirySPkUBc= +go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= +go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= +go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= +go.opencensus.io v0.22.6-0.20201102222123-380f4078db9f h1:IUmbcoP9XyEXW+R9AbrZgDvaYVfTbISN92Y5RIV+Mx4= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.25.0 h1:Wx7nFnvCaissIUZxPkBqDz2963Z+Cl+PkYbDKzTxDqQ= +go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.25.0/go.mod h1:E5NNboN0UqSAki0Atn9kVwaN7I+l25gGxDqBueo/74E= +go.opentelemetry.io/contrib/instrumentation/runtime v0.33.0 h1:YhjJQGhEoxXXKwH16MQEW37KgdZSACk+HyHnFtv/NcI= +go.opentelemetry.io/contrib/instrumentation/runtime v0.33.0/go.mod h1:cu2qiP1YaeuJtMVDUuMJZPfCBqJr4GB9kkwXbg5knMA= +go.opentelemetry.io/contrib/propagators/b3 v1.9.0 h1:Lzb9zU98jCE2kyfCjWfSSsiQoGtvBL+COxvUBf7FNhU= +go.opentelemetry.io/contrib/propagators/b3 v1.9.0/go.mod h1:fyx3gFXn+4w5uWTTiqaI8oBNBW/6w9Ow5zxXf7NGixU= +go.opentelemetry.io/contrib/propagators/jaeger v1.8.0 h1:Qmaw0Uwaw+iRL4U8eU+gP07xctL1IfXxvZH7Hy72rIE= +go.opentelemetry.io/contrib/propagators/opencensus v0.33.0 h1:HdPvVV3TW2xmPt1SzeYbkdhHKPq5of3whkDulCt8zMg= +go.opentelemetry.io/contrib/propagators/ot v1.9.0 h1:+pYoqyFoA3H6EZ7Wie2ZQdqS4ZfG42PAGvj3eLUukHE= +go.opentelemetry.io/contrib/propagators/ot v1.9.0/go.mod h1:D2GfaecHHX67fXT93/5iKl2DArjt8+H0XWtFD8b4Z+k= +go.opentelemetry.io/otel v1.0.1/go.mod h1:OPEOD4jIT2SlZPMmwT6FqZz2C0ZNdQqiWcoK6M0SNFU= +go.opentelemetry.io/otel v1.4.1/go.mod h1:StM6F/0fSwpd8dKWDCdRr7uRvEPYdW0hBSlbdTiUde4= +go.opentelemetry.io/otel v1.9.0 h1:8WZNQFIB2a71LnANS9JeyidJKKGOOremcUtb/OtHISw= +go.opentelemetry.io/otel v1.9.0/go.mod h1:np4EoPGzoPs3O67xUVNoPPcmSvsfOxNlNA4F4AC+0Eo= +go.opentelemetry.io/otel/bridge/opencensus v0.31.0 h1:8Wk5/hHtEdTpYwUz0Ny8I+ccqfIMbp8Ce8/ZXlN4WPc= +go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.9.0 h1:ggqApEjDKczicksfvZUCxuvoyDmR6Sbm56LwiK8DVR0= +go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.9.0/go.mod h1:78XhIg8Ht9vR4tbLNUhXsiOnE2HOuSeKAiAcoVQEpOY= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.31.0 h1:H0+xwv4shKw0gfj/ZqR13qO2N/dBQogB1OcRjJjV39Y= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.31.0/go.mod h1:nkenGD8vcvs0uN6WhR90ZVHQlgDsRmXicnNadMnk+XQ= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.31.0 h1:BaQ2xM5cPmldVCMvbLoy5tcLUhXCtIhItDYBNw83B7Y= +go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.31.0/go.mod h1:VRr8tlXQEsTdesDCh0qBe2iKDWhpi3ZqDYw6VlZ8MhI= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.0.1/go.mod h1:Kv8liBeVNFkkkbilbgWRpV+wWuu+H5xdOT6HAgd30iw= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.9.0 h1:NN90Cuna0CnBg8YNu1Q0V35i2E8LDByFOwHRCq/ZP9I= +go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.9.0/go.mod h1:0EsCXjZAiiZGnLdEUXM9YjCKuuLZMYyglh2QDXcYKVA= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.0.1/go.mod h1:xOvWoTOrQjxjW61xtOmD/WKGRYb/P4NzRo3bs65U6Rk= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.9.0 h1:M0/hqGuJBLeIEu20f89H74RGtqV2dn+SFWEz9ATAAwY= +go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.9.0/go.mod h1:K5G92gbtCrYJ0mn6zj9Pst7YFsDFuvSYEhYKRMcufnM= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.4.1/go.mod h1:BFiGsTMZdqtxufux8ANXuMeRz9dMPVFdJZadUWDFD7o= +go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.7.0 h1:8hPcgCg0rUJiKE6VWahRvjgLUrNl7rW2hffUEPKXVEM= +go.opentelemetry.io/otel/metric v0.31.0 h1:6SiklT+gfWAwWUR0meEMxQBtihpiEs4c+vL9spDTqUs= +go.opentelemetry.io/otel/metric v0.31.0/go.mod h1:ohmwj9KTSIeBnDBm/ZwH2PSZxZzoOaG2xZeekTRzL5A= +go.opentelemetry.io/otel/sdk v1.0.1/go.mod h1:HrdXne+BiwsOHYYkBE5ysIcv2bvdZstxzmCQhxTcZkI= +go.opentelemetry.io/otel/sdk v1.4.1/go.mod h1:NBwHDgDIBYjwK2WNu1OPgsIc2IJzmBXNnvIJxJc8BpE= +go.opentelemetry.io/otel/sdk v1.9.0 h1:LNXp1vrr83fNXTHgU8eO89mhzxb/bbWAsHG6fNf3qWo= +go.opentelemetry.io/otel/sdk v1.9.0/go.mod h1:AEZc8nt5bd2F7BC24J5R0mrjYnpEgYHyTcM/vrSple4= +go.opentelemetry.io/otel/sdk/metric v0.31.0 h1:2sZx4R43ZMhJdteKAlKoHvRgrMp53V1aRxvEf5lCq8Q= +go.opentelemetry.io/otel/sdk/metric v0.31.0/go.mod h1:fl0SmNnX9mN9xgU6OLYLMBMrNAsaZQi7qBwprwO3abk= +go.opentelemetry.io/otel/trace v1.0.1/go.mod h1:5g4i4fKLaX2BQpSBsxw8YYcgKpMMSW3x7ZTuYBr3sUk= +go.opentelemetry.io/otel/trace v1.4.1/go.mod h1:iYEVbroFCNut9QkwEczV9vMRPHNKSSwYZjulEtsmhFc= +go.opentelemetry.io/otel/trace v1.9.0 h1:oZaCNJUjWcg60VXWee8lJKlqhPbXAPB51URuR47pQYc= +go.opentelemetry.io/otel/trace v1.9.0/go.mod h1:2737Q0MuG8q1uILYm2YYVkAyLtOofiTNGg6VODnOiPo= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +go.opentelemetry.io/proto/otlp v0.9.0/go.mod h1:1vKfU9rv61e9EVGthD1zNvUbiwPcimSsOPU9brfSHJg= +go.opentelemetry.io/proto/otlp v0.18.0 h1:W5hyXNComRa23tGpKwG+FRAc4rfF6ZUg1JReK+QHS80= +go.opentelemetry.io/proto/otlp v0.18.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI405h3+duxN4U= +go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= +go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/atomic v1.8.0 h1:CUhrE4N1rqSE6FM9ecihEjRkLQu8cDfgDyoOs83mEY4= +go.uber.org/atomic v1.8.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.12 h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA= +go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= +go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= +go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= +go.uber.org/multierr v1.8.0/go.mod h1:7EAYxJLBy9rStEaz58O2t4Uvip6FSURkq8/ppBp95ak= +go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q= +go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U= +go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/arch v0.0.0-20220722155209-00200b7164a7 h1:VBQqJMNMRfQsWSiCTLgz9XjAfWlgnJAPv8nsp1HF8Tw= +golang.org/x/arch v0.0.0-20220722155209-00200b7164a7/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= +golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/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-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8= +golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= +golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f h1:OeJjE6G4dgCY4PIXvIRQbE8+RX+uXZyGhUy/ksMGJoc= +golang.org/x/crypto v0.0.0-20220427172511-eb4f295cb31f/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= +golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= +golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= +golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= +golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= +golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= +golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= +golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= +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-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= +golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= +golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= +golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= +golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= +golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= +golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20181220203305-927f97764cc3/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-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20200707034311-ab3426394381/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-20201202161906-c7110b5ffcbb/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-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20210614182718-04defd469f4e/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f h1:oA4XRj0qtSt8Yo1Zms0CUlsT3KG69V2UGQWPBxujDmc= +golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= +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-20190227155943-e225da77a7e6/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-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/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-20201207232520-09787c993a3a/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-20220601150217-0de741cfad7f h1:Ax0t5p6N38Ga0dThY21weqDEyz2oklo4IvDkpigvkD8= +golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/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-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181107165924-66b7b1311ac8/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/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-20190312061237-fead79001313/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-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200923182605-d9f96fdee20d/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-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210415045647-66c3f260301c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210423185535-09eb48e85fd7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210818153620-00dd8d7831e7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211205182925-97ca703d548d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220110181412-a018aaa089fe/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2 h1:fqTvyMIIj+HRzMmnzr9NtpHP6uVpvB5fkHcgPDC4nu8= +golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= +golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= +golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/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.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.7 h1:olpwvP2KacW1ZWvsR7uQhoyTYvKAupfQrRGBFM352Gk= +golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba h1:O8mE0/t419eoIwhTFpKVkHiTs/Igowgfkj25AcZrtiE= +golang.org/x/time v0.0.0-20210220033141-f8bda1e9f3ba/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180221164845-07fd8470d635/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20181030221726-6c7e314b6563/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/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-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= +golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/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-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= +golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= +golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200522201501-cb1345f3a375/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20200717024301-6ddee64345a6/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= +golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= +golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= +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= +gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= +gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= +gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= +gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= +google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= +google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= +google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= +google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= +google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= +google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= +google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= +google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= +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/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= +google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= +google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= +google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= +google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= +google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= +google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= +google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200423170343-7949de9c1215/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= +google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= +google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= +google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= +google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1 h1:b9mVrqYfq3P4bCdaLg1qtBnPzUYgglsIdjZkL/fQVOE= +google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= +google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= +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.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= +google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= +google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= +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.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= +google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.41.0/go.mod h1:U3l9uK9J0sini8mHphKoXyaqDA/8VyGnDee1zzIUK6k= +google.golang.org/grpc v1.42.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= +google.golang.org/grpc v1.46.2 h1:u+MLGgVf7vRdjEYZ8wDFhAVNmhkbJ5hmrA1LMWK1CAQ= +google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +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.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.25.1-0.20200805231151-a709e31e5d12/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/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= +gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= +gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= +gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= +gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= +gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= +gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= +gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +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.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.3.0/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= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/driver/mysql v1.4.5 h1:u1lytId4+o9dDaNcPCFzNv7h6wvmc92UjNk3z8enSBU= +gorm.io/driver/mysql v1.4.5/go.mod h1:SxzItlnT1cb6e1e4ZRpgJN2VYtcqJgqnHxWr4wsP8oc= +gorm.io/driver/sqlite v1.3.2 h1:nWTy4cE52K6nnMhv23wLmur9Y3qWbZvOBz+V4PrGAxg= +gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk= +gorm.io/gorm v1.24.3 h1:WL2ifUmzR/SLp85CSURAfybcHnGZ+yLSGSxgYXlFBHg= +gorm.io/gorm v1.24.3/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA= +gorm.io/plugin/opentelemetry v0.1.0 h1:92rFfYzQ1uw56xQBLroz5LptKznjzhNnaBMQesRiiWM= +gorm.io/plugin/opentelemetry v0.1.0/go.mod h1:GtjuDxlX1O/vcLs/8J8q9QEIY/jfT2iEmqgyBGVDZRc= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/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.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= +honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= +moul.io/http2curl/v2 v2.3.0 h1:9r3JfDzWPcbIklMOs2TnIFzDYvfAZvjeavG6EzP7jYs= +moul.io/http2curl/v2 v2.3.0/go.mod h1:RW4hyBjTWSYDOxapodpNEtX0g5Eb16sxklBqmd2RHcE= +nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50= +rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= +rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= +rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= +rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= +sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q= +sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc= diff --git a/sample_douyin/idl/api.thrift b/sample_douyin/idl/api.thrift new file mode 100644 index 00000000..ca23b60a --- /dev/null +++ b/sample_douyin/idl/api.thrift @@ -0,0 +1,52 @@ +namespace go douyinapi + +struct BaseResp { + 1: i64 status_code + 2: string status_msg +} + +struct User { + 1: i64 user_id + 2: string username + 3: i64 follow_count + 4: i64 follower_count +} + +struct CreateUserRequest { + 1: string username (api.query="username", api.vd="len($) > 0") + 2: string password (api.query="password", api.vd="len($) > 0") +} + +struct CreateUserResponse { + 1: BaseResp base_resp + 2: i64 user_id + 3: string token +} + +struct CheckUserRequest { + 1: string username (api.query="username", api.vd="len($) > 0") + 2: string password (api.query="password", api.vd="len($) > 0") +} + +struct CheckUserResponse { + 1: BaseResp base_resp + 2: i64 user_id + 3: string token +} + +struct GetUserRequest { + 1: string user_id (api.query="user_id") + 2: string token (api.query="token") +} + +struct GetUserResponse { + 1: BaseResp base_resp + 2: User user +} + +service ApiService { + CreateUserResponse CreateUser(1: CreateUserRequest req) (api.post="/douyin/user/register/") + CheckUserResponse CheckUser(1: CheckUserRequest req) (api.post="/douyin/user/login/") + GetUserResponse GetUser(1: GetUserRequest req) (api.get="/douyin/user/") +} + diff --git a/sample_douyin/idl/comment.thrift b/sample_douyin/idl/comment.thrift new file mode 100644 index 00000000..e8ea86ac --- /dev/null +++ b/sample_douyin/idl/comment.thrift @@ -0,0 +1,50 @@ +namespace go douyincomment + +struct BaseResp { + 1: i64 status_code + 2: string status_message +} + +struct Comment { + 1: i64 comment_id + 2: i64 video + 3: i64 user + 4: string content + 5: string create_date +} + +struct CreateCommentRequest { + 1: i64 video + 2: i64 user + 3: string content (vt.min_size = "1") + 4: string create_date (vt.min_size = "1") +} + +struct DeleteCommentRequest { + 1: i64 comment_id +} + +struct GetVideoCommentsRequest { + 1: i64 video +} + +struct CreateCommentResponse { + 1: BaseResp base_resp + 2: i64 comment_id +} + +struct DeleteCommentResponse { + 1: BaseResp base_resp +} + +struct GetVideoCommentsResponse { + 1: BaseResp base_resp + 2: list comments +} + + +service CommentService { + CreateCommentResponse CreateComment(1: CreateCommentRequest req) + DeleteCommentResponse DeleteComment(1: DeleteCommentRequest req) + GetVideoCommentsResponse GetVideoComments(1: GetVideoCommentsRequest req) +} \ No newline at end of file diff --git a/sample_douyin/idl/favorite.thrift b/sample_douyin/idl/favorite.thrift new file mode 100644 index 00000000..c1dc5a18 --- /dev/null +++ b/sample_douyin/idl/favorite.thrift @@ -0,0 +1,48 @@ +namespace go douyinfavorite + +struct BaseResp { + 1: i64 status_code + 2: string status_message +} + +struct Favorite { + 1: i64 favorite_id + 2: i64 user_id + 3: i64 video_id +} + +struct FavoriteActionRequest { + 1: i64 user_id + 2: i64 video_id + 3: string action_type +} + +struct FavoriteActionResponse { + 1: BaseResp base_resp +} + +struct GetListRequest { + 1: i64 user_id +} + +struct GetListResponse { + 1: BaseResp base_resp + 2: list video_ids +} + +struct GetIsFavoriteRequest{ + 1: list favorite_list +} + +struct GetIsFavoriteResponse { + 1: list is_favorites + 2: BaseResp base_resp +} + +service FavoriteService { + FavoriteActionResponse FavoriteAction(1: FavoriteActionRequest req) + GetListResponse GetList(1: GetListRequest req) + GetIsFavoriteResponse GetIsFavorite(1: GetIsFavoriteRequest req) +} + + diff --git a/sample_douyin/idl/message.thrift b/sample_douyin/idl/message.thrift new file mode 100644 index 00000000..2259f451 --- /dev/null +++ b/sample_douyin/idl/message.thrift @@ -0,0 +1,64 @@ +namespace go message + + +struct BaseResp { + 1: i64 status_code + 2: string status_message +} + +struct Message { + 1: i64 id + 2: i64 to_user_id + 3: i64 from_user_id + 4: string content + 5: i64 create_time +} + +struct FirstMessage { + 1: string message (vt.min_size = "1") + 2: i64 msgType (vt.min_size = "1") + 3: i64 friend_id +} + + + +struct CreateMessageRequest { + 1: i64 from_user_id + 2: i64 to_user_id + 3: string content +} + +struct CreateMessageResponse { + 1: i64 id + 2: i64 create_time + 3: BaseResp base_resp +} + +struct GetMessageListRequest { + 1: i64 from_user_id + 2: i64 to_user_id + 3: i64 pre_msg_time +} + +struct GetMessageListResponse { + 1: BaseResp base_resp + 2: list message_list +} + +struct GetFirstMessageRequest { + 1: i64 id + 2: list friend_ids +} + +struct GetFirstMessageResponse { + 1: list first_message_list + 2: BaseResp base_resp +} + + + +service MessageService { + CreateMessageResponse CreateMessage(1: CreateMessageRequest req) + GetMessageListResponse GetMessageList(1: GetMessageListRequest req) + GetFirstMessageResponse GetFirstMessage(1: GetFirstMessageRequest req) +} \ No newline at end of file diff --git a/sample_douyin/idl/relation.thrift b/sample_douyin/idl/relation.thrift new file mode 100644 index 00000000..a6aed83e --- /dev/null +++ b/sample_douyin/idl/relation.thrift @@ -0,0 +1,62 @@ +namespace go relation + +struct BaseResp { + 1: i64 status_code + 2: string status_message +} + +struct CreateRelationRequest { + 1: i64 follow_id + 2: i64 follower_id +} + +struct DeleteRelationRequest { + 1: i64 follow_id + 2: i64 follower_id +} + +struct GetFollowListRequest { + 1: i64 follower_id +} + +struct GetFollowerListRequest { + 1: i64 follow_id +} + +struct GetFollowListResponse { + 1: list follow_ids + 2: BaseResp base_resp +} + +struct GetFollowerListResponse { + 1: list follower_ids + 2: BaseResp base_resp +} + +struct GetFriendRequest { + 1: i64 me_id +} + +struct GetFriendResponse { + 1: list friend_ids + 2: BaseResp base_resp +} + +struct ValidIfFollowRequest { + 1: i64 follow_id + 2: i64 follower_id +} + +struct ValidIfFollowResponse { + 1: bool if_follow + 2: BaseResp base_resp +} + +service RelationService { + BaseResp CreateRelation(1: CreateRelationRequest req) + BaseResp DeleteRelation(1: DeleteRelationRequest req) + GetFollowListResponse GetFollow(1: GetFollowListRequest req) + GetFollowerListResponse GetFollower(1: GetFollowerListRequest req) + GetFriendResponse GetFriend(1: GetFriendRequest req) + ValidIfFollowResponse ValidIfFollowRequest(1: ValidIfFollowRequest req) +} \ No newline at end of file diff --git a/sample_douyin/idl/user.thrift b/sample_douyin/idl/user.thrift new file mode 100644 index 00000000..9f5b5ae2 --- /dev/null +++ b/sample_douyin/idl/user.thrift @@ -0,0 +1,68 @@ +namespace go douyinuser + +enum ErrCode { + SuccessCode = 0 + ServiceErrCode = 10001 + ParamErrCode = 10002 + UserAlreadyExistErrCode = 10003 + AuthorizationFailedErrCode = 10004 + QueryErrCode = 10005 +} + +struct BaseResp { + 1: i64 status_code + 2: string status_message +} + +struct User { + 1: i64 user_id + 2: string username + 3: i64 follow_count + 4: i64 follower_count + 5: bool is_follow + 6: i64 favorite_count + 7: i64 work_count + 8: i64 total_favorited + 9: string background_image + 10: string avatar + 11: string signature +} + +struct CreateUserRequest { + 1: string username (vt.min_size = "1") + 2: string password (vt.min_size = "1") + 3: string background_image + 4: string avatar + 5: string signature +} + +struct CreateUserResponse { + 1: BaseResp base_resp + 2: i64 user_id + 3: string token +} + +struct CheckUserRequest { + 1: string username (vt.min_size = "1") + 2: string password (vt.min_size = "1") +} + +struct CheckUserResponse { + 1: i64 user_id + 2: BaseResp base_resp +} + +struct MGetUserRequest { + 1: list user_ids (vt.min_size = "1") +} + +struct MGetUserResponse { + 1: list users + 2: BaseResp base_resp +} + +service UserService { + CreateUserResponse CreateUser(1: CreateUserRequest req) + CheckUserResponse CheckUser(1: CheckUserRequest req) + MGetUserResponse MGetUser(1: MGetUserRequest req) +} \ No newline at end of file diff --git a/sample_douyin/idl/video.thrift b/sample_douyin/idl/video.thrift new file mode 100644 index 00000000..abda46b4 --- /dev/null +++ b/sample_douyin/idl/video.thrift @@ -0,0 +1,87 @@ +namespace go douyinvideo + +struct BaseResp { + 1: i64 status_code + 2: string status_message +} + +struct Video { + 1: i64 video_id + 2: i64 author + 3: string play_url + 4: string cover_url + 5: i64 favorite_count + 6: i64 comment_count + 7: bool is_favorite + 8: string title + 9: string upload_time +} + +struct GetFeedRequest { + 1: string latest_time + 2: i64 user_id +} + +struct GetFeedResponse { + 1: BaseResp base_resp + 2: i64 next_time + 3: list