Skip to content

Commit

Permalink
optimize interfaces reademe and structure (#189)
Browse files Browse the repository at this point in the history
  • Loading branch information
xjlgod authored Apr 20, 2022
1 parent 8c5500f commit fe4ade1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 63 deletions.
60 changes: 25 additions & 35 deletions server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ $ ./nebula-studio-server -studio-config="./config/example-config.yaml"
| Name | Path | Method |
| ------------------ | ------------------------- | -------- |
| ExecNGQL | /api-nebula/db/exec | POST |
| BatchExecNGQL | /api-nebula/db/batchExec | POST |
| ConnectDB | /api-nebula/db/connect | POST |
| DisconnectDB | /api-nebula/db/disconnect | POST |
| ImportData | /api/import-tasks/import | POST |
| HandleImportAction | /api/import-tasks/action | POST |
| QueryImportStats | /api/import-tasks/stats/{id:string} | GET |
| DownloadConfig | /api/import-tasks/config/{id:string} | GET |
| DownloadImportLog | /api/import-tasks/{id:string}/log | GET |
| DownloadErrLog | /api/import-tasks/{id:string}/err-logs | GET |
Expand Down Expand Up @@ -66,6 +66,29 @@ Response:
}
```

#### BatchExecNGQL

The request json body:

```json
{gql: [""], paramList: [":params"]}
```

Response:

```json
{
"code": 0,
"message": "",
"data": {
"headers": [],
"tables": [],
"timeCost": 0,
"localParams": null
}
}
```

#### ConnectDB API

Header:
Expand Down Expand Up @@ -165,40 +188,6 @@ Response:
}
```

#### QueryImportStats API

/api/import-tasks/stats/3

Response:

```json
{
"code": 0,
"message": "Processing a task action successfully",
"data": {
"taskID": 3,
"name": "task1",
"space": "test",
"nebulaAddress": "192.168.8.233:9669",
"createdTime": 1646989643,
"updatedTime": 1646989646,
"user": "root",
"taskStatus": "statusFinished",
"taskMessage": "",
"stats": {
"numFailed": 0,
"numReadFailed": 0,
"totalCount": 52,
"totalBatches": 10,
"totalLatency": 30089,
"totalReqTime": 532718,
"totalBytes": 1583,
"totalImportedBytes": 1583
}
}
}
```

#### DownloadConfig API

/api/import-tasks/config/2
Expand Down Expand Up @@ -350,6 +339,7 @@ Response:
"data": [
{
"name": "import.log"
}
{
"name": "err 1.log"
},
Expand Down
4 changes: 0 additions & 4 deletions server/pkg/api/routes/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ var ImportRoute = base.Route{
Path: "action",
POST: controller.HandleImportAction,
},
{
Path: "stats/{id:string}",
GET: controller.QueryImportStats,
},
{
Path: "config/{id:string}",
GET: controller.DownloadConfigFile,
Expand Down
24 changes: 0 additions & 24 deletions server/pkg/webserver/controller/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,30 +136,6 @@ func ImportData(ctx iris.Context) base.Result {
}
}

func QueryImportStats(ctx iris.Context) base.Result {
id := ctx.Params().GetString("id")
if id == "" {
zap.L().Warn("queryImportStats id get fail")
return base.Response{
Code: base.Error,
Message: "queryImportStats id get fail",
}
}
taskInfo, err := importer.ImportStatus(id)
if err != nil {
zap.L().Warn("queryImportStats fail", zap.Error(err))
return base.Response{
Code: base.Error,
Message: err.Error(),
}
}
return base.Response{
Code: base.Success,
Message: "Processing a task action successfully",
Data: taskInfo,
}
}

func HandleImportAction(ctx iris.Context) base.Result {
params := new(handleImportActionParams)
err := ctx.ReadJSON(params)
Expand Down

0 comments on commit fe4ade1

Please sign in to comment.