Skip to content

Commit

Permalink
Merge pull request #537 from isucon/461_fix-post-condition-endpoint
Browse files Browse the repository at this point in the history
POST condition endpointの変更
  • Loading branch information
ryoha000 authored Jul 26, 2021
2 parents bf36994 + 39a1759 commit c49c7e3
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions bench/scenario/action.go
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ func getIsuIconErrorAction(ctx context.Context, a *agent.Agent, id string) (stri
}

func postIsuConditionAction(ctx context.Context, a *agent.Agent, id string, req service.PostIsuConditionRequest) (*http.Response, error) {
reqUrl := fmt.Sprintf("/api/isu/%s/condition", id)
reqUrl := fmt.Sprintf("/api/condition/%s", id)
body, err := json.Marshal(req)
if err != nil {
logger.AdminLogger.Panic(err)
Expand All @@ -446,7 +446,7 @@ func postIsuConditionAction(ctx context.Context, a *agent.Agent, id string, req
}

func postIsuConditionErrorAction(ctx context.Context, a *agent.Agent, id string, req service.PostIsuConditionRequest) (string, *http.Response, error) {
reqUrl := fmt.Sprintf("/api/isu/%s/condition", id)
reqUrl := fmt.Sprintf("/api/condition/%s", id)
body, err := json.Marshal(req)
if err != nil {
logger.AdminLogger.Panic(err)
Expand Down
4 changes: 2 additions & 2 deletions bench/scenario/posting.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type posterState struct {
isuStateDelete bool //椅子を削除する(正の点数が出るpostを行わない)
}

//POST /api/isu/{jia_isu_id}/conditionをたたく Goroutine
//POST /api/condition/{jia_isu_id}をたたく Goroutine
func (s *Scenario) keepPosting(ctx context.Context, step *isucandar.BenchmarkStep, targetBaseURL string, jiaIsuUUID string, scenarioChan *model.StreamsForPoster) {
defer func() { scenarioChan.ActiveChan <- false }() //deactivate 容量1で、ここでしか使わないのでブロックしない

Expand All @@ -53,7 +53,7 @@ func (s *Scenario) keepPosting(ctx context.Context, step *isucandar.BenchmarkSte
isuStateDelete: false,
}
randEngine := rand.New(rand.NewSource(0))
targetURL := fmt.Sprintf("%s/api/isu/%s/condition", targetBaseURL, jiaIsuUUID)
targetURL := fmt.Sprintf("%s/api/condition/%s", targetBaseURL, jiaIsuUUID)
httpClient := http.Client{}
httpClient.Timeout = agent.DefaultRequestTimeout + 5*time.Second //MEMO: post conditionがtimeoutすると付随してたくさんエラーが出るので、timeoutしにくいようにする

Expand Down
4 changes: 2 additions & 2 deletions development/doc/api/isu-condition.yml
Original file line number Diff line number Diff line change
Expand Up @@ -468,10 +468,10 @@ paths:
$ref: "#/components/responses/NotFoundError"


/api/isu/{jia_isu_uuid}/condition:
/api/condition/{jia_isu_uuid}:
post:
tags: [backend]
summary: '/api/isu/{jia_isu_uuid}/condition'
summary: '/api/condition/{jia_isu_uuid}'
description: 'ISUからのセンサデータを受け取る'
parameters:
- name: jia_isu_uuid
Expand Down
2 changes: 1 addition & 1 deletion extra/jiaapi-mock/model/isu_poster.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func NewIsuConditionPoster(targetIP string, targetPort int, isuUUID string) IsuC

func (m *IsuConditionPoster) KeepPosting() {
targetURL := fmt.Sprintf(
"http://%s:%d/api/isu/%s/condition",
"http://%s:%d/api/condition/%s",
m.TargetIP, m.TargetPort, m.IsuUUID,
)
randEngine := rand.New(rand.NewSource(0))
Expand Down
4 changes: 2 additions & 2 deletions webapp/go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func main() {
e.GET("/api/condition", getAllIsuConditions)
e.GET("/api/condition/:jia_isu_uuid", getIsuConditions)
// API for Isu
e.POST("/api/isu/:jia_isu_uuid/condition", postIsuCondition)
e.POST("/api/condition/:jia_isu_uuid", postIsuCondition)
// Frontend
e.GET("/", getIndex)
e.GET("/condition", getIndex)
Expand Down Expand Up @@ -1161,7 +1161,7 @@ func getIsuConditionsFromDB(jiaIsuUUID string, cursorEndTime time.Time, conditio
return conditionsResponse, nil
}

// POST /api/isu/{jia_isu_uuid}/condition
// POST /api/condition/{jia_isu_uuid}
// ISUからのセンサデータを受け取る
func postIsuCondition(c echo.Context) error {
// input (path_param)
Expand Down

0 comments on commit c49c7e3

Please sign in to comment.