Skip to content

Commit 1ef460a

Browse files
authored
TINKERPOP-3177: Fix configuration of sessions in Go Client (#3164)
1 parent db36986 commit 1ef460a

File tree

3 files changed

+35
-1
lines changed

3 files changed

+35
-1
lines changed

CHANGELOG.asciidoc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
4343
* Fixed bug in 'gremlin-server.sh' to account for spaces in directory names.
4444
* Deprecated `gremlin_python.process.__.has_key_` in favor of `gremlin_python.process.__.has_key`.
4545
* Added `gremlin.spark.outputRepartition` configuration to customize the partitioning of HDFS files from `OutputRDD`.
46+
* Added `ClientSettings.Session` configuration in `gremlin-go` to configure a sessioned client.
4647
* Allowed `mergeV()` and `mergeE()` to supply `null` in `Map` values.
4748
* Fixed limitation in multi-line detection preventing `:remote console` scripts from being sent to the server.
4849
* Changed signature of `hasId(P<Object>)` and `hasValue(P<Object>)` to `hasId(P<?>)` and `hasValue(P<?>)`.

gremlin-go/driver/client.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type ClientSettings struct {
4242
EnableCompression bool
4343
ReadBufferSize int
4444
WriteBufferSize int
45+
Session string
4546

4647
// Minimum amount of concurrent active traversals on a connection to trigger creation of a new connection
4748
NewConnectionThreshold int
@@ -124,7 +125,7 @@ func NewClient(url string, configurations ...func(settings *ClientSettings)) (*C
124125
logHandler: logHandler,
125126
transporterType: settings.TransporterType,
126127
connections: pool,
127-
session: "",
128+
session: settings.Session,
128129
}
129130

130131
return client, nil

gremlin-go/driver/client_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,38 @@ func TestClient(t *testing.T) {
146146

147147
AssertVertexPropertiesWithProperties(t, result)
148148
})
149+
150+
t.Run("Test sessioned client", func(t *testing.T) {
151+
skipTestsIfNotEnabled(t, integrationTestSuiteName, testNoAuthEnable)
152+
client, err := NewClient(testNoAuthUrl,
153+
func(settings *ClientSettings) {
154+
settings.TlsConfig = testNoAuthTlsConfig
155+
settings.AuthInfo = testNoAuthAuthInfo
156+
settings.TraversalSource = testServerModernGraphAlias
157+
settings.Session = "sessionID"
158+
})
159+
assert.NoError(t, err)
160+
assert.NotNil(t, client)
161+
defer client.Close()
162+
163+
resultSet, err := client.Submit("x = 1+1")
164+
assert.NoError(t, err)
165+
assert.NotNil(t, resultSet)
166+
167+
result, ok, err := resultSet.One()
168+
assert.NoError(t, err)
169+
assert.True(t, ok)
170+
assert.EqualValues(t, 2, result.Data)
171+
172+
resultSet, err = client.Submit("x+1")
173+
assert.NoError(t, err)
174+
assert.NotNil(t, resultSet)
175+
176+
result, ok, err = resultSet.One()
177+
assert.NoError(t, err)
178+
assert.True(t, ok)
179+
assert.EqualValues(t, 3, result.Data)
180+
})
149181
}
150182

151183
func AssertVertexPropertiesWithProperties(t *testing.T, result *Result) {

0 commit comments

Comments
 (0)