Skip to content

Commit

Permalink
Remove socket receive and send timout config options
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-ince committed Oct 25, 2018
1 parent 9ccf087 commit fc06a33
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 101 deletions.
22 changes: 0 additions & 22 deletions neo4j/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
}
}
Expand Down Expand Up @@ -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
}
28 changes: 0 additions & 28 deletions neo4j/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
})
Expand Down Expand Up @@ -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))
})
})

})
4 changes: 2 additions & 2 deletions neo4j/gobolt_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{},
Expand Down
49 changes: 0 additions & 49 deletions neo4j/test-integration/timeout_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})

})

0 comments on commit fc06a33

Please sign in to comment.