-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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 orchestrahq/add-orchestra-to-docs
- Loading branch information
Showing
341 changed files
with
10,393 additions
and
8,203 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
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
75 changes: 0 additions & 75 deletions
75
...e-cdk/bulk/core/load/src/main/kotlin/io/airbyte/cdk/message/AirbyteStateMessageFactory.kt
This file was deleted.
Oops, something went wrong.
76 changes: 76 additions & 0 deletions
76
airbyte-cdk/bulk/core/load/src/main/kotlin/io/airbyte/cdk/message/MessageConverter.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,76 @@ | ||
/* | ||
* Copyright (c) 2024 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.cdk.message | ||
|
||
import io.airbyte.protocol.models.v0.AirbyteGlobalState | ||
import io.airbyte.protocol.models.v0.AirbyteMessage | ||
import io.airbyte.protocol.models.v0.AirbyteStateMessage | ||
import io.airbyte.protocol.models.v0.AirbyteStateStats | ||
import io.airbyte.protocol.models.v0.AirbyteStreamState | ||
import io.airbyte.protocol.models.v0.StreamDescriptor | ||
import jakarta.inject.Singleton | ||
|
||
/** | ||
* Converts the internal @[DestinationStateMessage] case class to the Protocol state messages | ||
* required by @[io.airbyte.cdk.output.OutputConsumer] | ||
*/ | ||
interface MessageConverter<T, U> { | ||
fun from(message: T): U | ||
} | ||
|
||
@Singleton | ||
class DefaultMessageConverter : MessageConverter<DestinationStateMessage, AirbyteMessage> { | ||
override fun from(message: DestinationStateMessage): AirbyteMessage { | ||
val state = | ||
when (message) { | ||
is DestinationStreamState -> | ||
AirbyteStateMessage() | ||
.withSourceStats( | ||
AirbyteStateStats() | ||
.withRecordCount(message.sourceStats.recordCount.toDouble()) | ||
) | ||
.withDestinationStats( | ||
message.destinationStats?.let { | ||
AirbyteStateStats().withRecordCount(it.recordCount.toDouble()) | ||
} | ||
?: throw IllegalStateException( | ||
"Destination stats must be provided for DestinationStreamState" | ||
) | ||
) | ||
.withType(AirbyteStateMessage.AirbyteStateType.STREAM) | ||
.withStream(fromStreamState(message.streamState)) | ||
is DestinationGlobalState -> | ||
AirbyteStateMessage() | ||
.withSourceStats( | ||
AirbyteStateStats() | ||
.withRecordCount(message.sourceStats.recordCount.toDouble()) | ||
) | ||
.withDestinationStats( | ||
message.destinationStats?.let { | ||
AirbyteStateStats().withRecordCount(it.recordCount.toDouble()) | ||
} | ||
) | ||
.withType(AirbyteStateMessage.AirbyteStateType.GLOBAL) | ||
.withGlobal( | ||
AirbyteGlobalState() | ||
.withSharedState(message.state) | ||
.withStreamStates(message.streamStates.map { fromStreamState(it) }) | ||
) | ||
} | ||
return AirbyteMessage().withState(state) | ||
} | ||
|
||
private fun fromStreamState( | ||
streamState: DestinationStateMessage.StreamState | ||
): AirbyteStreamState { | ||
return AirbyteStreamState() | ||
.withStreamDescriptor( | ||
StreamDescriptor() | ||
.withNamespace(streamState.stream.descriptor.namespace) | ||
.withName(streamState.stream.descriptor.name) | ||
) | ||
.withStreamState(streamState.state) | ||
} | ||
} |
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.