This commit is contained in:
parent
6d7314b9a3
commit
4ec0cd1564
16
.gitea/workflows/build-push.yml
Normal file
16
.gitea/workflows/build-push.yml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
name: Build image
|
||||||
|
on: [push]
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
- name: build
|
||||||
|
run: docker build -t ${{ vars.DOCKER_REGISTRY }}/${{ vars.IMAGE_NAME }}:1.3 -f Dockerfile .
|
||||||
|
- name: tag
|
||||||
|
run: docker tag ${{ vars.DOCKER_REGISTRY }}/${{ vars.IMAGE_NAME }}:1.3 ${{ vars.DOCKER_REGISTRY }}/${{ vars.IMAGE_NAME }}:latest
|
||||||
|
- name: push 1.3
|
||||||
|
run: docker push ${{ vars.DOCKER_REGISTRY }}/${{ vars.IMAGE_NAME }}:1.3
|
||||||
|
- name: push latest
|
||||||
|
run: docker push ${{ vars.DOCKER_REGISTRY }}/${{ vars.IMAGE_NAME }}:latest
|
16
Dockerfile
Normal file
16
Dockerfile
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
|
||||||
|
FROM golang:1.22 as back
|
||||||
|
WORKDIR /build
|
||||||
|
COPY . /build
|
||||||
|
ARG CGO_ENABLED=0
|
||||||
|
ARG GOPROXY=https://goproxy.cn,direct
|
||||||
|
ARG GOPRIVATE=gitea.timerzz.com
|
||||||
|
ARG GONOSUMDB=gitea.timerzz.com
|
||||||
|
ARG GONOPROXY=gitea.timerzz.com
|
||||||
|
RUN go build -trimpath -ldflags '-w -s' -o pusher .
|
||||||
|
|
||||||
|
FROM alpine:latest
|
||||||
|
WORKDIR /work
|
||||||
|
COPY --from=back /build/run /work/
|
||||||
|
ENTRYPOINT ["/work/pusher"]
|
||||||
|
|
@ -1,9 +1,9 @@
|
|||||||
package dal
|
package dal
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gitea.timerzz.com/kedaya_haitao/pusher/biz/dal/pgsql"
|
"gitea.timerzz.com/kedaya_haitao/pusher/biz/dal/postgres"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
pgsql.Init()
|
postgres.Init()
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package pgsql
|
package postgres
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"gitea.timerzz.com/kedaya_haitao/pusher/conf"
|
"gitea.timerzz.com/kedaya_haitao/pusher/conf"
|
||||||
|
"gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
|
||||||
|
|
||||||
"gorm.io/driver/postgres"
|
"gorm.io/driver/postgres"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
@ -22,4 +23,5 @@ func Init() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
_ = DB.AutoMigrate(&config.PusherConfig{})
|
||||||
}
|
}
|
@ -4,7 +4,85 @@ package push
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"gitea.timerzz.com/kedaya_haitao/pusher/biz/service"
|
||||||
|
config "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
|
||||||
|
push "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push"
|
||||||
"github.com/cloudwego/hertz/pkg/app"
|
"github.com/cloudwego/hertz/pkg/app"
|
||||||
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
"github.com/cloudwego/hertz/pkg/protocol/consts"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Push .
|
||||||
|
// @router /api/v1/push [POST]
|
||||||
|
func Push(ctx context.Context, c *app.RequestContext) {
|
||||||
|
var err error
|
||||||
|
var req push.PushReq
|
||||||
|
err = c.BindAndValidate(&req)
|
||||||
|
if err != nil {
|
||||||
|
c.String(consts.StatusBadRequest, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp, err := service.NewPushService(ctx).Run(&req)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
c.String(consts.StatusBadRequest, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(consts.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add .
|
||||||
|
// @router /api/v1/pushers [POST]
|
||||||
|
func Add(ctx context.Context, c *app.RequestContext) {
|
||||||
|
var err error
|
||||||
|
var req config.PusherConfig
|
||||||
|
err = c.BindAndValidate(&req)
|
||||||
|
if err != nil {
|
||||||
|
c.String(consts.StatusBadRequest, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
resp := new(push.Resp)
|
||||||
|
|
||||||
|
resp, err = service.NewAddService(ctx).Run(&req)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
c.String(consts.StatusBadRequest, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(consts.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// List .
|
||||||
|
// @router /api/v1/pushers [GET]
|
||||||
|
func List(ctx context.Context, c *app.RequestContext) {
|
||||||
|
var err error
|
||||||
|
var req push.ListPusherRequest
|
||||||
|
err = c.BindAndValidate(&req)
|
||||||
|
if err != nil {
|
||||||
|
c.String(consts.StatusBadRequest, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
var resp *push.ListPusherResponse
|
||||||
|
resp, err = service.NewListService(ctx).Run(&req)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
c.String(consts.StatusBadRequest, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.JSON(consts.StatusOK, resp)
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetPusherOptions .
|
||||||
|
// @router /api/v1/pushers/options [GET]
|
||||||
|
func GetPusherOptions(ctx context.Context, c *app.RequestContext) {
|
||||||
|
resp, err := service.NewGetPusherOptionsService(ctx).Run()
|
||||||
|
if err != nil {
|
||||||
|
c.String(consts.StatusBadRequest, err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
c.JSON(consts.StatusOK, resp)
|
||||||
|
}
|
||||||
|
@ -5,3 +5,43 @@ package push
|
|||||||
import (
|
import (
|
||||||
"github.com/cloudwego/hertz/pkg/app"
|
"github.com/cloudwego/hertz/pkg/app"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func rootMw() []app.HandlerFunc {
|
||||||
|
// your code...
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func _apiMw() []app.HandlerFunc {
|
||||||
|
// your code...
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func _v1Mw() []app.HandlerFunc {
|
||||||
|
// your code...
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func _pushMw() []app.HandlerFunc {
|
||||||
|
// your code...
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func _pushersMw() []app.HandlerFunc {
|
||||||
|
// your code...
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func _addMw() []app.HandlerFunc {
|
||||||
|
// your code...
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func _getpusheroptionsMw() []app.HandlerFunc {
|
||||||
|
// your code...
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func _listMw() []app.HandlerFunc {
|
||||||
|
// your code...
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
@ -16,4 +16,16 @@ import (
|
|||||||
// Register register routes based on the IDL 'api.${HTTP Method}' annotation.
|
// Register register routes based on the IDL 'api.${HTTP Method}' annotation.
|
||||||
func Register(r *server.Hertz) {
|
func Register(r *server.Hertz) {
|
||||||
|
|
||||||
|
root := r.Group("/", rootMw()...)
|
||||||
|
{
|
||||||
|
_api := root.Group("/api", _apiMw()...)
|
||||||
|
{
|
||||||
|
_v1 := _api.Group("/v1", _v1Mw()...)
|
||||||
|
_v1.POST("/push", append(_pushMw(), push.Push)...)
|
||||||
|
_v1.POST("/pushers", append(_addMw(), push.Add)...)
|
||||||
|
_pushers := _v1.Group("/pushers", _pushersMw()...)
|
||||||
|
_pushers.GET("/options", append(_getpusheroptionsMw(), push.GetPusherOptions)...)
|
||||||
|
_v1.GET("/pushers", append(_listMw(), push.List)...)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,21 +2,26 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"gitea.timerzz.com/kedaya_haitao/pusher/biz/dal/postgres"
|
||||||
config "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
|
config "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
|
||||||
|
push "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push"
|
||||||
)
|
)
|
||||||
|
|
||||||
type AddService struct {
|
type AddService struct {
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
}
|
} // NewAddService new AddService
|
||||||
|
|
||||||
// NewAddService new AddService
|
|
||||||
func NewAddService(ctx context.Context) *AddService {
|
func NewAddService(ctx context.Context) *AddService {
|
||||||
return &AddService{ctx: ctx}
|
return &AddService{ctx: ctx}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run create note info
|
// Run create note info
|
||||||
func (s *AddService) Run(req *config.PushConfig) error {
|
func (s *AddService) Run(req *config.PusherConfig) (resp *push.Resp, err error) {
|
||||||
// Finish your business logic.
|
// Finish your business logic.
|
||||||
|
resp = push.NewResp()
|
||||||
return nil
|
err = postgres.DB.Create(req).Error
|
||||||
|
if err != nil {
|
||||||
|
resp.Code = 100
|
||||||
|
resp.Msg = err.Error()
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package service
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
config "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
|
config "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
|
||||||
|
push "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push"
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -11,12 +12,11 @@ func TestAdd_Run(t *testing.T) {
|
|||||||
s := NewAddService(ctx)
|
s := NewAddService(ctx)
|
||||||
// init req and assert value
|
// init req and assert value
|
||||||
|
|
||||||
req := &config.PushConfig{}
|
req := &config.PusherConfig{}
|
||||||
|
resp, err := s.Run(req)
|
||||||
|
t.Logf("err: %v", err)
|
||||||
|
t.Logf("resp: %v", resp)
|
||||||
|
|
||||||
err := s.Run(req)
|
|
||||||
if err != nil {
|
|
||||||
t.Errorf("unexpected error: %v", err)
|
|
||||||
}
|
|
||||||
// todo: edit your unit test
|
// todo: edit your unit test
|
||||||
|
|
||||||
}
|
}
|
||||||
|
40
biz/service/get_pusher_options.go
Normal file
40
biz/service/get_pusher_options.go
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
|
||||||
|
push "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push"
|
||||||
|
"reflect"
|
||||||
|
)
|
||||||
|
|
||||||
|
type GetPusherOptionsService struct {
|
||||||
|
ctx context.Context
|
||||||
|
} // NewGetPusherOptionsService new GetPusherOptionsService
|
||||||
|
func NewGetPusherOptionsService(ctx context.Context) *GetPusherOptionsService {
|
||||||
|
return &GetPusherOptionsService{ctx: ctx}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run create note info
|
||||||
|
func (s *GetPusherOptionsService) Run() (resp *push.GetPusherOptionsResponse, err error) {
|
||||||
|
// Finish your business logic.
|
||||||
|
resp = new(push.GetPusherOptionsResponse)
|
||||||
|
resp.Options = map[config.PusherConfigType][]*config.FormItem{
|
||||||
|
config.PusherConfigType_AnPush: toFormItems(config.AnPush{}),
|
||||||
|
config.PusherConfigType_Email: toFormItems(config.EmailPush{}),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func toFormItems(in any) []*config.FormItem {
|
||||||
|
valueOfIn := reflect.ValueOf(in)
|
||||||
|
numOfFields := valueOfIn.NumField()
|
||||||
|
items := make([]*config.FormItem, 0, numOfFields)
|
||||||
|
for i := 0; i < numOfFields; i++ {
|
||||||
|
items = append(items, &config.FormItem{
|
||||||
|
Param: valueOfIn.Field(i).String(),
|
||||||
|
Type: valueOfIn.Field(i).Type().String(),
|
||||||
|
Require: true,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return items
|
||||||
|
}
|
19
biz/service/get_pusher_options_test.go
Normal file
19
biz/service/get_pusher_options_test.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
push "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestGetPusherOptions_Run(t *testing.T) {
|
||||||
|
ctx := context.Background()
|
||||||
|
s := NewGetPusherOptionsService(ctx)
|
||||||
|
// init req and assert value
|
||||||
|
resp, err := s.Run()
|
||||||
|
t.Logf("err: %v", err)
|
||||||
|
t.Logf("resp: %v", resp)
|
||||||
|
|
||||||
|
// todo: edit your unit test
|
||||||
|
|
||||||
|
}
|
@ -2,6 +2,9 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"gitea.timerzz.com/kedaya_haitao/pusher/biz/dal/postgres"
|
||||||
|
"gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
|
||||||
push "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push"
|
push "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,6 +18,32 @@ func NewListService(ctx context.Context) *ListService {
|
|||||||
// Run create note info
|
// Run create note info
|
||||||
func (s *ListService) Run(req *push.ListPusherRequest) (resp *push.ListPusherResponse, err error) {
|
func (s *ListService) Run(req *push.ListPusherRequest) (resp *push.ListPusherResponse, err error) {
|
||||||
// Finish your business logic.
|
// Finish your business logic.
|
||||||
|
tx := postgres.DB
|
||||||
|
if req.Keyword != "" {
|
||||||
|
tx = tx.Where("name LIKE ? or remark LIKE ?", fmt.Sprintf("%%%s%%", req.Keyword), fmt.Sprintf("%%%s%%", req.Keyword))
|
||||||
|
}
|
||||||
|
resp = new(push.ListPusherResponse)
|
||||||
|
|
||||||
|
if err = tx.Model(&config.PusherConfig{}).Find(&resp.List).Error; err != nil {
|
||||||
|
return nil, fmt.Errorf("查询总数失败:%v", err)
|
||||||
|
}
|
||||||
|
resp.Total = int64(len(resp.List))
|
||||||
|
if req.All || resp.Total == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询列表
|
||||||
|
if req.Page < 1 {
|
||||||
|
req.Page = 1
|
||||||
|
}
|
||||||
|
if req.Size < 1 {
|
||||||
|
req.Size = 10
|
||||||
|
}
|
||||||
|
offset := (req.Page - 1) * int64(req.Size)
|
||||||
|
|
||||||
|
if err = tx.Order("created_at desc").Limit(int(req.Size)).Offset(int(offset)).
|
||||||
|
Find(&resp.List).Error; err != nil {
|
||||||
|
return nil, fmt.Errorf("查询列表失败:%v", err)
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,9 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
"fmt"
|
||||||
push "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push"
|
push "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push"
|
||||||
|
"gitea.timerzz.com/kedaya_haitao/pusher/pushers"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PushService struct {
|
type PushService struct {
|
||||||
@ -13,8 +15,16 @@ func NewPushService(ctx context.Context) *PushService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Run create note info
|
// Run create note info
|
||||||
func (s *PushService) Run(req *push.PushReq) (resp *push.PushResp, err error) {
|
func (s *PushService) Run(req *push.PushReq) (resp *push.Resp, err error) {
|
||||||
// Finish your business logic.
|
// 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 {
|
||||||
|
resp.Code = 100
|
||||||
|
resp.Msg = err.Error()
|
||||||
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
7
build.sh
7
build.sh
@ -1,7 +0,0 @@
|
|||||||
#!/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}
|
|
@ -54,7 +54,7 @@ func GetConf() *Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func initConf() {
|
func initConf() {
|
||||||
prefix := "conf"
|
prefix := "/data"
|
||||||
confFileRelPath := filepath.Join(prefix, filepath.Join(GetEnv(), "conf.yaml"))
|
confFileRelPath := filepath.Join(prefix, filepath.Join(GetEnv(), "conf.yaml"))
|
||||||
content, err := ioutil.ReadFile(confFileRelPath)
|
content, err := ioutil.ReadFile(confFileRelPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -14,4 +14,4 @@ registry:
|
|||||||
password: ""
|
password: ""
|
||||||
|
|
||||||
db:
|
db:
|
||||||
dsn: "gorm:gorm@tcp(127.0.0.1:3306)/gorm?charset=utf8mb4&parseTime=True&loc=Local"
|
dsn: "host=192.168.31.55 user=timerzz password=zhhg1997 dbname=kedaya_dev port=5432 sslmode=disable TimeZone=Asia/Shanghai"
|
||||||
|
@ -14,4 +14,4 @@ registry:
|
|||||||
password: ""
|
password: ""
|
||||||
|
|
||||||
db:
|
db:
|
||||||
dsn: "gorm:gorm@tcp(127.0.0.1:3306)/gorm?charset=utf8mb4&parseTime=True&loc=Local"
|
dsn: "host=192.168.31.55 user=timerzz password=zhhg1997 dbname=kedaya port=5432 sslmode=disable TimeZone=Asia/Shanghai"
|
||||||
|
2
gen.sh
Normal file
2
gen.sh
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
cwgo server --type RPC --idl .\idl\push.thrift --service pusher --module gitea.timerzz.com/kedaya_haitao/pusher --hex
|
||||||
|
cwgo client --type RPC --idl .\idl\push.thrift --service pusher --module gitea.timerzz.com/kedaya_haitao/pusher
|
10
go.mod
10
go.mod
@ -8,6 +8,7 @@ require (
|
|||||||
github.com/apache/thrift v0.13.0
|
github.com/apache/thrift v0.13.0
|
||||||
github.com/cloudwego/hertz v0.9.0
|
github.com/cloudwego/hertz v0.9.0
|
||||||
github.com/cloudwego/kitex v0.9.1
|
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/obs-opentelemetry/logging/logrus v0.0.0-20240515092919-1f776656cb66
|
||||||
github.com/kr/pretty v0.3.0
|
github.com/kr/pretty v0.3.0
|
||||||
go.uber.org/zap v1.27.0
|
go.uber.org/zap v1.27.0
|
||||||
@ -62,15 +63,16 @@ require (
|
|||||||
github.com/tidwall/match v1.1.1 // indirect
|
github.com/tidwall/match v1.1.1 // indirect
|
||||||
github.com/tidwall/pretty v1.2.0 // indirect
|
github.com/tidwall/pretty v1.2.0 // indirect
|
||||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||||
|
github.com/wneessen/go-mail v0.4.1 // indirect
|
||||||
go.opentelemetry.io/otel v1.19.0 // indirect
|
go.opentelemetry.io/otel v1.19.0 // indirect
|
||||||
go.opentelemetry.io/otel/trace v1.19.0 // indirect
|
go.opentelemetry.io/otel/trace v1.19.0 // indirect
|
||||||
go.uber.org/multierr v1.10.0 // indirect
|
go.uber.org/multierr v1.10.0 // indirect
|
||||||
golang.org/x/arch v0.2.0 // indirect
|
golang.org/x/arch v0.2.0 // indirect
|
||||||
golang.org/x/crypto v0.14.0 // indirect
|
golang.org/x/crypto v0.23.0 // indirect
|
||||||
golang.org/x/net v0.17.0 // indirect
|
golang.org/x/net v0.25.0 // indirect
|
||||||
golang.org/x/sync v0.1.0 // indirect
|
golang.org/x/sync v0.1.0 // indirect
|
||||||
golang.org/x/sys v0.13.0 // indirect
|
golang.org/x/sys v0.20.0 // indirect
|
||||||
golang.org/x/text v0.13.0 // indirect
|
golang.org/x/text v0.15.0 // indirect
|
||||||
google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384 // indirect
|
google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384 // indirect
|
||||||
google.golang.org/protobuf v1.28.1 // indirect
|
google.golang.org/protobuf v1.28.1 // indirect
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
|
24
go.sum
24
go.sum
@ -116,6 +116,8 @@ github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag=
|
|||||||
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE=
|
||||||
github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M=
|
github.com/go-pdf/fpdf v0.5.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M=
|
||||||
github.com/go-pdf/fpdf v0.6.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M=
|
github.com/go-pdf/fpdf v0.6.0/go.mod h1:HzcnA+A23uwogo0tp9yU+l3V+KXhiESpt1PMayhOh5M=
|
||||||
|
github.com/go-resty/resty/v2 v2.13.1 h1:x+LHXBI2nMB1vqndymf26quycC4aggYJ7DECYbiz03g=
|
||||||
|
github.com/go-resty/resty/v2 v2.13.1/go.mod h1:GznXlLxkq6Nh4sU59rPmUw3VtgpO3aS96ORAI6Q7d+0=
|
||||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||||
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k=
|
||||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
@ -255,6 +257,8 @@ github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2
|
|||||||
github.com/v2pro/plz v0.0.0-20221028024117-e5f9aec5b631/go.mod h1:3gacX+hQo+xvl0vtLqCMufzxuNCwt4geAVOMt2LQYfE=
|
github.com/v2pro/plz v0.0.0-20221028024117-e5f9aec5b631/go.mod h1:3gacX+hQo+xvl0vtLqCMufzxuNCwt4geAVOMt2LQYfE=
|
||||||
github.com/v2pro/quokka v0.0.0-20171201153428-382cb39c6ee6/go.mod h1:0VP5W9AFNVWU8C1QLNeVg8TvzoEkIHWZ4vxtxEVFWUY=
|
github.com/v2pro/quokka v0.0.0-20171201153428-382cb39c6ee6/go.mod h1:0VP5W9AFNVWU8C1QLNeVg8TvzoEkIHWZ4vxtxEVFWUY=
|
||||||
github.com/v2pro/wombat v0.0.0-20180402055224-a56dbdcddef2/go.mod h1:wen8nMxrRrUmXnRwH+3wGAW+hyYTHcOrTNhMpxyp/i0=
|
github.com/v2pro/wombat v0.0.0-20180402055224-a56dbdcddef2/go.mod h1:wen8nMxrRrUmXnRwH+3wGAW+hyYTHcOrTNhMpxyp/i0=
|
||||||
|
github.com/wneessen/go-mail v0.4.1 h1:m2rSg/sc8FZQCdtrV5M8ymHYOFrC6KJAQAIcgrXvqoo=
|
||||||
|
github.com/wneessen/go-mail v0.4.1/go.mod h1:zxOlafWCP/r6FEhAaRgH4IC1vg2YXxO0Nar9u0IScZ8=
|
||||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||||
@ -287,8 +291,10 @@ golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8U
|
|||||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/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-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/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 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
|
||||||
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||||
|
golang.org/x/crypto v0.19.0/go.mod h1:Iy9bg/ha4yyC70EfRS8jz+B6ybOBKMaSxLj6P6oBDfU=
|
||||||
|
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
||||||
|
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
||||||
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
@ -340,8 +346,10 @@ golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug
|
|||||||
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
golang.org/x/net v0.0.0-20221014081412-f15817d10f9b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
|
||||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||||
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
|
||||||
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||||
|
golang.org/x/net v0.21.0/go.mod h1:bIjVDfnllIU7BJ2DNgfnXvpSvtn8VRwhlsaeUTyUS44=
|
||||||
|
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
||||||
|
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
||||||
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
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-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
@ -382,13 +390,17 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc
|
|||||||
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220817070843-5a390386f1f2/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
|
|
||||||
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
||||||
|
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
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.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||||
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
|
golang.org/x/term v0.13.0/go.mod h1:LTmsnFJwVN6bCy1rVCoS+qHT1HhALEFxKncY3WNNh4U=
|
||||||
|
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||||
|
golang.org/x/term v0.20.0/go.mod h1:8UkIAJTvZgivsXaD6/pH6U9ecQzZ45awqEOzuCvwpFY=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
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.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
@ -397,8 +409,12 @@ golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
|||||||
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||||
golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
|
||||||
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
|
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
|
||||||
|
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
|
golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk=
|
||||||
|
golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM=
|
||||||
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-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-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
16
handler.go
16
handler.go
@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
"gitea.timerzz.com/kedaya_haitao/pusher/biz/service"
|
"gitea.timerzz.com/kedaya_haitao/pusher/biz/service"
|
||||||
config "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
|
config "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
|
||||||
push "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push"
|
push "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push"
|
||||||
@ -12,17 +11,17 @@ import (
|
|||||||
type PushServiceImpl struct{}
|
type PushServiceImpl struct{}
|
||||||
|
|
||||||
// Push implements the PushServiceImpl interface.
|
// Push implements the PushServiceImpl interface.
|
||||||
func (s *PushServiceImpl) Push(ctx context.Context, req *push.PushReq) (resp *push.PushResp, err error) {
|
func (s *PushServiceImpl) Push(ctx context.Context, req *push.PushReq) (resp *push.Resp, err error) {
|
||||||
resp, err = service.NewPushService(ctx).Run(req)
|
resp, err = service.NewPushService(ctx).Run(req)
|
||||||
|
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add implements the PushServiceImpl interface.
|
// Add implements the PushServiceImpl interface.
|
||||||
func (s *PushServiceImpl) Add(ctx context.Context, req *config.PushConfig) (err error) {
|
func (s *PushServiceImpl) Add(ctx context.Context, req *config.PusherConfig) (resp *push.Resp, err error) {
|
||||||
err = service.NewAddService(ctx).Run(req)
|
resp, err = service.NewAddService(ctx).Run(req)
|
||||||
|
|
||||||
return err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// List implements the PushServiceImpl interface.
|
// List implements the PushServiceImpl interface.
|
||||||
@ -31,3 +30,10 @@ func (s *PushServiceImpl) List(ctx context.Context, req *push.ListPusherRequest)
|
|||||||
|
|
||||||
return resp, err
|
return resp, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetPusherOptions implements the PushServiceImpl interface.
|
||||||
|
func (s *PushServiceImpl) GetPusherOptions(ctx context.Context) (resp *push.GetPusherOptionsResponse, err error) {
|
||||||
|
resp, err = service.NewGetPusherOptionsService(ctx).Run()
|
||||||
|
|
||||||
|
return resp, err
|
||||||
|
}
|
||||||
|
@ -1,8 +1,33 @@
|
|||||||
struct PushConfig {
|
enum PusherConfigType {
|
||||||
|
AnPush = 1,
|
||||||
|
Email
|
||||||
|
}
|
||||||
|
|
||||||
|
struct PusherConfig {
|
||||||
1: i64 id
|
1: i64 id
|
||||||
2: i64 createdAt
|
2: i64 createdAt
|
||||||
3: i8 type
|
3: PusherConfigType type
|
||||||
4: string name
|
4: required string name
|
||||||
5: string remark
|
5: string remark
|
||||||
6: string option
|
6: required string option
|
||||||
|
}
|
||||||
|
|
||||||
|
struct FormItem {
|
||||||
|
1: string param
|
||||||
|
2: string type
|
||||||
|
3: bool require
|
||||||
|
}
|
||||||
|
|
||||||
|
struct AnPush {
|
||||||
|
1: string token
|
||||||
|
2: string channel
|
||||||
|
}
|
||||||
|
|
||||||
|
struct EmailPush {
|
||||||
|
1: string from
|
||||||
|
2: string to
|
||||||
|
3: string username
|
||||||
|
4: string password
|
||||||
|
5: string host
|
||||||
|
6: i32 port
|
||||||
}
|
}
|
@ -1,31 +1,36 @@
|
|||||||
include "config.thrift"
|
include "config.thrift"
|
||||||
|
|
||||||
struct PushReq {
|
struct PushReq {
|
||||||
1: required i64 id
|
1: required list<i64> ids (api.body="ids");
|
||||||
2: required string title
|
2: required string title (api.body="title");
|
||||||
3: required string content
|
3: required string content (api.body="content");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct PushResp {
|
struct Resp {
|
||||||
1: required i64 errCode
|
1: required i64 code (api.body="code");
|
||||||
2: string errMsg
|
2: string msg (api.body="msg");
|
||||||
3: string msgId
|
3: string msgId (api.body="msgId");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ListPusherRequest {
|
struct ListPusherRequest {
|
||||||
1: string keyword
|
1: string keyword (api.query="keyword");
|
||||||
2: optional i64 page = 10
|
2: optional i64 page = 10 (api.query="page");
|
||||||
3: optional i16 size = 1
|
3: optional i16 size = 1 (api.query="size");
|
||||||
4: bool all
|
4: bool all (api.query="all");
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ListPusherResponse {
|
struct ListPusherResponse {
|
||||||
1: i64 total
|
1: i64 total (api.body="total");
|
||||||
2: list<config.PushConfig> list
|
2: list<config.PusherConfig> list (api.body="list");
|
||||||
|
}
|
||||||
|
|
||||||
|
struct GetPusherOptionsResponse {
|
||||||
|
1: map<config.PusherConfigType,list<config.FormItem>> options
|
||||||
}
|
}
|
||||||
|
|
||||||
service PushService{
|
service PushService{
|
||||||
PushResp Push(1: PushReq req)
|
Resp Push(1: PushReq req) (api.post="/api/v1/push");
|
||||||
void Add(1: config.PushConfig req)
|
Resp Add(1: config.PusherConfig req) (api.post="/api/v1/pushers");
|
||||||
ListPusherResponse List(1: ListPusherRequest req)
|
ListPusherResponse List(1: ListPusherRequest req) (api.get="/api/v1/pushers");
|
||||||
|
GetPusherOptionsResponse GetPusherOptions() (api.get="/api/v1/pushers/options")
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -32,7 +32,7 @@ func (p *PushReq) FastRead(buf []byte) (int, error) {
|
|||||||
var l int
|
var l int
|
||||||
var fieldTypeId thrift.TType
|
var fieldTypeId thrift.TType
|
||||||
var fieldId int16
|
var fieldId int16
|
||||||
var issetId bool = false
|
var issetIds bool = false
|
||||||
var issetTitle bool = false
|
var issetTitle bool = false
|
||||||
var issetContent bool = false
|
var issetContent bool = false
|
||||||
_, l, err = bthrift.Binary.ReadStructBegin(buf)
|
_, l, err = bthrift.Binary.ReadStructBegin(buf)
|
||||||
@ -52,13 +52,13 @@ func (p *PushReq) FastRead(buf []byte) (int, error) {
|
|||||||
}
|
}
|
||||||
switch fieldId {
|
switch fieldId {
|
||||||
case 1:
|
case 1:
|
||||||
if fieldTypeId == thrift.I64 {
|
if fieldTypeId == thrift.LIST {
|
||||||
l, err = p.FastReadField1(buf[offset:])
|
l, err = p.FastReadField1(buf[offset:])
|
||||||
offset += l
|
offset += l
|
||||||
if err != nil {
|
if err != nil {
|
||||||
goto ReadFieldError
|
goto ReadFieldError
|
||||||
}
|
}
|
||||||
issetId = true
|
issetIds = true
|
||||||
} else {
|
} else {
|
||||||
l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
|
l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
|
||||||
offset += l
|
offset += l
|
||||||
@ -116,7 +116,7 @@ func (p *PushReq) FastRead(buf []byte) (int, error) {
|
|||||||
goto ReadStructEndError
|
goto ReadStructEndError
|
||||||
}
|
}
|
||||||
|
|
||||||
if !issetId {
|
if !issetIds {
|
||||||
fieldId = 1
|
fieldId = 1
|
||||||
goto RequiredFieldNotSetError
|
goto RequiredFieldNotSetError
|
||||||
}
|
}
|
||||||
@ -150,13 +150,29 @@ RequiredFieldNotSetError:
|
|||||||
func (p *PushReq) FastReadField1(buf []byte) (int, error) {
|
func (p *PushReq) FastReadField1(buf []byte) (int, error) {
|
||||||
offset := 0
|
offset := 0
|
||||||
|
|
||||||
if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil {
|
_, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:])
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
return offset, err
|
||||||
|
}
|
||||||
|
p.Ids = make([]int64, 0, size)
|
||||||
|
for i := 0; i < size; i++ {
|
||||||
|
var _elem int64
|
||||||
|
if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil {
|
||||||
|
return offset, err
|
||||||
|
} else {
|
||||||
|
offset += l
|
||||||
|
|
||||||
|
_elem = v
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
p.Ids = append(p.Ids, _elem)
|
||||||
|
}
|
||||||
|
if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil {
|
||||||
return offset, err
|
return offset, err
|
||||||
} else {
|
} else {
|
||||||
offset += l
|
offset += l
|
||||||
|
|
||||||
p.Id = v
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return offset, nil
|
return offset, nil
|
||||||
}
|
}
|
||||||
@ -222,9 +238,17 @@ func (p *PushReq) BLength() int {
|
|||||||
|
|
||||||
func (p *PushReq) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int {
|
func (p *PushReq) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int {
|
||||||
offset := 0
|
offset := 0
|
||||||
offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "id", thrift.I64, 1)
|
offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "ids", thrift.LIST, 1)
|
||||||
offset += bthrift.Binary.WriteI64(buf[offset:], p.Id)
|
listBeginOffset := offset
|
||||||
|
offset += bthrift.Binary.ListBeginLength(thrift.I64, 0)
|
||||||
|
var length int
|
||||||
|
for _, v := range p.Ids {
|
||||||
|
length++
|
||||||
|
offset += bthrift.Binary.WriteI64(buf[offset:], v)
|
||||||
|
|
||||||
|
}
|
||||||
|
bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.I64, length)
|
||||||
|
offset += bthrift.Binary.WriteListEnd(buf[offset:])
|
||||||
offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
|
offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
|
||||||
return offset
|
return offset
|
||||||
}
|
}
|
||||||
@ -249,9 +273,11 @@ func (p *PushReq) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter)
|
|||||||
|
|
||||||
func (p *PushReq) field1Length() int {
|
func (p *PushReq) field1Length() int {
|
||||||
l := 0
|
l := 0
|
||||||
l += bthrift.Binary.FieldBeginLength("id", thrift.I64, 1)
|
l += bthrift.Binary.FieldBeginLength("ids", thrift.LIST, 1)
|
||||||
l += bthrift.Binary.I64Length(p.Id)
|
l += bthrift.Binary.ListBeginLength(thrift.I64, len(p.Ids))
|
||||||
|
var tmpV int64
|
||||||
|
l += bthrift.Binary.I64Length(int64(tmpV)) * len(p.Ids)
|
||||||
|
l += bthrift.Binary.ListEndLength()
|
||||||
l += bthrift.Binary.FieldEndLength()
|
l += bthrift.Binary.FieldEndLength()
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
@ -274,13 +300,13 @@ func (p *PushReq) field3Length() int {
|
|||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PushResp) FastRead(buf []byte) (int, error) {
|
func (p *Resp) FastRead(buf []byte) (int, error) {
|
||||||
var err error
|
var err error
|
||||||
var offset int
|
var offset int
|
||||||
var l int
|
var l int
|
||||||
var fieldTypeId thrift.TType
|
var fieldTypeId thrift.TType
|
||||||
var fieldId int16
|
var fieldId int16
|
||||||
var issetErrCode bool = false
|
var issetCode bool = false
|
||||||
_, l, err = bthrift.Binary.ReadStructBegin(buf)
|
_, l, err = bthrift.Binary.ReadStructBegin(buf)
|
||||||
offset += l
|
offset += l
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -304,7 +330,7 @@ func (p *PushResp) FastRead(buf []byte) (int, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
goto ReadFieldError
|
goto ReadFieldError
|
||||||
}
|
}
|
||||||
issetErrCode = true
|
issetCode = true
|
||||||
} else {
|
} else {
|
||||||
l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
|
l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
|
||||||
offset += l
|
offset += l
|
||||||
@ -360,7 +386,7 @@ func (p *PushResp) FastRead(buf []byte) (int, error) {
|
|||||||
goto ReadStructEndError
|
goto ReadStructEndError
|
||||||
}
|
}
|
||||||
|
|
||||||
if !issetErrCode {
|
if !issetCode {
|
||||||
fieldId = 1
|
fieldId = 1
|
||||||
goto RequiredFieldNotSetError
|
goto RequiredFieldNotSetError
|
||||||
}
|
}
|
||||||
@ -370,7 +396,7 @@ ReadStructBeginError:
|
|||||||
ReadFieldBeginError:
|
ReadFieldBeginError:
|
||||||
return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
||||||
ReadFieldError:
|
ReadFieldError:
|
||||||
return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PushResp[fieldId]), err)
|
return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_Resp[fieldId]), err)
|
||||||
SkipFieldError:
|
SkipFieldError:
|
||||||
return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
||||||
ReadFieldEndError:
|
ReadFieldEndError:
|
||||||
@ -378,10 +404,10 @@ ReadFieldEndError:
|
|||||||
ReadStructEndError:
|
ReadStructEndError:
|
||||||
return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
||||||
RequiredFieldNotSetError:
|
RequiredFieldNotSetError:
|
||||||
return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_PushResp[fieldId]))
|
return offset, thrift.NewTProtocolExceptionWithType(thrift.INVALID_DATA, fmt.Errorf("required field %s is not set", fieldIDToName_Resp[fieldId]))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PushResp) FastReadField1(buf []byte) (int, error) {
|
func (p *Resp) FastReadField1(buf []byte) (int, error) {
|
||||||
offset := 0
|
offset := 0
|
||||||
|
|
||||||
if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil {
|
if v, l, err := bthrift.Binary.ReadI64(buf[offset:]); err != nil {
|
||||||
@ -389,13 +415,13 @@ func (p *PushResp) FastReadField1(buf []byte) (int, error) {
|
|||||||
} else {
|
} else {
|
||||||
offset += l
|
offset += l
|
||||||
|
|
||||||
p.ErrCode = v
|
p.Code = v
|
||||||
|
|
||||||
}
|
}
|
||||||
return offset, nil
|
return offset, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PushResp) FastReadField2(buf []byte) (int, error) {
|
func (p *Resp) FastReadField2(buf []byte) (int, error) {
|
||||||
offset := 0
|
offset := 0
|
||||||
|
|
||||||
if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil {
|
if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil {
|
||||||
@ -403,13 +429,13 @@ func (p *PushResp) FastReadField2(buf []byte) (int, error) {
|
|||||||
} else {
|
} else {
|
||||||
offset += l
|
offset += l
|
||||||
|
|
||||||
p.ErrMsg = v
|
p.Msg = v
|
||||||
|
|
||||||
}
|
}
|
||||||
return offset, nil
|
return offset, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PushResp) FastReadField3(buf []byte) (int, error) {
|
func (p *Resp) FastReadField3(buf []byte) (int, error) {
|
||||||
offset := 0
|
offset := 0
|
||||||
|
|
||||||
if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil {
|
if v, l, err := bthrift.Binary.ReadString(buf[offset:]); err != nil {
|
||||||
@ -424,13 +450,13 @@ func (p *PushResp) FastReadField3(buf []byte) (int, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// for compatibility
|
// for compatibility
|
||||||
func (p *PushResp) FastWrite(buf []byte) int {
|
func (p *Resp) FastWrite(buf []byte) int {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PushResp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int {
|
func (p *Resp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int {
|
||||||
offset := 0
|
offset := 0
|
||||||
offset += bthrift.Binary.WriteStructBegin(buf[offset:], "PushResp")
|
offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Resp")
|
||||||
if p != nil {
|
if p != nil {
|
||||||
offset += p.fastWriteField1(buf[offset:], binaryWriter)
|
offset += p.fastWriteField1(buf[offset:], binaryWriter)
|
||||||
offset += p.fastWriteField2(buf[offset:], binaryWriter)
|
offset += p.fastWriteField2(buf[offset:], binaryWriter)
|
||||||
@ -441,9 +467,9 @@ func (p *PushResp) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter
|
|||||||
return offset
|
return offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PushResp) BLength() int {
|
func (p *Resp) BLength() int {
|
||||||
l := 0
|
l := 0
|
||||||
l += bthrift.Binary.StructBeginLength("PushResp")
|
l += bthrift.Binary.StructBeginLength("Resp")
|
||||||
if p != nil {
|
if p != nil {
|
||||||
l += p.field1Length()
|
l += p.field1Length()
|
||||||
l += p.field2Length()
|
l += p.field2Length()
|
||||||
@ -454,25 +480,25 @@ func (p *PushResp) BLength() int {
|
|||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PushResp) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int {
|
func (p *Resp) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int {
|
||||||
offset := 0
|
offset := 0
|
||||||
offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "errCode", thrift.I64, 1)
|
offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "code", thrift.I64, 1)
|
||||||
offset += bthrift.Binary.WriteI64(buf[offset:], p.ErrCode)
|
offset += bthrift.Binary.WriteI64(buf[offset:], p.Code)
|
||||||
|
|
||||||
offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
|
offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
|
||||||
return offset
|
return offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PushResp) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int {
|
func (p *Resp) fastWriteField2(buf []byte, binaryWriter bthrift.BinaryWriter) int {
|
||||||
offset := 0
|
offset := 0
|
||||||
offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "errMsg", thrift.STRING, 2)
|
offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "msg", thrift.STRING, 2)
|
||||||
offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.ErrMsg)
|
offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.Msg)
|
||||||
|
|
||||||
offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
|
offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
|
||||||
return offset
|
return offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PushResp) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int {
|
func (p *Resp) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter) int {
|
||||||
offset := 0
|
offset := 0
|
||||||
offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "msgId", thrift.STRING, 3)
|
offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "msgId", thrift.STRING, 3)
|
||||||
offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.MsgId)
|
offset += bthrift.Binary.WriteStringNocopy(buf[offset:], binaryWriter, p.MsgId)
|
||||||
@ -481,25 +507,25 @@ func (p *PushResp) fastWriteField3(buf []byte, binaryWriter bthrift.BinaryWriter
|
|||||||
return offset
|
return offset
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PushResp) field1Length() int {
|
func (p *Resp) field1Length() int {
|
||||||
l := 0
|
l := 0
|
||||||
l += bthrift.Binary.FieldBeginLength("errCode", thrift.I64, 1)
|
l += bthrift.Binary.FieldBeginLength("code", thrift.I64, 1)
|
||||||
l += bthrift.Binary.I64Length(p.ErrCode)
|
l += bthrift.Binary.I64Length(p.Code)
|
||||||
|
|
||||||
l += bthrift.Binary.FieldEndLength()
|
l += bthrift.Binary.FieldEndLength()
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PushResp) field2Length() int {
|
func (p *Resp) field2Length() int {
|
||||||
l := 0
|
l := 0
|
||||||
l += bthrift.Binary.FieldBeginLength("errMsg", thrift.STRING, 2)
|
l += bthrift.Binary.FieldBeginLength("msg", thrift.STRING, 2)
|
||||||
l += bthrift.Binary.StringLengthNocopy(p.ErrMsg)
|
l += bthrift.Binary.StringLengthNocopy(p.Msg)
|
||||||
|
|
||||||
l += bthrift.Binary.FieldEndLength()
|
l += bthrift.Binary.FieldEndLength()
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PushResp) field3Length() int {
|
func (p *Resp) field3Length() int {
|
||||||
l := 0
|
l := 0
|
||||||
l += bthrift.Binary.FieldBeginLength("msgId", thrift.STRING, 3)
|
l += bthrift.Binary.FieldBeginLength("msgId", thrift.STRING, 3)
|
||||||
l += bthrift.Binary.StringLengthNocopy(p.MsgId)
|
l += bthrift.Binary.StringLengthNocopy(p.MsgId)
|
||||||
@ -897,9 +923,9 @@ func (p *ListPusherResponse) FastReadField2(buf []byte) (int, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return offset, err
|
return offset, err
|
||||||
}
|
}
|
||||||
p.List = make([]*config.PushConfig, 0, size)
|
p.List = make([]*config.PusherConfig, 0, size)
|
||||||
for i := 0; i < size; i++ {
|
for i := 0; i < size; i++ {
|
||||||
_elem := config.NewPushConfig()
|
_elem := config.NewPusherConfig()
|
||||||
if l, err := _elem.FastRead(buf[offset:]); err != nil {
|
if l, err := _elem.FastRead(buf[offset:]); err != nil {
|
||||||
return offset, err
|
return offset, err
|
||||||
} else {
|
} else {
|
||||||
@ -991,6 +1017,202 @@ func (p *ListPusherResponse) field2Length() int {
|
|||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *GetPusherOptionsResponse) FastRead(buf []byte) (int, error) {
|
||||||
|
var err error
|
||||||
|
var offset int
|
||||||
|
var l int
|
||||||
|
var fieldTypeId thrift.TType
|
||||||
|
var fieldId int16
|
||||||
|
_, l, err = bthrift.Binary.ReadStructBegin(buf)
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto ReadStructBeginError
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
_, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:])
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto ReadFieldBeginError
|
||||||
|
}
|
||||||
|
if fieldTypeId == thrift.STOP {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
switch fieldId {
|
||||||
|
case 1:
|
||||||
|
if fieldTypeId == thrift.MAP {
|
||||||
|
l, err = p.FastReadField1(buf[offset:])
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto ReadFieldError
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto SkipFieldError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto SkipFieldError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
l, err = bthrift.Binary.ReadFieldEnd(buf[offset:])
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto ReadFieldEndError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
l, err = bthrift.Binary.ReadStructEnd(buf[offset:])
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto ReadStructEndError
|
||||||
|
}
|
||||||
|
|
||||||
|
return offset, nil
|
||||||
|
ReadStructBeginError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
|
||||||
|
ReadFieldBeginError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
||||||
|
ReadFieldError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_GetPusherOptionsResponse[fieldId]), err)
|
||||||
|
SkipFieldError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
||||||
|
ReadFieldEndError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
|
||||||
|
ReadStructEndError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *GetPusherOptionsResponse) FastReadField1(buf []byte) (int, error) {
|
||||||
|
offset := 0
|
||||||
|
|
||||||
|
_, _, size, l, err := bthrift.Binary.ReadMapBegin(buf[offset:])
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
return offset, err
|
||||||
|
}
|
||||||
|
p.Options = make(map[config.PusherConfigType][]*config.FormItem, size)
|
||||||
|
for i := 0; i < size; i++ {
|
||||||
|
var _key config.PusherConfigType
|
||||||
|
if v, l, err := bthrift.Binary.ReadI32(buf[offset:]); err != nil {
|
||||||
|
return offset, err
|
||||||
|
} else {
|
||||||
|
offset += l
|
||||||
|
|
||||||
|
_key = config.PusherConfigType(v)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
_, size, l, err := bthrift.Binary.ReadListBegin(buf[offset:])
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
return offset, err
|
||||||
|
}
|
||||||
|
_val := make([]*config.FormItem, 0, size)
|
||||||
|
for i := 0; i < size; i++ {
|
||||||
|
_elem := config.NewFormItem()
|
||||||
|
if l, err := _elem.FastRead(buf[offset:]); err != nil {
|
||||||
|
return offset, err
|
||||||
|
} else {
|
||||||
|
offset += l
|
||||||
|
}
|
||||||
|
|
||||||
|
_val = append(_val, _elem)
|
||||||
|
}
|
||||||
|
if l, err := bthrift.Binary.ReadListEnd(buf[offset:]); err != nil {
|
||||||
|
return offset, err
|
||||||
|
} else {
|
||||||
|
offset += l
|
||||||
|
}
|
||||||
|
|
||||||
|
p.Options[_key] = _val
|
||||||
|
}
|
||||||
|
if l, err := bthrift.Binary.ReadMapEnd(buf[offset:]); err != nil {
|
||||||
|
return offset, err
|
||||||
|
} else {
|
||||||
|
offset += l
|
||||||
|
}
|
||||||
|
return offset, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// for compatibility
|
||||||
|
func (p *GetPusherOptionsResponse) FastWrite(buf []byte) int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *GetPusherOptionsResponse) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int {
|
||||||
|
offset := 0
|
||||||
|
offset += bthrift.Binary.WriteStructBegin(buf[offset:], "GetPusherOptionsResponse")
|
||||||
|
if p != nil {
|
||||||
|
offset += p.fastWriteField1(buf[offset:], binaryWriter)
|
||||||
|
}
|
||||||
|
offset += bthrift.Binary.WriteFieldStop(buf[offset:])
|
||||||
|
offset += bthrift.Binary.WriteStructEnd(buf[offset:])
|
||||||
|
return offset
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *GetPusherOptionsResponse) BLength() int {
|
||||||
|
l := 0
|
||||||
|
l += bthrift.Binary.StructBeginLength("GetPusherOptionsResponse")
|
||||||
|
if p != nil {
|
||||||
|
l += p.field1Length()
|
||||||
|
}
|
||||||
|
l += bthrift.Binary.FieldStopLength()
|
||||||
|
l += bthrift.Binary.StructEndLength()
|
||||||
|
return l
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *GetPusherOptionsResponse) fastWriteField1(buf []byte, binaryWriter bthrift.BinaryWriter) int {
|
||||||
|
offset := 0
|
||||||
|
offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "options", thrift.MAP, 1)
|
||||||
|
mapBeginOffset := offset
|
||||||
|
offset += bthrift.Binary.MapBeginLength(thrift.I32, thrift.LIST, 0)
|
||||||
|
var length int
|
||||||
|
for k, v := range p.Options {
|
||||||
|
length++
|
||||||
|
|
||||||
|
offset += bthrift.Binary.WriteI32(buf[offset:], int32(k))
|
||||||
|
|
||||||
|
listBeginOffset := offset
|
||||||
|
offset += bthrift.Binary.ListBeginLength(thrift.STRUCT, 0)
|
||||||
|
var length int
|
||||||
|
for _, v := range v {
|
||||||
|
length++
|
||||||
|
offset += v.FastWriteNocopy(buf[offset:], binaryWriter)
|
||||||
|
}
|
||||||
|
bthrift.Binary.WriteListBegin(buf[listBeginOffset:], thrift.STRUCT, length)
|
||||||
|
offset += bthrift.Binary.WriteListEnd(buf[offset:])
|
||||||
|
}
|
||||||
|
bthrift.Binary.WriteMapBegin(buf[mapBeginOffset:], thrift.I32, thrift.LIST, length)
|
||||||
|
offset += bthrift.Binary.WriteMapEnd(buf[offset:])
|
||||||
|
offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
|
||||||
|
return offset
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *GetPusherOptionsResponse) field1Length() int {
|
||||||
|
l := 0
|
||||||
|
l += bthrift.Binary.FieldBeginLength("options", thrift.MAP, 1)
|
||||||
|
l += bthrift.Binary.MapBeginLength(thrift.I32, thrift.LIST, len(p.Options))
|
||||||
|
for k, v := range p.Options {
|
||||||
|
|
||||||
|
l += bthrift.Binary.I32Length(int32(k))
|
||||||
|
|
||||||
|
l += bthrift.Binary.ListBeginLength(thrift.STRUCT, len(v))
|
||||||
|
for _, v := range v {
|
||||||
|
l += v.BLength()
|
||||||
|
}
|
||||||
|
l += bthrift.Binary.ListEndLength()
|
||||||
|
}
|
||||||
|
l += bthrift.Binary.MapEndLength()
|
||||||
|
l += bthrift.Binary.FieldEndLength()
|
||||||
|
return l
|
||||||
|
}
|
||||||
|
|
||||||
func (p *PushServicePushArgs) FastRead(buf []byte) (int, error) {
|
func (p *PushServicePushArgs) FastRead(buf []byte) (int, error) {
|
||||||
var err error
|
var err error
|
||||||
var offset int
|
var offset int
|
||||||
@ -1192,7 +1414,7 @@ ReadStructEndError:
|
|||||||
func (p *PushServicePushResult) FastReadField0(buf []byte) (int, error) {
|
func (p *PushServicePushResult) FastReadField0(buf []byte) (int, error) {
|
||||||
offset := 0
|
offset := 0
|
||||||
|
|
||||||
tmp := NewPushResp()
|
tmp := NewResp()
|
||||||
if l, err := tmp.FastRead(buf[offset:]); err != nil {
|
if l, err := tmp.FastRead(buf[offset:]); err != nil {
|
||||||
return offset, err
|
return offset, err
|
||||||
} else {
|
} else {
|
||||||
@ -1323,7 +1545,7 @@ ReadStructEndError:
|
|||||||
func (p *PushServiceAddArgs) FastReadField1(buf []byte) (int, error) {
|
func (p *PushServiceAddArgs) FastReadField1(buf []byte) (int, error) {
|
||||||
offset := 0
|
offset := 0
|
||||||
|
|
||||||
tmp := config.NewPushConfig()
|
tmp := config.NewPusherConfig()
|
||||||
if l, err := tmp.FastRead(buf[offset:]); err != nil {
|
if l, err := tmp.FastRead(buf[offset:]); err != nil {
|
||||||
return offset, err
|
return offset, err
|
||||||
} else {
|
} else {
|
||||||
@ -1397,10 +1619,27 @@ func (p *PushServiceAddResult) FastRead(buf []byte) (int, error) {
|
|||||||
if fieldTypeId == thrift.STOP {
|
if fieldTypeId == thrift.STOP {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
|
switch fieldId {
|
||||||
offset += l
|
case 0:
|
||||||
if err != nil {
|
if fieldTypeId == thrift.STRUCT {
|
||||||
goto SkipFieldError
|
l, err = p.FastReadField0(buf[offset:])
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto ReadFieldError
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto SkipFieldError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto SkipFieldError
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
l, err = bthrift.Binary.ReadFieldEnd(buf[offset:])
|
l, err = bthrift.Binary.ReadFieldEnd(buf[offset:])
|
||||||
@ -1420,6 +1659,8 @@ ReadStructBeginError:
|
|||||||
return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
|
return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
|
||||||
ReadFieldBeginError:
|
ReadFieldBeginError:
|
||||||
return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
||||||
|
ReadFieldError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PushServiceAddResult[fieldId]), err)
|
||||||
SkipFieldError:
|
SkipFieldError:
|
||||||
return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
||||||
ReadFieldEndError:
|
ReadFieldEndError:
|
||||||
@ -1428,6 +1669,19 @@ ReadStructEndError:
|
|||||||
return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *PushServiceAddResult) FastReadField0(buf []byte) (int, error) {
|
||||||
|
offset := 0
|
||||||
|
|
||||||
|
tmp := NewResp()
|
||||||
|
if l, err := tmp.FastRead(buf[offset:]); err != nil {
|
||||||
|
return offset, err
|
||||||
|
} else {
|
||||||
|
offset += l
|
||||||
|
}
|
||||||
|
p.Success = tmp
|
||||||
|
return offset, nil
|
||||||
|
}
|
||||||
|
|
||||||
// for compatibility
|
// for compatibility
|
||||||
func (p *PushServiceAddResult) FastWrite(buf []byte) int {
|
func (p *PushServiceAddResult) FastWrite(buf []byte) int {
|
||||||
return 0
|
return 0
|
||||||
@ -1437,6 +1691,7 @@ func (p *PushServiceAddResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.
|
|||||||
offset := 0
|
offset := 0
|
||||||
offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Add_result")
|
offset += bthrift.Binary.WriteStructBegin(buf[offset:], "Add_result")
|
||||||
if p != nil {
|
if p != nil {
|
||||||
|
offset += p.fastWriteField0(buf[offset:], binaryWriter)
|
||||||
}
|
}
|
||||||
offset += bthrift.Binary.WriteFieldStop(buf[offset:])
|
offset += bthrift.Binary.WriteFieldStop(buf[offset:])
|
||||||
offset += bthrift.Binary.WriteStructEnd(buf[offset:])
|
offset += bthrift.Binary.WriteStructEnd(buf[offset:])
|
||||||
@ -1447,12 +1702,33 @@ func (p *PushServiceAddResult) BLength() int {
|
|||||||
l := 0
|
l := 0
|
||||||
l += bthrift.Binary.StructBeginLength("Add_result")
|
l += bthrift.Binary.StructBeginLength("Add_result")
|
||||||
if p != nil {
|
if p != nil {
|
||||||
|
l += p.field0Length()
|
||||||
}
|
}
|
||||||
l += bthrift.Binary.FieldStopLength()
|
l += bthrift.Binary.FieldStopLength()
|
||||||
l += bthrift.Binary.StructEndLength()
|
l += bthrift.Binary.StructEndLength()
|
||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *PushServiceAddResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int {
|
||||||
|
offset := 0
|
||||||
|
if p.IsSetSuccess() {
|
||||||
|
offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0)
|
||||||
|
offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter)
|
||||||
|
offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
|
||||||
|
}
|
||||||
|
return offset
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PushServiceAddResult) field0Length() int {
|
||||||
|
l := 0
|
||||||
|
if p.IsSetSuccess() {
|
||||||
|
l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0)
|
||||||
|
l += p.Success.BLength()
|
||||||
|
l += bthrift.Binary.FieldEndLength()
|
||||||
|
}
|
||||||
|
return l
|
||||||
|
}
|
||||||
|
|
||||||
func (p *PushServiceListArgs) FastRead(buf []byte) (int, error) {
|
func (p *PushServiceListArgs) FastRead(buf []byte) (int, error) {
|
||||||
var err error
|
var err error
|
||||||
var offset int
|
var offset int
|
||||||
@ -1711,6 +1987,214 @@ func (p *PushServiceListResult) field0Length() int {
|
|||||||
return l
|
return l
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *PushServiceGetPusherOptionsArgs) FastRead(buf []byte) (int, error) {
|
||||||
|
var err error
|
||||||
|
var offset int
|
||||||
|
var l int
|
||||||
|
var fieldTypeId thrift.TType
|
||||||
|
var fieldId int16
|
||||||
|
_, l, err = bthrift.Binary.ReadStructBegin(buf)
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto ReadStructBeginError
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
_, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:])
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto ReadFieldBeginError
|
||||||
|
}
|
||||||
|
if fieldTypeId == thrift.STOP {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto SkipFieldError
|
||||||
|
}
|
||||||
|
|
||||||
|
l, err = bthrift.Binary.ReadFieldEnd(buf[offset:])
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto ReadFieldEndError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
l, err = bthrift.Binary.ReadStructEnd(buf[offset:])
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto ReadStructEndError
|
||||||
|
}
|
||||||
|
|
||||||
|
return offset, nil
|
||||||
|
ReadStructBeginError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
|
||||||
|
ReadFieldBeginError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
||||||
|
SkipFieldError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
||||||
|
ReadFieldEndError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
|
||||||
|
ReadStructEndError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// for compatibility
|
||||||
|
func (p *PushServiceGetPusherOptionsArgs) FastWrite(buf []byte) int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PushServiceGetPusherOptionsArgs) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int {
|
||||||
|
offset := 0
|
||||||
|
offset += bthrift.Binary.WriteStructBegin(buf[offset:], "GetPusherOptions_args")
|
||||||
|
if p != nil {
|
||||||
|
}
|
||||||
|
offset += bthrift.Binary.WriteFieldStop(buf[offset:])
|
||||||
|
offset += bthrift.Binary.WriteStructEnd(buf[offset:])
|
||||||
|
return offset
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PushServiceGetPusherOptionsArgs) BLength() int {
|
||||||
|
l := 0
|
||||||
|
l += bthrift.Binary.StructBeginLength("GetPusherOptions_args")
|
||||||
|
if p != nil {
|
||||||
|
}
|
||||||
|
l += bthrift.Binary.FieldStopLength()
|
||||||
|
l += bthrift.Binary.StructEndLength()
|
||||||
|
return l
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PushServiceGetPusherOptionsResult) FastRead(buf []byte) (int, error) {
|
||||||
|
var err error
|
||||||
|
var offset int
|
||||||
|
var l int
|
||||||
|
var fieldTypeId thrift.TType
|
||||||
|
var fieldId int16
|
||||||
|
_, l, err = bthrift.Binary.ReadStructBegin(buf)
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto ReadStructBeginError
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
_, fieldTypeId, fieldId, l, err = bthrift.Binary.ReadFieldBegin(buf[offset:])
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto ReadFieldBeginError
|
||||||
|
}
|
||||||
|
if fieldTypeId == thrift.STOP {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
switch fieldId {
|
||||||
|
case 0:
|
||||||
|
if fieldTypeId == thrift.STRUCT {
|
||||||
|
l, err = p.FastReadField0(buf[offset:])
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto ReadFieldError
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto SkipFieldError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
l, err = bthrift.Binary.Skip(buf[offset:], fieldTypeId)
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto SkipFieldError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
l, err = bthrift.Binary.ReadFieldEnd(buf[offset:])
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto ReadFieldEndError
|
||||||
|
}
|
||||||
|
}
|
||||||
|
l, err = bthrift.Binary.ReadStructEnd(buf[offset:])
|
||||||
|
offset += l
|
||||||
|
if err != nil {
|
||||||
|
goto ReadStructEndError
|
||||||
|
}
|
||||||
|
|
||||||
|
return offset, nil
|
||||||
|
ReadStructBeginError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T read struct begin error: ", p), err)
|
||||||
|
ReadFieldBeginError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T read field %d begin error: ", p, fieldId), err)
|
||||||
|
ReadFieldError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T read field %d '%s' error: ", p, fieldId, fieldIDToName_PushServiceGetPusherOptionsResult[fieldId]), err)
|
||||||
|
SkipFieldError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T field %d skip type %d error: ", p, fieldId, fieldTypeId), err)
|
||||||
|
ReadFieldEndError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T read field end error", p), err)
|
||||||
|
ReadStructEndError:
|
||||||
|
return offset, thrift.PrependError(fmt.Sprintf("%T read struct end error: ", p), err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PushServiceGetPusherOptionsResult) FastReadField0(buf []byte) (int, error) {
|
||||||
|
offset := 0
|
||||||
|
|
||||||
|
tmp := NewGetPusherOptionsResponse()
|
||||||
|
if l, err := tmp.FastRead(buf[offset:]); err != nil {
|
||||||
|
return offset, err
|
||||||
|
} else {
|
||||||
|
offset += l
|
||||||
|
}
|
||||||
|
p.Success = tmp
|
||||||
|
return offset, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
// for compatibility
|
||||||
|
func (p *PushServiceGetPusherOptionsResult) FastWrite(buf []byte) int {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PushServiceGetPusherOptionsResult) FastWriteNocopy(buf []byte, binaryWriter bthrift.BinaryWriter) int {
|
||||||
|
offset := 0
|
||||||
|
offset += bthrift.Binary.WriteStructBegin(buf[offset:], "GetPusherOptions_result")
|
||||||
|
if p != nil {
|
||||||
|
offset += p.fastWriteField0(buf[offset:], binaryWriter)
|
||||||
|
}
|
||||||
|
offset += bthrift.Binary.WriteFieldStop(buf[offset:])
|
||||||
|
offset += bthrift.Binary.WriteStructEnd(buf[offset:])
|
||||||
|
return offset
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PushServiceGetPusherOptionsResult) BLength() int {
|
||||||
|
l := 0
|
||||||
|
l += bthrift.Binary.StructBeginLength("GetPusherOptions_result")
|
||||||
|
if p != nil {
|
||||||
|
l += p.field0Length()
|
||||||
|
}
|
||||||
|
l += bthrift.Binary.FieldStopLength()
|
||||||
|
l += bthrift.Binary.StructEndLength()
|
||||||
|
return l
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PushServiceGetPusherOptionsResult) fastWriteField0(buf []byte, binaryWriter bthrift.BinaryWriter) int {
|
||||||
|
offset := 0
|
||||||
|
if p.IsSetSuccess() {
|
||||||
|
offset += bthrift.Binary.WriteFieldBegin(buf[offset:], "success", thrift.STRUCT, 0)
|
||||||
|
offset += p.Success.FastWriteNocopy(buf[offset:], binaryWriter)
|
||||||
|
offset += bthrift.Binary.WriteFieldEnd(buf[offset:])
|
||||||
|
}
|
||||||
|
return offset
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PushServiceGetPusherOptionsResult) field0Length() int {
|
||||||
|
l := 0
|
||||||
|
if p.IsSetSuccess() {
|
||||||
|
l += bthrift.Binary.FieldBeginLength("success", thrift.STRUCT, 0)
|
||||||
|
l += p.Success.BLength()
|
||||||
|
l += bthrift.Binary.FieldEndLength()
|
||||||
|
}
|
||||||
|
return l
|
||||||
|
}
|
||||||
|
|
||||||
func (p *PushServicePushArgs) GetFirstArgument() interface{} {
|
func (p *PushServicePushArgs) GetFirstArgument() interface{} {
|
||||||
return p.Req
|
return p.Req
|
||||||
}
|
}
|
||||||
@ -1724,7 +2208,7 @@ func (p *PushServiceAddArgs) GetFirstArgument() interface{} {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PushServiceAddResult) GetResult() interface{} {
|
func (p *PushServiceAddResult) GetResult() interface{} {
|
||||||
return nil
|
return p.Success
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PushServiceListArgs) GetFirstArgument() interface{} {
|
func (p *PushServiceListArgs) GetFirstArgument() interface{} {
|
||||||
@ -1734,3 +2218,11 @@ func (p *PushServiceListArgs) GetFirstArgument() interface{} {
|
|||||||
func (p *PushServiceListResult) GetResult() interface{} {
|
func (p *PushServiceListResult) GetResult() interface{} {
|
||||||
return p.Success
|
return p.Success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *PushServiceGetPusherOptionsArgs) GetFirstArgument() interface{} {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *PushServiceGetPusherOptionsResult) GetResult() interface{} {
|
||||||
|
return p.Success
|
||||||
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -12,9 +12,10 @@ import (
|
|||||||
|
|
||||||
// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework.
|
// Client is designed to provide IDL-compatible methods with call-option parameter for kitex framework.
|
||||||
type Client interface {
|
type Client interface {
|
||||||
Push(ctx context.Context, req *push.PushReq, callOptions ...callopt.Option) (r *push.PushResp, err error)
|
Push(ctx context.Context, req *push.PushReq, callOptions ...callopt.Option) (r *push.Resp, err error)
|
||||||
Add(ctx context.Context, req *config.PushConfig, callOptions ...callopt.Option) (err error)
|
Add(ctx context.Context, req *config.PusherConfig, callOptions ...callopt.Option) (r *push.Resp, err error)
|
||||||
List(ctx context.Context, req *push.ListPusherRequest, callOptions ...callopt.Option) (r *push.ListPusherResponse, err error)
|
List(ctx context.Context, req *push.ListPusherRequest, callOptions ...callopt.Option) (r *push.ListPusherResponse, err error)
|
||||||
|
GetPusherOptions(ctx context.Context, callOptions ...callopt.Option) (r *push.GetPusherOptionsResponse, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewClient creates a client for the service defined in IDL.
|
// NewClient creates a client for the service defined in IDL.
|
||||||
@ -46,12 +47,12 @@ type kPushServiceClient struct {
|
|||||||
*kClient
|
*kClient
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *kPushServiceClient) Push(ctx context.Context, req *push.PushReq, callOptions ...callopt.Option) (r *push.PushResp, err error) {
|
func (p *kPushServiceClient) Push(ctx context.Context, req *push.PushReq, callOptions ...callopt.Option) (r *push.Resp, err error) {
|
||||||
ctx = client.NewCtxWithCallOptions(ctx, callOptions)
|
ctx = client.NewCtxWithCallOptions(ctx, callOptions)
|
||||||
return p.kClient.Push(ctx, req)
|
return p.kClient.Push(ctx, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *kPushServiceClient) Add(ctx context.Context, req *config.PushConfig, callOptions ...callopt.Option) (err error) {
|
func (p *kPushServiceClient) Add(ctx context.Context, req *config.PusherConfig, callOptions ...callopt.Option) (r *push.Resp, err error) {
|
||||||
ctx = client.NewCtxWithCallOptions(ctx, callOptions)
|
ctx = client.NewCtxWithCallOptions(ctx, callOptions)
|
||||||
return p.kClient.Add(ctx, req)
|
return p.kClient.Add(ctx, req)
|
||||||
}
|
}
|
||||||
@ -60,3 +61,8 @@ func (p *kPushServiceClient) List(ctx context.Context, req *push.ListPusherReque
|
|||||||
ctx = client.NewCtxWithCallOptions(ctx, callOptions)
|
ctx = client.NewCtxWithCallOptions(ctx, callOptions)
|
||||||
return p.kClient.List(ctx, req)
|
return p.kClient.List(ctx, req)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *kPushServiceClient) GetPusherOptions(ctx context.Context, callOptions ...callopt.Option) (r *push.GetPusherOptionsResponse, err error) {
|
||||||
|
ctx = client.NewCtxWithCallOptions(ctx, callOptions)
|
||||||
|
return p.kClient.GetPusherOptions(ctx)
|
||||||
|
}
|
||||||
|
@ -35,6 +35,13 @@ var serviceMethods = map[string]kitex.MethodInfo{
|
|||||||
false,
|
false,
|
||||||
kitex.WithStreamingMode(kitex.StreamingNone),
|
kitex.WithStreamingMode(kitex.StreamingNone),
|
||||||
),
|
),
|
||||||
|
"GetPusherOptions": kitex.NewMethodInfo(
|
||||||
|
getPusherOptionsHandler,
|
||||||
|
newPushServiceGetPusherOptionsArgs,
|
||||||
|
newPushServiceGetPusherOptionsResult,
|
||||||
|
false,
|
||||||
|
kitex.WithStreamingMode(kitex.StreamingNone),
|
||||||
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -121,12 +128,12 @@ func newPushServicePushResult() interface{} {
|
|||||||
|
|
||||||
func addHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
|
func addHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
|
||||||
realArg := arg.(*push.PushServiceAddArgs)
|
realArg := arg.(*push.PushServiceAddArgs)
|
||||||
|
realResult := result.(*push.PushServiceAddResult)
|
||||||
err := handler.(push.PushService).Add(ctx, realArg.Req)
|
success, err := handler.(push.PushService).Add(ctx, realArg.Req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
realResult.Success = success
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func newPushServiceAddArgs() interface{} {
|
func newPushServiceAddArgs() interface{} {
|
||||||
@ -155,6 +162,24 @@ func newPushServiceListResult() interface{} {
|
|||||||
return push.NewPushServiceListResult()
|
return push.NewPushServiceListResult()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getPusherOptionsHandler(ctx context.Context, handler interface{}, arg, result interface{}) error {
|
||||||
|
_ = arg.(*push.PushServiceGetPusherOptionsArgs)
|
||||||
|
realResult := result.(*push.PushServiceGetPusherOptionsResult)
|
||||||
|
success, err := handler.(push.PushService).GetPusherOptions(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
realResult.Success = success
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func newPushServiceGetPusherOptionsArgs() interface{} {
|
||||||
|
return push.NewPushServiceGetPusherOptionsArgs()
|
||||||
|
}
|
||||||
|
|
||||||
|
func newPushServiceGetPusherOptionsResult() interface{} {
|
||||||
|
return push.NewPushServiceGetPusherOptionsResult()
|
||||||
|
}
|
||||||
|
|
||||||
type kClient struct {
|
type kClient struct {
|
||||||
c client.Client
|
c client.Client
|
||||||
}
|
}
|
||||||
@ -165,7 +190,7 @@ func newServiceClient(c client.Client) *kClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *kClient) Push(ctx context.Context, req *push.PushReq) (r *push.PushResp, err error) {
|
func (p *kClient) Push(ctx context.Context, req *push.PushReq) (r *push.Resp, err error) {
|
||||||
var _args push.PushServicePushArgs
|
var _args push.PushServicePushArgs
|
||||||
_args.Req = req
|
_args.Req = req
|
||||||
var _result push.PushServicePushResult
|
var _result push.PushServicePushResult
|
||||||
@ -175,14 +200,14 @@ func (p *kClient) Push(ctx context.Context, req *push.PushReq) (r *push.PushResp
|
|||||||
return _result.GetSuccess(), nil
|
return _result.GetSuccess(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *kClient) Add(ctx context.Context, req *config.PushConfig) (err error) {
|
func (p *kClient) Add(ctx context.Context, req *config.PusherConfig) (r *push.Resp, err error) {
|
||||||
var _args push.PushServiceAddArgs
|
var _args push.PushServiceAddArgs
|
||||||
_args.Req = req
|
_args.Req = req
|
||||||
var _result push.PushServiceAddResult
|
var _result push.PushServiceAddResult
|
||||||
if err = p.c.Call(ctx, "Add", &_args, &_result); err != nil {
|
if err = p.c.Call(ctx, "Add", &_args, &_result); err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
return nil
|
return _result.GetSuccess(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *kClient) List(ctx context.Context, req *push.ListPusherRequest) (r *push.ListPusherResponse, err error) {
|
func (p *kClient) List(ctx context.Context, req *push.ListPusherRequest) (r *push.ListPusherResponse, err error) {
|
||||||
@ -194,3 +219,12 @@ func (p *kClient) List(ctx context.Context, req *push.ListPusherRequest) (r *pus
|
|||||||
}
|
}
|
||||||
return _result.GetSuccess(), nil
|
return _result.GetSuccess(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *kClient) GetPusherOptions(ctx context.Context) (r *push.GetPusherOptionsResponse, err error) {
|
||||||
|
var _args push.PushServiceGetPusherOptionsArgs
|
||||||
|
var _result push.PushServiceGetPusherOptionsResult
|
||||||
|
if err = p.c.Call(ctx, "GetPusherOptions", &_args, &_result); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return _result.GetSuccess(), nil
|
||||||
|
}
|
||||||
|
28
main.go
28
main.go
@ -1,6 +1,8 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"gitea.timerzz.com/kedaya_haitao/pusher/biz/dal"
|
||||||
|
"gitea.timerzz.com/kedaya_haitao/pusher/pushers"
|
||||||
"net"
|
"net"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -16,6 +18,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
dal.Init()
|
||||||
|
pushers.Init()
|
||||||
opts := kitexInit()
|
opts := kitexInit()
|
||||||
|
|
||||||
svr := pushservice.NewServer(new(PushServiceImpl), opts...)
|
svr := pushservice.NewServer(new(PushServiceImpl), opts...)
|
||||||
@ -30,6 +34,30 @@ func kitexInit() (opts []server.Option) {
|
|||||||
opts = append(opts, server.
|
opts = append(opts, server.
|
||||||
WithTransHandlerFactory(&mixTransHandlerFactory{nil}))
|
WithTransHandlerFactory(&mixTransHandlerFactory{nil}))
|
||||||
|
|
||||||
|
opts = append(opts, server.
|
||||||
|
WithTransHandlerFactory(&mixTransHandlerFactory{nil}))
|
||||||
|
|
||||||
|
opts = append(opts, server.
|
||||||
|
WithTransHandlerFactory(&mixTransHandlerFactory{nil}))
|
||||||
|
|
||||||
|
opts = append(opts, server.
|
||||||
|
WithTransHandlerFactory(&mixTransHandlerFactory{nil}))
|
||||||
|
|
||||||
|
opts = append(opts, server.
|
||||||
|
WithTransHandlerFactory(&mixTransHandlerFactory{nil}))
|
||||||
|
|
||||||
|
opts = append(opts, server.
|
||||||
|
WithTransHandlerFactory(&mixTransHandlerFactory{nil}))
|
||||||
|
|
||||||
|
opts = append(opts, server.
|
||||||
|
WithTransHandlerFactory(&mixTransHandlerFactory{nil}))
|
||||||
|
|
||||||
|
opts = append(opts, server.
|
||||||
|
WithTransHandlerFactory(&mixTransHandlerFactory{nil}))
|
||||||
|
|
||||||
|
opts = append(opts, server.
|
||||||
|
WithTransHandlerFactory(&mixTransHandlerFactory{nil}))
|
||||||
|
|
||||||
// address
|
// address
|
||||||
addr, err := net.ResolveTCPAddr("tcp", conf.GetConf().Kitex.Address)
|
addr, err := net.ResolveTCPAddr("tcp", conf.GetConf().Kitex.Address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
33
model/pusher.go
Normal file
33
model/pusher.go
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PusherType int
|
||||||
|
|
||||||
|
const (
|
||||||
|
PusherType_AnPusher = iota + 1
|
||||||
|
)
|
||||||
|
|
||||||
|
type Pusher struct {
|
||||||
|
ID uint `gorm:"primaryKey" json:"id"`
|
||||||
|
CreatedAt time.Time `json:"createdAt"`
|
||||||
|
UpdatedAt time.Time `json:"updatedAt"`
|
||||||
|
DeletedAt gorm.DeletedAt `gorm:"index"`
|
||||||
|
|
||||||
|
Type PusherType `json:"type"`
|
||||||
|
Name string `json:"name"`
|
||||||
|
Remark string `json:"remark"`
|
||||||
|
RawOption string `json:"option" gorm:"type:json"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p *Pusher) TableName() string {
|
||||||
|
return "pusher"
|
||||||
|
}
|
||||||
|
|
||||||
|
type AnPushOption struct {
|
||||||
|
Token string `json:"token"`
|
||||||
|
Channel string `json:"channel"`
|
||||||
|
}
|
7
model/pusher_test.go
Normal file
7
model/pusher_test.go
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestModel(t *testing.T) {
|
||||||
|
var a AnPushOption
|
||||||
|
}
|
35
pushers/anPush.go
Normal file
35
pushers/anPush.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package pushers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
|
||||||
|
"github.com/go-resty/resty/v2"
|
||||||
|
"strings"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AnPush struct {
|
||||||
|
opt *config.AnPush
|
||||||
|
client *resty.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewAnPush(opt *config.AnPush) *AnPush {
|
||||||
|
return &AnPush{
|
||||||
|
opt: opt,
|
||||||
|
client: resty.New().SetHeader("Content-Type", "application/x-www-form-urlencoded"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type msgResponse struct {
|
||||||
|
Errcode int `json:"errcode"`
|
||||||
|
Errmsg string `json:"errmsg"`
|
||||||
|
Msgid uint64 `json:"msgid"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *AnPush) Push(ctx context.Context, title, content string) error {
|
||||||
|
r := a.client.R().SetBody(strings.NewReader(fmt.Sprintf("title=%s&content=%s&channel=%s", title, content, a.opt.Channel))).SetContext(ctx)
|
||||||
|
var result msgResponse
|
||||||
|
r.SetResult(&result)
|
||||||
|
_, err := r.Post(fmt.Sprintf("https://api.anpush.com/push/%s", a.opt.Token))
|
||||||
|
return err
|
||||||
|
}
|
67
pushers/controller.go
Normal file
67
pushers/controller.go
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
package pushers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"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/sync/errgroup"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Init() {
|
||||||
|
c = &Controller{
|
||||||
|
pushers: make(map[int64]Pusher),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func Push(ctx context.Context, ids []int64, title, content string) error {
|
||||||
|
return c.Push(ctx, ids, title, content)
|
||||||
|
}
|
||||||
|
|
||||||
|
type Pusher interface {
|
||||||
|
Push(ctx context.Context, title, content string) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type Controller struct {
|
||||||
|
pushers map[int64]Pusher
|
||||||
|
l sync.Mutex
|
||||||
|
}
|
||||||
|
|
||||||
|
var c *Controller
|
||||||
|
|
||||||
|
func (c *Controller) Push(ctx context.Context, ids []int64, title, content string) error {
|
||||||
|
wg, sub := errgroup.WithContext(ctx)
|
||||||
|
for _, id := range ids {
|
||||||
|
var i = id
|
||||||
|
wg.Go(func() error {
|
||||||
|
if pusher, ok := c.pushers[i]; ok {
|
||||||
|
return pusher.Push(sub, title, content)
|
||||||
|
} else {
|
||||||
|
var cfg config.PusherConfig
|
||||||
|
if err := postgres.DB.Where("id = ?", i).Find(&cfg).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
c.l.Lock()
|
||||||
|
c.pushers[cfg.Id] = NewPusher(cfg)
|
||||||
|
c.l.Unlock()
|
||||||
|
return c.pushers[cfg.Id].Push(sub, title, content)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return wg.Wait()
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPusher(cfg config.PusherConfig) Pusher {
|
||||||
|
switch cfg.Type {
|
||||||
|
case config.PusherConfigType_AnPush:
|
||||||
|
var opt config.AnPush
|
||||||
|
_ = sonic.UnmarshalString(cfg.Option, &opt)
|
||||||
|
return NewAnPush(&opt)
|
||||||
|
case config.PusherConfigType_Email:
|
||||||
|
var opt config.EmailPush
|
||||||
|
_ = sonic.UnmarshalString(cfg.Option, &opt)
|
||||||
|
return NewEmailPusher(&opt)
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
35
pushers/email.go
Normal file
35
pushers/email.go
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
package pushers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
|
||||||
|
"github.com/wneessen/go-mail"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Email struct {
|
||||||
|
opt *config.EmailPush
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewEmailPusher(opt *config.EmailPush) *Email {
|
||||||
|
return &Email{opt: opt}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *Email) Push(ctx context.Context, title, content string) error {
|
||||||
|
em := mail.NewMsg()
|
||||||
|
if err := em.From(e.opt.From); err != nil {
|
||||||
|
return fmt.Errorf("设置from失败:%v", err)
|
||||||
|
}
|
||||||
|
if err := em.To(e.opt.To); err != nil {
|
||||||
|
return fmt.Errorf("设置to失败:%v", err)
|
||||||
|
}
|
||||||
|
em.Subject(title)
|
||||||
|
em.SetBodyString(mail.TypeTextPlain, content)
|
||||||
|
|
||||||
|
c, err := mail.NewClient(e.opt.Host, mail.WithPort(int(e.opt.Port)), mail.WithSMTPAuth(mail.SMTPAuthPlain),
|
||||||
|
mail.WithUsername(e.opt.Username), mail.WithPassword(e.opt.Password))
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("创建email客户端失败:%v", err)
|
||||||
|
}
|
||||||
|
return c.DialAndSendWithContext(ctx, em)
|
||||||
|
}
|
62
rpc/pusher/pusher_client.go
Normal file
62
rpc/pusher/pusher_client.go
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
package pusher
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
config "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
|
||||||
|
push "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push"
|
||||||
|
|
||||||
|
"gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push/pushservice"
|
||||||
|
"github.com/cloudwego/kitex/client"
|
||||||
|
"github.com/cloudwego/kitex/client/callopt"
|
||||||
|
)
|
||||||
|
|
||||||
|
type RPCClient interface {
|
||||||
|
KitexClient() pushservice.Client
|
||||||
|
Service() string
|
||||||
|
Push(ctx context.Context, req *push.PushReq, callOptions ...callopt.Option) (r *push.Resp, err error)
|
||||||
|
Add(ctx context.Context, req *config.PusherConfig, callOptions ...callopt.Option) (r *push.Resp, err error)
|
||||||
|
List(ctx context.Context, req *push.ListPusherRequest, callOptions ...callopt.Option) (r *push.ListPusherResponse, err error)
|
||||||
|
GetPusherOptions(ctx context.Context, callOptions ...callopt.Option) (r *push.GetPusherOptionsResponse, err error)
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewRPCClient(dstService string, opts ...client.Option) (RPCClient, error) {
|
||||||
|
kitexClient, err := pushservice.NewClient(dstService, opts...)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
cli := &clientImpl{
|
||||||
|
service: dstService,
|
||||||
|
kitexClient: kitexClient,
|
||||||
|
}
|
||||||
|
|
||||||
|
return cli, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
type clientImpl struct {
|
||||||
|
service string
|
||||||
|
kitexClient pushservice.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *clientImpl) Service() string {
|
||||||
|
return c.service
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *clientImpl) KitexClient() pushservice.Client {
|
||||||
|
return c.kitexClient
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *clientImpl) Push(ctx context.Context, req *push.PushReq, callOptions ...callopt.Option) (r *push.Resp, err error) {
|
||||||
|
return c.kitexClient.Push(ctx, req, callOptions...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *clientImpl) Add(ctx context.Context, req *config.PusherConfig, callOptions ...callopt.Option) (r *push.Resp, err error) {
|
||||||
|
return c.kitexClient.Add(ctx, req, callOptions...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *clientImpl) List(ctx context.Context, req *push.ListPusherRequest, callOptions ...callopt.Option) (r *push.ListPusherResponse, err error) {
|
||||||
|
return c.kitexClient.List(ctx, req, callOptions...)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *clientImpl) GetPusherOptions(ctx context.Context, callOptions ...callopt.Option) (r *push.GetPusherOptionsResponse, err error) {
|
||||||
|
return c.kitexClient.GetPusherOptions(ctx, callOptions...)
|
||||||
|
}
|
45
rpc/pusher/pusher_default.go
Normal file
45
rpc/pusher/pusher_default.go
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
package pusher
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
config "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/config"
|
||||||
|
push "gitea.timerzz.com/kedaya_haitao/pusher/kitex_gen/push"
|
||||||
|
"github.com/cloudwego/kitex/client/callopt"
|
||||||
|
"github.com/cloudwego/kitex/pkg/klog"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Push(ctx context.Context, req *push.PushReq, callOptions ...callopt.Option) (resp *push.Resp, err error) {
|
||||||
|
resp, err = defaultClient.Push(ctx, req, callOptions...)
|
||||||
|
if err != nil {
|
||||||
|
klog.CtxErrorf(ctx, "Push call failed,err =%+v", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func Add(ctx context.Context, req *config.PusherConfig, callOptions ...callopt.Option) (resp *push.Resp, err error) {
|
||||||
|
resp, err = defaultClient.Add(ctx, req, callOptions...)
|
||||||
|
if err != nil {
|
||||||
|
klog.CtxErrorf(ctx, "Add call failed,err =%+v", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func List(ctx context.Context, req *push.ListPusherRequest, callOptions ...callopt.Option) (resp *push.ListPusherResponse, err error) {
|
||||||
|
resp, err = defaultClient.List(ctx, req, callOptions...)
|
||||||
|
if err != nil {
|
||||||
|
klog.CtxErrorf(ctx, "List call failed,err =%+v", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetPusherOptions(ctx context.Context, callOptions ...callopt.Option) (resp *push.GetPusherOptionsResponse, err error) {
|
||||||
|
resp, err = defaultClient.GetPusherOptions(ctx, callOptions...)
|
||||||
|
if err != nil {
|
||||||
|
klog.CtxErrorf(ctx, "GetPusherOptions call failed,err =%+v", err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return resp, nil
|
||||||
|
}
|
44
rpc/pusher/pusher_init.go
Normal file
44
rpc/pusher/pusher_init.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package pusher
|
||||||
|
|
||||||
|
import (
|
||||||
|
"sync"
|
||||||
|
|
||||||
|
"github.com/cloudwego/kitex/client"
|
||||||
|
"github.com/cloudwego/kitex/pkg/transmeta"
|
||||||
|
"github.com/cloudwego/kitex/transport"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
// todo edit custom config
|
||||||
|
defaultClient RPCClient
|
||||||
|
defaultDstService = "pusher"
|
||||||
|
defaultClientOpts = []client.Option{
|
||||||
|
client.WithHostPorts("127.0.0.1:8888"),
|
||||||
|
client.WithMetaHandler(transmeta.ClientTTHeaderHandler),
|
||||||
|
client.WithTransportProtocol(transport.TTHeader),
|
||||||
|
}
|
||||||
|
once sync.Once
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
DefaultClient()
|
||||||
|
}
|
||||||
|
|
||||||
|
func DefaultClient() RPCClient {
|
||||||
|
once.Do(func() {
|
||||||
|
defaultClient = newClient(defaultDstService, defaultClientOpts...)
|
||||||
|
})
|
||||||
|
return defaultClient
|
||||||
|
}
|
||||||
|
|
||||||
|
func newClient(dstService string, opts ...client.Option) RPCClient {
|
||||||
|
c, err := NewRPCClient(dstService, opts...)
|
||||||
|
if err != nil {
|
||||||
|
panic("failed to init client: " + err.Error())
|
||||||
|
}
|
||||||
|
return c
|
||||||
|
}
|
||||||
|
|
||||||
|
func InitClient(dstService string, opts ...client.Option) {
|
||||||
|
defaultClient = newClient(dstService, opts...)
|
||||||
|
}
|
@ -1,4 +0,0 @@
|
|||||||
#! /usr/bin/env bash
|
|
||||||
CURDIR=$(cd $(dirname $0); pwd)
|
|
||||||
echo "$CURDIR/bin/pusher"
|
|
||||||
exec "$CURDIR/bin/pusher"
|
|
Loading…
Reference in New Issue
Block a user