-
Notifications
You must be signed in to change notification settings - Fork 276
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Clean up control flow actions (#6616)
- Loading branch information
Showing
7 changed files
with
165 additions
and
107 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
airbyte-commons-worker/src/main/java/io/airbyte/workers/context/ReplicationFeatureFlags.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,12 @@ | ||
/* | ||
* Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.workers.context; | ||
|
||
/** | ||
* Feature flags to consider during a Replication job. | ||
*/ | ||
public record ReplicationFeatureFlags(boolean shouldCommitStateAsap, boolean shouldCommitStatsAsap, boolean shouldHandleStreamStatus) { | ||
|
||
} |
124 changes: 34 additions & 90 deletions
124
...yte-commons-worker/src/main/java/io/airbyte/workers/general/DefaultReplicationWorker.java
Large diffs are not rendered by default.
Oops, something went wrong.
67 changes: 67 additions & 0 deletions
67
...commons-worker/src/main/java/io/airbyte/workers/general/ReplicationFeatureFlagReader.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,67 @@ | ||
/* | ||
* Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.workers.general; | ||
|
||
import io.airbyte.config.StandardSyncInput; | ||
import io.airbyte.featureflag.FeatureFlagClient; | ||
import io.airbyte.featureflag.HandleStreamStatus; | ||
import io.airbyte.featureflag.Workspace; | ||
import io.airbyte.workers.context.ReplicationContext; | ||
import io.airbyte.workers.context.ReplicationFeatureFlags; | ||
|
||
/** | ||
* Read features flags we need to consider during a sync. | ||
*/ | ||
public class ReplicationFeatureFlagReader { | ||
|
||
private final FeatureFlagClient featureFlagClient; | ||
|
||
public ReplicationFeatureFlagReader(final FeatureFlagClient featureFlagClient) { | ||
this.featureFlagClient = featureFlagClient; | ||
} | ||
|
||
/** | ||
* Read Feature flags we need to consider during a sync. | ||
* | ||
* @param replicationContext the context of the sync. | ||
* @param syncInput the input of the sync. | ||
* @return The flags. | ||
*/ | ||
public ReplicationFeatureFlags readReplicationFeatureFlags(final ReplicationContext replicationContext, final StandardSyncInput syncInput) { | ||
return new ReplicationFeatureFlags( | ||
ReplicationFeatureFlagReader.shouldCommitStateAsap(syncInput), | ||
ReplicationFeatureFlagReader.shouldCommitStatsAsap(syncInput), | ||
shouldHandleStreamStatus(replicationContext)); | ||
} | ||
|
||
/** | ||
* Helper function to read the shouldCommitStateAsap feature flag. | ||
*/ | ||
static boolean shouldCommitStateAsap(final StandardSyncInput syncInput) { | ||
return syncInput.getCommitStateAsap() != null && syncInput.getCommitStateAsap(); | ||
} | ||
|
||
/** | ||
* Helper function to read the shouldCommitStatsAsap feature flag. | ||
*/ | ||
static boolean shouldCommitStatsAsap(final StandardSyncInput syncInput) { | ||
// For consistency, we should only be committing stats early if we are committing states early. | ||
// Otherwise, we are risking stats discrepancy as we are committing stats for states that haven't | ||
// been persisted yet. | ||
return shouldCommitStateAsap(syncInput) && syncInput.getCommitStatsAsap() != null && syncInput.getCommitStatsAsap(); | ||
} | ||
|
||
/** | ||
* Helper function to read the status of the {@link HandleStreamStatus} feature flag once at the | ||
* start of the replication exection. | ||
* | ||
* @param replicationContext The {@link ReplicationContext} of the replication. | ||
* @return The result of checking the status of the {@link HandleStreamStatus} feature flag. | ||
*/ | ||
private boolean shouldHandleStreamStatus(final ReplicationContext replicationContext) { | ||
return featureFlagClient.boolVariation(HandleStreamStatus.INSTANCE, new Workspace(replicationContext.workspaceId())); | ||
} | ||
|
||
} |
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
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