Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(interactive): Support Http Gremlin Service #4394

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

shirly121
Copy link
Collaborator

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":[]}}}
  1. The HTTP API also supports streaming results using HTTP Chunked Transfer Encoding. You can use curl or other SDKs to check the streamed results.

  2. 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.

Related issue number

Fixes

@shirly121 shirly121 requested a review from BingqingLyu January 2, 2025 01:57
Copy link
Contributor

github-actions bot commented Jan 2, 2025

Please check the preview of the documentation changes at
https://bdc0edf6.graphscope-docs-preview.pages.dev

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 34.33%. Comparing base (a9a865b) to head (8b3f9f9).
Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #4394   +/-   ##
=======================================
  Coverage   34.33%   34.33%           
=======================================
  Files         126      126           
  Lines       13257    13257           
=======================================
  Hits         4552     4552           
  Misses       8705     8705           

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a9a865b...8b3f9f9. Read the comment docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants