Skip to content
This repository has been archived by the owner on Feb 27, 2023. It is now read-only.

Commit

Permalink
feature: define the interface and http api of preheat
Browse files Browse the repository at this point in the history
Signed-off-by: lowzj <zj3142063@gmail.com>
  • Loading branch information
lowzj committed May 7, 2020
1 parent 0d3e9b2 commit 435eb38
Show file tree
Hide file tree
Showing 10 changed files with 483 additions and 50 deletions.
49 changes: 45 additions & 4 deletions apis/swagger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,10 @@ paths:
description: "bad parameter"
schema:
$ref: '#/definitions/Error'
409:
description: "preheat task already exists"
schema:
$ref: '#/definitions/Error'
500:
$ref: "#/responses/500ErrorResponse"

Expand Down Expand Up @@ -628,6 +632,28 @@ paths:
500:
$ref: "#/responses/500ErrorResponse"

delete:
summary: "Delete a preheat task"
description: |
delete a preheat task
produces:
- "application/json"
parameters:
- name: id
in: path
required: true
description: "ID of preheat task"
type: string
responses:
200:
description: "no error"
404:
description: "no such preheat task"
schema:
$ref: "#/responses/404ErrorResponse"
500:
$ref: "#/responses/500ErrorResponse"

/task/metrics:
post:
summary: "upload dfclient download metrics"
Expand Down Expand Up @@ -1225,7 +1251,7 @@ definitions:
taskId:
type: "string"
description: |
the taskID of the piece.
the taskID of the piece.
srcCid:
type: "string"
description: |
Expand Down Expand Up @@ -1270,15 +1296,14 @@ definitions:
description: |
ID of preheat task.
status:
type: "string"
$ref: "#/definitions/PreheatStatus"
description: |
The status of preheat task.
WAITING -----> RUNNING -----> SUCCESS
|--> FAILED
The initial status of a created preheat task is WAITING.
It's finished when a preheat task's status is FAILED or SUCCESS.
A finished preheat task's information can be queried within 24 hours.
enum: ["WAITING", "RUNNING", "FAILED", "SUCCESS"]
startTime:
type: "string"
format: "date-time"
Expand All @@ -1288,17 +1313,33 @@ definitions:
format: "date-time"
description: "the preheat task finish time"

PreheatStatus:
type: string
description: |
The status of preheat task.
WAITING -----> RUNNING -----> SUCCESS
|--> FAILED
The initial status of a created preheat task is WAITING.
It's finished when a preheat task's status is FAILED or SUCCESS.
A finished preheat task's information can be queried within 24 hours.
enum: ["WAITING", "RUNNING", "FAILED", "SUCCESS"]

PreheatCreateRequest:
type: "object"
description: |
Request option of creating a preheat task in supernode.
required:
- type
- url
properties:
type:
type: "string"
enum: ["image", "file"]
description: |
this must be image or file
url:
type: "string"
minLength: 3
description: "the image or file location"
filter:
type: "string"
Expand Down Expand Up @@ -1356,7 +1397,7 @@ definitions:
status:
type: "string"
description: |
The status of Dfget download process.
The status of Dfget download process.
enum: ["WAITING", "RUNNING", "FAILED", "SUCCESS"]
peerID:
type: "string"
Expand Down
81 changes: 79 additions & 2 deletions apis/types/preheat_create_request.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 5 additions & 41 deletions apis/types/preheat_info.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 75 additions & 0 deletions apis/types/preheat_status.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions client/preheat_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func TestPreheatInfo(t *testing.T) {
id := "1234567890"
startTime := strfmt.DateTime(time.Now())
finishTime := strfmt.DateTime(time.Now().Add(time.Duration(time.Minute)))
status := "SUCCESS"
status := types.PreheatStatusSUCCESS

expectedURL := fmt.Sprintf("/preheats/%s", id)

Expand All @@ -65,7 +65,7 @@ func TestPreheatInfo(t *testing.T) {
ID: id,
StartTime: startTime,
FinishTime: finishTime,
Status: "SUCCESS",
Status: types.PreheatStatusSUCCESS,
}
b, err := json.Marshal(info)
if err != nil {
Expand Down
Loading

0 comments on commit 435eb38

Please sign in to comment.