Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/improve legacy config stability #764

Merged
merged 2 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,22 @@ public String getGatewayAddress() {

@Override
public URI getRestAddress() {
return URI.create(camundaClientProperties.getZeebe().getBaseUrl().toString());
return getOrLegacyOrDefault(
"RestAddress",
() -> URI.create(camundaClientProperties.getZeebe().getBaseUrl().toString()),
this::composeRestAddress,
DEFAULT.getRestAddress(),
configCache);
}

@Override
public URI getGrpcAddress() {
return URI.create(camundaClientProperties.getZeebe().getGatewayUrl().toString());
return getOrLegacyOrDefault(
"GrpcAddress",
() -> URI.create(camundaClientProperties.getZeebe().getGatewayUrl().toString()),
this::composeGrpcAddress,
DEFAULT.getGrpcAddress(),
configCache);
}

private String composeGatewayAddress() {
Expand Down Expand Up @@ -108,6 +118,17 @@ private String composeGatewayAddress() {
return camundaClientProperties.getZeebe().getGatewayUrl().getHost();
}

private URI composeGrpcAddress() {
String protocol = properties.getSecurity().isPlaintext() ? "http" : "https";
String gatewayAddress = PropertiesUtil.getZeebeGatewayAddress(properties);
return URI.create(String.format("%s://%s", protocol, gatewayAddress));
}

private URI composeRestAddress() {
throw new IllegalStateException(
"Cannot compose rest address from legacy ZeebeClientConfiguration");
}

@Override
public String getDefaultTenantId() {
return getOrLegacyOrDefault(
Expand Down Expand Up @@ -221,7 +242,7 @@ public boolean isPlaintextConnectionEnabled() {
}

private boolean composePlaintext() {
String protocol = camundaClientProperties.getZeebe().getGatewayUrl().getProtocol();
String protocol = camundaClientProperties.getZeebe().getBaseUrl().getProtocol();
if (protocol.equals("http")) {
return true;
}
Expand All @@ -231,7 +252,7 @@ private boolean composePlaintext() {
throw new IllegalStateException(
String.format(
"Unrecognized zeebe protocol '%s'",
camundaClientProperties.getZeebe().getGatewayUrl().getProtocol()));
camundaClientProperties.getZeebe().getBaseUrl().getProtocol()));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@
@ExtendWith(SpringExtension.class)
@TestPropertySource(
properties = {
"camunda.client.zeebe.base-url=http://localhost:12345",
"camunda.client.zeebe.gateway-url=http://localhost:12346",
"zeebe.client.broker.gatewayAddress=localhost12345",
"zeebe.client.requestTimeout=99s",
"zeebe.client.job.timeout=99s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
@ExtendWith(SpringExtension.class)
@TestPropertySource(
properties = {
"camunda.client.zeebe.base-url=http://localhost:12345",
"camunda.client.zeebe.gateway-url=http://localhost:12346",
"zeebe.client.broker.gatewayAddress=localhost12345",
"zeebe.client.requestTimeout=99s",
"zeebe.client.job.timeout=99s",
Expand Down