DR1N0 opened a new pull request, #3285: URL: https://github.com/apache/tinkerpop/pull/3285
## Motivation The current gremlin-go driver only supports WebSocket transport. However, many modern graph database deployments use alternative protocols like gRPC for better performance, streaming capabilities, and infrastructure compatibility. The serialization logic (GraphBinary) in gremlin-go is currently internal/private, preventing developers from building custom transport implementations while maintaining Gremlin API compatibility. **JIRA:** [TINKERPOP-3219](https://issues.apache.org/jira/browse/TINKERPOP-3219) Add public serialization API for alternative transport protocols ## Changes This PR adds a single new file `gremlin-go/driver/serializer_export.go` that exports 5 wrapper functions around existing internal serialization logic: 1. **`SerializeRequest(bytecode, traversalSource)`** - Serializes complete request with bytecode 2. **`SerializeBytecode(bytecode)`** - Convenience wrapper using default traversal source "g" 3. **`SerializeStringQuery(query, traversalSource, options)`** - Serializes string queries 4. **`DeserializeResult(data)`** - Deserializes response bytes into Result objects 5. **`NewResultSet(results)`** - Creates ResultSet from collected results ### Key Characteristics - ✅ **Zero modifications** to existing code - only adds new exported functions - ✅ **Fully backward compatible** - no changes to public APIs - ✅ **Minimal maintenance burden** - delegates to existing internal code - ✅ **Well documented** - comprehensive godoc comments with examples - ✅ **Compiles successfully** - tested with `go build ./...` - ✅ **CHANGELOG updated** - entry added to version 4.0.0 section ## Use Case We're building a production gRPC client for a graph database that needs to: 1. Serialize Gremlin bytecode to GraphBinary format 2. Send requests over gRPC instead of WebSocket 3. Deserialize responses from gRPC streams 4. Maintain 100% Gremlin traversal API compatibility This enables the same Gremlin API across different transport protocols. ## Benefits to TinkerPop Ecosystem - Enables vendor innovation without forking - Opens ecosystem to transport protocol diversity (gRPC, HTTP/2, etc.) - Aligns with TinkerPop's transport-agnostic philosophy - Minimal code to maintain (simple wrappers) - No breaking changes or new dependencies ## Example Usage ```go // Serialize a traversal for custom transport g := traversal.NewGraphTraversalSource() bytecode := g.V().HasLabel("person").Limit(10).Bytecode bytes, err := gremlingo.SerializeRequest(bytecode, "g") // Send bytes over gRPC, HTTP/2, etc. // Deserialize response from custom transport result, err := gremlingo.DeserializeResult(responseBytes) value := result.Data -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
