Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Acquiring channel should not block graceful shutdown #14

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ package com.snowplowanalytics.snowplow.snowflake.processing
import cats.effect.implicits._
import cats.effect.kernel.{Ref, Resource}
import cats.effect.std.{Hotswap, Semaphore}
import cats.effect.{Async, Sync}
import cats.effect.{Async, Poll, Sync}
import cats.implicits._
import com.snowplowanalytics.snowplow.snowflake.{Alert, Config, Monitoring}
import net.snowflake.ingest.streaming.internal.SnowsFlakePlowInterop
Expand Down Expand Up @@ -201,16 +201,18 @@ object ChannelProvider {
.setDefaultTimezone(ZoneOffset.UTC)
.build

val make = Logger[F].info(s"Opening channel ${config.channel}") *>
SnowflakeRetrying.retryIndefinitely(snowflakeHealth, retriesConfig) {
Async[F]
.blocking(client.openChannel(request))
.onError { cause =>
monitoring.alert(Alert.FailedToOpenSnowflakeChannel(cause))
}
}
def make(poll: Poll[F]) = poll {
Logger[F].info(s"Opening channel ${config.channel}") *>
SnowflakeRetrying.retryIndefinitely(snowflakeHealth, retriesConfig) {
Async[F]
.blocking(client.openChannel(request))
.onError { cause =>
monitoring.alert(Alert.FailedToOpenSnowflakeChannel(cause))
}
}
}

Resource.make(make) { channel =>
Resource.makeFull(make) { channel =>
Logger[F].info(s"Closing channel ${config.channel}") *>
Async[F]
.fromCompletableFuture {
Expand Down
Loading