Skip to content

Commit

Permalink
Merge pull request #642 from isucon/nearbychair
Browse files Browse the repository at this point in the history
2つまでは椅子が想定よりも足りてなくても許容する
  • Loading branch information
wtks authored Dec 5, 2024
2 parents 5eb373a + 5e4ad66 commit 6d2f58d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
3 changes: 3 additions & 0 deletions bench/benchmarker/world/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ const (
ErrorCodeChairReceivedDataIsWrong
// ErrorCodeWrongNearbyChairs 取得した付近の椅子情報に不備があります
ErrorCodeWrongNearbyChairs
// ErrorCodeLackOfNearbyChairs 取得した付近の椅子情報が足りません
ErrorCodeLackOfNearbyChairs
)

var CriticalErrorCodes = map[ErrorCode]bool{
Expand Down Expand Up @@ -110,6 +112,7 @@ var ErrorTexts = map[ErrorCode]string{
ErrorCodeUncontrollableRequestReceived: "アサインされたライドがベンチマーカー外で作られたものであるため処理できません",
ErrorCodeChairReceivedDataIsWrong: "椅子が受け取った通知の内容が想定と異なります",
ErrorCodeWrongNearbyChairs: "取得した付近の椅子情報に不備があります",
ErrorCodeLackOfNearbyChairs: "付近の椅子情報が想定よりも3つ以上足りていません",
}

type codeError struct {
Expand Down
10 changes: 8 additions & 2 deletions bench/benchmarker/world/world.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ func (w *World) checkNearbyChairsResponse(baseTime time.Time, current Coordinate
}
checked[chair.ID] = true
}
if len(errs) > 0 {
go w.PublishEvent(&EventSoftError{Error: WrapCodeError(ErrorCodeTooOldNearbyChairsResponse, errors.Join(errs...))})
errs = nil
}

for chair := range w.EmptyChairs.Iter() {
if !checked[chair.ServerID] && chair.matchingData == nil && chair.Request == nil && chair.ActivatedAt.Before(baseTime) {
ok := false
Expand All @@ -389,8 +394,9 @@ func (w *World) checkNearbyChairsResponse(baseTime time.Time, current Coordinate
}
}
}
if len(errs) > 0 {
go w.PublishEvent(&EventSoftError{Error: WrapCodeError(ErrorCodeTooOldNearbyChairsResponse, errors.Join(errs...))})
// 2個までは無くても許容する
if len(errs) >= 3 {
go w.PublishEvent(&EventSoftError{Error: CodeError(ErrorCodeLackOfNearbyChairs)})
}
return nil
}
Expand Down

0 comments on commit 6d2f58d

Please sign in to comment.