Skip to content

Commit

Permalink
GetLivestreamStatisticsの呼び出し頻度調整
Browse files Browse the repository at this point in the history
初期状態で重すぎて全員呼ぶと何もできないので、とりあえず1/10
  • Loading branch information
fujiwara committed Nov 23, 2023
1 parent 60b6e3a commit c1fb85f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
10 changes: 6 additions & 4 deletions bench/scenario/viewer.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ func BasicViewerScenario(
return err
}

lgr.Info("get livestream stats")
if _, err := client.GetLivestreamStatistics(ctx, livestream.ID, livestream.Owner.Name); err != nil && !errors.Is(err, bencherror.ErrTimeout) {
lgr.Warnf("view: failed to get livestream stats: %s\n", err.Error())
return err
if n%10 == 1 { // NOTE: 本来のクライアントは全員statsを呼ぶが、重すぎるので調整
lgr.Info("get livestream stats")
if _, err := client.GetLivestreamStatistics(ctx, livestream.ID, livestream.Owner.Name); err != nil && !errors.Is(err, bencherror.ErrTimeout) {
lgr.Warnf("view: failed to get livestream stats: %s\n", err.Error())
return err
}
}

contestantLogger.Info("視聴を開始しました", zap.String("username", username), zap.Int("duration_hours", livestream.Hours()))
Expand Down
11 changes: 7 additions & 4 deletions bench/scenario/visit_page.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,13 @@ func VisitLivestream(ctx context.Context, contestantLogger *zap.Logger, client *
return err
}

_, err := client.GetLivestreamStatistics(ctx, livestream.ID, livestream.Owner.Name)
if err != nil {
return err
}
/*
// NOTE: viwersのほうで呼ぶのでこっちは一旦やめます
_, err := client.GetLivestreamStatistics(ctx, livestream.ID, livestream.Owner.Name)
if err != nil {
return err
}
*/

livecomments, err := client.GetLivecomments(ctx, livestream.ID, livestream.Owner.Name, isupipe.WithLimitQueryParam(10))
if err != nil {
Expand Down

0 comments on commit c1fb85f

Please sign in to comment.