diff --git a/neo4j/config.go b/neo4j/config.go index 1b356696..f05a0f7a 100644 --- a/neo4j/config.go +++ b/neo4j/config.go @@ -75,16 +75,6 @@ type Config struct { // // default: 5 * time.Second SocketConnectTimeout time.Duration - // Receive timeout that will be set on underlying sockets. Values less than - // or equal to 0 results in no timeout being applied. - // - // default: 0 - SocketReceiveTimeout time.Duration - // Send timeout that will be set on underlying sockets. Values less than - // or equal to 0 results in no timeout being applied. - // - // default: 0 - SocketSendTimeout time.Duration // Whether to enable TCP keep alive on underlying sockets. // // default: true @@ -102,8 +92,6 @@ func defaultConfig() *Config { MaxConnectionLifetime: 1 * time.Hour, ConnectionAcquisitionTimeout: 1 * time.Minute, SocketConnectTimeout: 5 * time.Second, - SocketReceiveTimeout: 0 * time.Second, - SocketSendTimeout: 0 * time.Second, SocketKeepalive: true, } } @@ -138,15 +126,5 @@ func validateAndNormaliseConfig(config *Config) error { config.SocketConnectTimeout = 0 } - // Socket Receive Timeout - if config.SocketReceiveTimeout < 0 { - config.SocketReceiveTimeout = 0 - } - - // Socket Send Timeout - if config.SocketSendTimeout < 0 { - config.SocketSendTimeout = 0 - } - return nil } diff --git a/neo4j/config_test.go b/neo4j/config_test.go index 6e19e951..eaae2e13 100644 --- a/neo4j/config_test.go +++ b/neo4j/config_test.go @@ -59,14 +59,6 @@ var _ = Describe("Config", func() { Expect(config.SocketConnectTimeout).To(BeIdenticalTo(5 * time.Second)) }) - It("should have socket receive timeout to be 0", func() { - Expect(config.SocketReceiveTimeout).To(BeIdenticalTo(0 * time.Second)) - }) - - It("should have socket send timeout to be 0", func() { - Expect(config.SocketSendTimeout).To(BeIdenticalTo(0 * time.Second)) - }) - It("should have socket keep alive enabled", func() { Expect(config.SocketKeepalive).To(BeTrue()) }) @@ -131,26 +123,6 @@ var _ = Describe("Config", func() { Expect(config.SocketConnectTimeout).To(Equal(0 * time.Nanosecond)) }) - - It("should normalize SocketReceiveTimeout to 0 when negative", func() { - config := defaultConfig() - config.SocketReceiveTimeout = -1 * time.Second - - err := validateAndNormaliseConfig(config) - Expect(err).To(BeNil()) - - Expect(config.SocketReceiveTimeout).To(Equal(0 * time.Nanosecond)) - }) - - It("should normalize SocketSendTimeout to 0 when negative", func() { - config := defaultConfig() - config.SocketSendTimeout = -1 * time.Second - - err := validateAndNormaliseConfig(config) - Expect(err).To(BeNil()) - - Expect(config.SocketSendTimeout).To(Equal(0 * time.Nanosecond)) - }) }) }) diff --git a/neo4j/gobolt_driver.go b/neo4j/gobolt_driver.go index 77f9e183..a64e4c9c 100644 --- a/neo4j/gobolt_driver.go +++ b/neo4j/gobolt_driver.go @@ -46,8 +46,8 @@ func configToGoboltConfig(config *Config) *gobolt.Config { MaxConnLifetime: config.MaxConnectionLifetime, ConnAcquisitionTimeout: config.ConnectionAcquisitionTimeout, SockConnectTimeout: config.SocketConnectTimeout, - SockRecvTimeout: config.SocketReceiveTimeout, - SockSendTimeout: config.SocketSendTimeout, + SockRecvTimeout: 0, + SockSendTimeout: 0, SockKeepalive: config.SocketKeepalive, ValueHandlers: []gobolt.ValueHandler{ &nodeValueHandler{}, diff --git a/neo4j/test-integration/examples_test.go b/neo4j/test-integration/examples_test.go index 77456304..856e9e41 100644 --- a/neo4j/test-integration/examples_test.go +++ b/neo4j/test-integration/examples_test.go @@ -445,7 +445,6 @@ func createDriverWithConnectionTimeout(uri, username, password string) (neo4j.Dr func createDriverWithMaxRetryTime(uri, username, password string) (neo4j.Driver, error) { return neo4j.NewDriver(uri, neo4j.BasicAuth(username, password, ""), func(config *neo4j.Config) { config.MaxTransactionRetryTime = 15 * time.Second - config.Log = neo4j.ConsoleLogger(neo4j.DEBUG) }) } diff --git a/neo4j/test-integration/timeout_test.go b/neo4j/test-integration/timeout_test.go index 256561ea..f99c609f 100644 --- a/neo4j/test-integration/timeout_test.go +++ b/neo4j/test-integration/timeout_test.go @@ -114,53 +114,4 @@ var _ = Describe("Timeout and Lifetime", func() { Expect(err).To(test.BeConnectorErrorWithCode(6)) }) - //It("should timeout receive when SocketReceiveTimeout is hit on encrypted connection", func() { - // var err error - // var driver neo4j.Driver - // var session neo4j.Session - // var result neo4j.Result - // - // driver, err = neo4j.NewDriver(server.BoltURI(), server.AuthToken(), server.Config(), func(config *neo4j.Config) { - // config.Log = log - // config.SocketReceiveTimeout = 1 * time.Second - // }) - // Expect(err).To(BeNil()) - // Expect(driver).NotTo(BeNil()) - // defer driver.Close() - // - // session = newSession(driver, neo4j.AccessModeRead) - // defer session.Close() - // - // result, err = session.Run("UNWIND RANGE(1,100000000) AS N RETURN SUM(N)", nil) - // Expect(err).To(BeNil()) - // - // _, err = result.Consume() - // Expect(err).To(test.BeConnectorErrorWithCode(6)) - //}) - - It("should timeout receive when SocketReceiveTimeout is hit on plaintext connection", func() { - var err error - var driver neo4j.Driver - var session neo4j.Session - var result neo4j.Result - - driver, err = neo4j.NewDriver(server.BoltURI(), server.AuthToken(), server.Config(), func(config *neo4j.Config) { - config.Encrypted = false - config.Log = log - config.SocketReceiveTimeout = 1 * time.Second - }) - Expect(err).To(BeNil()) - Expect(driver).NotTo(BeNil()) - defer driver.Close() - - session = newSession(driver, neo4j.AccessModeRead) - defer session.Close() - - result, err = session.Run("UNWIND RANGE(1,100000000) AS N RETURN SUM(N)", nil) - Expect(err).To(BeNil()) - - _, err = result.Consume() - Expect(err).To(test.BeConnectorErrorWithCode(6)) - }) - }) diff --git a/neo4j/values_graph_handlers.go b/neo4j/values_graph_handlers.go index ed8885cb..ceef1dec 100644 --- a/neo4j/values_graph_handlers.go +++ b/neo4j/values_graph_handlers.go @@ -34,15 +34,15 @@ type relationshipValueHandler struct { type pathValueHandler struct { } -func (handler *nodeValueHandler) ReadableStructs() []int8 { - return []int8{'N'} +func (handler *nodeValueHandler) ReadableStructs() []int16 { + return []int16{'N'} } func (handler *nodeValueHandler) WritableTypes() []reflect.Type { return []reflect.Type(nil) } -func (handler *nodeValueHandler) Read(signature int8, values []interface{}) (interface{}, error) { +func (handler *nodeValueHandler) Read(signature int16, values []interface{}) (interface{}, error) { if len(values) != 3 { return nil, gobolt.NewValueHandlerError("expected node struct to have %d fields but received %d", 3, len(values)) } @@ -64,19 +64,19 @@ func (handler *nodeValueHandler) Read(signature int8, values []interface{}) (int }, nil } -func (handler *nodeValueHandler) Write(value interface{}) (int8, []interface{}, error) { +func (handler *nodeValueHandler) Write(value interface{}) (int16, []interface{}, error) { return 0, nil, gobolt.NewValueHandlerError("Write is not supported for node values") } -func (handler *relationshipValueHandler) ReadableStructs() []int8 { - return []int8{'R', 'r'} +func (handler *relationshipValueHandler) ReadableStructs() []int16 { + return []int16{'R', 'r'} } func (handler *relationshipValueHandler) WritableTypes() []reflect.Type { return []reflect.Type(nil) } -func (handler *relationshipValueHandler) Read(signature int8, values []interface{}) (interface{}, error) { +func (handler *relationshipValueHandler) Read(signature int16, values []interface{}) (interface{}, error) { if signature == 'R' { if len(values) != 5 { 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 }, nil } -func (handler *relationshipValueHandler) Write(value interface{}) (int8, []interface{}, error) { +func (handler *relationshipValueHandler) Write(value interface{}) (int16, []interface{}, error) { return 0, nil, gobolt.NewValueHandlerError("Write is not supported for relationship values") } -func (handler *pathValueHandler) ReadableStructs() []int8 { - return []int8{'P'} +func (handler *pathValueHandler) ReadableStructs() []int16 { + return []int16{'P'} } func (handler *pathValueHandler) WritableTypes() []reflect.Type { return []reflect.Type(nil) } -func (handler *pathValueHandler) Read(signature int8, values []interface{}) (interface{}, error) { +func (handler *pathValueHandler) Read(signature int16, values []interface{}) (interface{}, error) { if len(values) != 3 { return nil, gobolt.NewValueHandlerError("expected path struct to have %d fields but received %d", 3, len(values)) } @@ -179,6 +179,6 @@ func (handler *pathValueHandler) Read(signature int8, values []interface{}) (int return &pathValue{segments: segments, nodes: nodes, relationships: rels}, nil } -func (handler *pathValueHandler) Write(value interface{}) (int8, []interface{}, error) { +func (handler *pathValueHandler) Write(value interface{}) (int16, []interface{}, error) { return 0, nil, gobolt.NewValueHandlerError("Write is not supported for path values") } diff --git a/neo4j/values_spatial_handlers.go b/neo4j/values_spatial_handlers.go index c0504379..ffb7ee38 100644 --- a/neo4j/values_spatial_handlers.go +++ b/neo4j/values_spatial_handlers.go @@ -27,24 +27,24 @@ import ( ) const ( - point2DSignature int8 = 'X' + point2DSignature int16 = 'X' point2DSize = 3 - point3DSignature int8 = 'Y' + point3DSignature int16 = 'Y' point3DSize = 4 ) type pointValueHandler struct { } -func (handler *pointValueHandler) ReadableStructs() []int8 { - return []int8{point2DSignature, point3DSignature} +func (handler *pointValueHandler) ReadableStructs() []int16 { + return []int16{point2DSignature, point3DSignature} } func (handler *pointValueHandler) WritableTypes() []reflect.Type { return []reflect.Type{reflect.TypeOf(Point{}), reflect.TypeOf(&Point{})} } -func (handler *pointValueHandler) Read(signature int8, values []interface{}) (interface{}, error) { +func (handler *pointValueHandler) Read(signature int16, values []interface{}) (interface{}, error) { var ( dimension int srId int @@ -85,7 +85,7 @@ func (handler *pointValueHandler) Read(signature int8, values []interface{}) (in }, nil } -func (handler *pointValueHandler) Write(value interface{}) (int8, []interface{}, error) { +func (handler *pointValueHandler) Write(value interface{}) (int16, []interface{}, error) { var point *Point var ok bool diff --git a/neo4j/values_temporal_handlers.go b/neo4j/values_temporal_handlers.go index 5738cb55..5b12d5bd 100644 --- a/neo4j/values_temporal_handlers.go +++ b/neo4j/values_temporal_handlers.go @@ -27,18 +27,18 @@ import ( ) const ( - dateSignature int8 = 'D' + dateSignature int16 = 'D' dateSize = 1 - localTimeSignature int8 = 't' + localTimeSignature int16 = 't' localTimeSize = 1 - offsetTimeSignature int8 = 'T' + offsetTimeSignature int16 = 'T' offsetTimeSize = 2 - durationSignature int8 = 'E' + durationSignature int16 = 'E' durationSize = 4 - localDateTimeSignature int8 = 'd' + localDateTimeSignature int16 = 'd' localDateTimeSize int = 2 - dateTimeWithOffsetSignature int8 = 'F' - dateTimeWithZoneIdSignature int8 = 'f' + dateTimeWithOffsetSignature int16 = 'F' + dateTimeWithZoneIdSignature int16 = 'f' dateTimeSize int = 3 ) @@ -60,15 +60,15 @@ type localDateTimeValueHandler struct { type durationValueHandler struct { } -func (handler *dateValueHandler) ReadableStructs() []int8 { - return []int8{dateSignature} +func (handler *dateValueHandler) ReadableStructs() []int16 { + return []int16{dateSignature} } func (handler *dateValueHandler) WritableTypes() []reflect.Type { return []reflect.Type{reflect.TypeOf(Date{})} } -func (handler *dateValueHandler) Read(signature int8, values []interface{}) (interface{}, error) { +func (handler *dateValueHandler) Read(signature int16, values []interface{}) (interface{}, error) { switch signature { case dateSignature: if len(values) != dateSize { @@ -81,7 +81,7 @@ func (handler *dateValueHandler) Read(signature int8, values []interface{}) (int return nil, gobolt.NewValueHandlerError("unexpected struct signature provided to dateTimeValueHandler: %#x", signature) } -func (handler *dateValueHandler) Write(value interface{}) (int8, []interface{}, error) { +func (handler *dateValueHandler) Write(value interface{}) (int16, []interface{}, error) { var date Date var ok bool @@ -92,15 +92,15 @@ func (handler *dateValueHandler) Write(value interface{}) (int8, []interface{}, return dateSignature, []interface{}{date.epochDays}, nil } -func (handler *localTimeValueHandler) ReadableStructs() []int8 { - return []int8{localTimeSignature} +func (handler *localTimeValueHandler) ReadableStructs() []int16 { + return []int16{localTimeSignature} } func (handler *localTimeValueHandler) WritableTypes() []reflect.Type { return []reflect.Type{reflect.TypeOf(LocalTime{})} } -func (handler *localTimeValueHandler) Read(signature int8, values []interface{}) (interface{}, error) { +func (handler *localTimeValueHandler) Read(signature int16, values []interface{}) (interface{}, error) { switch signature { case localTimeSignature: if len(values) != localTimeSize { @@ -113,7 +113,7 @@ func (handler *localTimeValueHandler) Read(signature int8, values []interface{}) return nil, gobolt.NewValueHandlerError("unexpected struct signature provided to localTimeValueHandler: %#x", signature) } -func (handler *localTimeValueHandler) Write(value interface{}) (int8, []interface{}, error) { +func (handler *localTimeValueHandler) Write(value interface{}) (int16, []interface{}, error) { var localTime LocalTime var ok bool @@ -124,15 +124,15 @@ func (handler *localTimeValueHandler) Write(value interface{}) (int8, []interfac return localTimeSignature, []interface{}{int64(localTime.nanosOfDay)}, nil } -func (handler *offsetTimeValueHandler) ReadableStructs() []int8 { - return []int8{offsetTimeSignature} +func (handler *offsetTimeValueHandler) ReadableStructs() []int16 { + return []int16{offsetTimeSignature} } func (handler *offsetTimeValueHandler) WritableTypes() []reflect.Type { return []reflect.Type{reflect.TypeOf(OffsetTime{})} } -func (handler *offsetTimeValueHandler) Read(signature int8, values []interface{}) (interface{}, error) { +func (handler *offsetTimeValueHandler) Read(signature int16, values []interface{}) (interface{}, error) { switch signature { case offsetTimeSignature: if len(values) != offsetTimeSize { @@ -146,7 +146,7 @@ func (handler *offsetTimeValueHandler) Read(signature int8, values []interface{} return nil, gobolt.NewValueHandlerError("unexpected struct signature provided to offsetTimeValueHandler: %#x", signature) } -func (handler *offsetTimeValueHandler) Write(value interface{}) (int8, []interface{}, error) { +func (handler *offsetTimeValueHandler) Write(value interface{}) (int16, []interface{}, error) { var offsetTime OffsetTime var ok bool @@ -157,15 +157,15 @@ func (handler *offsetTimeValueHandler) Write(value interface{}) (int8, []interfa return offsetTimeSignature, []interface{}{int64(offsetTime.nanosOfDay), offsetTime.offset}, nil } -func (handler *durationValueHandler) ReadableStructs() []int8 { - return []int8{durationSignature} +func (handler *durationValueHandler) ReadableStructs() []int16 { + return []int16{durationSignature} } func (handler *durationValueHandler) WritableTypes() []reflect.Type { return []reflect.Type{reflect.TypeOf(Duration{})} } -func (handler *durationValueHandler) Read(signature int8, values []interface{}) (interface{}, error) { +func (handler *durationValueHandler) Read(signature int16, values []interface{}) (interface{}, error) { switch signature { case durationSignature: if len(values) != durationSize { @@ -181,7 +181,7 @@ func (handler *durationValueHandler) Read(signature int8, values []interface{}) return nil, gobolt.NewValueHandlerError("unexpected struct signature provided to durationValueHandler: %#x", signature) } -func (handler *durationValueHandler) Write(value interface{}) (int8, []interface{}, error) { +func (handler *durationValueHandler) Write(value interface{}) (int16, []interface{}, error) { var duration Duration var ok bool @@ -192,15 +192,15 @@ func (handler *durationValueHandler) Write(value interface{}) (int8, []interface return durationSignature, []interface{}{duration.months, duration.days, duration.seconds, duration.nanos}, nil } -func (handler *localDateTimeValueHandler) ReadableStructs() []int8 { - return []int8{localDateTimeSignature} +func (handler *localDateTimeValueHandler) ReadableStructs() []int16 { + return []int16{localDateTimeSignature} } func (handler *localDateTimeValueHandler) WritableTypes() []reflect.Type { return []reflect.Type{reflect.TypeOf(LocalDateTime{})} } -func (handler *localDateTimeValueHandler) Read(signature int8, values []interface{}) (interface{}, error) { +func (handler *localDateTimeValueHandler) Read(signature int16, values []interface{}) (interface{}, error) { switch signature { case localDateTimeSignature: if len(values) != localDateTimeSize { @@ -216,7 +216,7 @@ func (handler *localDateTimeValueHandler) Read(signature int8, values []interfac return nil, gobolt.NewValueHandlerError("unexpected struct signature provided to localDateTimeValueHandler: %#x", signature) } -func (handler *localDateTimeValueHandler) Write(value interface{}) (int8, []interface{}, error) { +func (handler *localDateTimeValueHandler) Write(value interface{}) (int16, []interface{}, error) { var localDateTime LocalDateTime var ok bool @@ -230,15 +230,15 @@ func (handler *localDateTimeValueHandler) Write(value interface{}) (int8, []inte }, nil } -func (handler *dateTimeValueHandler) ReadableStructs() []int8 { - return []int8{dateTimeWithOffsetSignature, dateTimeWithZoneIdSignature} +func (handler *dateTimeValueHandler) ReadableStructs() []int16 { + return []int16{dateTimeWithOffsetSignature, dateTimeWithZoneIdSignature} } func (handler *dateTimeValueHandler) WritableTypes() []reflect.Type { return []reflect.Type{reflect.TypeOf(time.Time{})} } -func (handler *dateTimeValueHandler) Read(signature int8, values []interface{}) (interface{}, error) { +func (handler *dateTimeValueHandler) Read(signature int16, values []interface{}) (interface{}, error) { switch signature { case dateTimeWithZoneIdSignature: if len(values) != dateTimeSize { @@ -274,7 +274,7 @@ func (handler *dateTimeValueHandler) Read(signature int8, values []interface{}) return nil, gobolt.NewValueHandlerError("unexpected struct signature provided to dateTimeValueHandler: %#x", signature) } -func (handler *dateTimeValueHandler) Write(value interface{}) (int8, []interface{}, error) { +func (handler *dateTimeValueHandler) Write(value interface{}) (int16, []interface{}, error) { var dateTime time.Time var ok bool