Skip to content

Update order of operation for request interceptor and serialization in gremlin-go#3358

Open
xiazcy wants to merge 6 commits intomasterfrom
go-http-fix
Open

Update order of operation for request interceptor and serialization in gremlin-go#3358
xiazcy wants to merge 6 commits intomasterfrom
go-http-fix

Conversation

@xiazcy
Copy link
Contributor

@xiazcy xiazcy commented Mar 25, 2026

Go serializes request before passing to interceptors, which was a concern highlighted in .NET PR review and deviating from other GLVs. This PR mainly fixes that by changing order of operation, and passing in the raw request message to interceptors first, then serialize the request.

Slightly different design from .NET and python, as go DRC/client API did not expose the serializer setting to users. Here by default, if interceptor does not perform serialization, then the unserialized request (now RequestMessage) gets serialized by GraphBinary into byte[]. If users wish to use their own serializer via interceptors, they should return either byte[], io.Reader, or a http.Request, which are the types accepted by the http client library.

Some minor fixes also tagging along here:

  • Changed request struct to RequestMessage, as it can get confusing with an http.Request. Also exported the type for easier interceptor access, and is now consistent as this is public also in other GLVs.
  • Added json/plain text error handling that was missing
  • Added WaitGroup to ensure in-flight goroutines complete before close
  • Drained response body before close to prevent TCP RST errors (results in harmless but annoying errors from server)

VOTE +1

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.

1 participant