Skip to content

Commit

Permalink
fix bugs: rpc_client post 1000 rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
hellodudu committed Oct 25, 2019
1 parent 6e626f6 commit f1ee26a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
Binary file modified apps/rpc_presure/rpc-client
Binary file not shown.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ services:
#options:
#loki-url: http://host.docker.internal:3100/api/prom/push
#loki-retries: "5"
#loki-batch-size: "400"
# loki-batch-size: "400"

consul:
image: consul
Expand Down
23 changes: 12 additions & 11 deletions internal/rpc_presure/rpc_presure.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,67 +82,67 @@ func (r *RPCPresure) initService() {
func (r *RPCPresure) initRandFuncs() {
// game: get player info
r.randFuncs = append(r.randFuncs, func(game pbGame.GameService, arena pbArena.ArenaService) error {
resp, err := game.GetPlayerInfoByID(r.ctx, &pbGame.GetPlayerInfoByIDRequest{Id: playerID[rand.Intn(len(playerID))]})
_, err := game.GetPlayerInfoByID(r.ctx, &pbGame.GetPlayerInfoByIDRequest{Id: playerID[rand.Intn(len(playerID))]})
return err
})

// game: get guild info
r.randFuncs = append(r.randFuncs, func(game pbGame.GameService, arena pbArena.ArenaService) error {
resp, err := game.GetGuildInfoByID(r.ctx, &pbGame.GetGuildInfoByIDRequest{Id: guildID[rand.Intn(len(guildID))]})
_, err := game.GetGuildInfoByID(r.ctx, &pbGame.GetGuildInfoByIDRequest{Id: guildID[rand.Intn(len(guildID))]})
return err
})

// arena: get season data
r.randFuncs = append(r.randFuncs, func(game pbGame.GameService, arena pbArena.ArenaService) error {
resp, err := arena.GetSeasonData(r.ctx, &pbArena.GetSeasonDataRequest{})
_, err := arena.GetSeasonData(r.ctx, &pbArena.GetSeasonDataRequest{})
return err
})

// arena: get champion
r.randFuncs = append(r.randFuncs, func(game pbGame.GameService, arena pbArena.ArenaService) error {
resp, err := arena.GetChampion(r.ctx, &pbArena.GetChampionRequest{})
_, err := arena.GetChampion(r.ctx, &pbArena.GetChampionRequest{})
return err
})

// arena: get rank
r.randFuncs = append(r.randFuncs, func(game pbGame.GameService, arena pbArena.ArenaService) error {
resp, err := arena.GetRank(r.ctx, &pbArena.GetRankRequest{PlayerId: playerID[rand.Intn(len(playerID))], Page: rand.Int31n(maxPage)})
_, err := arena.GetRank(r.ctx, &pbArena.GetRankRequest{PlayerId: playerID[rand.Intn(len(playerID))], Page: rand.Int31n(maxPage)})
return err
})

// arena: get arena data num
r.randFuncs = append(r.randFuncs, func(game pbGame.GameService, arena pbArena.ArenaService) error {
resp, err := arena.GetArenaDataNum(r.ctx, &pbArena.GetArenaDataNumRequest{})
_, err := arena.GetArenaDataNum(r.ctx, &pbArena.GetArenaDataNumRequest{})
return err
})

// arena: get record num
r.randFuncs = append(r.randFuncs, func(game pbGame.GameService, arena pbArena.ArenaService) error {
resp, err := arena.GetRecordNum(r.ctx, &pbArena.GetRecordNumRequest{})
_, err := arena.GetRecordNum(r.ctx, &pbArena.GetRecordNumRequest{})
return err
})

// arena: get matching list
r.randFuncs = append(r.randFuncs, func(game pbGame.GameService, arena pbArena.ArenaService) error {
resp, err := arena.GetMatchingList(r.ctx, &pbArena.GetMatchingListRequest{})
_, err := arena.GetMatchingList(r.ctx, &pbArena.GetMatchingListRequest{})
return err
})

// arena: get record req list
r.randFuncs = append(r.randFuncs, func(game pbGame.GameService, arena pbArena.ArenaService) error {
resp, err := arena.GetRecordReqList(r.ctx, &pbArena.GetRecordReqListRequest{})
_, err := arena.GetRecordReqList(r.ctx, &pbArena.GetRecordReqListRequest{})
return err
})

// arena: get record by id
r.randFuncs = append(r.randFuncs, func(game pbGame.GameService, arena pbArena.ArenaService) error {
resp, err := arena.GetRecordByID(r.ctx, &pbArena.GetRecordByIDRequest{Id: playerID[rand.Intn(len(playerID))]})
_, err := arena.GetRecordByID(r.ctx, &pbArena.GetRecordByIDRequest{Id: playerID[rand.Intn(len(playerID))]})
return err
})

// arena: get rank list by page
r.randFuncs = append(r.randFuncs, func(game pbGame.GameService, arena pbArena.ArenaService) error {
resp, err := arena.GetRankListByPage(r.ctx, &pbArena.GetRankListByPageRequest{Page: rand.Int31n(maxPage)})
_, err := arena.GetRankListByPage(r.ctx, &pbArena.GetRankListByPageRequest{Page: rand.Int31n(maxPage)})
return err
})
}
Expand Down Expand Up @@ -208,6 +208,7 @@ func (r *RPCPresure) work() error {
logger.Info("do rpc call ", r.opts.RPCTimes, " times, cost time ", d)
time.Sleep(time.Second - d)
now = time.Now()
times = 0
}
}
}
Expand Down

0 comments on commit f1ee26a

Please sign in to comment.