Skip to content

Commit

Permalink
rename Id to ID
Browse files Browse the repository at this point in the history
Signed-off-by: Drumato <[email protected]>
  • Loading branch information
Drumato committed Oct 31, 2023
1 parent 1b07393 commit 171fcbb
Show file tree
Hide file tree
Showing 25 changed files with 217 additions and 217 deletions.
4 changes: 2 additions & 2 deletions bench/internal/scheduler/livecomment_scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ var LivecommentScheduler = mustNewLivecommentScheduler()
// それ以外、通常に分類され、ユーザは通常配信者と視聴者になる

type Livecomment struct {
UserId int
LivestreamId int
UserID int
LivestreamID int
Comment string
Tip int
}
Expand Down
12 changes: 6 additions & 6 deletions bench/internal/scheduler/reaction_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ package scheduler
import "sync"

var (
reactionIdx int
reactionIdxMu sync.Mutex
reactionIDx int
reactionIDxMu sync.Mutex
)

func GetReaction() string {
reactionIdxMu.Lock()
defer reactionIdxMu.Unlock()
reactionIDxMu.Lock()
defer reactionIDxMu.Unlock()

reaction := reactionPool[reactionIdx]
reactionIdx = (reactionIdx + 1) % len(reactionPool)
reaction := reactionPool[reactionIDx]
reactionIDx = (reactionIDx + 1) % len(reactionPool)
return reaction
}

Expand Down
4 changes: 2 additions & 2 deletions bench/internal/scheduler/reservation.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ func mustNewReservation(id int, UserName string, title string, description strin
EndAt: endAt.Unix(),
}
// for i := 0; i < tagCount; i++ {
// tagIdx := rand.Intn(len(tagPool))
// reservation.Tags = append(reservation.Tags, tagIdx)
// tagIDx := rand.Intn(len(tagPool))
// reservation.Tags = append(reservation.Tags, tagIDx)
// }

return reservation
Expand Down
26 changes: 13 additions & 13 deletions bench/isupipe/client_livecomment.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

type Livecomment struct {
Id int `json:"id"`
ID int `json:"id"`
User User `json:"user"`
Livestream Livestream `json:"livestream"`
Comment string `json:"comment"`
Expand All @@ -24,7 +24,7 @@ type Livecomment struct {
}

type LivecommentReport struct {
Id int `json:"id"`
ID int `json:"id"`
Reporter User `json:"reporter"`
Livecomment Livecomment `json:"livecomment"`
CreatedAt int `json:"created_at"`
Expand All @@ -37,7 +37,7 @@ type (
Tip int `json:"tip"`
}
PostLivecommentResponse struct {
Id int `json:"id"`
ID int `json:"id"`
User User `json:"user"`
Livestream Livestream `json:"livestream"`
Comment string `json:"comment"`
Expand All @@ -51,13 +51,13 @@ type ModerateRequest struct {
NGWord string `json:"ng_word"`
}

func (c *Client) GetLivecomments(ctx context.Context, livestreamId int, opts ...ClientOption) ([]Livecomment, error) {
func (c *Client) GetLivecomments(ctx context.Context, livestreamID int, opts ...ClientOption) ([]Livecomment, error) {
var (
defaultStatusCode = http.StatusOK
o = newClientOptions(defaultStatusCode, opts...)
)

urlPath := fmt.Sprintf("/api/livestream/%d/livecomment", livestreamId)
urlPath := fmt.Sprintf("/api/livestream/%d/livecomment", livestreamID)
req, err := c.agent.NewRequest(http.MethodGet, urlPath, nil)
if err != nil {
return nil, bencherror.NewInternalError(err)
Expand Down Expand Up @@ -87,13 +87,13 @@ func (c *Client) GetLivecomments(ctx context.Context, livestreamId int, opts ...
return livecomments, nil
}

func (c *Client) GetLivecommentReports(ctx context.Context, livestreamId int, opts ...ClientOption) ([]LivecommentReport, error) {
func (c *Client) GetLivecommentReports(ctx context.Context, livestreamID int, opts ...ClientOption) ([]LivecommentReport, error) {
var (
defaultStatusCode = http.StatusOK
o = newClientOptions(defaultStatusCode, opts...)
)

urlPath := fmt.Sprintf("/api/livestream/%d/report", livestreamId)
urlPath := fmt.Sprintf("/api/livestream/%d/report", livestreamID)
req, err := c.agent.NewRequest(http.MethodGet, urlPath, nil)
if err != nil {
return nil, bencherror.NewInternalError(err)
Expand Down Expand Up @@ -123,7 +123,7 @@ func (c *Client) GetLivecommentReports(ctx context.Context, livestreamId int, op
return reports, nil
}

func (c *Client) PostLivecomment(ctx context.Context, livestreamId int, r *PostLivecommentRequest, opts ...ClientOption) (*PostLivecommentResponse, error) {
func (c *Client) PostLivecomment(ctx context.Context, livestreamID int, r *PostLivecommentRequest, opts ...ClientOption) (*PostLivecommentResponse, error) {
var (
defaultStatusCode = http.StatusCreated
o = newClientOptions(defaultStatusCode, opts...)
Expand All @@ -134,7 +134,7 @@ func (c *Client) PostLivecomment(ctx context.Context, livestreamId int, r *PostL
return nil, bencherror.NewInternalError(err)
}

urlPath := fmt.Sprintf("/api/livestream/%d/livecomment", livestreamId)
urlPath := fmt.Sprintf("/api/livestream/%d/livecomment", livestreamID)
req, err := c.agent.NewRequest(http.MethodPost, urlPath, bytes.NewReader(payload))
if err != nil {
return nil, bencherror.NewInternalError(err)
Expand Down Expand Up @@ -168,13 +168,13 @@ func (c *Client) PostLivecomment(ctx context.Context, livestreamId int, r *PostL
return livecommentResponse, nil
}

func (c *Client) ReportLivecomment(ctx context.Context, livestreamId, livecommentId int, opts ...ClientOption) error {
func (c *Client) ReportLivecomment(ctx context.Context, livestreamID, livecommentID int, opts ...ClientOption) error {
var (
defaultStatusCode = http.StatusCreated
o = newClientOptions(defaultStatusCode, opts...)
)

urlPath := fmt.Sprintf("/api/livestream/%d/livecomment/%d/report", livestreamId, livecommentId)
urlPath := fmt.Sprintf("/api/livestream/%d/livecomment/%d/report", livestreamID, livecommentID)
req, err := c.agent.NewRequest(http.MethodPost, urlPath, nil)
if err != nil {
return bencherror.NewInternalError(err)
Expand All @@ -198,13 +198,13 @@ func (c *Client) ReportLivecomment(ctx context.Context, livestreamId, livecommen
return nil
}

func (c *Client) Moderate(ctx context.Context, livestreamId int, ngWord string, opts ...ClientOption) error {
func (c *Client) Moderate(ctx context.Context, livestreamID int, ngWord string, opts ...ClientOption) error {
var (
defaultStatusCode = http.StatusCreated
o = newClientOptions(defaultStatusCode, opts...)
)

urlPath := fmt.Sprintf("/api/livestream/%d/moderate", livestreamId)
urlPath := fmt.Sprintf("/api/livestream/%d/moderate", livestreamID)
payload, err := json.Marshal(&ModerateRequest{
NGWord: ngWord,
})
Expand Down
14 changes: 7 additions & 7 deletions bench/isupipe/client_livestream.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
)

type Livestream struct {
Id int `json:"id"`
ID int `json:"id"`
Owner User `json:"owner"`
Tags []Tag `json:"tags"`
Title string `json:"title"`
Expand All @@ -39,15 +39,15 @@ type (

func (c *Client) GetLivestream(
ctx context.Context,
livestreamId int,
livestreamID int,
opts ...ClientOption,
) error {
var (
defaultStatusCode = http.StatusOK
o = newClientOptions(defaultStatusCode, opts...)
)

urlPath := fmt.Sprintf("/api/livestream/%d", livestreamId)
urlPath := fmt.Sprintf("/api/livestream/%d", livestreamID)
req, err := c.agent.NewRequest(http.MethodGet, urlPath, nil)
if err != nil {
return bencherror.NewInternalError(err)
Expand Down Expand Up @@ -181,13 +181,13 @@ func (c *Client) ReserveLivestream(ctx context.Context, r *ReserveLivestreamRequ
return livestream, nil
}

func (c *Client) EnterLivestream(ctx context.Context, livestreamId int, opts ...ClientOption) error {
func (c *Client) EnterLivestream(ctx context.Context, livestreamID int, opts ...ClientOption) error {
var (
defaultStatusCode = http.StatusOK
o = newClientOptions(defaultStatusCode, opts...)
)

urlPath := fmt.Sprintf("/api/livestream/%d/enter", livestreamId)
urlPath := fmt.Sprintf("/api/livestream/%d/enter", livestreamID)
req, err := c.agent.NewRequest(http.MethodPost, urlPath, nil)
if err != nil {
return bencherror.NewInternalError(err)
Expand All @@ -211,13 +211,13 @@ func (c *Client) EnterLivestream(ctx context.Context, livestreamId int, opts ...
return nil
}

func (c *Client) LeaveLivestream(ctx context.Context, livestreamId int, opts ...ClientOption) error {
func (c *Client) LeaveLivestream(ctx context.Context, livestreamID int, opts ...ClientOption) error {
var (
defaultStatusCode = http.StatusOK
o = newClientOptions(defaultStatusCode, opts...)
)

urlPath := fmt.Sprintf("/api/livestream/%d/enter", livestreamId)
urlPath := fmt.Sprintf("/api/livestream/%d/enter", livestreamID)
req, err := c.agent.NewRequest(http.MethodDelete, urlPath, nil)
if err != nil {
return bencherror.NewInternalError(err)
Expand Down
2 changes: 1 addition & 1 deletion bench/isupipe/client_payment.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

type Payment struct {
ReservationId int
ReservationID int
Tip int
}

Expand Down
10 changes: 5 additions & 5 deletions bench/isupipe/client_reaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@ type PostReactionRequest struct {
}

type Reaction struct {
Id int `json:"id"`
ID int `json:"id"`
EmojiName string `json:"emoji_name"`
User User `json:"user"`
Livestream Livestream `json:"livestream"`
CreatedAt int `json:"created_at"`
}

func (c *Client) GetReactions(ctx context.Context, livestreamId int, opts ...ClientOption) ([]Reaction, error) {
func (c *Client) GetReactions(ctx context.Context, livestreamID int, opts ...ClientOption) ([]Reaction, error) {
var (
defaultStatusCode = http.StatusOK
o = newClientOptions(defaultStatusCode, opts...)
)

urlPath := fmt.Sprintf("/api/livestream/%d/reaction", livestreamId)
urlPath := fmt.Sprintf("/api/livestream/%d/reaction", livestreamID)
req, err := c.agent.NewRequest(http.MethodGet, urlPath, nil)
if err != nil {
return nil, bencherror.NewInternalError(err)
Expand Down Expand Up @@ -60,7 +60,7 @@ func (c *Client) GetReactions(ctx context.Context, livestreamId int, opts ...Cli
return reactions, nil
}

func (c *Client) PostReaction(ctx context.Context, livestreamId int, r *PostReactionRequest, opts ...ClientOption) (*Reaction, error) {
func (c *Client) PostReaction(ctx context.Context, livestreamID int, r *PostReactionRequest, opts ...ClientOption) (*Reaction, error) {
var (
defaultStatusCode = http.StatusCreated
o = newClientOptions(defaultStatusCode, opts...)
Expand All @@ -71,7 +71,7 @@ func (c *Client) PostReaction(ctx context.Context, livestreamId int, r *PostReac
return nil, bencherror.NewInternalError(err)
}

urlPath := fmt.Sprintf("/api/livestream/%d/reaction", livestreamId)
urlPath := fmt.Sprintf("/api/livestream/%d/reaction", livestreamID)
req, err := c.agent.NewRequest(http.MethodPost, urlPath, bytes.NewReader(payload))
if err != nil {
return nil, bencherror.NewInternalError(err)
Expand Down
4 changes: 2 additions & 2 deletions bench/isupipe/client_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ func (c *Client) GetUserStatistics(ctx context.Context, username string, opts ..
return stats, nil
}

func (c *Client) GetLivestreamStatistics(ctx context.Context, livestreamId int, opts ...ClientOption) (*LivestreamStatistics, error) {
func (c *Client) GetLivestreamStatistics(ctx context.Context, livestreamID int, opts ...ClientOption) (*LivestreamStatistics, error) {
var (
defaultStatusCode = http.StatusOK
o = newClientOptions(defaultStatusCode, opts...)
)

urlPath := fmt.Sprintf("/api/livestream/%d/statistics", livestreamId)
urlPath := fmt.Sprintf("/api/livestream/%d/statistics", livestreamID)
req, err := c.agent.NewRequest(http.MethodGet, urlPath, nil)
if err != nil {
return nil, bencherror.NewInternalError(err)
Expand Down
4 changes: 2 additions & 2 deletions bench/isupipe/client_top.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

type Tag struct {
Id int `json:"id"`
ID int `json:"id"`
Name string `json:"name"`
// CreatedAt is the created timestamp that forms an UNIX time.
CreatedAt int `json:"created_at"`
Expand Down Expand Up @@ -68,7 +68,7 @@ func (c *Client) GetRandomTags(ctx context.Context, n int) ([]int, error) {

var tags []int
for i := 0; i < n; i++ {
tags = append(tags, resp.Tags[i].Id)
tags = append(tags, resp.Tags[i].ID)
}

return tags, nil
Expand Down
2 changes: 1 addition & 1 deletion bench/isupipe/client_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
)

type User struct {
Id int `json:"id"`
ID int `json:"id"`
Name string `json:"name"`
DisplayName string `json:"display_name"`
Description string `json:"description"`
Expand Down
2 changes: 1 addition & 1 deletion bench/scenario/core_finalcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func FinalcheckScenario(ctx context.Context, client *isupipe.Client) error {
// 予約の整合性チェック
for _, payment := range result.Payments {
_ = payment
// payment.ReservationId
// payment.ReservationID
}

lgr.Infof("result = %+v\n", result)
Expand Down
28 changes: 14 additions & 14 deletions bench/scenario/core_pretest.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ func Pretest(ctx context.Context, client *isupipe.Client) error {

var (
tagCount = rand.Intn(5)
tagStartIdx = rand.Intn(len(tagResponse.Tags))
tagEndIdx = min(tagStartIdx+tagCount, len(tagResponse.Tags))
tagStartIDx = rand.Intn(len(tagResponse.Tags))
tagEndIDx = min(tagStartIDx+tagCount, len(tagResponse.Tags))
)
var tags []int
for _, tag := range tagResponse.Tags[tagStartIdx:tagEndIdx] {
tags = append(tags, tag.Id)
for _, tag := range tagResponse.Tags[tagStartIDx:tagEndIDx] {
tags = append(tags, tag.ID)
}

// FIXME: 枠数を超えて予約した場合にエラーになるか
Expand All @@ -95,40 +95,40 @@ func Pretest(ctx context.Context, client *isupipe.Client) error {
}
scheduler.ReservationSched.CommitReservation(reservation)

if _, err = client.GetLivecommentReports(ctx, livestream.Id); err != nil {
if _, err = client.GetLivecommentReports(ctx, livestream.ID); err != nil {
return err
}
if err = client.GetLivestream(ctx, livestream.Id); err != nil {
if err = client.GetLivestream(ctx, livestream.ID); err != nil {
return err
}

if err := client.EnterLivestream(ctx, livestream.Id); err != nil {
if err := client.EnterLivestream(ctx, livestream.ID); err != nil {
return err
}

livecomment, err := client.PostLivecomment(ctx, livestream.Id, &isupipe.PostLivecommentRequest{
livecomment, err := client.PostLivecomment(ctx, livestream.ID, &isupipe.PostLivecommentRequest{
Comment: "test",
Tip: 3,
})
if err != nil {
return err
}

if _, err := client.GetLivecomments(ctx, livestream.Id /* livestream id*/); err != nil {
if _, err := client.GetLivecomments(ctx, livestream.ID /* livestream id*/); err != nil {
return err
}

if err := client.ReportLivecomment(ctx, livestream.Id, livecomment.Id); err != nil {
if err := client.ReportLivecomment(ctx, livestream.ID, livecomment.ID); err != nil {
return err
}

if _, err := client.PostReaction(ctx, livestream.Id /* livestream id*/, &isupipe.PostReactionRequest{
if _, err := client.PostReaction(ctx, livestream.ID /* livestream id*/, &isupipe.PostReactionRequest{
EmojiName: "chair",
}); err != nil {
return err
}

if _, err := client.GetReactions(ctx, livestream.Id /* livestream id*/); err != nil {
if _, err := client.GetReactions(ctx, livestream.ID /* livestream id*/); err != nil {
return err
}

Expand All @@ -140,11 +140,11 @@ func Pretest(ctx context.Context, client *isupipe.Client) error {
return err
}

if _, err := client.GetLivestreamStatistics(ctx, livestream.Id); err != nil {
if _, err := client.GetLivestreamStatistics(ctx, livestream.ID); err != nil {
return err
}

if err := client.LeaveLivestream(ctx, livestream.Id); err != nil {
if err := client.LeaveLivestream(ctx, livestream.ID); err != nil {
return err
}

Expand Down
Loading

0 comments on commit 171fcbb

Please sign in to comment.