-
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 christo/pardot-v5-justin
- Loading branch information
Showing
1,088 changed files
with
17,918 additions
and
12,005 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
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
33 changes: 33 additions & 0 deletions
33
...te-cdk/bulk/core/load/src/main/kotlin/io/airbyte/cdk/load/message/MultiProducerChannel.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,33 @@ | ||
/* | ||
* Copyright (c) 2024 Airbyte, Inc., all rights reserved. | ||
*/ | ||
|
||
package io.airbyte.cdk.load.message | ||
|
||
import io.github.oshai.kotlinlogging.KotlinLogging | ||
import java.util.concurrent.atomic.AtomicLong | ||
import kotlinx.coroutines.channels.Channel | ||
|
||
/** | ||
* A channel designed for use with a fixed amount of producers. Close will be called on the | ||
* underlying channel, when there are no remaining registered producers. | ||
*/ | ||
class MultiProducerChannel<T>( | ||
producerCount: Long, | ||
override val channel: Channel<T>, | ||
) : ChannelMessageQueue<T>() { | ||
private val log = KotlinLogging.logger {} | ||
private val initializedProducerCount = producerCount | ||
private val producerCount = AtomicLong(producerCount) | ||
|
||
override suspend fun close() { | ||
val count = producerCount.decrementAndGet() | ||
log.info { | ||
"Closing producer (active count=$count, initialized count: $initializedProducerCount)" | ||
} | ||
if (count == 0L) { | ||
log.info { "Closing underlying queue" } | ||
channel.close() | ||
} | ||
} | ||
} |
Oops, something went wrong.