-
Notifications
You must be signed in to change notification settings - Fork 280
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Connection Updater worker should use data plane to run check_connecti…
…on (#6191)
- Loading branch information
1 parent
8347949
commit a82ce3d
Showing
8 changed files
with
186 additions
and
27 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
27 changes: 27 additions & 0 deletions
27
...main/java/io/airbyte/workers/temporal/check/connection/SubmitCheckConnectionActivity.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,27 @@ | ||
/* | ||
* Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.workers.temporal.check.connection; | ||
|
||
import io.airbyte.config.ConnectorJobOutput; | ||
import io.temporal.activity.ActivityInterface; | ||
import java.util.UUID; | ||
|
||
/** | ||
* Temporal activity to submit a check_connection request to airbyte server. | ||
*/ | ||
@ActivityInterface | ||
public interface SubmitCheckConnectionActivity { | ||
|
||
/** | ||
* Submits an API request to airbyte server to run check connection for source. | ||
*/ | ||
ConnectorJobOutput submitCheckConnectionToSource(final UUID sourceId); | ||
|
||
/** | ||
* Submits an API request to airbyte server to run check connection for destination. | ||
*/ | ||
ConnectorJobOutput submitCheckConnectionToDestination(final UUID destinationId); | ||
|
||
} |
91 changes: 91 additions & 0 deletions
91
.../java/io/airbyte/workers/temporal/check/connection/SubmitCheckConnectionActivityImpl.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,91 @@ | ||
/* | ||
* Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.workers.temporal.check.connection; | ||
|
||
import static io.airbyte.metrics.lib.ApmTraceConstants.ACTIVITY_TRACE_OPERATION_NAME; | ||
|
||
import datadog.trace.api.Trace; | ||
import io.airbyte.api.client.AirbyteApiClient; | ||
import io.airbyte.api.client.generated.DestinationApi; | ||
import io.airbyte.api.client.generated.SourceApi; | ||
import io.airbyte.api.client.model.generated.CheckConnectionRead; | ||
import io.airbyte.api.client.model.generated.CheckConnectionRead.StatusEnum; | ||
import io.airbyte.api.client.model.generated.DestinationIdRequestBody; | ||
import io.airbyte.api.client.model.generated.SourceIdRequestBody; | ||
import io.airbyte.commons.features.EnvVariableFeatureFlags; | ||
import io.airbyte.config.ConnectorJobOutput; | ||
import io.airbyte.config.ConnectorJobOutput.OutputType; | ||
import io.airbyte.config.FailureReason; | ||
import io.airbyte.config.FailureReason.FailureType; | ||
import io.airbyte.config.StandardCheckConnectionOutput; | ||
import io.airbyte.config.StandardCheckConnectionOutput.Status; | ||
import jakarta.inject.Singleton; | ||
import java.util.UUID; | ||
import lombok.extern.slf4j.Slf4j; | ||
|
||
/** | ||
* | ||
* Implementation of SubmitCheckConnectionActivity. | ||
*/ | ||
@Slf4j | ||
@Singleton | ||
public class SubmitCheckConnectionActivityImpl implements SubmitCheckConnectionActivity { | ||
|
||
private final SourceApi sourceApi; | ||
private final DestinationApi destinationApi; | ||
private final EnvVariableFeatureFlags envVariableFeatureFlags; | ||
|
||
public SubmitCheckConnectionActivityImpl(final SourceApi sourceApi, | ||
DestinationApi destinationApi, | ||
final EnvVariableFeatureFlags envVariableFeatureFlags) { | ||
this.sourceApi = sourceApi; | ||
this.destinationApi = destinationApi; | ||
this.envVariableFeatureFlags = envVariableFeatureFlags; | ||
} | ||
|
||
@Override | ||
@Trace(operationName = ACTIVITY_TRACE_OPERATION_NAME) | ||
public ConnectorJobOutput submitCheckConnectionToSource(final UUID sourceId) { | ||
ConnectorJobOutput jobOutput = new ConnectorJobOutput().withOutputType(OutputType.CHECK_CONNECTION); | ||
try { | ||
CheckConnectionRead checkResult = AirbyteApiClient.retryWithJitter( | ||
() -> sourceApi.checkConnectionToSource(new SourceIdRequestBody().sourceId(sourceId)), | ||
"Trigger check connection to source"); | ||
jobOutput.withCheckConnection(convertApiOutputToStandardOutput(checkResult)); | ||
} catch (Exception ex) { | ||
jobOutput.withFailureReason(new FailureReason().withFailureType(FailureType.SYSTEM_ERROR).withInternalMessage(ex.getMessage())); | ||
throw ex; | ||
} | ||
return jobOutput; | ||
} | ||
|
||
@Override | ||
@Trace(operationName = ACTIVITY_TRACE_OPERATION_NAME) | ||
public ConnectorJobOutput submitCheckConnectionToDestination(final UUID destinationId) { | ||
ConnectorJobOutput jobOutput = new ConnectorJobOutput().withOutputType(OutputType.CHECK_CONNECTION); | ||
try { | ||
CheckConnectionRead checkResult = AirbyteApiClient.retryWithJitter( | ||
() -> destinationApi.checkConnectionToDestination(new DestinationIdRequestBody().destinationId(destinationId)), | ||
"Trigger check connection to destination"); | ||
jobOutput.withCheckConnection(convertApiOutputToStandardOutput(checkResult)); | ||
} catch (Exception ex) { | ||
jobOutput.withFailureReason(new FailureReason().withFailureType(FailureType.SYSTEM_ERROR).withInternalMessage(ex.getMessage())); | ||
throw ex; | ||
} | ||
return jobOutput; | ||
} | ||
|
||
private StandardCheckConnectionOutput convertApiOutputToStandardOutput(final CheckConnectionRead apiOutput) { | ||
StandardCheckConnectionOutput output = new StandardCheckConnectionOutput().withMessage(apiOutput.getMessage()); | ||
|
||
if (apiOutput.getStatus().equals(StatusEnum.SUCCEEDED)) { | ||
output.withStatus(Status.SUCCEEDED); | ||
} else { | ||
output.withStatus(Status.FAILED); | ||
} | ||
return output; | ||
} | ||
|
||
} |
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
Oops, something went wrong.