Skip to content

Commit 520f8ab

Browse files
authored
Merge pull request #32 from ali-ince/1.7-update-signature-size
Update struct signature sizes
2 parents dcd86b4 + fc06a33 commit 520f8ab

File tree

8 files changed

+51
-151
lines changed

8 files changed

+51
-151
lines changed

neo4j/config.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -75,16 +75,6 @@ type Config struct {
7575
//
7676
// default: 5 * time.Second
7777
SocketConnectTimeout time.Duration
78-
// Receive timeout that will be set on underlying sockets. Values less than
79-
// or equal to 0 results in no timeout being applied.
80-
//
81-
// default: 0
82-
SocketReceiveTimeout time.Duration
83-
// Send timeout that will be set on underlying sockets. Values less than
84-
// or equal to 0 results in no timeout being applied.
85-
//
86-
// default: 0
87-
SocketSendTimeout time.Duration
8878
// Whether to enable TCP keep alive on underlying sockets.
8979
//
9080
// default: true
@@ -102,8 +92,6 @@ func defaultConfig() *Config {
10292
MaxConnectionLifetime: 1 * time.Hour,
10393
ConnectionAcquisitionTimeout: 1 * time.Minute,
10494
SocketConnectTimeout: 5 * time.Second,
105-
SocketReceiveTimeout: 0 * time.Second,
106-
SocketSendTimeout: 0 * time.Second,
10795
SocketKeepalive: true,
10896
}
10997
}
@@ -138,15 +126,5 @@ func validateAndNormaliseConfig(config *Config) error {
138126
config.SocketConnectTimeout = 0
139127
}
140128

141-
// Socket Receive Timeout
142-
if config.SocketReceiveTimeout < 0 {
143-
config.SocketReceiveTimeout = 0
144-
}
145-
146-
// Socket Send Timeout
147-
if config.SocketSendTimeout < 0 {
148-
config.SocketSendTimeout = 0
149-
}
150-
151129
return nil
152130
}

neo4j/config_test.go

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,6 @@ var _ = Describe("Config", func() {
5959
Expect(config.SocketConnectTimeout).To(BeIdenticalTo(5 * time.Second))
6060
})
6161

62-
It("should have socket receive timeout to be 0", func() {
63-
Expect(config.SocketReceiveTimeout).To(BeIdenticalTo(0 * time.Second))
64-
})
65-
66-
It("should have socket send timeout to be 0", func() {
67-
Expect(config.SocketSendTimeout).To(BeIdenticalTo(0 * time.Second))
68-
})
69-
7062
It("should have socket keep alive enabled", func() {
7163
Expect(config.SocketKeepalive).To(BeTrue())
7264
})
@@ -131,26 +123,6 @@ var _ = Describe("Config", func() {
131123

132124
Expect(config.SocketConnectTimeout).To(Equal(0 * time.Nanosecond))
133125
})
134-
135-
It("should normalize SocketReceiveTimeout to 0 when negative", func() {
136-
config := defaultConfig()
137-
config.SocketReceiveTimeout = -1 * time.Second
138-
139-
err := validateAndNormaliseConfig(config)
140-
Expect(err).To(BeNil())
141-
142-
Expect(config.SocketReceiveTimeout).To(Equal(0 * time.Nanosecond))
143-
})
144-
145-
It("should normalize SocketSendTimeout to 0 when negative", func() {
146-
config := defaultConfig()
147-
config.SocketSendTimeout = -1 * time.Second
148-
149-
err := validateAndNormaliseConfig(config)
150-
Expect(err).To(BeNil())
151-
152-
Expect(config.SocketSendTimeout).To(Equal(0 * time.Nanosecond))
153-
})
154126
})
155127

156128
})

neo4j/gobolt_driver.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ func configToGoboltConfig(config *Config) *gobolt.Config {
4646
MaxConnLifetime: config.MaxConnectionLifetime,
4747
ConnAcquisitionTimeout: config.ConnectionAcquisitionTimeout,
4848
SockConnectTimeout: config.SocketConnectTimeout,
49-
SockRecvTimeout: config.SocketReceiveTimeout,
50-
SockSendTimeout: config.SocketSendTimeout,
49+
SockRecvTimeout: 0,
50+
SockSendTimeout: 0,
5151
SockKeepalive: config.SocketKeepalive,
5252
ValueHandlers: []gobolt.ValueHandler{
5353
&nodeValueHandler{},

neo4j/test-integration/examples_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,6 @@ func createDriverWithConnectionTimeout(uri, username, password string) (neo4j.Dr
445445
func createDriverWithMaxRetryTime(uri, username, password string) (neo4j.Driver, error) {
446446
return neo4j.NewDriver(uri, neo4j.BasicAuth(username, password, ""), func(config *neo4j.Config) {
447447
config.MaxTransactionRetryTime = 15 * time.Second
448-
config.Log = neo4j.ConsoleLogger(neo4j.DEBUG)
449448
})
450449
}
451450

neo4j/test-integration/timeout_test.go

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -114,53 +114,4 @@ var _ = Describe("Timeout and Lifetime", func() {
114114
Expect(err).To(test.BeConnectorErrorWithCode(6))
115115
})
116116

117-
//It("should timeout receive when SocketReceiveTimeout is hit on encrypted connection", func() {
118-
// var err error
119-
// var driver neo4j.Driver
120-
// var session neo4j.Session
121-
// var result neo4j.Result
122-
//
123-
// driver, err = neo4j.NewDriver(server.BoltURI(), server.AuthToken(), server.Config(), func(config *neo4j.Config) {
124-
// config.Log = log
125-
// config.SocketReceiveTimeout = 1 * time.Second
126-
// })
127-
// Expect(err).To(BeNil())
128-
// Expect(driver).NotTo(BeNil())
129-
// defer driver.Close()
130-
//
131-
// session = newSession(driver, neo4j.AccessModeRead)
132-
// defer session.Close()
133-
//
134-
// result, err = session.Run("UNWIND RANGE(1,100000000) AS N RETURN SUM(N)", nil)
135-
// Expect(err).To(BeNil())
136-
//
137-
// _, err = result.Consume()
138-
// Expect(err).To(test.BeConnectorErrorWithCode(6))
139-
//})
140-
141-
It("should timeout receive when SocketReceiveTimeout is hit on plaintext connection", func() {
142-
var err error
143-
var driver neo4j.Driver
144-
var session neo4j.Session
145-
var result neo4j.Result
146-
147-
driver, err = neo4j.NewDriver(server.BoltURI(), server.AuthToken(), server.Config(), func(config *neo4j.Config) {
148-
config.Encrypted = false
149-
config.Log = log
150-
config.SocketReceiveTimeout = 1 * time.Second
151-
})
152-
Expect(err).To(BeNil())
153-
Expect(driver).NotTo(BeNil())
154-
defer driver.Close()
155-
156-
session = newSession(driver, neo4j.AccessModeRead)
157-
defer session.Close()
158-
159-
result, err = session.Run("UNWIND RANGE(1,100000000) AS N RETURN SUM(N)", nil)
160-
Expect(err).To(BeNil())
161-
162-
_, err = result.Consume()
163-
Expect(err).To(test.BeConnectorErrorWithCode(6))
164-
})
165-
166117
})

neo4j/values_graph_handlers.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ type relationshipValueHandler struct {
3434
type pathValueHandler struct {
3535
}
3636

37-
func (handler *nodeValueHandler) ReadableStructs() []int8 {
38-
return []int8{'N'}
37+
func (handler *nodeValueHandler) ReadableStructs() []int16 {
38+
return []int16{'N'}
3939
}
4040

4141
func (handler *nodeValueHandler) WritableTypes() []reflect.Type {
4242
return []reflect.Type(nil)
4343
}
4444

45-
func (handler *nodeValueHandler) Read(signature int8, values []interface{}) (interface{}, error) {
45+
func (handler *nodeValueHandler) Read(signature int16, values []interface{}) (interface{}, error) {
4646
if len(values) != 3 {
4747
return nil, gobolt.NewValueHandlerError("expected node struct to have %d fields but received %d", 3, len(values))
4848
}
@@ -64,19 +64,19 @@ func (handler *nodeValueHandler) Read(signature int8, values []interface{}) (int
6464
}, nil
6565
}
6666

67-
func (handler *nodeValueHandler) Write(value interface{}) (int8, []interface{}, error) {
67+
func (handler *nodeValueHandler) Write(value interface{}) (int16, []interface{}, error) {
6868
return 0, nil, gobolt.NewValueHandlerError("Write is not supported for node values")
6969
}
7070

71-
func (handler *relationshipValueHandler) ReadableStructs() []int8 {
72-
return []int8{'R', 'r'}
71+
func (handler *relationshipValueHandler) ReadableStructs() []int16 {
72+
return []int16{'R', 'r'}
7373
}
7474

7575
func (handler *relationshipValueHandler) WritableTypes() []reflect.Type {
7676
return []reflect.Type(nil)
7777
}
7878

79-
func (handler *relationshipValueHandler) Read(signature int8, values []interface{}) (interface{}, error) {
79+
func (handler *relationshipValueHandler) Read(signature int16, values []interface{}) (interface{}, error) {
8080
if signature == 'R' {
8181
if len(values) != 5 {
8282
return nil, gobolt.NewValueHandlerError("expected relationship struct to have %d fields but received %d", 5, len(values))
@@ -114,19 +114,19 @@ func (handler *relationshipValueHandler) Read(signature int8, values []interface
114114
}, nil
115115
}
116116

117-
func (handler *relationshipValueHandler) Write(value interface{}) (int8, []interface{}, error) {
117+
func (handler *relationshipValueHandler) Write(value interface{}) (int16, []interface{}, error) {
118118
return 0, nil, gobolt.NewValueHandlerError("Write is not supported for relationship values")
119119
}
120120

121-
func (handler *pathValueHandler) ReadableStructs() []int8 {
122-
return []int8{'P'}
121+
func (handler *pathValueHandler) ReadableStructs() []int16 {
122+
return []int16{'P'}
123123
}
124124

125125
func (handler *pathValueHandler) WritableTypes() []reflect.Type {
126126
return []reflect.Type(nil)
127127
}
128128

129-
func (handler *pathValueHandler) Read(signature int8, values []interface{}) (interface{}, error) {
129+
func (handler *pathValueHandler) Read(signature int16, values []interface{}) (interface{}, error) {
130130
if len(values) != 3 {
131131
return nil, gobolt.NewValueHandlerError("expected path struct to have %d fields but received %d", 3, len(values))
132132
}
@@ -179,6 +179,6 @@ func (handler *pathValueHandler) Read(signature int8, values []interface{}) (int
179179
return &pathValue{segments: segments, nodes: nodes, relationships: rels}, nil
180180
}
181181

182-
func (handler *pathValueHandler) Write(value interface{}) (int8, []interface{}, error) {
182+
func (handler *pathValueHandler) Write(value interface{}) (int16, []interface{}, error) {
183183
return 0, nil, gobolt.NewValueHandlerError("Write is not supported for path values")
184184
}

neo4j/values_spatial_handlers.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,24 @@ import (
2727
)
2828

2929
const (
30-
point2DSignature int8 = 'X'
30+
point2DSignature int16 = 'X'
3131
point2DSize = 3
32-
point3DSignature int8 = 'Y'
32+
point3DSignature int16 = 'Y'
3333
point3DSize = 4
3434
)
3535

3636
type pointValueHandler struct {
3737
}
3838

39-
func (handler *pointValueHandler) ReadableStructs() []int8 {
40-
return []int8{point2DSignature, point3DSignature}
39+
func (handler *pointValueHandler) ReadableStructs() []int16 {
40+
return []int16{point2DSignature, point3DSignature}
4141
}
4242

4343
func (handler *pointValueHandler) WritableTypes() []reflect.Type {
4444
return []reflect.Type{reflect.TypeOf(Point{}), reflect.TypeOf(&Point{})}
4545
}
4646

47-
func (handler *pointValueHandler) Read(signature int8, values []interface{}) (interface{}, error) {
47+
func (handler *pointValueHandler) Read(signature int16, values []interface{}) (interface{}, error) {
4848
var (
4949
dimension int
5050
srId int
@@ -85,7 +85,7 @@ func (handler *pointValueHandler) Read(signature int8, values []interface{}) (in
8585
}, nil
8686
}
8787

88-
func (handler *pointValueHandler) Write(value interface{}) (int8, []interface{}, error) {
88+
func (handler *pointValueHandler) Write(value interface{}) (int16, []interface{}, error) {
8989
var point *Point
9090
var ok bool
9191

0 commit comments

Comments
 (0)