Skip to content

Commit

Permalink
refactor(interactive): Return the correct http code (#3700)
Browse files Browse the repository at this point in the history
- Internally use `Result<>` to store the runtime error, and map the
error to http code at `admin_http_handler`.
- Extract commonly used code into utils function `http_utils.h`.
  • Loading branch information
zhanglei1949 committed Apr 9, 2024
1 parent ff9fcec commit 12cbced
Show file tree
Hide file tree
Showing 7 changed files with 326 additions and 322 deletions.
28 changes: 27 additions & 1 deletion docs/flex/interactive/development/admin_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -1085,4 +1085,30 @@ To start admin service in development, use the command line argument `--enable-a
The Compiler service could be started as a subprocess of the AdminService. This ensures that when switching graphs in the AdminService, the Compiler service also switches to the corresponding graph's schema. This is the default behavior in the current Interactive.

```bash
./bin/interactive_server -c ${ENGINE_CONFIG} -w ${WORKSPACE} --enable-admin-service true --start-compiler true
./bin/interactive_server -c ${ENGINE_CONFIG} -w ${WORKSPACE} --enable-admin-service true --start-compiler true
```


## Http error code

Internally we use [`StatusCode`](https://github.com/alibaba/GraphScope/blob/main/flex/utils/result.h) to record the runtime errors.
The mapping between statusCode and http code is shown in the following table.

| Code | HTTP Code |
| ----------------------------------- | ----------- |
| gs::StatusCode::OK | 200 |
| gs::StatusCode::InValidArgument | 400 |
| gs::StatusCode::UnsupportedOperator | 400 |
| gs::StatusCode::AlreadyExists | 409 |
| gs::StatusCode::NotExists | 404 |
| gs::StatusCode::CodegenError | 500 |
| gs::StatusCode::UninitializedStatus | 500 |
| gs::StatusCode::InvalidSchema | 400 |
| gs::StatusCode::PermissionError | 403 |
| gs::StatusCode::IllegalOperation | 400 |
| gs::StatusCode::InternalError | 500 |
| gs::StatusCode::InvalidImportFile | 400 |
| gs::StatusCode::IOError | 500 |
| gs::StatusCode::NotFound | 404 |
| gs::StatusCode::QueryFailed | 500 |
| default | 500 |
Loading

0 comments on commit 12cbced

Please sign in to comment.