-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add leader election configuration
- Loading branch information
1 parent
1c5a73f
commit 107c93d
Showing
8 changed files
with
137 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
docs/modules/onecx-product-store-operator/pages/onecx-product-store-operator.adoc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
:summaryTableId: onecx-product-store-operator | ||
[.configuration-legend] | ||
icon:lock[title=Fixed at build time] Configuration property fixed at build time - All other configuration properties are overridable at runtime | ||
[.configuration-reference.searchable, cols="80,.^10,.^10"] | ||
|=== | ||
|
||
h|[.header-title]##Configuration property## | ||
h|Type | ||
h|Default | ||
|
||
a| [[onecx-product-store-operator_onecx-product-store-operator-leader-election-lease-name]] [.property-path]##link:#onecx-product-store-operator_onecx-product-store-operator-leader-election-lease-name[`onecx.product-store.operator.leader-election.lease-name`]## | ||
|
||
[.description] | ||
-- | ||
Lease name | ||
|
||
|
||
ifdef::add-copy-button-to-env-var[] | ||
Environment variable: env_var_with_copy_button:+++ONECX_PRODUCT_STORE_OPERATOR_LEADER_ELECTION_LEASE_NAME+++[] | ||
endif::add-copy-button-to-env-var[] | ||
ifndef::add-copy-button-to-env-var[] | ||
Environment variable: `+++ONECX_PRODUCT_STORE_OPERATOR_LEADER_ELECTION_LEASE_NAME+++` | ||
endif::add-copy-button-to-env-var[] | ||
-- | ||
|string | ||
|`onecx-product-store-operator-lease` | ||
|
||
|=== | ||
|
||
|
||
:!summaryTableId: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/main/java/org/tkit/onecx/product/store/operator/LeaderConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package org.tkit.onecx.product.store.operator; | ||
|
||
import jakarta.inject.Singleton; | ||
|
||
import io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration; | ||
|
||
@Singleton | ||
public class LeaderConfiguration extends LeaderElectionConfiguration { | ||
|
||
public LeaderConfiguration(OperatorConfig config) { | ||
super(config.leaderElectionConfig().leaseName()); | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
src/main/java/org/tkit/onecx/product/store/operator/OperatorConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.tkit.onecx.product.store.operator; | ||
|
||
import io.quarkus.runtime.annotations.ConfigDocFilename; | ||
import io.quarkus.runtime.annotations.ConfigPhase; | ||
import io.quarkus.runtime.annotations.ConfigRoot; | ||
import io.quarkus.runtime.annotations.StaticInitSafe; | ||
import io.smallrye.config.ConfigMapping; | ||
import io.smallrye.config.WithDefault; | ||
import io.smallrye.config.WithName; | ||
|
||
@StaticInitSafe | ||
@ConfigDocFilename("onecx-product-store-operator.adoc") | ||
@ConfigMapping(prefix = "onecx.product-store.operator") | ||
@ConfigRoot(phase = ConfigPhase.RUN_TIME) | ||
public interface OperatorConfig { | ||
|
||
/** | ||
* Leader election configuration | ||
*/ | ||
@WithName("leader-election") | ||
LeaderElectionConfig leaderElectionConfig(); | ||
|
||
/** | ||
* Leader election config | ||
*/ | ||
interface LeaderElectionConfig { | ||
|
||
/** | ||
* Lease name | ||
*/ | ||
@WithName("lease-name") | ||
@WithDefault("onecx-product-store-operator-lease") | ||
String leaseName(); | ||
} | ||
} |
28 changes: 28 additions & 0 deletions
28
src/test/java/org/tkit/onecx/product/store/operator/LeaderConfigurationTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package org.tkit.onecx.product.store.operator; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import jakarta.inject.Inject; | ||
|
||
import org.junit.jupiter.api.Test; | ||
import org.tkit.onecx.product.store.test.AbstractTest; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
|
||
@QuarkusTest | ||
class LeaderConfigurationTest extends AbstractTest { | ||
|
||
@Inject | ||
OperatorConfig dataConfig; | ||
|
||
@Inject | ||
LeaderConfiguration leaderConfiguration; | ||
|
||
@Test | ||
void testLeaderConfiguration() { | ||
assertThat(dataConfig).isNotNull(); | ||
assertThat(dataConfig.leaderElectionConfig()).isNotNull(); | ||
assertThat(leaderConfiguration).isNotNull(); | ||
assertThat(leaderConfiguration.getLeaseName()).isNotNull().isEqualTo(dataConfig.leaderElectionConfig().leaseName()); | ||
} | ||
} |