commit eca9bb696f55a5e8422730a6112b9b6b012d00ad Author: otto <965391514@qq.com> Date: Tue Nov 15 10:01:57 2022 +0800 up diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..703a94a --- /dev/null +++ b/.gitignore @@ -0,0 +1,38 @@ +# Reference https://github.com/github/gitignore/blob/master/Go.gitignore +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +vendor/ + +# Go workspace file +go.work + +# Compiled Object files, Static and Dynamic libs (Shared Objects) +*.o +*.a +*.so + +# OS General +Thumbs.db +.DS_Store + +# project +*.cert +*.key +*.log +bin/ +# Develop tools +.vscode/ +.idea/ +*.swp diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..bbf967b --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM golang:1.18 AS builder + +ENV CGO_ENABLED 0 +ENV GOOS linux + +COPY . /src +WORKDIR /src + +RUN export GIT_TERMINAL_PROMPT=1 +RUN git config --global url."git.gz.internal.jumaiyx.cn:222".insteadof "https://git.gz.internal.jumaiyx.cn/" +RUN go env -w GOPROXY="https://goproxy.cn" +RUN go env -w GOINSECURE="git.gz.internal.jumaiyx.cn" +RUN go env -w GOPRIVATE="git.gz.internal.jumaiyx.cn/" +RUN go env -w GONOSUMDB="git.gz.internal.jumaiyx.cn/" +RUN go env -w GONOPROXY="git.gz.internal.jumaiyx.cn/" +RUN go env +RUN go mod tidy +RUN make build + +FROM alpine + +RUN apk update --no-cache && apk add --no-cache ca-certificates tzdata +ENV TZ Asia/Shanghai + +WORKDIR /app +COPY --from=builder /src/bin/server /app/server +COPY --from=builder /src/configs /app/configs +#EXPOSE 9000 +ENTRYPOINT ["./server"] \ No newline at end of file diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..f054143 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,64 @@ +def buildService(serverName){ + docker.withRegistry('https://registry.internal.jumaiyx.cn', 'docker-registry-internal-backend') { + def img = docker.build("jm/$serverName:${env.BUILD_ID}",".") + img.push() + } +} + +pipeline { + agent any + + environment { + // 服务名 + SERVER_NAME = 'feedback' + // 镜像名称,对应K8S_FILE里面Deployment.containers的name + IMAGE_NAME = 'feedback' + // git路径 + GIT_URL = 'http://git.gz.internal.jumaiyx.cn/job/room-server-clear.git' + // 分支 + GIT_BRANCH = '*/master' + // kubectl执行文件 + K8S_FILE = 'feedback-dev.yaml' + // k8s deployment名称,对应K8S_FILE里面Deployment的name + K8S_DEPLOYMENT = 'feedback-deployment' + } + + stages { + stage('git代码拉取') { + steps { + checkout([$class: 'GitSCM', branches: [[name: "${env.GIT_BRANCH}"]], extensions: [], userRemoteConfigs: [[url: "${env.GIT_URL}"]]]) + echo 'git代码拉取 成功' + } + } + stage('docker镜像打包') { + steps { + echo "镜像版本:${env.BUILD_ID}" + buildService("${env.SERVER_NAME}") + echo 'docker镜像打包' + } + } + stage('传入k8s-master') { + steps { + //sshPublisher(publishers: [sshPublisherDesc(configName: 'k8s', transfers: [sshTransfer(cleanRemote: false, excludes: '', execCommand: '', execTimeout: 120000, flatten: false, makeEmptyDirs: false, noDefaultExcludes: false, patternSeparator: '[, ]+', remoteDirectory: '', remoteDirectorySDF: false, removePrefix: '', sourceFiles: "${env.K8S_FILE}")], usePromotionTimestamp: false, useWorkspaceInPromotion: false, verbose: false)]) + echo '将yaml传入k8s-master' + } + } + stage('部署服务') { + steps { + //sh "ssh root@192.168.1.156 kubectl apply -f /usr/local/k8s/${env.K8S_FILE}" + echo '部署服务' + //sh '''if if (( ${env.BUILD_ID} == 1 )) + //then + // ssh root@192.168.1.156 kubectl apply -f /usr/local/k8s/${env.K8S_FILE} + // echo '部署服务' + //fi''' + } + } + stage('更新image') { + steps { + sh "ssh root@192.168.1.156 kubectl set image Deployment/${env.K8S_DEPLOYMENT} ${env.IMAGE_NAME}=registry.internal.jumaiyx.cn/jm/${env.SERVER_NAME}:${env.BUILD_ID} -n dev" + echo '部署服务' + } + } + } +} diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..684318c --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2020 go-kratos + +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. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..42abfe7 --- /dev/null +++ b/Makefile @@ -0,0 +1,43 @@ +GOHOSTOS:=$(shell go env GOHOSTOS) +GOPATH:=$(shell go env GOPATH) +VERSION=$(shell git describe --tags --always) + +ifeq ($(GOHOSTOS), windows) + #the `find.exe` is different from `find` in bash/shell. + #to see https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/find. + #changed to use git-bash.exe to run find cli or other cli friendly, caused of every developer has a Git. + Git_Bash= $(subst cmd\,bin\bash.exe,$(dir $(shell where git))) + INTERNAL_PROTO_FILES=$(shell $(Git_Bash) -c "find internal -name *.proto") + API_PROTO_FILES=$(shell $(Git_Bash) -c "find api -name *.proto") +else + INTERNAL_PROTO_FILES=$(shell find internal -name *.proto) + API_PROTO_FILES=$(shell find api -name *.proto) +endif + + +.PHONY: build +# build +build: + mkdir -p bin/ && go build -ldflags "-X main.Version=$(VERSION)" -o ./bin ./... + +run: + mkdir -p bin/ && go build -ldflags "-X main.Version=$(VERSION)" -o ./bin ./... + ./bin/server + +up: + go mod tidy + go get -u git.gz.internal.jumaiyx.cn/jm/jmproto + go get -u git.gz.internal.jumaiyx.cn/pkg/k8s-client + go get -u git.gz.internal.jumaiyx.cn/pkg/log + go get -u git.gz.internal.jumaiyx.cn/pkg/config + go get -u git.gz.internal.jumaiyx.cn/pkg/id-encode + +.PHONY: generate +# generate +generate: + go mod tidy + go get github.com/google/wire/cmd/wire@latest + go generate ./... +wire: + cd ./cmd/src-room && wire + diff --git a/README.md b/README.md new file mode 100644 index 0000000..fdb6b05 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +## 房间清除多余容器任务 + +```sh +docker login -u devops-internal -p yVZUucBSMTJ8HDct https://registry.internal.jumaiyx.cn +docker build -t registry.internal.jumaiyx.cn/jm/message:latest . +docker tag registry.internal.jumaiyx.cn/jm/message:latest registry.internal.jumaiyx.cn/jm/message:v1.0.0 +docker push registry.internal.jumaiyx.cn/jm/message:v1.0.0 +``` + + + + diff --git a/cmd/server/main.go b/cmd/server/main.go new file mode 100644 index 0000000..ba06b7c --- /dev/null +++ b/cmd/server/main.go @@ -0,0 +1,38 @@ +package main + +import ( + "context" + "flag" + "fmt" + "git.gz.internal.jumaiyx.cn/pkg/config" + "git.gz.internal.jumaiyx.cn/pkg/log" + "os" +) + +var ( + Name string + Version string + + id, _ = os.Hostname() +) + +func main() { + flag.Parse() + + c, err := config.New().Conf("./configs/config.yaml") + if err != nil { + fmt.Println(err) + panic(err) + } + bc := c.Get() + + l := log.NewLogger(c.Get().Log) + biz, cleanup, err := wireApp(bc.Server, bc.Data, l) + if err != nil { + panic(err) + } + defer cleanup() + ctx := context.TODO() + l.WithContext(ctx) + biz.Check(ctx) +} diff --git a/cmd/server/wire.go b/cmd/server/wire.go new file mode 100644 index 0000000..2eb602c --- /dev/null +++ b/cmd/server/wire.go @@ -0,0 +1,20 @@ +//go:build wireinject +// +build wireinject + +// The build tag makes sure the stub is not built in the final build. + +package main + +import ( + "git.gz.internal.jumaiyx.cn/jm/jmproto/conf" + "git.gz.internal.jumaiyx.cn/job/room-hot-compute/internal/biz" + "git.gz.internal.jumaiyx.cn/job/room-hot-compute/internal/data" + "git.gz.internal.jumaiyx.cn/job/room-hot-compute/pkg" + "git.gz.internal.jumaiyx.cn/pkg/log" + "github.com/google/wire" +) + +// wireApp init kratos application. +func wireApp(*conf.Server, *conf.Data, log.Logger) (*biz.Biz, func(), error) { + panic(wire.Build(biz.ProviderBizSet, data.ProviderDataSet, pkg.ProviderPkgSet)) +} diff --git a/cmd/server/wire_gen.go b/cmd/server/wire_gen.go new file mode 100644 index 0000000..7949a73 --- /dev/null +++ b/cmd/server/wire_gen.go @@ -0,0 +1,33 @@ +// Code generated by Wire. DO NOT EDIT. + +//go:generate go run github.com/google/wire/cmd/wire +//go:build !wireinject +// +build !wireinject + +package main + +import ( + "git.gz.internal.jumaiyx.cn/jm/jmproto/conf" + "git.gz.internal.jumaiyx.cn/job/room-hot-compute/internal/biz" + "git.gz.internal.jumaiyx.cn/job/room-hot-compute/internal/data" + "git.gz.internal.jumaiyx.cn/job/room-hot-compute/pkg/room" + "git.gz.internal.jumaiyx.cn/pkg/log" +) + +// Injectors from wire.go: + +// wireApp init kratos application. +func wireApp(server *conf.Server, confData *conf.Data, logger log.Logger) (*biz.Biz, func(), error) { + roomClient, err := room.NewRoomService(logger) + if err != nil { + return nil, nil, err + } + dataData, cleanup, err := data.NewData(confData, logger) + if err != nil { + return nil, nil, err + } + bizBiz := biz.NewBiz(logger, roomClient, dataData) + return bizBiz, func() { + cleanup() + }, nil +} diff --git a/configs/config b/configs/config new file mode 100644 index 0000000..2e8027a --- /dev/null +++ b/configs/config @@ -0,0 +1,19 @@ +apiVersion: v1 +clusters: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Z4b0ZsUE85M1lyZ1o1VTd0bVlRN3FTOUZXV1VWR3hZCk42TFpjbEtrYTM4MEFZRzd2TlZZNFdacHZDVG9Ed2xsb2JMOE85WVdWdmp2TGw1TDAwL201MDNNZTViREEydVEKSjdPa1dENGtiL2Rob0paQjdaOWZId0tWaTgxYUkxNm9ERlAwbTR5YWQvckZBS3FHUlcxdVpLTXNYK29JL0ttVApVcHp0QStzSXhZZXlBK1VaSXJoN1NjSkZ3amVHdE1YUkJIM0RRUzRZc05SdHkxUnZjUnJXSk1uU3Z1MD0KLS0tLS1FTkQgQ0VSVElGSUNBVEUtLS0tLQo= + server: https://192.168.1.156:6443 + name: kubernetes +contexts: +- context: + cluster: kubernetes + user: kubernetes-admin + name: kubernetes-admin@kubernetes +current-context: kubernetes-admin@kubernetes +kind: Config +preferences: {} +users: +- name: kubernetes-admin + user: + client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJTFV6blJtKzZqUkV3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TWpBNU1qY3dNVE0wTXpsYUZ3MHlNekE1TWpjd01UTTBOREJhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQTNYOFZrc2x3N3AxQUF3aG4KbW5nRHU3NWRUUUpXUm1EN014a3ZPN0ZiWFFXVTVHUDg3bHpEV2pMeUt2L1NqZTZ5a1VTTkE5Z21kTmRrOTY0RgpnYWpyRnRHSUZXVzM2NVFXeitRT25ZVWFHQk9VRHQ2VFloOWlSRXJIRjhsR3NRVW0vVi9NemttMXpkY284ZEtHCm5VbktDWDhyMW5yVm53UkRiRTE2VEozcFRh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EVKZVFMUFl0Q0l1Q25YOS9JOXF1azBvVHR3NDliaUpyUUlVQlY4Skg4cWJOTy81SXNZY2tyOGNIOExIQzBQTwpRcEttYzIyWTV1MmJJYnNEbEZEckt0bGdQQWpOVTFOdFd0RU9tUFY1UlBxUDdzaGxEZk1qNmRWNTlzZ0dxVEdRCmtKU01oczE1ekJJcURPNVVNeFpZbTlrcUczSE1EQ0NCVlFJVXEwa0NnWUJtMWRFb0p2QUo5anp0bEczTzFmelkKV291VHNSL0RvV0tMVkI1WWx1cjloaDFRTmp1RHNNK211ckx6UTRDMVZZQkxMTnBGWHcyUXM0ZkloemFJbHYvdQpRN3k3L1FvNEdmUlE4Yzl4YlBHcjlMV1oyeTNqQWZ1ZlFjK3p5bmlrZml1T1ZCRmZZM0NRenAvUTUzQitLa0x0Cnk1SVMzZFA4eEF0NVl1TmE4WDBtSVFLQmdRQ2RBSkFaQlNGZi9yN05uVEJnY3M2MEo2cG55TW1BSitoSkN5WnoKYVpIUzgrOXl4SFhPaThQYlphdHhmMmJYQ2tEUFp2ZFk3MGErUEswTmJSdzhGUUZRbXF6ckFDVTNCOXJ5NDUraAplbkRXR0Racy9Rakd3QytYOHZNbUFvNHdBanhHbVJ2b01kWjFtN0RNbW1lTzZKQ1ZrNnNRd1BRclNVVk9PRGdVCmgyRWJNUUtCZ0RQamNEdjN6SjJJVjFrY01kbjNEMWVyQjBFR0I1M2NYeHFoa0pET3Rqd3RUV3V2dHNIYzI0R3gKNmFQODI1QllUV2NQNEJ6dEFIN1A5RkE2QmlBa0t3T3lrWFR5dDg2RTBUZUM5L3FtSW9EY255aHdReHVCZlB3UQo2bVhxeVFLZFBOTnVoKzlReDBEcGxHMTkzVTFid0pya3k3b3hKc0dackg1OUdGK3VTT3J0Ci0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg== \ No newline at end of file diff --git a/configs/config.yaml b/configs/config.yaml new file mode 100644 index 0000000..08ab35b --- /dev/null +++ b/configs/config.yaml @@ -0,0 +1,42 @@ +server: + name: room + http: + addr: 0.0.0.0:8000 + timeout: 30 + grpc: + addr: 0.0.0.0:9000 + timeout: 30 +data: + database: + source: "host=192.168.1.156 user=metachat password=metachat dbname=feedback port=15433 sslmode=disable TimeZone=Asia/Shanghai" +# source: postgresql://metachat:metachat@127.0.0.1:15432/room + redis: + addr: 192.168.1.156:16378 + password: MM5ZsXL0 + read_timeout: 1 + write_timeout: 1 + +etcd: + host: "127.0.0.1:20000" + +log: + level: "debug" + name: "room" + kafka: + addr: + - "127.0.0.1:9092" +amqp: + host: 192.168.1.156:5672 + username: jm + password: jm123456 + +id_encode: + uid: + salt: "test" + min_length: 8 + +rtctoken: + app_id: 6eeb2e6be9a141d1b0db920f36a5a9f3 + app_certificate: 80438856882e4563841d56f3cefeb763 + privilege_expiration: 3600 + token_expiration: 3600 \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..9067c51 --- /dev/null +++ b/go.mod @@ -0,0 +1,73 @@ +module git.gz.internal.jumaiyx.cn/job/room-hot-compute + +go 1.18 + +require ( + git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20221114080632-fdff5af719f3 + git.gz.internal.jumaiyx.cn/pkg/config v0.0.0-20221014090146-8fd721834886 + git.gz.internal.jumaiyx.cn/pkg/k8s-client v0.0.0-20221111084006-d3558f68d33b + git.gz.internal.jumaiyx.cn/pkg/kubediscovery v0.0.0-20221104101240-01cad3403ec0 + git.gz.internal.jumaiyx.cn/pkg/log v0.0.0-20221029084114-f67ca5716ca1 + github.com/go-redis/redis/v8 v8.11.5 + github.com/google/wire v0.5.0 + github.com/pkg/errors v0.9.1 +) + +require ( + git.gz.internal.jumaiyx.cn/pkg/id-encode v0.0.0-20221018014421-fe47b648265b // indirect + git.gz.internal.jumaiyx.cn/pkg/kafka v0.0.0-20221010085437-f3a4ed57181c // indirect + github.com/cespare/xxhash/v2 v2.1.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect + github.com/emicklei/go-restful/v3 v3.10.0 // indirect + github.com/fsnotify/fsnotify v1.6.0 // indirect + github.com/go-kratos/kratos/v2 v2.5.3 // indirect + github.com/go-logr/logr v1.2.3 // indirect + github.com/go-openapi/jsonpointer v0.19.5 // indirect + github.com/go-openapi/jsonreference v0.20.0 // indirect + github.com/go-openapi/swag v0.22.3 // indirect + github.com/go-playground/form/v4 v4.2.0 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/gnostic v0.6.9 // indirect + github.com/google/go-cmp v0.5.9 // indirect + github.com/google/gofuzz v1.2.0 // indirect + github.com/gorilla/mux v1.8.0 // indirect + github.com/imdario/mergo v0.3.13 // indirect + github.com/josharian/intern v1.0.0 // indirect + github.com/json-iterator/go v1.1.12 // indirect + github.com/klauspost/compress v1.15.12 // indirect + github.com/mailru/easyjson v0.7.7 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect + github.com/pierrec/lz4/v4 v4.1.17 // indirect + github.com/segmentio/kafka-go v0.4.38 // indirect + github.com/speps/go-hashids/v2 v2.0.1 // indirect + github.com/spf13/pflag v1.0.5 // indirect + github.com/xdg/scram v1.0.5 // indirect + github.com/xdg/stringprep v1.0.3 // indirect + golang.org/x/crypto v0.2.0 // indirect + golang.org/x/net v0.2.0 // indirect + golang.org/x/oauth2 v0.2.0 // indirect + golang.org/x/sys v0.2.0 // indirect + golang.org/x/term v0.2.0 // indirect + golang.org/x/text v0.4.0 // indirect + golang.org/x/time v0.2.0 // indirect + google.golang.org/appengine v1.6.7 // indirect + google.golang.org/genproto v0.0.0-20221111202108-142d8a6fa32e // indirect + google.golang.org/grpc v1.50.1 // indirect + google.golang.org/protobuf v1.28.1 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect + k8s.io/api v0.25.4 // indirect + k8s.io/apimachinery v0.25.4 // indirect + k8s.io/client-go v0.25.4 // indirect + k8s.io/klog/v2 v2.80.1 // indirect + k8s.io/kube-openapi v0.0.0-20221110221610-a28e98eb7c70 // indirect + k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2 // indirect + sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect + sigs.k8s.io/yaml v1.3.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..933304b --- /dev/null +++ b/go.sum @@ -0,0 +1,358 @@ +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= +git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20221114074402-8ee109365a6b h1:PeQrex+iaICUQCmPhhcyryTjPDur4HwLbtxViXfdoBw= +git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20221114074402-8ee109365a6b/go.mod h1:RuwVCwjm2L1MfZAePy5exPb/0OKHglXM+Q5lXrcdGxs= +git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20221114080632-fdff5af719f3 h1:ZAnktqr9aXVILpDrCBKLIizI9HU9CWuLz+Q8snJUoXk= +git.gz.internal.jumaiyx.cn/jm/jmproto v0.0.0-20221114080632-fdff5af719f3/go.mod h1:RuwVCwjm2L1MfZAePy5exPb/0OKHglXM+Q5lXrcdGxs= +git.gz.internal.jumaiyx.cn/pkg/config v0.0.0-20221014090146-8fd721834886 h1:LP4psj3ygJEKL6748ZQPNwYnYPmbo8dDwtwU08coRiw= +git.gz.internal.jumaiyx.cn/pkg/config v0.0.0-20221014090146-8fd721834886/go.mod h1:yEnzjNrnPNIr0Zq926QiJrbyReS+VZqX5bmkYhnSV7I= +git.gz.internal.jumaiyx.cn/pkg/id-encode v0.0.0-20221018014421-fe47b648265b h1:Bb+j4SrJMb00+QKQO1FcCDDOxzTnoBZCi2n0DrT39lE= +git.gz.internal.jumaiyx.cn/pkg/id-encode v0.0.0-20221018014421-fe47b648265b/go.mod h1:+1j9TQXFahHrK3TYJjXLuuDNCqKRscAWR2fD1ZhZE0c= +git.gz.internal.jumaiyx.cn/pkg/k8s-client v0.0.0-20221111084006-d3558f68d33b h1:dfhLVPDgTb8R5a5zs4/Rin6e6kdfvuGK0/m4BpNvLJw= +git.gz.internal.jumaiyx.cn/pkg/k8s-client v0.0.0-20221111084006-d3558f68d33b/go.mod h1:PjyxKfTWowQjJcim7h5DB+9pE7gI0U7BYx2z200hVyc= +git.gz.internal.jumaiyx.cn/pkg/kafka v0.0.0-20221010085437-f3a4ed57181c h1:C/1lKDrxi2xM2BPGG843kEcmZivhOdEr7Eg86bDIBVY= +git.gz.internal.jumaiyx.cn/pkg/kafka v0.0.0-20221010085437-f3a4ed57181c/go.mod h1:TujX5RTIJ6vz8QYG1R6JwssH5DHGrAVpdGBaWG+uVqY= +git.gz.internal.jumaiyx.cn/pkg/kubediscovery v0.0.0-20221104101240-01cad3403ec0 h1:G3Hb4Bz9Ku3hSkIIZZu33iN+CNqPEnjVbsOa+MVnat4= +git.gz.internal.jumaiyx.cn/pkg/kubediscovery v0.0.0-20221104101240-01cad3403ec0/go.mod h1:oc2Nm1tO4n09zn9u0KGlQzWzthO5WZ3PPq0CUMCYByg= +git.gz.internal.jumaiyx.cn/pkg/log v0.0.0-20221029084114-f67ca5716ca1 h1:IWra+Xfxk9ay45YZL+Qlb/LiplX+RRwhdJ1Gwa9mxxw= +git.gz.internal.jumaiyx.cn/pkg/log v0.0.0-20221029084114-f67ca5716ca1/go.mod h1:1sRiFBXx4Mc4/HXl2SqnuP3iqUtu5f6XOC+uFaBXltA= +github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= +github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= +github.com/StackExchange/wmi v1.2.1/go.mod h1:rcmrprowKIVzvc+NUiLncP2uuArMWLCbu9SBzvHz7e8= +github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= +github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= +github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= +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/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= +github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= +github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= +github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= +github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/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/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/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/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= +github.com/emicklei/go-restful/v3 v3.10.0 h1:X4gma4HM7hFm6WMeAsTfqA0GOfdNoCzBIkHGoRLGXuM= +github.com/emicklei/go-restful/v3 v3.10.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= +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.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= +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/flowstack/go-jsonschema v0.1.1/go.mod h1:yL7fNggx1o8rm9RlgXv7hTBWxdBM0rVwpMwimd3F3N0= +github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU= +github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= +github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= +github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= +github.com/go-kratos/aegis v0.1.2/go.mod h1:jYeSQ3Gesba478zEnujOiG5QdsyF3Xk/8owFUeKcHxw= +github.com/go-kratos/kratos/v2 v2.5.3 h1:v3F0fIFXh4HJgXprHKPGhRaobggolwPAbaBAjR+wC+Q= +github.com/go-kratos/kratos/v2 v2.5.3/go.mod h1:5acyLj4EgY428AJnZl2EwCrMV1OVlttQFBum+SghMiA= +github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +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/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-ole/go-ole v1.2.5/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiUsvbm0= +github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonpointer v0.19.5 h1:gZr+CIYByUqjcgeLXnQu2gHYQC9o73G2XUeOFYEICuY= +github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg= +github.com/go-openapi/jsonreference v0.20.0 h1:MYlu0sBgChmCfJxxUKZ8g1cPWFOB37YSZqewK7OKeyA= +github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo= +github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk= +github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= +github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= +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/form/v4 v4.2.0 h1:N1wh+Goz61e6w66vo8vJkQt+uwZSoLz50kZPJWR8eic= +github.com/go-playground/form/v4 v4.2.0/go.mod h1:q1a2BY+AQUUzhl6xA/6hBetay6dEIhMHjgvJiGo6K7U= +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/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/go.mod h1:m21LjoU+eqJr34lmDMbreY2eSTRJ1cv77w39/MY0Ch0= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= +github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.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.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= +github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= +github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= +github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= +github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= +github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= +github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/gnostic v0.6.9 h1:ZK/5VhkoX835RikCHpSUJV9a+S3e1zLh59YnyWeBW+0= +github.com/google/gnostic v0.6.9/go.mod h1:Nm8234We1lq6iB9OmlgNv3nH91XLLVZHCDayfA3xq+E= +github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= +github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.5.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.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= +github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= +github.com/google/wire v0.5.0 h1:I7ELFeVBr3yfPIcc8+MWvrjk+3VjbcSzoXm3JVa+jD8= +github.com/google/wire v0.5.0/go.mod h1:ngWDr9Qvq3yZA10YrxfyGELY/AFWGVpy9c1LTRi1EoU= +github.com/gorilla/mux v1.8.0 h1:i40aqfkR1h2SlN9hojwV5ZA91wcXFOvkdNIeFDP5koI= +github.com/gorilla/mux v1.8.0/go.mod h1:DVbg23sWSpFRCP0SfiEN6jmj59UnW/n46BH5rLB71So= +github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/imdario/mergo v0.3.12/go.mod h1:jmQim1M+e3UYxmgPu/WyfjB3N3VflVyUjjjwH0dnCYA= +github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk= +github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg= +github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= +github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= +github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= +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/klauspost/compress v1.15.9/go.mod h1:PhcZ0MbTNciWF3rruxRgKxI5NkcHHrHUDtV4Yw2GlzU= +github.com/klauspost/compress v1.15.12 h1:YClS/PImqYbn+UILDnqxQCZ3RehC9N318SU3kElDUEM= +github.com/klauspost/compress v1.15.12/go.mod h1:QPwzmACJjUTFsnSHH934V6woptycfrDDJnH7hvFVbGM= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pretty v0.2.0 h1:s5hAObm+yFO5uHYt5dYjxi2rXrsnmRpJx4OYvIWUaQs= +github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +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/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc= +github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= +github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= +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 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= +github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE= +github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE= +github.com/onsi/ginkgo/v2 v2.1.6 h1:Fx2POJZfKRQcM1pH49qSZiYeu319wji004qX+GDovrU= +github.com/onsi/gomega v1.20.1 h1:PA/3qinGoukvymdIDV8pii6tiZgC8kbmJO6Z5+b002Q= +github.com/pierrec/lz4/v4 v4.1.15/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= +github.com/pierrec/lz4/v4 v4.1.17 h1:kV4Ip+/hUBC+8T6+2EgburRtkE9ef4nbY3f4dFhGjMc= +github.com/pierrec/lz4/v4 v4.1.17/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= +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 v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= +github.com/segmentio/kafka-go v0.4.38 h1:iQdOBbUSdfuYlFpvjuALgj7N6DrdPA0HfB4AhREOdtg= +github.com/segmentio/kafka-go v0.4.38/go.mod h1:ikyuGon/60MN/vXFgykf7Zm8P5Be49gJU6vezwjnnhU= +github.com/shirou/gopsutil/v3 v3.21.8/go.mod h1:YWp/H8Qs5fVmf17v7JNZzA0mPJ+mS2e9JdiUF9LlKzQ= +github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= +github.com/speps/go-hashids/v2 v2.0.1 h1:ViWOEqWES/pdOSq+C1SLVa8/Tnsd52XC34RY7lt7m4g= +github.com/speps/go-hashids/v2 v2.0.1/go.mod h1:47LKunwvDZki/uRVD6NImtyk712yFzIs3UF3KlHohGw= +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/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= +github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= +github.com/stretchr/testify v1.7.1/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/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs= +github.com/tklauser/numcpus v0.3.0/go.mod h1:yFGUr7TUHQRAhyqBcEg0Ge34zDBAsIvJJcyE6boqnA8= +github.com/xdg/scram v1.0.5 h1:TuS0RFmt5Is5qm9Tm2SoD89OPqe4IRiFtyFY4iwWXsw= +github.com/xdg/scram v1.0.5/go.mod h1:lB8K/P019DLNhemzwFU4jHLhdvlE6uDZjXFejJXr49I= +github.com/xdg/stringprep v1.0.3 h1:cmL5Enob4W83ti/ZHuZLuKD/xqJfus4fVPwE+/BDm+4= +github.com/xdg/stringprep v1.0.3/go.mod h1:Jhud4/sHMO4oL310DaZAKk9ZaJ08SJfe+sJh0HrGL1Y= +github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU= +github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ= +github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y= +github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk= +go.opentelemetry.io/otel/sdk v1.7.0/go.mod h1:uTEOTwaqIVuTGiJN7ii13Ibp75wJmYUDe374q6cZwUU= +go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU= +go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-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-20220622213112-05595931fe9d/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4= +golang.org/x/crypto v0.2.0 h1:BRXPfhNivWL5Yq0BGQ39a2sW6t44aODpfxkWjYdzewE= +golang.org/x/crypto v0.2.0/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4= +golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= +golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= +golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= +golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= +golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.3.0/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-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-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/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-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-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.0.0-20210805182204-aaa1db679c0d/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= +golang.org/x/net v0.0.0-20220706163947-c90051bbdb60/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= +golang.org/x/net v0.2.0 h1:sZfSu1wtKLGlWI4ZZayP0ck9Y73K1ynO6gqzTdBVdPU= +golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= +golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= +golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= +golang.org/x/oauth2 v0.2.0 h1:GtQkldQ9m7yvzCL1V+LrYow3Khe0eJH0w7RbX/VbaIU= +golang.org/x/oauth2 v0.2.0/go.mod h1:Cwn6afJ8jrQwYMxQDTpISoXmXW9I6qF6vDeuuoX3Ibs= +golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/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-20220513210516-0976fa681c29/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/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-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210816074244-15123e1e1f71/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-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.2.0 h1:ljd4t30dBnAvMZaQCevtY0xLLD0A+bRZXbgLMLU1F/A= +golang.org/x/sys v0.2.0/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/term v0.2.0 h1:z85xZCsEl7bi/KwbNADeBYoOP0++7W1ipu+aGnpwzRM= +golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= +golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= +golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= +golang.org/x/text v0.3.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/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= +golang.org/x/text v0.4.0 h1:BrVqGRd7+k1DiOgtnFvAkoQEWQvBc25ouMJM6429SFg= +golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= +golang.org/x/time v0.2.0 h1:52I/1L54xyEQAYdtcSuxtiT84KGYTBGXwayxmIpNJhE= +golang.org/x/time v0.2.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= +golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= +golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= +golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190422233926-fe54fb35175b/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= +golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= +golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= +golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= +golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= +google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= +google.golang.org/appengine v1.6.7 h1:FZR1q0exgwxzPzp/aF+VccGrSfxfPpkBqjIIEq3ru6c= +google.golang.org/appengine v1.6.7/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-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= +google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= +google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= +google.golang.org/genproto v0.0.0-20220107163113-42d7afdf6368/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= +google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= +google.golang.org/genproto v0.0.0-20221111202108-142d8a6fa32e h1:azcyH5lGzGy7pkLCbhPe0KkKxsM7c6UA/FZIXImKE7M= +google.golang.org/genproto v0.0.0-20221111202108-142d8a6fa32e/go.mod h1:rZS5c/ZVYMaOGBfO68GWtjOw/eLaZM1X6iVtgjZ+EWg= +google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= +google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= +google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= +google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= +google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= +google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= +google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= +google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= +google.golang.org/grpc v1.50.1 h1:DS/BukOZWp8s6p4Dt/tOaJaTQyPyOoCcrjroHuCeLzY= +google.golang.org/grpc v1.50.1/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= +google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= +google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= +google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= +google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= +google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= +google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= +google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.27.1/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/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-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= +gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= +gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= +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.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-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= +k8s.io/api v0.25.4 h1:3YO8J4RtmG7elEgaWMb4HgmpS2CfY1QlaOz9nwB+ZSs= +k8s.io/api v0.25.4/go.mod h1:IG2+RzyPQLllQxnhzD8KQNEu4c4YvyDTpSMztf4A0OQ= +k8s.io/apimachinery v0.25.4 h1:CtXsuaitMESSu339tfhVXhQrPET+EiWnIY1rcurKnAc= +k8s.io/apimachinery v0.25.4/go.mod h1:jaF9C/iPNM1FuLl7Zuy5b9v+n35HGSh6AQ4HYRkCqwo= +k8s.io/client-go v0.25.4 h1:3RNRDffAkNU56M/a7gUfXaEzdhZlYhoW8dgViGy5fn8= +k8s.io/client-go v0.25.4/go.mod h1:8trHCAC83XKY0wsBIpbirZU4NTUpbuhc2JnI7OruGZw= +k8s.io/klog/v2 v2.80.1 h1:atnLQ121W371wYYFawwYx1aEY2eUfs4l3J72wtgAwV4= +k8s.io/klog/v2 v2.80.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= +k8s.io/kube-openapi v0.0.0-20221110221610-a28e98eb7c70 h1:zfqQc1V6/ZgGpvrOVvr62OjiqQX4lZjfznK34NQwkqw= +k8s.io/kube-openapi v0.0.0-20221110221610-a28e98eb7c70/go.mod h1:+Axhij7bCpeqhklhUTe3xmOn6bWxolyZEeyaFpjGtl4= +k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2 h1:GfD9OzL11kvZN5iArC6oTS7RTj7oJOIfnislxYlqTj8= +k8s.io/utils v0.0.0-20221108210102-8e77b1f39fe2/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= +sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2 h1:iXTIw73aPyC+oRdyqqvVJuloN1p0AC/kzH07hu3NE+k= +sigs.k8s.io/json v0.0.0-20220713155537-f223a00ba0e2/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= +sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= +sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= +sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= +sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/internal/biz/biz.go b/internal/biz/biz.go new file mode 100644 index 0000000..65924db --- /dev/null +++ b/internal/biz/biz.go @@ -0,0 +1,182 @@ +package biz + +import ( + "context" + gv1 "git.gz.internal.jumaiyx.cn/jm/jmproto/gift/v1" + v1 "git.gz.internal.jumaiyx.cn/jm/jmproto/room/v1" + "git.gz.internal.jumaiyx.cn/job/room-hot-compute/internal/data" + "git.gz.internal.jumaiyx.cn/job/room-hot-compute/internal/util" + jredis "git.gz.internal.jumaiyx.cn/job/room-hot-compute/pkg/redis" + "git.gz.internal.jumaiyx.cn/pkg/log" + "github.com/go-redis/redis/v8" + "github.com/google/wire" + "sync" + "time" +) + +const ( + NumberKey = "room:number:ranking" + HotKey = "room:hot:ranking" +) + +var wg sync.WaitGroup + +// ProviderBizSet is biz providers. +var ProviderBizSet = wire.NewSet(NewBiz) + +type hotData struct { + roomId int64 + number int64 + diamond int64 +} +type hot struct { + roomIds []int64 + list []*hotData +} + +type Biz struct { + log log.Logger + room v1.RoomClient + gift gv1.GiftClient + redis *jredis.Cache + + hotChan chan *hot + computeChan chan *hotData +} + +func NewBiz(logger log.Logger, roomServer v1.RoomClient, gift gv1.GiftClient, data *data.Data) *Biz { + return &Biz{ + log: logger, + room: roomServer, + gift: gift, + redis: data.Cache, + hotChan: make(chan *hot, 100), + computeChan: make(chan *hotData, 100), + } +} + +func (biz *Biz) Check(ctx context.Context) { + wg.Add(3) + // 获取去房间人数值 + go func() { + defer wg.Done() + biz.getScores(ctx) + }() + + // 获取房间开播时间 + // 获取房间消费数值 + go func() { + defer wg.Done() + biz.getRoomDiamond(ctx) + }() + + // 获取固定热度参数值 + + // 统计热点值 + //写入排序 + go func() { + defer wg.Done() + biz.statistics(ctx) + }() + + wg.Wait() +} + +func (biz *Biz) getScores(ctx context.Context) { + // 获取去房间人数值 + var ( + o int64 + ) + for { + l := o + 2 + scores, err := biz.redis.ZRevRangeWithScores(ctx, NumberKey, o, l) + if err != nil { + biz.log.Errorf("error:%v", err) + return + } + if len(scores) == 0 { + biz.log.Info("Get scores out") + return + } + var ( + ids []int64 + list []*hotData + ) + for _, score := range scores { + roomId := util.StringTarnsInt64(score.Member.(string)) + ids = append(ids, roomId) + list = append(list, &hotData{ + roomId: roomId, + number: util.Float64IncrTarnsInt64(score.Score), + }) + } + biz.hotChan <- &hot{ + roomIds: ids, + list: list, + } + o = l + 1 + } +} + +func (biz *Biz) getRoomDiamond(ctx context.Context) { + for { + select { + case h := <-biz.hotChan: + // 获取房间开播时间 + room, err := biz.room.ListRoom(ctx, &v1.ListRoomRequest{ + Status: 1, + Ids: h.roomIds, + }) + if err != nil { + biz.log.Errorf("error:%v", err) + return + } + roomNumber := make(map[int64]int64, len(h.list)) + for _, v := range h.list { + roomNumber[v.roomId] = v.number + } + for _, r := range room.Data { + // 获取房间消费数值 + startTime := util.TraStrToUnix(r.StartTime) + gift, err := biz.gift.QueryGiveRoomGift(ctx, &gv1.QueryGiveRoomGiftReq{ + Uid: 0, + RoomIdList: []int64{r.Id}, + CreateAtStart: &startTime, + }) + if err != nil { + biz.log.Errorf("error:%v", err) + continue + } + biz.computeChan <- &hotData{ + roomId: r.Id, + number: roomNumber[r.Id], + diamond: gift.TotalAmountDiamond, + } + } + case <-time.After(time.Second * 10): + biz.log.Info("Get room diamond out") + return + } + } +} + +// 实时人数 * 10 + 流水 * 10 - 自定义值 = 热播 +// 初始热度分 + 用户交互产生的热度分 – 随时间衰减的热度分 +func (biz *Biz) statistics(ctx context.Context) { + for { + select { + case h := <-biz.computeChan: + _, err := biz.redis.ZAdd(ctx, HotKey, &redis.Z{ + Member: h.roomId, + Score: float64(h.number*10 + h.diamond*10), + }) + if err != nil { + biz.log.Errorf("Set room hot ranking err:%v", err) + continue + } + case <-time.After(time.Second * 10): + biz.log.Info("Statistics out") + return + } + } +} diff --git a/internal/biz/biz_test.go b/internal/biz/biz_test.go new file mode 100644 index 0000000..5f51d8f --- /dev/null +++ b/internal/biz/biz_test.go @@ -0,0 +1,35 @@ +package biz + +import ( + "context" + "git.gz.internal.jumaiyx.cn/jm/jmproto/conf" + "git.gz.internal.jumaiyx.cn/job/room-hot-compute/internal/data" + "git.gz.internal.jumaiyx.cn/job/room-hot-compute/pkg/gift" + "git.gz.internal.jumaiyx.cn/job/room-hot-compute/pkg/room" + "git.gz.internal.jumaiyx.cn/pkg/log" + "testing" +) + +func TestNewBiz(t *testing.T) { + l := log.DefaultLogger() + roomServer, err := room.NewRoomService(l) + if err != nil { + t.Fatal(err) + } + giftServer, err := gift.NewGiftService(l) + c := &conf.Data{ + Redis: &conf.Data_Redis{ + Addr: "192.168.1.156:16378", + Password: "MM5ZsXL0", + ReadTimeout: 1, + WriteTimeout: 1, + }, + } + newData, _, err := data.NewData(c, l) + if err != nil { + t.Fatal(err) + } + biz := NewBiz(l, roomServer, giftServer, newData) + ctx := context.TODO() + biz.Check(ctx) +} diff --git a/internal/biz/configs/config b/internal/biz/configs/config new file mode 100644 index 0000000..2e8027a --- /dev/null +++ b/internal/biz/configs/config @@ -0,0 +1,19 @@ +apiVersion: v1 +clusters: +- cluster: + certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUN5RENDQWJDZ0F3SUJBZ0lCQURBTkJna3Foa2lHOXcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeU1Ea3lOekF4TXpRek9Wb1hEVE15TURreU5EQXhNelF6T1Zvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJ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0VSVElGSUNBVEUtLS0tLQo= + server: https://192.168.1.156:6443 + name: kubernetes +contexts: +- context: + cluster: kubernetes + user: kubernetes-admin + name: kubernetes-admin@kubernetes +current-context: kubernetes-admin@kubernetes +kind: Config +preferences: {} +users: +- name: kubernetes-admin + user: + client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM4akNDQWRxZ0F3SUJBZ0lJTFV6blJtKzZqUkV3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TWpBNU1qY3dNVE0wTXpsYUZ3MHlNekE1TWpjd01UTTBOREJhTURReApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sa3dGd1lEVlFRREV4QnJkV0psY201bGRHVnpMV0ZrCmJXbHVNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQTNYOFZrc2x3N3AxQUF3aG4KbW5nRHU3NWRUUUpXUm1EN014a3ZPN0ZiWFFXVTVHUDg3bHpEV2pMeUt2L1NqZTZ5a1VTTkE5Z21kTmRrOTY0RgpnYWpyRnRHSUZXVzM2NVFXeitRT25ZVWFHQk9VRHQ2VFloOWlSRXJIRjhsR3NRVW0vVi9NemttMXpkY284ZEtHCm5VbktDWDhyMW5yVm53UkRiRTE2VEozcFRhK2tXdmVHYlFoRW5PZHpBMkJFTDl3cWR4bUljNm1GMnFla0ZDVXoKMlF1cGtMR3JOMlBEVGd2YmdwcS9pbTdldUIyYXNLczE2RjByMElrMk83VHhoK2twZkQrazVTLzdUdTEyWGttVwpkNWIyZHlVMFlCZFZDRUJFV1JiK3ROU3oxQXlVdEZQbEkxRmdabWZaajdKRGFkYzlDMG9ML2hoOFA0UzU3NFlECnFjaEZxUUlEQVFBQm95Y3dKVEFPQmdOVkhROEJBZjhFQkFNQ0JhQXdFd1lEVlIwbEJBd3dDZ1lJS3dZQkJRVU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ZQkxMTnBGWHcyUXM0ZkloemFJbHYvdQpRN3k3L1FvNEdmUlE4Yzl4YlBHcjlMV1oyeTNqQWZ1ZlFjK3p5bmlrZml1T1ZCRmZZM0NRenAvUTUzQitLa0x0Cnk1SVMzZFA4eEF0NVl1TmE4WDBtSVFLQmdRQ2RBSkFaQlNGZi9yN05uVEJnY3M2MEo2cG55TW1BSitoSkN5WnoKYVpIUzgrOXl4SFhPaThQYlphdHhmMmJYQ2tEUFp2ZFk3MGErUEswTmJSdzhGUUZRbXF6ckFDVTNCOXJ5NDUraAplbkRXR0Racy9Rakd3QytYOHZNbUFvNHdBanhHbVJ2b01kWjFtN0RNbW1lTzZKQ1ZrNnNRd1BRclNVVk9PRGdVCmgyRWJNUUtCZ0RQamNEdjN6SjJJVjFrY01kbjNEMWVyQjBFR0I1M2NYeHFoa0pET3Rqd3RUV3V2dHNIYzI0R3gKNmFQODI1QllUV2NQNEJ6dEFIN1A5RkE2QmlBa0t3T3lrWFR5dDg2RTBUZUM5L3FtSW9EY255aHdReHVCZlB3UQo2bVhxeVFLZFBOTnVoKzlReDBEcGxHMTkzVTFid0pya3k3b3hKc0dackg1OUdGK3VTT3J0Ci0tLS0tRU5EIFJTQSBQUklWQVRFIEtFWS0tLS0tCg== \ No newline at end of file diff --git a/internal/biz/configs/config.yaml b/internal/biz/configs/config.yaml new file mode 100644 index 0000000..08ab35b --- /dev/null +++ b/internal/biz/configs/config.yaml @@ -0,0 +1,42 @@ +server: + name: room + http: + addr: 0.0.0.0:8000 + timeout: 30 + grpc: + addr: 0.0.0.0:9000 + timeout: 30 +data: + database: + source: "host=192.168.1.156 user=metachat password=metachat dbname=feedback port=15433 sslmode=disable TimeZone=Asia/Shanghai" +# source: postgresql://metachat:metachat@127.0.0.1:15432/room + redis: + addr: 192.168.1.156:16378 + password: MM5ZsXL0 + read_timeout: 1 + write_timeout: 1 + +etcd: + host: "127.0.0.1:20000" + +log: + level: "debug" + name: "room" + kafka: + addr: + - "127.0.0.1:9092" +amqp: + host: 192.168.1.156:5672 + username: jm + password: jm123456 + +id_encode: + uid: + salt: "test" + min_length: 8 + +rtctoken: + app_id: 6eeb2e6be9a141d1b0db920f36a5a9f3 + app_certificate: 80438856882e4563841d56f3cefeb763 + privilege_expiration: 3600 + token_expiration: 3600 \ No newline at end of file diff --git a/internal/data/data.go b/internal/data/data.go new file mode 100644 index 0000000..98052df --- /dev/null +++ b/internal/data/data.go @@ -0,0 +1,24 @@ +package data + +import ( + "git.gz.internal.jumaiyx.cn/jm/jmproto/conf" + jredis "git.gz.internal.jumaiyx.cn/job/room-hot-compute/pkg/redis" + "git.gz.internal.jumaiyx.cn/pkg/log" + "github.com/google/wire" +) + +var ProviderDataSet = wire.NewSet(NewData) + +type Data struct { + Cache *jredis.Cache +} + +func NewData(c *conf.Data, log log.Logger) (*Data, func(), error) { + cleanup := func() { + log.Info("closing the data resources") + } + cache := jredis.NewCache(log, c.Redis) + return &Data{ + Cache: cache, // redis + }, cleanup, nil +} diff --git a/internal/util/time.go b/internal/util/time.go new file mode 100644 index 0000000..bc57547 --- /dev/null +++ b/internal/util/time.go @@ -0,0 +1,22 @@ +package util + +import "time" + +// GetNowYmdHms 获取当前datetime +func GetNowYmdHms() string { + return time.Now().Format("2006-01-02 15:04:05") +} + +// GetNowUnix 获取当前时间戳 +func GetNowUnix() int64 { + return time.Now().Unix() +} + +func TraTime(t time.Time) int64 { + return t.Unix() +} + +func TraStrToUnix(val string) int64 { + t, _ := time.ParseInLocation("2006-01-02 15:04:05", val, time.Local) + return t.Unix() +} diff --git a/internal/util/transform.go b/internal/util/transform.go new file mode 100644 index 0000000..d489b30 --- /dev/null +++ b/internal/util/transform.go @@ -0,0 +1,52 @@ +package util + +import ( + "math" + "strconv" +) + +func IntTransString(i int) string { + return strconv.Itoa(i) +} + +func Int32TarnsString(i int32) string { + return IntTransString(int(i)) +} + +func Int64TarnsString(i int64) string { + return IntTransString(int(i)) +} + +func StringTarnsInt(s string) int { + i, _ := strconv.Atoi(s) + return i +} + +func StringTarnsInt64(s string) int64 { + return int64(StringTarnsInt(s)) +} + +// Float64TarnsInt float64转int +func Float64TarnsInt(i float64) int { + return int(i) +} + +// Float64IncrTarnsInt float64 向上递增转int +func Float64IncrTarnsInt(i float64) int { + return int(math.Ceil(i)) +} + +// Float64DecrTarnsInt float64 向下递增转int +func Float64DecrTarnsInt(i float64) int { + return int(math.Floor(i)) +} + +// Float64IncrTarnsInt32 float64 向上递增转int32 +func Float64IncrTarnsInt32(i float64) int32 { + return int32(Float64IncrTarnsInt(i)) +} + +// Float64IncrTarnsInt64 float64 向上递增转int32 +func Float64IncrTarnsInt64(i float64) int64 { + return int64(Float64IncrTarnsInt(i)) +} diff --git a/job.yaml b/job.yaml new file mode 100644 index 0000000..5838b46 --- /dev/null +++ b/job.yaml @@ -0,0 +1,44 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: feedback-deployment + namespace: dev + labels: + app: feedback +spec: + replicas: 2 # 节点资源 + selector: + matchLabels: + app: feedback + template: + metadata: # 资源的元数据/属性 + labels: # 设定资源的标签 + app: feedback + spec: + containers: + - image: registry.internal.jumaiyx.cn/jm/feedback:1 # 自动化版本往后配置 + name: feedback + imagePullPolicy: Always + ports: + - name: grpc + containerPort: 9000 + protocol: TCP + imagePullSecrets: + - name: registry-harbor +--- +apiVersion: v1 +kind: Service +metadata: + name: feedback-service # 改名字对应服务发现serviceName + namespace: dev + labels: + name: feedback +spec: + type: ClusterIP + ports: + - name: grpc + port: 9000 + targetPort: grpc + protocol: TCP + selector: + app: feedback \ No newline at end of file diff --git a/pkg/gift/gift.go b/pkg/gift/gift.go new file mode 100644 index 0000000..b35a4ae --- /dev/null +++ b/pkg/gift/gift.go @@ -0,0 +1,18 @@ +package gift + +import ( + "context" + v1 "git.gz.internal.jumaiyx.cn/jm/jmproto/gift/v1" + k8s_client "git.gz.internal.jumaiyx.cn/pkg/k8s-client" + "git.gz.internal.jumaiyx.cn/pkg/kubediscovery" + "git.gz.internal.jumaiyx.cn/pkg/log" +) + +func NewGiftService(log log.Logger) (v1.GiftClient, error) { + discovery, err := kubediscovery.Discovery(context.TODO(), log, "gift-service", kubediscovery.Namespace(k8s_client.DevNamespace)) + if err != nil { + log.Errorf("Connect room service failed:%v", err) + return nil, err + } + return v1.NewGiftClient(discovery), nil +} diff --git a/pkg/pkg.go b/pkg/pkg.go new file mode 100644 index 0000000..89d7535 --- /dev/null +++ b/pkg/pkg.go @@ -0,0 +1,9 @@ +package pkg + +import ( + "git.gz.internal.jumaiyx.cn/job/room-hot-compute/pkg/gift" + "git.gz.internal.jumaiyx.cn/job/room-hot-compute/pkg/room" + "github.com/google/wire" +) + +var ProviderPkgSet = wire.NewSet(room.NewRoomService, gift.NewGiftService) diff --git a/pkg/redis/redis.go b/pkg/redis/redis.go new file mode 100644 index 0000000..9b0d47b --- /dev/null +++ b/pkg/redis/redis.go @@ -0,0 +1,196 @@ +package jredis + +import ( + "context" + "git.gz.internal.jumaiyx.cn/jm/jmproto/conf" + "git.gz.internal.jumaiyx.cn/pkg/log" + "github.com/go-redis/redis/v8" + "github.com/pkg/errors" + "time" +) + +// todo 往后封包 +const ( + NullString = "" +) + +type Cache struct { + log log.Logger + client *redis.Client +} + +func NewCache(log log.Logger, c *conf.Data_Redis) *Cache { + client := redis.NewClient(&redis.Options{ + Network: c.Network, + Addr: c.Addr, + Password: c.Password, + PoolSize: 10, + }) + return &Cache{ + log: log, + client: client, + } +} + +func (rdb Cache) Get(ctx context.Context, key string) (string, error) { + val, err := rdb.client.Get(ctx, key).Result() + if err != nil { + if errors.Is(err, redis.Nil) { + return NullString, nil + } + rdb.log.Errorf("redis cache get err:%v", err) + return NullString, err + } + return val, nil +} + +func (rdb Cache) Set(ctx context.Context, key string, value interface{}) error { + err := rdb.client.Set(ctx, key, value, 0).Err() + if err != nil { + rdb.log.Errorf("redis cache set err:%v", err) + return err + } + return nil +} + +func (rdb Cache) Incr(ctx context.Context, key string) (int64, error) { + result, err := rdb.client.Incr(ctx, key).Result() + if err != nil { + rdb.log.Errorf("redis cache incr err:%v", err) + return result, err + } + return result, nil +} + +func (rdb Cache) Decr(ctx context.Context, key string) (int64, error) { + result, err := rdb.client.Decr(ctx, key).Result() + if err != nil { + rdb.log.Errorf("redis cache decr err:%v", err) + return result, err + } + return result, nil +} + +func (rdb Cache) SetExp(ctx context.Context, key string, value interface{}, exp time.Duration) error { + err := rdb.client.Set(ctx, key, value, exp).Err() + if err != nil { + rdb.log.Errorf("redis cache set exp err:%v", err) + return err + } + return nil +} + +func (rdb Cache) Del(ctx context.Context, key string) error { + _, err := rdb.client.Del(ctx, key).Result() + if err != nil { + rdb.log.Errorf("redis del err:%v", err) + return err + } + return nil +} + +func (rdb Cache) ZAdd(ctx context.Context, key string, z *redis.Z) (int64, error) { + result, err := rdb.client.ZAdd(ctx, key, z).Result() + if err != nil { + rdb.log.Errorf("redis cache zadd err:%v", err) + return 0, err + } + return result, err +} + +func (rdb Cache) ZIncrBy(ctx context.Context, key string, member string, incr float64) error { + _, err := rdb.client.ZIncrBy(ctx, key, incr, member).Result() + if err != nil { + rdb.log.Errorf("redis cache zadd err:%v", err) + return err + } + return err +} + +func (rdb Cache) ZRange(ctx context.Context, key string, tart, stop int64) ([]string, error) { + result, err := rdb.client.ZRange(ctx, key, tart, stop).Result() + if err != nil { + rdb.log.Errorf("redis cache zrange err:%v", err) + return nil, err + } + return result, nil +} + +func (rdb Cache) ZRevRange(ctx context.Context, key string, tart, stop int64) ([]string, error) { + result, err := rdb.client.ZRevRange(ctx, key, tart, stop).Result() + if err != nil { + rdb.log.Errorf("redis cache ZRevRange err:%v", err) + return nil, err + } + return result, nil +} + +func (rdb Cache) ZRevRangeWithScores(ctx context.Context, key string, tart, stop int64) ([]redis.Z, error) { + result, err := rdb.client.ZRevRangeWithScores(ctx, key, tart, stop).Result() + if err != nil { + rdb.log.Errorf("redis cache ZRevRange err:%v", err) + return nil, err + } + return result, nil +} + +func (rdb Cache) ZRem(ctx context.Context, key string, number string) error { + _, err := rdb.client.ZRem(ctx, key, number).Result() + if err != nil { + rdb.log.Errorf("Redis cache ZRem err:%v", err) + return err + } + return nil +} + +func (rdb Cache) ZScore(ctx context.Context, key string, number string) (float64, error) { + result, err := rdb.client.ZScore(ctx, key, number).Result() + if err != nil { + rdb.log.Errorf("Redis cache ZScore err:%v", err) + return 0, err + } + return result, nil +} + +func (rdb Cache) HSet(ctx context.Context, hkey string, key, value interface{}) error { + _, err := rdb.client.HSet(ctx, hkey, key, value).Result() + if err != nil { + rdb.log.Errorf("redis cache hset err:%v", err) + return err + } + return nil +} + +func (rdb Cache) HSetExp(ctx context.Context, hkey string, key, value interface{}, duration time.Duration) error { + err := rdb.client.HSet(ctx, hkey, key).Err() + if err != nil { + rdb.log.Errorf("redis cache hset Expire err:%v", err) + return err + } + + err = rdb.client.Expire(ctx, hkey, duration).Err() + if err != nil { + rdb.log.Errorf("redis cache hset Expire err:%v", err) + return err + } + + return nil +} + +func (rdb Cache) HGet(ctx context.Context, hkey string, key string) (string, error) { + result, err := rdb.client.HGet(ctx, hkey, key).Result() + if err != nil { + rdb.log.Errorf("redis cache hset Expire err:%v", err) + return "", err + } + return result, err +} + +func (rdb Cache) HKeys(ctx context.Context, hkey string) ([]string, error) { + result, err := rdb.client.HKeys(ctx, hkey).Result() + if err != nil { + rdb.log.Errorf("Get Redis cache hkeys err:%v", err) + return nil, err + } + return result, nil +} diff --git a/pkg/room/room.go b/pkg/room/room.go new file mode 100644 index 0000000..ed71d44 --- /dev/null +++ b/pkg/room/room.go @@ -0,0 +1,18 @@ +package room + +import ( + "context" + v1 "git.gz.internal.jumaiyx.cn/jm/jmproto/room/v1" + k8s_client "git.gz.internal.jumaiyx.cn/pkg/k8s-client" + "git.gz.internal.jumaiyx.cn/pkg/kubediscovery" + "git.gz.internal.jumaiyx.cn/pkg/log" +) + +func NewRoomService(log log.Logger) (v1.RoomClient, error) { + discovery, err := kubediscovery.Discovery(context.TODO(), log, "room-service", kubediscovery.Namespace(k8s_client.DevNamespace)) + if err != nil { + log.Errorf("Connect room service failed:%v", err) + return nil, err + } + return v1.NewRoomClient(discovery), nil +}