feat push可以不传id
All checks were successful
Build image / build (push) Successful in 1m21s

This commit is contained in:
timerzz 2024-11-29 21:53:59 +08:00
parent 6ad89f3a33
commit c16e02a7ea
19 changed files with 124 additions and 80 deletions

View File

@ -2,7 +2,7 @@ package service
import (
"context"
"fmt"
push "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push"
"gitea.timerzz.com/kedaya_haitao/pusher/pushers"
)
@ -17,9 +17,6 @@ func NewPushService(ctx context.Context) *PushService {
// Run create note info
func (s *PushService) Run(req *push.PushReq) (resp *push.Resp, err error) {
// Finish your business logic.
if len(req.Ids) == 0 {
return nil, fmt.Errorf("缺少id")
}
resp = push.NewResp()
err = pushers.Push(s.ctx, req.Ids, req.Title, req.Content)
if err != nil {

7
build.sh Normal file
View File

@ -0,0 +1,7 @@
#!/usr/bin/env bash
RUN_NAME="pusher"
mkdir -p output/bin output/conf
cp script/* output/
cp -r conf/* output/conf
chmod +x output/bootstrap.sh
go build -o output/bin/${RUN_NAME}

15
docker-compose.yaml Normal file
View File

@ -0,0 +1,15 @@
version: '3'
services:
mysql:
image: 'mysql:latest'
ports:
- 3306:3306
environment:
- MYSQL_DATABASE=gorm
- MYSQL_USER=gorm
- MYSQL_PASSWORD=gorm
- MYSQL_RANDOM_ROOT_PASSWORD="yes"
redis:
image: 'redis:latest'
ports:
- 6379:6379

8
go.mod
View File

@ -11,11 +11,11 @@ require (
github.com/cloudwego/kitex v0.9.1
github.com/go-resty/resty/v2 v2.13.1
github.com/kitex-contrib/obs-opentelemetry/logging/logrus v0.0.0-20240515092919-1f776656cb66
github.com/kitex-contrib/resolver-dns v0.0.0-20211026091019-d57feaffb777
github.com/kr/pretty v0.3.0
github.com/wneessen/go-mail v0.4.1
go.uber.org/zap v1.27.0
golang.org/x/sync v0.1.0
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f
golang.org/x/sync v0.9.0
gopkg.in/natefinch/lumberjack.v2 v2.0.0
gopkg.in/validator.v2 v2.0.1
gopkg.in/yaml.v2 v2.3.0
@ -39,7 +39,7 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/google/pprof v0.0.0-20220608213341-c488b8fa1db3 // indirect
github.com/henrylee2cn/ameda v1.4.10 // indirect
github.com/henrylee2cn/goutil v0.0.0-20210127050712-89660552f6f8 // indirect
@ -75,6 +75,6 @@ require (
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384 // indirect
google.golang.org/protobuf v1.28.1 // indirect
google.golang.org/protobuf v1.33.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)

29
go.sum
View File

@ -5,7 +5,6 @@ git.sr.ht/~sbinet/gg v0.3.1/go.mod h1:KGYtlADtqsqANL9ueOFkWymvzUvLMQllU5Ixo+8v3p
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
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/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY=
github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk=
github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=
@ -17,8 +16,6 @@ github.com/boombuler/barcode v1.0.1/go.mod h1:paBWMcWSl3LHKBqUq+rly7CNSldXjb2rDl
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-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=
@ -37,7 +34,6 @@ github.com/bytedance/sonic v1.10.2/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf5
github.com/bytedance/sonic v1.11.2 h1:ywfwo0a/3j9HR8wsYGWsIWl2mvRsI950HyoxiBERw5A=
github.com/bytedance/sonic v1.11.2/go.mod h1:iZcSUejdk5aukTND/Eu/ivjQuEL0Cu9/rf50Hi0u/g4=
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/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
github.com/chenzhuoyu/base64x v0.0.0-20230717121745-296ad89f973d h1:77cEq6EriyTZ0g/qfRdp61a3Uu/AWrgIq2s0ClJV1g0=
@ -70,7 +66,6 @@ github.com/cloudwego/frugal v0.1.14 h1:vkjQMb5OsPL779RfMdLI4YJZsOH8fR0ewJpTuAVSe
github.com/cloudwego/frugal v0.1.14/go.mod h1:zFBA63ne4+Tz4qayRZFZf+ZVwGqTzb+1Xe3ZDCq+Wfc=
github.com/cloudwego/hertz v0.9.0 h1:vmgSMSBx3qgB+ZnqbuEwfy+BFMS1cMr1ZSddif9zZ3A=
github.com/cloudwego/hertz v0.9.0/go.mod h1:WliNtVbwihWHHgAaIQEbVXl0O3aWj0ks1eoPrcEAnjs=
github.com/cloudwego/kitex v0.0.1/go.mod h1:NTTu8szFfMKY9pxa7JmI/4FZpD15p5YUHLTYMqsXj9o=
github.com/cloudwego/kitex v0.3.2/go.mod h1:/XD07VpUD9VQWmmoepASgZ6iw//vgWikVA9MpzLC5i0=
github.com/cloudwego/kitex v0.4.4/go.mod h1:3FcH5h9Qw+dhRljSzuGSpWuThttA8DvK0BsL7HUYydo=
github.com/cloudwego/kitex v0.6.1/go.mod h1:zI1GBrjT0qloTikcCfQTgxg3Ws+yQMyaChEEOcGNUvA=
@ -78,15 +73,12 @@ github.com/cloudwego/kitex v0.9.1 h1:4Rkmngk4b5nHQ6sPM9BNgnW5cb9niB7hzzQBkkfa8/s
github.com/cloudwego/kitex v0.9.1/go.mod h1:CBMfRKBuZ9EeSEfeoveC7cR6JG4lY1Bpo+d0Eb7zUDA=
github.com/cloudwego/localsession v0.0.2 h1:N9/IDtCPj1fCL9bCTP+DbXx3f40YjVYWcwkJG0YhQkY=
github.com/cloudwego/localsession v0.0.2/go.mod h1:kiJxmvAcy4PLgKtEnPS5AXed3xCiXcs7Z+KBHP72Wv8=
github.com/cloudwego/netpoll v0.0.2/go.mod h1:rZOiNI0FYjuvNybXKKhAPUja03loJi/cdv2F55AE6E8=
github.com/cloudwego/netpoll v0.2.4/go.mod h1:1T2WVuQ+MQw6h6DpE45MohSvDTKdy2DlzCx2KsnPI4E=
github.com/cloudwego/netpoll v0.3.1/go.mod h1:1T2WVuQ+MQw6h6DpE45MohSvDTKdy2DlzCx2KsnPI4E=
github.com/cloudwego/netpoll v0.4.0/go.mod h1:xVefXptcyheopwNDZjDPcfU6kIjZXZ4nY550k1yH9eQ=
github.com/cloudwego/netpoll v0.5.0/go.mod h1:xVefXptcyheopwNDZjDPcfU6kIjZXZ4nY550k1yH9eQ=
github.com/cloudwego/netpoll v0.6.0 h1:JRMkrA1o8k/4quxzg6Q1XM+zIhwZsyoWlq6ef+ht31U=
github.com/cloudwego/netpoll v0.6.0/go.mod h1:xVefXptcyheopwNDZjDPcfU6kIjZXZ4nY550k1yH9eQ=
github.com/cloudwego/netpoll-http2 v0.0.4/go.mod h1:iFr5SzJCXIYgBg0ubL0fZiCQ6W36s9p0KjXpV04lmoY=
github.com/cloudwego/thriftgo v0.0.1/go.mod h1:LzeafuLSiHA9JTiWC8TIMIq64iadeObgRUhmVG1OC/w=
github.com/cloudwego/thriftgo v0.1.2/go.mod h1:LzeafuLSiHA9JTiWC8TIMIq64iadeObgRUhmVG1OC/w=
github.com/cloudwego/thriftgo v0.2.4/go.mod h1:8i9AF5uDdWHGqzUhXDlubCjx4MEfKvWXGQlMWyR0tM4=
github.com/cloudwego/thriftgo v0.2.7/go.mod h1:8i9AF5uDdWHGqzUhXDlubCjx4MEfKvWXGQlMWyR0tM4=
@ -142,8 +134,9 @@ github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvq
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.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/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek=
github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps=
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=
@ -151,8 +144,8 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
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.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/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
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=
@ -182,7 +175,6 @@ github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkr
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
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/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
@ -193,8 +185,6 @@ github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
github.com/kitex-contrib/obs-opentelemetry/logging/logrus v0.0.0-20240515092919-1f776656cb66 h1:KHEWSTCleXom38JQodofbpY7HNR2KQ4+ypIurCPFy/A=
github.com/kitex-contrib/obs-opentelemetry/logging/logrus v0.0.0-20240515092919-1f776656cb66/go.mod h1:naiLX9zwKBzVA41wtvvmtSZdbCihqIT9RnOb8GZv8A4=
github.com/kitex-contrib/resolver-dns v0.0.0-20211026091019-d57feaffb777 h1:6JvDKwiRu956wMwRnQxNN2dv5NjEwkNOJWv69esLHuQ=
github.com/kitex-contrib/resolver-dns v0.0.0-20211026091019-d57feaffb777/go.mod h1:ow1HHTsbb0CCAF2f8DAgdI5dZ2Ws3OZBTNjBq7yigIw=
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
github.com/klauspost/cpuid/v2 v2.1.0/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
@ -240,7 +230,6 @@ github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d h1:zE9ykE
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4 h1:fv0U8FUIMPNf1L9lnHLvLhgicrIVChEkdzIKYqbNC9s=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
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/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
@ -302,7 +291,6 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/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-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
@ -314,6 +302,8 @@ golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL
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-20191002040644-a1355ae1e2c3/go.mod h1:NOZ3BPKG0ec/BKJQgnvsSFpcKLM5xXVWnvZS97DWHgE=
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo=
golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak=
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=
@ -372,8 +362,9 @@ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.1.0 h1:wsuoTGHzEhffawBOhz5CYhcrV4IdKZbEyZjBMuTp12o=
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ=
golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
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-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
@ -387,7 +378,6 @@ golang.org/x/sys v0.0.0-20210304124612-50617c2ba197/go.mod h1:h1NjWce9XRLGQEsW7w
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-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-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
@ -489,8 +479,9 @@ google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp0
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=
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
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-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=

View File

@ -1,7 +1,7 @@
include "config.thrift"
struct PushReq {
1: required list<i64> ids (api.body="ids");
1: list<i64> ids (api.body="ids");
2: required string title (api.body="title");
3: required string content (api.body="content");
}

View File

@ -1,4 +1,4 @@
// Code generated by thriftgo (0.3.12). DO NOT EDIT.
// Code generated by thriftgo (0.3.18). DO NOT EDIT.
package config
@ -66,7 +66,6 @@ func NewPusherConfig() *PusherConfig {
}
func (p *PusherConfig) InitDefault() {
*p = PusherConfig{}
}
func (p *PusherConfig) GetId() (v int64) {
@ -299,6 +298,7 @@ func (p *PusherConfig) ReadField6(iprot thrift.TProtocol) error {
}
func (p *PusherConfig) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("PusherConfig"); err != nil {
goto WriteStructBeginError
@ -537,7 +537,6 @@ func NewPusherOption() *PusherOption {
}
func (p *PusherOption) InitDefault() {
*p = PusherOption{}
}
func (p *PusherOption) GetTitle() (v string) {
@ -670,6 +669,7 @@ func (p *PusherOption) ReadField3(iprot thrift.TProtocol) error {
values := make([]FormItem, size)
for i := 0; i < size; i++ {
_elem := &values[i]
_elem.InitDefault()
if err := _elem.Read(iprot); err != nil {
return err
@ -685,6 +685,7 @@ func (p *PusherOption) ReadField3(iprot thrift.TProtocol) error {
}
func (p *PusherOption) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("PusherOption"); err != nil {
goto WriteStructBeginError
@ -844,7 +845,6 @@ func NewFormItem() *FormItem {
}
func (p *FormItem) InitDefault() {
*p = FormItem{}
}
func (p *FormItem) GetParam() (v string) {
@ -981,6 +981,7 @@ func (p *FormItem) ReadField3(iprot thrift.TProtocol) error {
}
func (p *FormItem) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("FormItem"); err != nil {
goto WriteStructBeginError
@ -1125,7 +1126,6 @@ func NewAnPush() *AnPush {
}
func (p *AnPush) InitDefault() {
*p = AnPush{}
}
func (p *AnPush) GetToken() (v string) {
@ -1235,6 +1235,7 @@ func (p *AnPush) ReadField2(iprot thrift.TProtocol) error {
}
func (p *AnPush) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("AnPush"); err != nil {
goto WriteStructBeginError
@ -1352,7 +1353,6 @@ func NewEmailPush() *EmailPush {
}
func (p *EmailPush) InitDefault() {
*p = EmailPush{}
}
func (p *EmailPush) GetFrom() (v string) {
@ -1570,6 +1570,7 @@ func (p *EmailPush) ReadField6(iprot thrift.TProtocol) error {
}
func (p *EmailPush) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("EmailPush"); err != nil {
goto WriteStructBeginError

View File

@ -1,4 +1,4 @@
// Code generated by Kitex v0.9.0. DO NOT EDIT.
// Code generated by Kitex v0.9.1. DO NOT EDIT.
package config

View File

@ -1,4 +1,4 @@
// Code generated by Kitex v0.9.0. DO NOT EDIT.
// Code generated by Kitex v0.9.1. DO NOT EDIT.
package push
@ -32,7 +32,6 @@ func (p *PushReq) FastRead(buf []byte) (int, error) {
var l int
var fieldTypeId thrift.TType
var fieldId int16
var issetIds bool = false
var issetTitle bool = false
var issetContent bool = false
_, l, err = bthrift.Binary.ReadStructBegin(buf)
@ -58,7 +57,6 @@ func (p *PushReq) FastRead(buf []byte) (int, error) {
if err != nil {
goto ReadFieldError
}
issetIds = true
} else {
l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
offset += l
@ -116,11 +114,6 @@ func (p *PushReq) FastRead(buf []byte) (int, error) {
goto ReadStructEndError
}
if !issetIds {
fieldId = 1
goto RequiredFieldNotSetError
}
if !issetTitle {
fieldId = 2
goto RequiredFieldNotSetError

View File

@ -1,4 +1,4 @@
// Code generated by thriftgo (0.3.12). DO NOT EDIT.
// Code generated by thriftgo (0.3.18). DO NOT EDIT.
package push
@ -11,7 +11,7 @@ import (
)
type PushReq struct {
Ids []int64 `thrift:"ids,1,required" frugal:"1,required,list<i64>" json:"ids"`
Ids []int64 `thrift:"ids,1" frugal:"1,default,list<i64>" json:"ids"`
Title string `thrift:"title,2,required" frugal:"2,required,string" json:"title"`
Content string `thrift:"content,3,required" frugal:"3,required,string" json:"content"`
}
@ -21,7 +21,6 @@ func NewPushReq() *PushReq {
}
func (p *PushReq) InitDefault() {
*p = PushReq{}
}
func (p *PushReq) GetIds() (v []int64) {
@ -55,7 +54,6 @@ func (p *PushReq) Read(iprot thrift.TProtocol) (err error) {
var fieldTypeId thrift.TType
var fieldId int16
var issetIds bool = false
var issetTitle bool = false
var issetContent bool = false
@ -78,7 +76,6 @@ func (p *PushReq) Read(iprot thrift.TProtocol) (err error) {
if err = p.ReadField1(iprot); err != nil {
goto ReadFieldError
}
issetIds = true
} else if err = iprot.Skip(fieldTypeId); err != nil {
goto SkipFieldError
}
@ -113,11 +110,6 @@ func (p *PushReq) Read(iprot thrift.TProtocol) (err error) {
goto ReadStructEndError
}
if !issetIds {
fieldId = 1
goto RequiredFieldNotSetError
}
if !issetTitle {
fieldId = 2
goto RequiredFieldNotSetError
@ -192,6 +184,7 @@ func (p *PushReq) ReadField3(iprot thrift.TProtocol) error {
}
func (p *PushReq) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("PushReq"); err != nil {
goto WriteStructBeginError
@ -351,7 +344,6 @@ func NewResp() *Resp {
}
func (p *Resp) InitDefault() {
*p = Resp{}
}
func (p *Resp) GetCode() (v int64) {
@ -496,6 +488,7 @@ func (p *Resp) ReadField3(iprot thrift.TProtocol) error {
}
func (p *Resp) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("Resp"); err != nil {
goto WriteStructBeginError
@ -646,11 +639,8 @@ func NewListPusherRequest() *ListPusherRequest {
}
func (p *ListPusherRequest) InitDefault() {
*p = ListPusherRequest{
Page: 10,
Size: 1,
}
p.Page = 10
p.Size = 1
}
func (p *ListPusherRequest) GetKeyword() (v string) {
@ -832,6 +822,7 @@ func (p *ListPusherRequest) ReadField4(iprot thrift.TProtocol) error {
}
func (p *ListPusherRequest) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("ListPusherRequest"); err != nil {
goto WriteStructBeginError
@ -1011,7 +1002,6 @@ func NewListPusherResponse() *ListPusherResponse {
}
func (p *ListPusherResponse) InitDefault() {
*p = ListPusherResponse{}
}
func (p *ListPusherResponse) GetTotal() (v int64) {
@ -1117,6 +1107,7 @@ func (p *ListPusherResponse) ReadField2(iprot thrift.TProtocol) error {
values := make([]config.PusherConfig, size)
for i := 0; i < size; i++ {
_elem := &values[i]
_elem.InitDefault()
if err := _elem.Read(iprot); err != nil {
return err
@ -1132,6 +1123,7 @@ func (p *ListPusherResponse) ReadField2(iprot thrift.TProtocol) error {
}
func (p *ListPusherResponse) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("ListPusherResponse"); err != nil {
goto WriteStructBeginError
@ -1258,7 +1250,6 @@ func NewGetPusherOptionsResponse() *GetPusherOptionsResponse {
}
func (p *GetPusherOptionsResponse) InitDefault() {
*p = GetPusherOptionsResponse{}
}
func (p *GetPusherOptionsResponse) GetOptions() (v []*config.PusherOption) {
@ -1337,6 +1328,7 @@ func (p *GetPusherOptionsResponse) ReadField1(iprot thrift.TProtocol) error {
values := make([]config.PusherOption, size)
for i := 0; i < size; i++ {
_elem := &values[i]
_elem.InitDefault()
if err := _elem.Read(iprot); err != nil {
return err
@ -1352,6 +1344,7 @@ func (p *GetPusherOptionsResponse) ReadField1(iprot thrift.TProtocol) error {
}
func (p *GetPusherOptionsResponse) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("GetPusherOptionsResponse"); err != nil {
goto WriteStructBeginError
@ -1755,7 +1748,6 @@ func NewPushServicePushArgs() *PushServicePushArgs {
}
func (p *PushServicePushArgs) InitDefault() {
*p = PushServicePushArgs{}
}
var PushServicePushArgs_Req_DEFAULT *PushReq
@ -1844,6 +1836,7 @@ func (p *PushServicePushArgs) ReadField1(iprot thrift.TProtocol) error {
}
func (p *PushServicePushArgs) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("Push_args"); err != nil {
goto WriteStructBeginError
@ -1925,7 +1918,6 @@ func NewPushServicePushResult() *PushServicePushResult {
}
func (p *PushServicePushResult) InitDefault() {
*p = PushServicePushResult{}
}
var PushServicePushResult_Success_DEFAULT *Resp
@ -2014,6 +2006,7 @@ func (p *PushServicePushResult) ReadField0(iprot thrift.TProtocol) error {
}
func (p *PushServicePushResult) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("Push_result"); err != nil {
goto WriteStructBeginError
@ -2097,7 +2090,6 @@ func NewPushServiceAddArgs() *PushServiceAddArgs {
}
func (p *PushServiceAddArgs) InitDefault() {
*p = PushServiceAddArgs{}
}
var PushServiceAddArgs_Req_DEFAULT *config.PusherConfig
@ -2186,6 +2178,7 @@ func (p *PushServiceAddArgs) ReadField1(iprot thrift.TProtocol) error {
}
func (p *PushServiceAddArgs) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("Add_args"); err != nil {
goto WriteStructBeginError
@ -2267,7 +2260,6 @@ func NewPushServiceAddResult() *PushServiceAddResult {
}
func (p *PushServiceAddResult) InitDefault() {
*p = PushServiceAddResult{}
}
var PushServiceAddResult_Success_DEFAULT *Resp
@ -2356,6 +2348,7 @@ func (p *PushServiceAddResult) ReadField0(iprot thrift.TProtocol) error {
}
func (p *PushServiceAddResult) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("Add_result"); err != nil {
goto WriteStructBeginError
@ -2439,7 +2432,6 @@ func NewPushServiceListArgs() *PushServiceListArgs {
}
func (p *PushServiceListArgs) InitDefault() {
*p = PushServiceListArgs{}
}
var PushServiceListArgs_Req_DEFAULT *ListPusherRequest
@ -2528,6 +2520,7 @@ func (p *PushServiceListArgs) ReadField1(iprot thrift.TProtocol) error {
}
func (p *PushServiceListArgs) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("List_args"); err != nil {
goto WriteStructBeginError
@ -2609,7 +2602,6 @@ func NewPushServiceListResult() *PushServiceListResult {
}
func (p *PushServiceListResult) InitDefault() {
*p = PushServiceListResult{}
}
var PushServiceListResult_Success_DEFAULT *ListPusherResponse
@ -2698,6 +2690,7 @@ func (p *PushServiceListResult) ReadField0(iprot thrift.TProtocol) error {
}
func (p *PushServiceListResult) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("List_result"); err != nil {
goto WriteStructBeginError
@ -2780,7 +2773,6 @@ func NewPushServiceGetPusherOptionsArgs() *PushServiceGetPusherOptionsArgs {
}
func (p *PushServiceGetPusherOptionsArgs) InitDefault() {
*p = PushServiceGetPusherOptionsArgs{}
}
var fieldIDToName_PushServiceGetPusherOptionsArgs = map[int16]string{}
@ -2828,6 +2820,7 @@ ReadStructEndError:
}
func (p *PushServiceGetPusherOptionsArgs) Write(oprot thrift.TProtocol) (err error) {
if err = oprot.WriteStructBegin("GetPusherOptions_args"); err != nil {
goto WriteStructBeginError
}
@ -2874,7 +2867,6 @@ func NewPushServiceGetPusherOptionsResult() *PushServiceGetPusherOptionsResult {
}
func (p *PushServiceGetPusherOptionsResult) InitDefault() {
*p = PushServiceGetPusherOptionsResult{}
}
var PushServiceGetPusherOptionsResult_Success_DEFAULT *GetPusherOptionsResponse
@ -2963,6 +2955,7 @@ func (p *PushServiceGetPusherOptionsResult) ReadField0(iprot thrift.TProtocol) e
}
func (p *PushServiceGetPusherOptionsResult) Write(oprot thrift.TProtocol) (err error) {
var fieldId int16
if err = oprot.WriteStructBegin("GetPusherOptions_result"); err != nil {
goto WriteStructBeginError

View File

@ -1,4 +1,4 @@
// Code generated by Kitex v0.9.0. DO NOT EDIT.
// Code generated by Kitex v0.9.1. DO NOT EDIT.
package pushservice

View File

@ -1,4 +1,4 @@
// Code generated by Kitex v0.9.0. DO NOT EDIT.
// Code generated by Kitex v0.9.1. DO NOT EDIT.
package pushservice

View File

@ -1,4 +1,4 @@
// Code generated by Kitex v0.9.0. DO NOT EDIT.
// Code generated by Kitex v0.9.1. DO NOT EDIT.
package pushservice
@ -102,7 +102,7 @@ func newServiceInfo(hasStreaming bool, keepStreamingMethods bool, keepNonStreami
HandlerType: handlerType,
Methods: methods,
PayloadCodec: kitex.Thrift,
KiteXGenVersion: "v0.9.0",
KiteXGenVersion: "v0.9.1",
Extra: extra,
}
return svcInfo

View File

@ -1,4 +1,4 @@
// Code generated by Kitex v0.9.0. DO NOT EDIT.
// Code generated by Kitex v0.9.1. DO NOT EDIT.
package pushservice
import (

View File

@ -1,3 +1,3 @@
kitexinfo:
ServiceName: 'pusher'
ToolVersion: 'v0.9.0'
ToolVersion: 'v0.9.1'

View File

@ -61,6 +61,9 @@ func kitexInit() (opts []server.Option) {
opts = append(opts, server.
WithTransHandlerFactory(&mixTransHandlerFactory{nil}))
opts = append(opts, server.
WithTransHandlerFactory(&mixTransHandlerFactory{nil}))
// address
addr, err := net.ResolveTCPAddr("tcp", conf.GetConf().Kitex.Address)
if err != nil {

View File

@ -2,17 +2,18 @@ package pushers
import (
"context"
"fmt"
"sync"
"gitea.timerzz.com/kedaya_haitao/pusher/biz/dal/postgres"
"gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
"github.com/bytedance/sonic"
"golang.org/x/exp/maps"
"golang.org/x/sync/errgroup"
"sync"
)
func Init() {
c = &Controller{
pushers: make(map[int64]Pusher),
}
c = NewController()
}
func Push(ctx context.Context, ids []int64, title, content string) error {
@ -25,13 +26,31 @@ type Pusher interface {
type Controller struct {
pushers map[int64]Pusher
l sync.Mutex
l sync.RWMutex
}
func NewController() *Controller {
var pushers []config.PusherConfig
_ = postgres.DB.Find(&pushers)
ctl := &Controller{
pushers: make(map[int64]Pusher, len(pushers)),
}
for _, pusher := range pushers {
c.pushers[pusher.Id] = NewPusher(pusher)
}
fmt.Printf("共%d个pusher\n", len(pushers))
return ctl
}
var c *Controller
func (c *Controller) Push(ctx context.Context, ids []int64, title, content string) error {
wg, sub := errgroup.WithContext(ctx)
if len(ids) == 0 {
c.l.RLock()
ids = maps.Keys(c.pushers)
c.l.RUnlock()
}
for _, id := range ids {
var i = id
wg.Go(func() error {

View File

@ -0,0 +1,21 @@
package pushers
import (
"fmt"
"testing"
"gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
"gorm.io/driver/postgres"
"gorm.io/gorm"
)
func GetDevDB() (*gorm.DB, error) {
dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%s sslmode=disable TimeZone=Asia/Shanghai", "192.168.31.55", "timerzz", "zhhg1997", "kedaya_dev", "5432")
return gorm.Open(postgres.Open(dsn), &gorm.Config{})
}
func TestNewController(t *testing.T) {
db, _ := GetDevDB()
var pushers []config.PusherConfig
_ = db.Find(&pushers)
fmt.Println(pushers)
}

4
script/bootstrap.sh Normal file
View File

@ -0,0 +1,4 @@
#! /usr/bin/env bash
CURDIR=$(cd $(dirname $0); pwd)
echo "$CURDIR/bin/pusher"
exec "$CURDIR/bin/pusher"