Skip to content

Commit

Permalink
feat(generator): add retry properties to generated templates (#1142)
Browse files Browse the repository at this point in the history
* feat(generator): add retry properties to generated templates

* feat(generator): rm retry count, make retry backoff hidden
  • Loading branch information
chillleader authored Sep 20, 2023
1 parent 3b22a12 commit 48d50fb
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,17 @@ public OutboundElementTemplate generate(Class<?> connectorDefinition) {
.binding(new ZeebeTaskHeader("errorExpression"))
.build())
.build();
var retriesGroup =
PropertyGroup.builder()
.id("retries")
.label("Retries")
.properties(
CommonProperties.RETRY_BACKOFF.binding(new ZeebeTaskHeader("retryBackoff")).build())
.build();

mergedGroups.add(outputGroup);
mergedGroups.add(errorGroup);
mergedGroups.add(retriesGroup);

var nonGroupedProperties =
properties.stream().filter(property -> property.build().getGroup() == null).toList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,12 @@ public class CommonProperties {
.description(
"Expression to handle errors. Details in the <a href=\"https://docs.camunda.io/docs/components/connectors/use-connectors/\" target=\"_blank\">documentation</a>.")
.feel(FeelMode.required);

public static final PropertyBuilder RETRY_BACKOFF =
HiddenProperty.builder()
.id("retryBackoff")
.label("Retry backoff")
.description("ISO-8601 duration to wait between retries")
.group("retries")
.value("PT0S");
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import io.camunda.connector.generator.dsl.OutboundElementTemplate.ElementType;
import io.camunda.connector.generator.dsl.Property.FeelMode;
import io.camunda.connector.generator.dsl.PropertyBinding;
import io.camunda.connector.generator.dsl.PropertyBinding.ZeebeTaskHeader;
import io.camunda.connector.generator.dsl.PropertyCondition;
import io.camunda.connector.generator.dsl.PropertyCondition.Equals;
import io.camunda.connector.generator.dsl.PropertyConstraints.Pattern;
Expand Down Expand Up @@ -115,6 +116,17 @@ void errorExpressionProperty() {
assertThat(property.getBinding().type()).isEqualTo("zeebe:taskHeader");
assertThat(property.getFeel()).isEqualTo(FeelMode.required);
}

@Test
void retryBackoffProperty() {
var template = generator.generate(MyConnectorFunction.MinimallyAnnotated.class);
var property = getPropertyByLabel("Retry backoff", template);
assertThat(property.getType()).isEqualTo("Hidden");
assertThat(property.getBinding().type()).isEqualTo("zeebe:taskHeader");
assertThat(((ZeebeTaskHeader) property.getBinding()).key()).isEqualTo("retryBackoff");
assertThat(property.getGroup()).isEqualTo("retries");
assertThat(property.getValue()).isEqualTo("PT0S");
}
}

@Nested
Expand Down Expand Up @@ -299,7 +311,8 @@ void propertyGroups_unordered() {
Map.entry("group1", "Group 1"),
Map.entry("group2", "Group 2"),
Map.entry("output", "Output mapping"),
Map.entry("error", "Error handling")),
Map.entry("error", "Error handling"),
Map.entry("retries", "Retries")),
template,
false);
}
Expand All @@ -312,7 +325,8 @@ void propertyGroups_orderedAndLabeledByAnnotation() {
Map.entry("group2", "Group Two"),
Map.entry("group1", "Group One"),
Map.entry("output", "Output mapping"),
Map.entry("error", "Error handling")),
Map.entry("error", "Error handling"),
Map.entry("retries", "Retries")),
template,
true);
}
Expand Down

0 comments on commit 48d50fb

Please sign in to comment.