DR1N0 commented on code in PR #3285:
URL: https://github.com/apache/tinkerpop/pull/3285#discussion_r2625372730
##########
gremlin-go/driver/resultSet.go:
##########
@@ -211,3 +211,49 @@ func newChannelResultSetCapacity(requestID string,
container *synchronizedMap, c
func newChannelResultSet(requestID string, container *synchronizedMap)
ResultSet {
return newChannelResultSetCapacity(requestID, container,
defaultCapacity)
}
+
+// NewResultSet creates a new ResultSet from a slice of Result objects.
+// This function enables custom transport implementations to create ResultSets
from
+// results collected via alternative protocols.
+//
+// The function creates a channel-based ResultSet, pre-populates it with the
provided results,
+// and closes the channel to indicate completion.
+//
+// Parameters:
+// - requestID: The request identifier for this ResultSet
+// - results: A slice of Result objects to include in the ResultSet
+//
+// Returns:
+// - ResultSet: A ResultSet containing all the provided results
+//
+// Example usage:
+//
+// var results []*Result
+// // Collect results from custom transport
+// for _, responseBytes := range responses {
+// result, _ := DeserializeResult(responseBytes)
+// results = append(results, result)
+// }
+// resultSet := NewResultSet("request-123", results)
+// allResults, _ := resultSet.All()
+func NewResultSet(requestID string, results []*Result) ResultSet {
Review Comment:
The existing constructor signature is:
```
func newChannelResultSet(requestID string, container *synchronizedMap)
ResultSet
```
The `synchronizedMap` parameter comes from `connection.results` and mainly
serve for connection-based, concurrent request handling, which is not needed in
my request-based use case.
Using `newChannelResultSet` would probably mean to make public `addResult`,
`synchronizedMap` along with itself, and even something from connection.go,
making everything complicated.
This new constructor enables `Submitxxx` to return a ResultSet from
`Response.ResponseResult.Data`, which aligns with current interfaces
--
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]