-
Notifications
You must be signed in to change notification settings - Fork 554
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
9274: [Backport stable/8.0] feat(broker): add feature flag template r=pihme a=github-actions[bot] # Description Backport of #9257 to `stable/8.0`. relates to #9254 Co-authored-by: pihme <pihme@users.noreply.github.com>
- Loading branch information
Showing
6 changed files
with
128 additions
and
0 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
41 changes: 41 additions & 0 deletions
41
broker/src/main/java/io/camunda/zeebe/broker/system/configuration/FeatureFlagsCfg.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,41 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
* one or more contributor license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding copyright ownership. | ||
* Licensed under the Zeebe Community License 1.1. You may not use this file | ||
* except in compliance with the Zeebe Community License 1.1. | ||
*/ | ||
package io.camunda.zeebe.broker.system.configuration; | ||
|
||
import com.fasterxml.jackson.databind.annotation.JsonSerialize; | ||
import io.camunda.zeebe.util.FeatureFlags; | ||
import org.apache.commons.lang3.builder.ToStringBuilder; | ||
import org.apache.commons.lang3.builder.ToStringStyle; | ||
|
||
@JsonSerialize // this annotation seems to implicitly disable | ||
// SerializationFeature.FAIL_ON_EMPTY_BEANS | ||
public final class FeatureFlagsCfg { | ||
|
||
// To add a new feature flag, read the comments in FeatureFlags | ||
|
||
private static final FeatureFlags DEFAULT_SETTINGS = FeatureFlags.createDefault(); | ||
// | ||
// private boolean enableFoo = DEFAULT_SETTINGS.foo(); | ||
// | ||
// public boolean isEnableFoo() { | ||
// return enableFoo; | ||
// } | ||
// | ||
// public void setEnableFoo(final boolean enableFoo) { | ||
// this.enableFoo = enableFoo; | ||
// } | ||
|
||
FeatureFlags toFeatureFlags() { | ||
return new FeatureFlags(/*enableFoo*/ ); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); | ||
} | ||
} |
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
44 changes: 44 additions & 0 deletions
44
util/src/main/java/io/camunda/zeebe/util/FeatureFlags.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,44 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
* one or more contributor license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding copyright ownership. | ||
* Licensed under the Zeebe Community License 1.1. You may not use this file | ||
* except in compliance with the Zeebe Community License 1.1. | ||
*/ | ||
package io.camunda.zeebe.util; | ||
|
||
import org.apache.commons.lang3.builder.ToStringBuilder; | ||
import org.apache.commons.lang3.builder.ToStringStyle; | ||
|
||
public record FeatureFlags(/*boolean foo*/ ) { | ||
|
||
/* To add a new feature toggle, please follow these steps: | ||
* | ||
* - add a record property to this class, and extend the test for this class | ||
* | ||
* - define the default value. When introducing a new feature flag the default | ||
* value should be 'false'. This way the feature is disabled by default | ||
* for all customers who do not change their configuration. | ||
* As we gain more confidence in the efficacy of the feature flag, the | ||
* default value can be set to 'true' | ||
* | ||
* - add a field, getter and setter to FeatureFlagsCfg | ||
* | ||
* - add a description of the feature flag to | ||
* - dist/src/main/config/broker.standalone.yaml.template | ||
* - dist/src/main/config/broker.yaml.template | ||
* | ||
* Be careful with parameter order in constructor calls! | ||
*/ | ||
|
||
// protected static final boolean FOO_DEFAULT = false; | ||
// | ||
public static FeatureFlags createDefault() { | ||
return new FeatureFlags(/*FOO_DEFAULT*/ ); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
util/src/test/java/io/camunda/zeebe/util/FeatureFlagsTest.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,22 @@ | ||
/* | ||
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH under | ||
* one or more contributor license agreements. See the NOTICE file distributed | ||
* with this work for additional information regarding copyright ownership. | ||
* Licensed under the Zeebe Community License 1.1. You may not use this file | ||
* except in compliance with the Zeebe Community License 1.1. | ||
*/ | ||
package io.camunda.zeebe.util; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class FeatureFlagsTest { | ||
|
||
@Test | ||
void testDefaultValues() { | ||
// given | ||
final var sut = FeatureFlags.createDefault(); | ||
|
||
// then | ||
// assertThat(sut.foo()).isFalse(); | ||
} | ||
} |