-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into tope/tiktok-marketing/add-sparkAds-stream
- Loading branch information
Showing
116 changed files
with
9,594 additions
and
1,259 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
9 changes: 9 additions & 0 deletions
9
airbyte-cdk/bulk/core/base/src/main/kotlin/io/airbyte/cdk/ConnectorUncleanExitException.kt
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,9 @@ | ||
/* | ||
* Copyright (c) 2024 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.cdk | ||
|
||
/** This is used only in tests. */ | ||
class ConnectorUncleanExitException(val exitCode: Int) : | ||
Exception("Destination process exited uncleanly: $exitCode") |
64 changes: 64 additions & 0 deletions
64
airbyte-cdk/bulk/core/base/src/main/kotlin/io/airbyte/cdk/command/FeatureFlag.kt
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,64 @@ | ||
/* | ||
* Copyright (c) 2024 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.cdk.command | ||
|
||
import io.micronaut.context.annotation.Factory | ||
import io.micronaut.context.env.Environment | ||
import jakarta.inject.Singleton | ||
import java.util.EnumSet | ||
|
||
/** | ||
* An enum of all feature flags, currently these are set via environment vars. | ||
* | ||
* Micronaut can inject a Set<FeatureFlag> singleton of all active feature flags. | ||
*/ | ||
enum class FeatureFlag( | ||
val micronautEnvironmentName: String, | ||
val envVar: EnvVar, | ||
val requiredEnvVarValue: String, | ||
private val transformActualValue: (String) -> String = { it } | ||
) { | ||
|
||
/** [AIRBYTE_CLOUD_DEPLOYMENT] is active when the connector is running in Airbyte Cloud. */ | ||
AIRBYTE_CLOUD_DEPLOYMENT( | ||
micronautEnvironmentName = AIRBYTE_CLOUD_ENV, | ||
envVar = EnvVar.DEPLOYMENT_MODE, | ||
requiredEnvVarValue = "CLOUD", | ||
transformActualValue = { it.trim().uppercase() }, | ||
); | ||
|
||
/** Environment variable binding shell declaration which activates the feature flag. */ | ||
val envVarBindingDeclaration: String | ||
get() = "${envVar.name}=$requiredEnvVarValue" | ||
|
||
enum class EnvVar(val defaultValue: String = "") { | ||
DEPLOYMENT_MODE | ||
} | ||
|
||
companion object { | ||
internal fun active(systemEnv: Map<String, String>): List<FeatureFlag> = | ||
entries.filter { featureFlag: FeatureFlag -> | ||
val envVar: EnvVar = featureFlag.envVar | ||
val envVarValue: String = systemEnv[envVar.name] ?: envVar.defaultValue | ||
featureFlag.transformActualValue(envVarValue) == featureFlag.requiredEnvVarValue | ||
} | ||
} | ||
|
||
@Factory | ||
private class MicronautFactory { | ||
|
||
@Singleton | ||
fun active(environment: Environment): Set<FeatureFlag> = | ||
EnumSet.noneOf(FeatureFlag::class.java).apply { | ||
addAll( | ||
FeatureFlag.entries.filter { | ||
environment.activeNames.contains(it.micronautEnvironmentName) | ||
} | ||
) | ||
} | ||
} | ||
} | ||
|
||
const val AIRBYTE_CLOUD_ENV = "airbyte-cloud" |
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
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.