forked from airbytehq/airbyte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor spec workflow (airbytehq#7354)
- Loading branch information
1 parent
c689e17
commit 98d87b1
Showing
8 changed files
with
131 additions
and
98 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
95 changes: 0 additions & 95 deletions
95
airbyte-workers/src/main/java/io/airbyte/workers/temporal/SpecWorkflow.java
This file was deleted.
Oops, something went wrong.
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
19 changes: 19 additions & 0 deletions
19
airbyte-workers/src/main/java/io/airbyte/workers/temporal/spec/SpecActivity.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,19 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.workers.temporal.spec; | ||
|
||
import io.airbyte.protocol.models.ConnectorSpecification; | ||
import io.airbyte.scheduler.models.IntegrationLauncherConfig; | ||
import io.airbyte.scheduler.models.JobRunConfig; | ||
import io.temporal.activity.ActivityInterface; | ||
import io.temporal.activity.ActivityMethod; | ||
|
||
@ActivityInterface | ||
public interface SpecActivity { | ||
|
||
@ActivityMethod | ||
ConnectorSpecification run(JobRunConfig jobRunConfig, IntegrationLauncherConfig launcherConfig); | ||
|
||
} |
59 changes: 59 additions & 0 deletions
59
airbyte-workers/src/main/java/io/airbyte/workers/temporal/spec/SpecActivityImpl.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,59 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.workers.temporal.spec; | ||
|
||
import io.airbyte.commons.functional.CheckedSupplier; | ||
import io.airbyte.config.JobGetSpecConfig; | ||
import io.airbyte.protocol.models.ConnectorSpecification; | ||
import io.airbyte.scheduler.models.IntegrationLauncherConfig; | ||
import io.airbyte.scheduler.models.JobRunConfig; | ||
import io.airbyte.workers.DefaultGetSpecWorker; | ||
import io.airbyte.workers.Worker; | ||
import io.airbyte.workers.WorkerUtils; | ||
import io.airbyte.workers.process.AirbyteIntegrationLauncher; | ||
import io.airbyte.workers.process.IntegrationLauncher; | ||
import io.airbyte.workers.process.ProcessFactory; | ||
import io.airbyte.workers.temporal.CancellationHandler; | ||
import io.airbyte.workers.temporal.TemporalAttemptExecution; | ||
import java.nio.file.Path; | ||
import java.util.function.Supplier; | ||
|
||
public class SpecActivityImpl implements SpecActivity { | ||
|
||
private final ProcessFactory processFactory; | ||
private final Path workspaceRoot; | ||
|
||
public SpecActivityImpl(final ProcessFactory processFactory, final Path workspaceRoot) { | ||
this.processFactory = processFactory; | ||
this.workspaceRoot = workspaceRoot; | ||
} | ||
|
||
public ConnectorSpecification run(final JobRunConfig jobRunConfig, final IntegrationLauncherConfig launcherConfig) { | ||
final Supplier<JobGetSpecConfig> inputSupplier = () -> new JobGetSpecConfig().withDockerImage(launcherConfig.getDockerImage()); | ||
|
||
final TemporalAttemptExecution<JobGetSpecConfig, ConnectorSpecification> temporalAttemptExecution = new TemporalAttemptExecution<>( | ||
workspaceRoot, | ||
jobRunConfig, | ||
getWorkerFactory(launcherConfig), | ||
inputSupplier, | ||
new CancellationHandler.TemporalCancellationHandler()); | ||
|
||
return temporalAttemptExecution.get(); | ||
} | ||
|
||
private CheckedSupplier<Worker<JobGetSpecConfig, ConnectorSpecification>, Exception> getWorkerFactory(final IntegrationLauncherConfig launcherConfig) { | ||
return () -> { | ||
final IntegrationLauncher integrationLauncher = new AirbyteIntegrationLauncher( | ||
launcherConfig.getJobId(), | ||
launcherConfig.getAttemptId().intValue(), | ||
launcherConfig.getDockerImage(), | ||
processFactory, | ||
WorkerUtils.DEFAULT_RESOURCE_REQUIREMENTS); | ||
|
||
return new DefaultGetSpecWorker(integrationLauncher); | ||
}; | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
airbyte-workers/src/main/java/io/airbyte/workers/temporal/spec/SpecWorkflow.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,19 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.workers.temporal.spec; | ||
|
||
import io.airbyte.protocol.models.ConnectorSpecification; | ||
import io.airbyte.scheduler.models.IntegrationLauncherConfig; | ||
import io.airbyte.scheduler.models.JobRunConfig; | ||
import io.temporal.workflow.WorkflowInterface; | ||
import io.temporal.workflow.WorkflowMethod; | ||
|
||
@WorkflowInterface | ||
public interface SpecWorkflow { | ||
|
||
@WorkflowMethod | ||
ConnectorSpecification run(JobRunConfig jobRunConfig, IntegrationLauncherConfig launcherConfig); | ||
|
||
} |
28 changes: 28 additions & 0 deletions
28
airbyte-workers/src/main/java/io/airbyte/workers/temporal/spec/SpecWorkflowImpl.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 @@ | ||
/* | ||
* Copyright (c) 2021 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.workers.temporal.spec; | ||
|
||
import io.airbyte.protocol.models.ConnectorSpecification; | ||
import io.airbyte.scheduler.models.IntegrationLauncherConfig; | ||
import io.airbyte.scheduler.models.JobRunConfig; | ||
import io.airbyte.workers.temporal.TemporalUtils; | ||
import io.temporal.activity.ActivityOptions; | ||
import io.temporal.workflow.Workflow; | ||
import java.time.Duration; | ||
|
||
public class SpecWorkflowImpl implements SpecWorkflow { | ||
|
||
final ActivityOptions options = ActivityOptions.newBuilder() | ||
.setScheduleToCloseTimeout(Duration.ofHours(1)) | ||
.setRetryOptions(TemporalUtils.NO_RETRY) | ||
.build(); | ||
private final SpecActivity activity = Workflow.newActivityStub(SpecActivity.class, options); | ||
|
||
@Override | ||
public ConnectorSpecification run(final JobRunConfig jobRunConfig, final IntegrationLauncherConfig launcherConfig) { | ||
return activity.run(jobRunConfig, launcherConfig); | ||
} | ||
|
||
} |
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