generated from kedaya_haitao/template
This commit is contained in:
parent
fe2702fb58
commit
5845828066
15
rate/rate.go
15
rate/rate.go
@ -4,12 +4,14 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"gitea.timerzz.com/kedaya_haitao/common/pkg/subscribe"
|
||||
"gitea.timerzz.com/kedaya_haitao/common/structs/storage"
|
||||
"gitea.timerzz.com/kedaya_haitao/common/structs/utils"
|
||||
"github.com/golang/glog"
|
||||
"github.com/redis/go-redis/v9"
|
||||
"golang.org/x/sync/errgroup"
|
||||
)
|
||||
|
||||
type Controller struct {
|
||||
@ -38,6 +40,19 @@ func (c *Controller) Run() error {
|
||||
|
||||
// 处理接受到的信息
|
||||
func (c *Controller) Rate(ctx context.Context, idString string) error {
|
||||
var ids = strings.Split(idString, ",")
|
||||
var wg errgroup.Group
|
||||
for _, id := range ids {
|
||||
var i = id
|
||||
wg.Go(func() error {
|
||||
return c.rate(ctx, i)
|
||||
})
|
||||
}
|
||||
return wg.Wait()
|
||||
}
|
||||
|
||||
// 处理接收到的信息
|
||||
func (c *Controller) rate(ctx context.Context, idString string) error {
|
||||
i, _ := strconv.Atoi(idString)
|
||||
if i <= 0 {
|
||||
return fmt.Errorf("接收到的id不正确:%s", idString)
|
||||
|
Loading…
x
Reference in New Issue
Block a user