This is an automated email from the ASF dual-hosted git repository.

xiazcy pushed a commit to branch go-http-fix
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 140a89fbdb3fada8f5feb4e5bd6f94f701bb6c68
Author: Yang Xia <[email protected]>
AuthorDate: Tue Mar 24 23:08:02 2026 -0700

    export request and rename to RequestMessage for clarity and public access 
like other GLVs
---
 gremlin-go/driver/connection.go       | 12 ++++-----
 gremlin-go/driver/connection_test.go  | 16 ++++++------
 gremlin-go/driver/interceptor.go      |  6 ++---
 gremlin-go/driver/interceptor_test.go | 48 +++++++++++++++++------------------
 gremlin-go/driver/request.go          | 16 ++++++------
 gremlin-go/driver/request_test.go     | 14 +++++-----
 gremlin-go/driver/serializer.go       |  6 ++---
 gremlin-go/driver/serializer_test.go  | 10 ++++----
 8 files changed, 64 insertions(+), 64 deletions(-)

diff --git a/gremlin-go/driver/connection.go b/gremlin-go/driver/connection.go
index 562bad80a3..5396b6ab43 100644
--- a/gremlin-go/driver/connection.go
+++ b/gremlin-go/driver/connection.go
@@ -118,7 +118,7 @@ func (c *connection) AddInterceptor(interceptor 
RequestInterceptor) {
 }
 
 // submit sends request and streams results directly to ResultSet
-func (c *connection) submit(req *request) (ResultSet, error) {
+func (c *connection) submit(req *RequestMessage) (ResultSet, error) {
        rs := newChannelResultSet()
 
        go c.executeAndStream(req, rs)
@@ -126,7 +126,7 @@ func (c *connection) submit(req *request) (ResultSet, 
error) {
        return rs, nil
 }
 
-func (c *connection) executeAndStream(req *request, rs ResultSet) {
+func (c *connection) executeAndStream(req *RequestMessage, rs ResultSet) {
        defer rs.Close()
 
        // Create HttpRequest for interceptors
@@ -140,10 +140,10 @@ func (c *connection) executeAndStream(req *request, rs 
ResultSet) {
        // Set default headers before interceptors
        c.setHttpRequestHeaders(httpReq)
 
-       // Set Body to the raw *request so interceptors can inspect/modify it
+       // Set Body to the raw *RequestMessage so interceptors can 
inspect/modify it
        httpReq.Body = req
 
-       // Apply interceptors — they see *request in Body (pre-serialization).
+       // Apply interceptors — they see *RequestMessage in Body 
(pre-serialization).
        // Interceptors may replace Body with []byte, io.Reader, or 
*http.Request.
        for _, interceptor := range c.interceptors {
                if err := interceptor(httpReq); err != nil {
@@ -153,8 +153,8 @@ func (c *connection) executeAndStream(req *request, rs 
ResultSet) {
                }
        }
 
-       // After interceptors, serialize if Body is still *request
-       if r, ok := httpReq.Body.(*request); ok {
+       // After interceptors, serialize if Body is still *RequestMessage
+       if r, ok := httpReq.Body.(*RequestMessage); ok {
                if c.serializer != nil {
                        data, err := c.serializer.SerializeMessage(r)
                        if err != nil {
diff --git a/gremlin-go/driver/connection_test.go 
b/gremlin-go/driver/connection_test.go
index 4bb2de5cce..980040be5d 100644
--- a/gremlin-go/driver/connection_test.go
+++ b/gremlin-go/driver/connection_test.go
@@ -958,7 +958,7 @@ func TestConnectionWithMockServer(t *testing.T) {
                        connectionTimeout: 100 * time.Millisecond,
                })
 
-               rs, err := conn.submit(&request{gremlin: "g.V()", fields: 
map[string]interface{}{}})
+               rs, err := conn.submit(&RequestMessage{Gremlin: "g.V()", 
Fields: map[string]interface{}{}})
                assert.NoError(t, err) // submit returns nil, error goes to 
ResultSet
 
                // All() blocks until stream closes, then we can check error
@@ -979,7 +979,7 @@ func TestConnectionWithMockServer(t *testing.T) {
                        enableCompression:        true,
                })
 
-               rs, err := conn.submit(&request{gremlin: "g.V()", fields: 
map[string]interface{}{}})
+               rs, err := conn.submit(&RequestMessage{Gremlin: "g.V()", 
Fields: map[string]interface{}{}})
                require.NoError(t, err)
 
                select {
@@ -1003,7 +1003,7 @@ func TestConnectionWithMockServer(t *testing.T) {
                defer server.Close()
 
                conn := newConnection(newTestLogHandler(), server.URL, 
&connectionSettings{})
-               rs, err := conn.submit(&request{gremlin: "g.V()", fields: 
map[string]interface{}{}})
+               rs, err := conn.submit(&RequestMessage{Gremlin: "g.V()", 
Fields: map[string]interface{}{}})
                require.NoError(t, err)
 
                _, _ = rs.All()
@@ -1022,7 +1022,7 @@ func TestConnectionWithMockServer(t *testing.T) {
                defer server.Close()
 
                conn := newConnection(newTestLogHandler(), server.URL, 
&connectionSettings{})
-               rs, err := conn.submit(&request{gremlin: "g.V()", fields: 
map[string]interface{}{}})
+               rs, err := conn.submit(&RequestMessage{Gremlin: "g.V()", 
Fields: map[string]interface{}{}})
                require.NoError(t, err)
 
                _, _ = rs.All()
@@ -1040,7 +1040,7 @@ func TestConnectionWithMockServer(t *testing.T) {
                defer server.Close()
 
                conn := newConnection(newTestLogHandler(), server.URL, 
&connectionSettings{})
-               rs, err := conn.submit(&request{gremlin: "g.V()", fields: 
map[string]interface{}{}})
+               rs, err := conn.submit(&RequestMessage{Gremlin: "g.V()", 
Fields: map[string]interface{}{}})
                require.NoError(t, err)
 
                _, _ = rs.All()
@@ -1061,7 +1061,7 @@ func TestConnectionWithMockServer(t *testing.T) {
                defer server.Close()
 
                conn := newConnection(newTestLogHandler(), server.URL, 
&connectionSettings{})
-               rs, err := conn.submit(&request{gremlin: "g.V()", fields: 
map[string]interface{}{}})
+               rs, err := conn.submit(&RequestMessage{Gremlin: "g.V()", 
Fields: map[string]interface{}{}})
                require.NoError(t, err)
 
                _, _ = rs.All()
@@ -1085,7 +1085,7 @@ func TestConnectionWithMockServer(t *testing.T) {
                        return nil
                })
 
-               rs, err := conn.submit(&request{gremlin: "g.V()", fields: 
map[string]interface{}{}})
+               rs, err := conn.submit(&RequestMessage{Gremlin: "g.V()", 
Fields: map[string]interface{}{}})
                require.NoError(t, err)
                _, _ = rs.All()
 
@@ -1281,7 +1281,7 @@ func TestConnectionWithMockServer_BasicAuth(t *testing.T) 
{
        conn := newConnection(newTestLogHandler(), server.URL, 
&connectionSettings{})
        conn.AddInterceptor(BasicAuth("testuser", "testpass"))
 
-       rs, err := conn.submit(&request{gremlin: "g.V()", fields: 
map[string]interface{}{}})
+       rs, err := conn.submit(&RequestMessage{Gremlin: "g.V()", Fields: 
map[string]interface{}{}})
        require.NoError(t, err)
        _, _ = rs.All() // drain
 
diff --git a/gremlin-go/driver/interceptor.go b/gremlin-go/driver/interceptor.go
index a5d63a31be..e7e0c8e087 100644
--- a/gremlin-go/driver/interceptor.go
+++ b/gremlin-go/driver/interceptor.go
@@ -93,15 +93,15 @@ func (r *HttpRequest) PayloadHash() string {
 // RequestInterceptor is a function that modifies an HTTP request before it is 
sent.
 type RequestInterceptor func(*HttpRequest) error
 
-// SerializeRequest returns a RequestInterceptor that serializes the raw 
*request body
+// SerializeRequest returns a RequestInterceptor that serializes the raw 
*RequestMessage body
 // to GraphBinary []byte. Place this before auth interceptors (e.g., 
SigV4Auth) that
 // need the serialized body bytes.
 func SerializeRequest() RequestInterceptor {
        serializer := newGraphBinarySerializer(nil)
        return func(req *HttpRequest) error {
-               r, ok := req.Body.(*request)
+               r, ok := req.Body.(*RequestMessage)
                if !ok {
-                       return nil // already serialized or not a *request
+                       return nil // already serialized or not a 
*RequestMessage
                }
                data, err := serializer.SerializeMessage(r)
                if err != nil {
diff --git a/gremlin-go/driver/interceptor_test.go 
b/gremlin-go/driver/interceptor_test.go
index 78e36a0b95..746d82c22a 100644
--- a/gremlin-go/driver/interceptor_test.go
+++ b/gremlin-go/driver/interceptor_test.go
@@ -32,7 +32,7 @@ import (
        "github.com/stretchr/testify/require"
 )
 
-// TestInterceptorReceivesRawRequest verifies that interceptors receive the 
raw *request
+// TestInterceptorReceivesRawRequest verifies that interceptors receive the 
raw *RequestMessage
 // object in HttpRequest.Body, not serialized []byte.
 func TestInterceptorReceivesRawRequest(t *testing.T) {
        // Mock server that accepts the request (we don't care about the 
response for this test)
@@ -54,23 +54,23 @@ func TestInterceptorReceivesRawRequest(t *testing.T) {
        })
 
        // Submit a request with a known gremlin query
-       rs, err := conn.submit(&request{gremlin: "g.V().count()", fields: 
map[string]interface{}{}})
+       rs, err := conn.submit(&RequestMessage{Gremlin: "g.V().count()", 
Fields: map[string]interface{}{}})
        require.NoError(t, err)
        _, _ = rs.All() // drain result set
 
-       assert.Equal(t, reflect.TypeOf((*request)(nil)), capturedBodyType,
-               "interceptor should receive *request in Body, got %v", 
capturedBodyType)
+       assert.Equal(t, reflect.TypeOf((*RequestMessage)(nil)), 
capturedBodyType,
+               "interceptor should receive *RequestMessage in Body, got %v", 
capturedBodyType)
 
-       r, typeAssertOk := capturedBody.(*request)
-       assert.True(t, typeAssertOk, "interceptor should be able to type-assert 
Body to *request")
+       r, typeAssertOk := capturedBody.(*RequestMessage)
+       assert.True(t, typeAssertOk, "interceptor should be able to type-assert 
Body to *RequestMessage")
        if typeAssertOk {
-               assert.Equal(t, "g.V().count()", r.gremlin,
-                       "interceptor should be able to read the gremlin field 
from the raw request")
+               assert.Equal(t, "g.V().count()", r.Gremlin,
+                       "interceptor should be able to read the Gremlin field 
from the raw request")
        }
 }
 
 // TestSigV4AuthWithSerializeInterceptor verifies that SerializeRequest() + 
SigV4Auth
-// works in a chain. SerializeRequest converts *request to []byte, then 
SigV4Auth
+// works in a chain. SerializeRequest converts *RequestMessage to []byte, then 
SigV4Auth
 // can sign the serialized body.
 func TestSigV4AuthWithSerializeInterceptor(t *testing.T) {
        var capturedHeaders http.Header
@@ -96,7 +96,7 @@ func TestSigV4AuthWithSerializeInterceptor(t *testing.T) {
        conn.AddInterceptor(SerializeRequest())
        conn.AddInterceptor(SigV4AuthWithCredentials("gremlin-east-1", 
"tinkerpop-sigv4", mockProvider))
 
-       rs, err := conn.submit(&request{gremlin: "g.V().count()", fields: 
map[string]interface{}{}})
+       rs, err := conn.submit(&RequestMessage{Gremlin: "g.V().count()", 
Fields: map[string]interface{}{}})
        require.NoError(t, err)
        _, _ = rs.All() // drain
 
@@ -134,22 +134,22 @@ func TestMultipleInterceptors_SerializeThenAuth(t 
*testing.T) {
 
        // Custom interceptor that modifies the raw request fields
        conn.AddInterceptor(func(req *HttpRequest) error {
-               r, ok := req.Body.(*request)
+               r, ok := req.Body.(*RequestMessage)
                if !ok {
-                       return fmt.Errorf("expected *request, got %T", req.Body)
+                       return fmt.Errorf("expected *RequestMessage, got %T", 
req.Body)
                }
                // Add a custom field to the request
-               r.fields["customField"] = "customValue"
+               r.Fields["customField"] = "customValue"
                return nil
        })
 
-       // SerializeRequest converts the modified *request to []byte
+       // SerializeRequest converts the modified *RequestMessage to []byte
        conn.AddInterceptor(SerializeRequest())
 
        // BasicAuth adds the Authorization header (works on any body type)
        conn.AddInterceptor(BasicAuth("admin", "secret"))
 
-       rs, err := conn.submit(&request{gremlin: "g.V()", fields: 
map[string]interface{}{}})
+       rs, err := conn.submit(&RequestMessage{Gremlin: "g.V()", Fields: 
map[string]interface{}{}})
        require.NoError(t, err)
        _, _ = rs.All() // drain
 
@@ -187,7 +187,7 @@ func TestInterceptor_IoReaderBody(t *testing.T) {
                return nil
        })
 
-       rs, err := conn.submit(&request{gremlin: "g.V()", fields: 
map[string]interface{}{}})
+       rs, err := conn.submit(&RequestMessage{Gremlin: "g.V()", Fields: 
map[string]interface{}{}})
        require.NoError(t, err)
        _, _ = rs.All() // drain
 
@@ -207,7 +207,7 @@ func TestInterceptor_NilSerializerNoSerialization(t 
*testing.T) {
        conn := newConnection(newTestLogHandler(), server.URL, 
&connectionSettings{})
        conn.serializer = nil // explicitly nil serializer
 
-       rs, err := conn.submit(&request{gremlin: "g.V()", fields: 
map[string]interface{}{}})
+       rs, err := conn.submit(&RequestMessage{Gremlin: "g.V()", Fields: 
map[string]interface{}{}})
        require.NoError(t, err)
 
        _, _ = rs.All() // drain — this triggers the async executeAndStream
@@ -257,7 +257,7 @@ func TestInterceptor_HttpRequestBody(t *testing.T) {
                return nil
        })
 
-       rs, err := conn.submit(&request{gremlin: "g.V()", fields: 
map[string]interface{}{}})
+       rs, err := conn.submit(&RequestMessage{Gremlin: "g.V()", Fields: 
map[string]interface{}{}})
        require.NoError(t, err)
        _, _ = rs.All() // drain
 
@@ -288,7 +288,7 @@ func TestInterceptor_ErrorPropagation(t *testing.T) {
                return fmt.Errorf("interceptor failed")
        })
 
-       rs, err := conn.submit(&request{gremlin: "g.V()", fields: 
map[string]interface{}{}})
+       rs, err := conn.submit(&RequestMessage{Gremlin: "g.V()", Fields: 
map[string]interface{}{}})
        require.NoError(t, err)
 
        _, _ = rs.All() // drain — triggers async executeAndStream
@@ -314,7 +314,7 @@ func TestInterceptor_UnsupportedBodyType(t *testing.T) {
                return nil
        })
 
-       rs, err := conn.submit(&request{gremlin: "g.V()", fields: 
map[string]interface{}{}})
+       rs, err := conn.submit(&RequestMessage{Gremlin: "g.V()", Fields: 
map[string]interface{}{}})
        require.NoError(t, err)
 
        _, _ = rs.All() // drain
@@ -348,7 +348,7 @@ func TestInterceptor_ChainOrder(t *testing.T) {
                return nil
        })
 
-       rs, err := conn.submit(&request{gremlin: "g.V()", fields: 
map[string]interface{}{}})
+       rs, err := conn.submit(&RequestMessage{Gremlin: "g.V()", Fields: 
map[string]interface{}{}})
        require.NoError(t, err)
        _, _ = rs.All() // drain
 
@@ -357,7 +357,7 @@ func TestInterceptor_ChainOrder(t *testing.T) {
 }
 
 // TestSigV4Auth_RejectsNonByteBody verifies that SigV4Auth returns an error 
when Body
-// is not []byte (e.g., an unserialized *request).
+// is not []byte (e.g., an unserialized *RequestMessage).
 func TestSigV4Auth_RejectsNonByteBody(t *testing.T) {
        provider := &mockCredentialsProvider{
                accessKey: "MOCK_ID",
@@ -370,8 +370,8 @@ func TestSigV4Auth_RejectsNonByteBody(t *testing.T) {
        req.Headers.Set("Content-Type", graphBinaryMimeType)
        req.Headers.Set("Accept", graphBinaryMimeType)
 
-       // Set Body to *request (not []byte) — SigV4Auth should reject this
-       req.Body = &request{gremlin: "g.V()", fields: map[string]interface{}{}}
+       // Set Body to *RequestMessage (not []byte) — SigV4Auth should reject 
this
+       req.Body = &RequestMessage{Gremlin: "g.V()", Fields: 
map[string]interface{}{}}
 
        err = interceptor(req)
        require.Error(t, err, "SigV4Auth should reject non-[]byte body")
diff --git a/gremlin-go/driver/request.go b/gremlin-go/driver/request.go
index 282a301108..eafc0a5071 100644
--- a/gremlin-go/driver/request.go
+++ b/gremlin-go/driver/request.go
@@ -19,10 +19,10 @@ under the License.
 
 package gremlingo
 
-// request represents a request to the server.
-type request struct {
-       gremlin string
-       fields  map[string]interface{}
+// RequestMessage represents a request to the server.
+type RequestMessage struct {
+       Gremlin string
+       Fields  map[string]interface{}
 }
 
 // MakeStringRequest creates a request from a Gremlin string query for 
submission to a Gremlin server.
@@ -45,7 +45,7 @@ type request struct {
 //     serializer := newGraphBinarySerializer(nil)
 //     bytes, _ := serializer.(graphBinarySerializer).SerializeMessage(&req)
 //     // Send bytes over gRPC, HTTP/2, etc.
-func MakeStringRequest(stringGremlin string, traversalSource string, 
requestOptions RequestOptions) (req request) {
+func MakeStringRequest(stringGremlin string, traversalSource string, 
requestOptions RequestOptions) (req RequestMessage) {
        newFields := map[string]interface{}{
                "language": "gremlin-lang",
                "g":        traversalSource,
@@ -71,9 +71,9 @@ func MakeStringRequest(stringGremlin string, traversalSource 
string, requestOpti
                newFields["materializeProperties"] = 
requestOptions.materializeProperties
        }
 
-       return request{
-               gremlin: stringGremlin,
-               fields:  newFields,
+       return RequestMessage{
+               Gremlin: stringGremlin,
+               Fields:  newFields,
        }
 }
 
diff --git a/gremlin-go/driver/request_test.go 
b/gremlin-go/driver/request_test.go
index d37e7420fd..6bd91f5756 100644
--- a/gremlin-go/driver/request_test.go
+++ b/gremlin-go/driver/request_test.go
@@ -28,27 +28,27 @@ import (
 func TestRequest(t *testing.T) {
        t.Run("Test makeStringRequest() with no bindings", func(t *testing.T) {
                r := MakeStringRequest("g.V()", "g", *new(RequestOptions))
-               assert.Equal(t, "g.V()", r.gremlin)
-               assert.Equal(t, "g", r.fields["g"])
-               assert.Equal(t, "gremlin-lang", r.fields["language"])
-               assert.Nil(t, r.fields["bindings"])
+               assert.Equal(t, "g.V()", r.Gremlin)
+               assert.Equal(t, "g", r.Fields["g"])
+               assert.Equal(t, "gremlin-lang", r.Fields["language"])
+               assert.Nil(t, r.Fields["bindings"])
        })
 
        t.Run("Test makeStringRequest() with custom evaluationTimeout", func(t 
*testing.T) {
                r := MakeStringRequest("g.V()", "g",
                        
new(RequestOptionsBuilder).SetEvaluationTimeout(1234).Create())
-               assert.Equal(t, 1234, r.fields["evaluationTimeout"])
+               assert.Equal(t, 1234, r.Fields["evaluationTimeout"])
        })
 
        t.Run("Test makeStringRequest() with custom batchSize", func(t 
*testing.T) {
                r := MakeStringRequest("g.V()", "g",
                        new(RequestOptionsBuilder).SetBatchSize(123).Create())
-               assert.Equal(t, 123, r.fields["batchSize"])
+               assert.Equal(t, 123, r.Fields["batchSize"])
        })
 
        t.Run("Test makeStringRequest() with custom userAgent", func(t 
*testing.T) {
                r := MakeStringRequest("g.V()", "g",
                        
new(RequestOptionsBuilder).SetUserAgent("TestUserAgent").Create())
-               assert.Equal(t, "TestUserAgent", r.fields["userAgent"])
+               assert.Equal(t, "TestUserAgent", r.Fields["userAgent"])
        })
 }
diff --git a/gremlin-go/driver/serializer.go b/gremlin-go/driver/serializer.go
index f1718a70d3..49030251cc 100644
--- a/gremlin-go/driver/serializer.go
+++ b/gremlin-go/driver/serializer.go
@@ -30,7 +30,7 @@ const graphBinaryMimeType = "application/vnd.graphbinary-v4.0"
 
 // Serializer interface for serializers.
 type Serializer interface {
-       SerializeMessage(request *request) ([]byte, error)
+       SerializeMessage(request *RequestMessage) ([]byte, error)
        DeserializeMessage(message []byte) (Response, error)
 }
 
@@ -90,8 +90,8 @@ const versionByte byte = 0x81
 //     // Send bytes over custom transport
 //
 // SerializeMessage serializes a request message into GraphBinary.
-func (gs *GraphBinarySerializer) SerializeMessage(request *request) ([]byte, 
error) {
-       finalMessage, err := gs.buildMessage(request.gremlin, request.fields)
+func (gs *GraphBinarySerializer) SerializeMessage(request *RequestMessage) 
([]byte, error) {
+       finalMessage, err := gs.buildMessage(request.Gremlin, request.Fields)
        if err != nil {
                return nil, err
        }
diff --git a/gremlin-go/driver/serializer_test.go 
b/gremlin-go/driver/serializer_test.go
index 87341999f9..fd8d660c8e 100644
--- a/gremlin-go/driver/serializer_test.go
+++ b/gremlin-go/driver/serializer_test.go
@@ -32,9 +32,9 @@ const mapDataOrder2 = "[129 0 0 0 2 3 0 0 0 0 1 103 3 0 0 0 0 
1 103 3 0 0 0 0 8
 
 func TestSerializer(t *testing.T) {
        t.Run("test serialized request message", func(t *testing.T) {
-               testRequest := request{
-                       gremlin: "g.V().count()",
-                       fields:  map[string]interface{}{"g": "g", "language": 
"gremlin-lang"},
+               testRequest := RequestMessage{
+                       Gremlin: "g.V().count()",
+                       Fields:  map[string]interface{}{"g": "g", "language": 
"gremlin-lang"},
                }
                serializer := 
newGraphBinarySerializer(newLogHandler(&defaultLogger{}, Error, 
language.English))
                serialized, _ := serializer.SerializeMessage(&testRequest)
@@ -59,9 +59,9 @@ func TestSerializer(t *testing.T) {
 func TestSerializerFailures(t *testing.T) {
        t.Run("test serialize request fields failure", func(t *testing.T) {
                invalid := "invalid"
-               testRequest := request{
+               testRequest := RequestMessage{
                        // Invalid pointer type in fields, so should fail
-                       fields: map[string]interface{}{"invalidInput": 
&invalid, "g": "g"},
+                       Fields: map[string]interface{}{"invalidInput": 
&invalid, "g": "g"},
                }
                serializer := 
newGraphBinarySerializer(newLogHandler(&defaultLogger{}, Error, 
language.English))
                resp, err := serializer.SerializeMessage(&testRequest)

Reply via email to