Skip to content

Commit

Permalink
chore: remove max retry attempts config property (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
Emrehzl94 authored Sep 3, 2024
1 parent fe279cc commit 7dbc695
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,6 @@ open class Neo4jConfiguration(configDef: ConfigDef, originals: Map<*, *>, val ty
get(): kotlin.time.Duration =
kotlin.time.Duration.parseSimpleString(getString(MAX_TRANSACTION_RETRY_TIMEOUT))

val maxRetryAttempts
get(): Int = getInt(MAX_TRANSACTION_RETRY_ATTEMPTS)

internal val maxConnectionPoolSize
get(): Int = getInt(POOL_MAX_CONNECTION_POOL_SIZE)

Expand Down Expand Up @@ -248,7 +245,6 @@ open class Neo4jConfiguration(configDef: ConfigDef, originals: Map<*, *>, val ty
const val AUTHENTICATION_CUSTOM_REALM = "neo4j.authentication.custom.realm"

const val MAX_TRANSACTION_RETRY_TIMEOUT = "neo4j.max-retry-time"
const val MAX_TRANSACTION_RETRY_ATTEMPTS = "neo4j.max-retry-attempts"

const val CONNECTION_TIMEOUT = "neo4j.connection-timeout"
const val POOL_MAX_CONNECTION_POOL_SIZE = "neo4j.pool.max-connection-pool-size"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,18 +307,10 @@ fun ConfigDef.definePoolSettings(): ConfigDef =

fun ConfigDef.defineRetrySettings(): ConfigDef =
this.define(
ConfigKeyBuilder.of(
Neo4jConfiguration.MAX_TRANSACTION_RETRY_TIMEOUT, ConfigDef.Type.STRING) {
importance = Importance.LOW
defaultValue = Neo4jConfiguration.DEFAULT_MAX_RETRY_DURATION.toSimpleString()
group = Groups.CONNECTION_ADVANCED.title
validator = Validators.pattern(SIMPLE_DURATION_PATTERN)
})
.define(
ConfigKeyBuilder.of(
Neo4jConfiguration.MAX_TRANSACTION_RETRY_ATTEMPTS, ConfigDef.Type.INT) {
importance = Importance.LOW
defaultValue = Neo4jConfiguration.DEFAULT_MAX_RETRY_ATTEMPTS
group = Groups.CONNECTION_ADVANCED.title
validator = Range.atLeast(1)
})
ConfigKeyBuilder.of(
Neo4jConfiguration.MAX_TRANSACTION_RETRY_TIMEOUT, ConfigDef.Type.STRING) {
importance = Importance.LOW
defaultValue = Neo4jConfiguration.DEFAULT_MAX_RETRY_DURATION.toSimpleString()
group = Groups.CONNECTION_ADVANCED.title
validator = Validators.pattern(SIMPLE_DURATION_PATTERN)
})
3 changes: 1 addition & 2 deletions common/src/main/resources/neo4j-configuration.properties
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,4 @@ neo4j.pool.max-connection-pool-size=Type: Integer;\nDescription: Maximum number
neo4j.pool.connection-acquisition-timeout=Type: Duration;\nDescription: Maximum duration to wait for acquiring a connection from the connection pool (valid units are: `ms`, `s`, `m`, `h` and `d`; default unit is `s`).
neo4j.pool.idle-time-before-connection-test=Type: Duration;\nDescription: Duration after which idle connections are tested for liveness (valid units are: `ms`, `s`, `m`, `h` and `d`; default unit is `s`).
neo4j.pool.max-connection-lifetime=Type: Duration;\nDescription: Duration after which a connection is dropped from the connection pool (valid units are: ``ms`, `s`, `m`, `h` and `d`; default unit is `s`).
neo4j.max-retry-time=Type: Duration;\nDescription: Maximum duration to retry a transaction.
neo4j.max-retry-attempts=Type: Integer;\nDescription: Maximum number of attempts during the duration specified by `neo4j.max-retry-time`.
neo4j.max-retry-time=Type: Duration;\nDescription: Maximum duration to retry a transaction.
Original file line number Diff line number Diff line change
Expand Up @@ -88,19 +88,6 @@ class Neo4jConfigurationTest {
Neo4jConfiguration.URI to "bolt://localhost",
Neo4jConfiguration.AUTHENTICATION_TYPE to "NONE",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_TIMEOUT to "5s",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_ATTEMPTS to 0),
type)
} shouldHaveMessage
"Invalid value 0 for configuration neo4j.max-retry-attempts: Value must be at least 1"

shouldThrow<ConfigException> {
Neo4jConfiguration(
Neo4jConfiguration.config(),
mapOf(
Neo4jConfiguration.URI to "bolt://localhost",
Neo4jConfiguration.AUTHENTICATION_TYPE to "NONE",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_TIMEOUT to "5s",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_ATTEMPTS to 5,
Neo4jConfiguration.CONNECTION_TIMEOUT to "1"),
type)
} shouldHaveMessage
Expand All @@ -113,7 +100,6 @@ class Neo4jConfigurationTest {
Neo4jConfiguration.URI to "bolt://localhost",
Neo4jConfiguration.AUTHENTICATION_TYPE to "NONE",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_TIMEOUT to "5s",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_ATTEMPTS to 5,
Neo4jConfiguration.CONNECTION_TIMEOUT to "1m",
Neo4jConfiguration.POOL_MAX_CONNECTION_POOL_SIZE to 0),
type)
Expand All @@ -127,7 +113,6 @@ class Neo4jConfigurationTest {
Neo4jConfiguration.URI to "bolt://localhost",
Neo4jConfiguration.AUTHENTICATION_TYPE to "NONE",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_TIMEOUT to "5s",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_ATTEMPTS to 5,
Neo4jConfiguration.CONNECTION_TIMEOUT to "1m",
Neo4jConfiguration.POOL_MAX_CONNECTION_POOL_SIZE to 5,
Neo4jConfiguration.POOL_CONNECTION_ACQUISITION_TIMEOUT to "5k"),
Expand All @@ -142,7 +127,6 @@ class Neo4jConfigurationTest {
Neo4jConfiguration.URI to "bolt://localhost",
Neo4jConfiguration.AUTHENTICATION_TYPE to "NONE",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_TIMEOUT to "5s",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_ATTEMPTS to 5,
Neo4jConfiguration.CONNECTION_TIMEOUT to "1m",
Neo4jConfiguration.POOL_MAX_CONNECTION_POOL_SIZE to 5,
Neo4jConfiguration.POOL_CONNECTION_ACQUISITION_TIMEOUT to "5m",
Expand All @@ -158,7 +142,6 @@ class Neo4jConfigurationTest {
Neo4jConfiguration.URI to "bolt://localhost",
Neo4jConfiguration.AUTHENTICATION_TYPE to "NONE",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_TIMEOUT to "5s",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_ATTEMPTS to 5,
Neo4jConfiguration.CONNECTION_TIMEOUT to "1m",
Neo4jConfiguration.POOL_MAX_CONNECTION_POOL_SIZE to 5,
Neo4jConfiguration.POOL_CONNECTION_ACQUISITION_TIMEOUT to "5m",
Expand All @@ -175,7 +158,6 @@ class Neo4jConfigurationTest {
Neo4jConfiguration.URI to "bolt://localhost",
Neo4jConfiguration.AUTHENTICATION_TYPE to "NONE",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_TIMEOUT to "5s",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_ATTEMPTS to 5,
Neo4jConfiguration.CONNECTION_TIMEOUT to "1m",
Neo4jConfiguration.POOL_MAX_CONNECTION_POOL_SIZE to 5,
Neo4jConfiguration.POOL_CONNECTION_ACQUISITION_TIMEOUT to "5m",
Expand All @@ -193,7 +175,6 @@ class Neo4jConfigurationTest {
Neo4jConfiguration.URI to "bolt://localhost",
Neo4jConfiguration.AUTHENTICATION_TYPE to "NONE",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_TIMEOUT to "5s",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_ATTEMPTS to 5,
Neo4jConfiguration.CONNECTION_TIMEOUT to "1m",
Neo4jConfiguration.POOL_MAX_CONNECTION_POOL_SIZE to 5,
Neo4jConfiguration.POOL_CONNECTION_ACQUISITION_TIMEOUT to "5m",
Expand All @@ -212,7 +193,6 @@ class Neo4jConfigurationTest {
Neo4jConfiguration.URI to "bolt://localhost",
Neo4jConfiguration.AUTHENTICATION_TYPE to "NONE",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_TIMEOUT to "5s",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_ATTEMPTS to 5,
Neo4jConfiguration.CONNECTION_TIMEOUT to "1m",
Neo4jConfiguration.POOL_MAX_CONNECTION_POOL_SIZE to 5,
Neo4jConfiguration.POOL_CONNECTION_ACQUISITION_TIMEOUT to "5m",
Expand All @@ -232,7 +212,6 @@ class Neo4jConfigurationTest {
Neo4jConfiguration.URI to "bolt://localhost",
Neo4jConfiguration.AUTHENTICATION_TYPE to "NONE",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_TIMEOUT to "5s",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_ATTEMPTS to 5,
Neo4jConfiguration.CONNECTION_TIMEOUT to "1m",
Neo4jConfiguration.POOL_MAX_CONNECTION_POOL_SIZE to 5,
Neo4jConfiguration.POOL_CONNECTION_ACQUISITION_TIMEOUT to "5m",
Expand Down Expand Up @@ -260,7 +239,6 @@ class Neo4jConfigurationTest {
Neo4jConfiguration.URI to "bolt://localhost",
Neo4jConfiguration.AUTHENTICATION_TYPE to "NONE",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_TIMEOUT to "5s",
Neo4jConfiguration.MAX_TRANSACTION_RETRY_ATTEMPTS to 5,
Neo4jConfiguration.CONNECTION_TIMEOUT to "1m",
Neo4jConfiguration.POOL_MAX_CONNECTION_POOL_SIZE to 5,
Neo4jConfiguration.POOL_CONNECTION_ACQUISITION_TIMEOUT to "5m",
Expand All @@ -275,7 +253,6 @@ class Neo4jConfigurationTest {
assertEquals(listOf(URI("bolt://localhost")), config.uris)
assertEquals(AuthTokens.none(), config.authenticationToken)
assertEquals(5.seconds, config.maxRetryTime)
assertEquals(5, config.maxRetryAttempts)
assertEquals(1.minutes, config.connectionTimeout)
assertEquals(5, config.maxConnectionPoolSize)
assertEquals(5.minutes, config.connectionAcquisitionTimeout)
Expand Down

0 comments on commit 7dbc695

Please sign in to comment.