Commit f3a1a02
authored
fix(interactive): Support Http Gremlin Service (#4394)
<!--
Thanks for your contribution! please review
https://github.com/alibaba/GraphScope/blob/main/CONTRIBUTING.md before
opening an issue.
-->
## What do these changes do?
1. Support sending Gremlin queries via HTTP requests. Clients can submit
queries using curl as shown below:
```
curl -X POST \
-H "Connection: close" \
-H "Content-Type: application/json" \
-d '{"gremlin": "g.V().limit(2)"}' \
http://localhost:8182/gremlin
```
The response will be in JSON format like:
```
{"requestId":"bb66ad80-336d-4541-8bd3-de0a40451436","status":{"message":"","code":200,"attributes":{"@type":"g:Map","@value":[]}},"result":{"data":{"@type":"g:List","@value":[{"@type":"g:Vertex","@value":{"id":{"@type":"g:Int64","@value":1},"label":"person"}},{"@type":"g:Vertex","@value":{"id":{"@type":"g:Int64","@value":2},"label":"person"}}]},"meta":{"@type":"g:Map","@value":[]}}}
```
If error occurs, the error message with the error code will be returned
in json format like:
```
{"requestId":"1882cbfd-a0b4-419d-924e-2ca3a63e209a","status":{"message":"ErrorCode: GREMLIN_INVALID_RESULT\nMessage: getKeyName fail code is TableNotExistError, msg is entity label_id 2 is not found\nEC: 03-0108\nQueryId: 9132153615669087179\n","code":500,"attributes":{"@type":"g:Map","@value":[]}},"result":{"data":null,"meta":{"@type":"g:Map","@value":[]}}}
```
2. The HTTP API also supports streaming results using HTTP Chunked
Transfer Encoding. You can use curl or other SDKs to check the streamed
results.
3. If the Gremlin service requires authentication, the request must
include the Authorization header, as shown below:
```
curl -X POST \
-H "Authorization: Basic YWRtaW46YWRtaW4=" \
-H "Connection: close" \
-H "Content-Type: application/json" \
-d '{"gremlin": "g.V().limit(5)"}' \
http://localhost:8182/gremlin
```
The expected format for the Authorization header is:
```
Authorization: Basic <Base64(user:password)>
```
In this example, `YWRtaW46YWRtaW4=` is the Base64 encoding of
`admin:admin`.
<!-- Please give a short brief about these changes. -->
## Related issue number
<!-- Are there any issues opened that will be resolved by merging this
change? -->
Fixes1 parent 89671f8 commit f3a1a02
File tree
5 files changed
+462
-6
lines changed- interactive_engine/compiler/src/main/java
- com/alibaba/graphscope/gremlin
- auth
- plugin/processor
- service
- org/apache/tinkerpop/gremlin/server/handler
5 files changed
+462
-6
lines changedLines changed: 79 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
31 | 33 | | |
32 | 34 | | |
33 | 35 | | |
| |||
42 | 44 | | |
43 | 45 | | |
44 | 46 | | |
| 47 | + | |
45 | 48 | | |
46 | 49 | | |
47 | 50 | | |
| |||
50 | 53 | | |
51 | 54 | | |
52 | 55 | | |
| 56 | + | |
53 | 57 | | |
54 | 58 | | |
55 | 59 | | |
| |||
205 | 209 | | |
206 | 210 | | |
207 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
208 | 273 | | |
209 | 274 | | |
210 | | - | |
| 275 | + | |
211 | 276 | | |
212 | 277 | | |
213 | 278 | | |
| |||
226 | 291 | | |
227 | 292 | | |
228 | 293 | | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
229 | 307 | | |
Lines changed: 109 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
0 commit comments