From ae65ec414f1883db83d952c2294b244a7e7eb63d Mon Sep 17 00:00:00 2001 From: Masahiro Nagano Date: Sat, 25 Nov 2023 14:00:07 +0900 Subject: [PATCH] Revert "Feature/inject urls for livestream" --- bench/internal/bencherror/message.go | 2 +- bench/internal/scheduler/reservation.go | 25 ++----------------- .../scheduler/reservation_scheduler.go | 18 ++++++------- bench/isupipe/client_payment.go | 4 +++ 4 files changed, 16 insertions(+), 33 deletions(-) diff --git a/bench/internal/bencherror/message.go b/bench/internal/bencherror/message.go index 254748ac0..aaea32266 100644 --- a/bench/internal/bencherror/message.go +++ b/bench/internal/bencherror/message.go @@ -13,7 +13,7 @@ var ErrTimeout = errors.New("タイムアウトによりリクエスト失敗") // ベンチマーカー本体由来のエラー func NewInternalError(err error) error { - err = fmt.Errorf("[致命的なエラー]: %w", err) + err = fmt.Errorf("[ベンチ本体のエラー] スタッフにのみ表示されます: %w", err) return WrapInternalError(SystemError, err) } diff --git a/bench/internal/scheduler/reservation.go b/bench/internal/scheduler/reservation.go index e5875833b..4af7577b2 100644 --- a/bench/internal/scheduler/reservation.go +++ b/bench/internal/scheduler/reservation.go @@ -2,7 +2,6 @@ package scheduler import ( "log" - "math/rand" "time" "github.com/biogo/store/interval" @@ -27,23 +26,6 @@ func ConvertFromIntInterface(i []interval.IntInterface) ([]*Reservation, error) return reservations, nil } -type ReservationUrls struct { - ThumbnailUrl string - PlaylistUrl string -} - -var urls = []*ReservationUrls{ - &ReservationUrls{ThumbnailUrl: "https://media.xiii.isucon.dev/BBB.webp", PlaylistUrl: "https://media.xiii.isucon.dev/bbb.m3u8"}, - &ReservationUrls{ThumbnailUrl: "https://media.xiii.isucon.dev/timewarp.webp", PlaylistUrl: "https://media.xiii.isucon.dev/timewarp.m3u8"}, - &ReservationUrls{ThumbnailUrl: "https://media.xiii.isucon.dev/yoru.webp", PlaylistUrl: "https://media.xiii.isucon.dev/yoru.m3u8"}, - &ReservationUrls{ThumbnailUrl: "https://media.xiii.isucon.dev/isucon11_final.webp", PlaylistUrl: "https://media.xiii.isucon.dev/isucon11_final.m3u8"}, - &ReservationUrls{ThumbnailUrl: "https://media.xiii.isucon.dev/isucon12_final_live.webp", PlaylistUrl: "https://media.xiii.isucon.dev/isucon12_final_live.m3u8"}, - &ReservationUrls{ThumbnailUrl: "https://media.xiii.isucon.dev/isucon13.webp", PlaylistUrl: "https://media.xiii.isucon.dev/isucon13.m3u8"}, - &ReservationUrls{ThumbnailUrl: "https://media.xiii.isucon.dev/isucon9.webp", PlaylistUrl: "https://media.xiii.isucon.dev/isucon9.m3u8"}, - &ReservationUrls{ThumbnailUrl: "https://media.xiii.isucon.dev/hkd.webp", PlaylistUrl: "https://media.xiii.isucon.dev/hkd.m3u8"}, - &ReservationUrls{ThumbnailUrl: "https://media.xiii.isucon.dev/ube.webp", PlaylistUrl: "https://media.xiii.isucon.dev/ube.m3u8"}, -} - type Reservation struct { // NOTE: id は、webappで割り振られるIDではなく、ReservationSchedulerが管理する上で利用するもの id int @@ -66,17 +48,14 @@ func mustNewReservation(id int, title string, description string, startAtStr str log.Fatalln(err) } - urlIdx := rand.Intn(len(urls)) - url := urls[urlIdx] - reservation := &Reservation{ id: id, Title: title, Description: description, StartAt: startAt.Unix(), EndAt: endAt.Unix(), - PlaylistUrl: url.PlaylistUrl, - ThumbnailUrl: url.ThumbnailUrl, + PlaylistUrl: playlistUrl, + ThumbnailUrl: thumbnailUrl, } return reservation diff --git a/bench/internal/scheduler/reservation_scheduler.go b/bench/internal/scheduler/reservation_scheduler.go index 685abbb98..bfc32f115 100644 --- a/bench/internal/scheduler/reservation_scheduler.go +++ b/bench/internal/scheduler/reservation_scheduler.go @@ -52,7 +52,7 @@ func mustNewReservationScheduler(baseAt int64, numSlots int64, hours int) *Reser intervalTempertures, err := newIntervalTemperture(baseAt, numSlots, hours) if err != nil { - lgr.Warnf("failed to initiate interval temperture: %s\n", err.Error()) + lgr.Fatalf("failed to initiate interval temperture: %s\n", err.Error()) } return &ReservationScheduler{ reservationPool: []*Reservation{}, @@ -126,7 +126,7 @@ func (r *ReservationScheduler) GetHotShortReservation() (*Reservation, error) { reservations, err := ConvertFromIntInterface(founds) if err != nil { - lgr.Warnf("GetHotShortReservation: failed to convert reservation: %s\n", err.Error()) + lgr.Fatalf("GetHotShortReservation: failed to convert reservation: %s\n", err.Error()) return nil, err } @@ -142,7 +142,7 @@ func (r *ReservationScheduler) GetHotShortReservation() (*Reservation, error) { } } - lgr.Warn("GetHotShortReservation: failed to get reservation (not found)") + lgr.Fatal("GetHotShortReservation: failed to get reservation (not found)") return nil, ErrNoReservation } @@ -171,7 +171,7 @@ func (r *ReservationScheduler) GetHotLongReservation() (*Reservation, error) { reservations, err := ConvertFromIntInterface(founds) if err != nil { - lgr.Warnf("GetHotLongReservation: failed to convert reservation: %s\n", err.Error()) + lgr.Fatalf("GetHotLongReservation: failed to convert reservation: %s\n", err.Error()) return nil, err } @@ -187,7 +187,7 @@ func (r *ReservationScheduler) GetHotLongReservation() (*Reservation, error) { } } - lgr.Warn("GetHotLongReservation: failed to get reservation (not found)") + lgr.Fatal("GetHotLongReservation: failed to get reservation (not found)") return nil, ErrNoReservation } @@ -216,7 +216,7 @@ func (r *ReservationScheduler) GetColdShortReservation() (*Reservation, error) { reservations, err := ConvertFromIntInterface(founds) if err != nil { - lgr.Warnf("GetColdShortReservation: failed to convert reservation: %s\n", err.Error()) + lgr.Fatalf("GetColdShortReservation: failed to convert reservation: %s\n", err.Error()) return nil, err } @@ -233,7 +233,7 @@ func (r *ReservationScheduler) GetColdShortReservation() (*Reservation, error) { } } - lgr.Warn("GetColdShortReservation: failed to get reservation (not found)") + lgr.Fatal("GetColdShortReservation: failed to get reservation (not found)") return nil, ErrNoReservation } @@ -262,7 +262,7 @@ func (r *ReservationScheduler) GetColdLongReservation() (*Reservation, error) { reservations, err := ConvertFromIntInterface(founds) if err != nil { - lgr.Warnf("GetColdLongReservation: failed to convert reservation: %s\n", err.Error()) + lgr.Fatalf("GetColdLongReservation: failed to convert reservation: %s\n", err.Error()) return nil, err } @@ -279,7 +279,7 @@ func (r *ReservationScheduler) GetColdLongReservation() (*Reservation, error) { } } - lgr.Warn("GetColdLongReservation: failed to get reservation (not found)") + lgr.Fatal("GetColdLongReservation: failed to get reservation (not found)") return nil, ErrNoReservation } diff --git a/bench/isupipe/client_payment.go b/bench/isupipe/client_payment.go index 64d512136..668124111 100644 --- a/bench/isupipe/client_payment.go +++ b/bench/isupipe/client_payment.go @@ -32,5 +32,9 @@ func (c *Client) GetPaymentResult(ctx context.Context) (*PaymentResult, error) { return nil, err } + if err := ValidateResponse(req, paymentResp); err != nil { + return nil, err + } + return paymentResp, nil }