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

Add support for source connector to control the poll interval from s3 #1293

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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 @@ -67,6 +67,10 @@ abstract class CloudSourceTask[MD <: FileMetadata, C <: CloudSourceConfig[MD], C

implicit var connectorTaskId: ConnectorTaskId = _

// Member variable for delayMs
@volatile
private var delayMs: Option[Long] = _

/**
* Start sets up readers for every configured connection in the properties
*/
Expand All @@ -87,6 +91,9 @@ abstract class CloudSourceTask[MD <: FileMetadata, C <: CloudSourceConfig[MD], C
cancelledRef = result.cancelledRef.some
partitionDiscoveryLoop = fiber.some
}).unsafeRunSync()

// Initialize delayMs from the configuration
delayMs = contextProperties.get("connect.s3.poll.interval.ms").map(_.toLong)
}

override def stop(): Unit = {
Expand All @@ -98,10 +105,14 @@ abstract class CloudSourceTask[MD <: FileMetadata, C <: CloudSourceConfig[MD], C
logger.info(s"Stopped S3 source task")
}

override def poll(): util.List[SourceRecord] =
override def poll(): util.List[SourceRecord] = {
if (delayMs.exists(_ > 0)) {
Thread.sleep(delayMs.get)
}
s3SourceTaskState.fold(Collections.emptyList[SourceRecord]()) { state =>
state.poll().unsafeRunSync().asJava
}
}

private def stopInternal(state: CloudSourceTaskState, signal: Ref[IO, Boolean], fiber: FiberIO[Unit]): Unit = {
(for {
Expand Down