-
Notifications
You must be signed in to change notification settings - Fork 644
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
607c9aa
commit 0757128
Showing
5 changed files
with
94 additions
and
64 deletions.
There are no files selected for viewing
21 changes: 0 additions & 21 deletions
21
kinesis/src/main/scala/akka/stream/alpakka/kinesis/CommittableRecord.scala
This file was deleted.
Oops, something went wrong.
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
35 changes: 35 additions & 0 deletions
35
kinesis/src/main/scala/akka/stream/alpakka/kinesis/worker/CommittableRecord.scala
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,35 @@ | ||
/* | ||
* Copyright (C) 2016-2017 Lightbend Inc. <http://www.lightbend.com> | ||
*/ | ||
package akka.stream.alpakka.kinesis.worker | ||
|
||
import com.amazonaws.services.kinesis.clientlibrary.interfaces.IRecordProcessorCheckpointer | ||
import com.amazonaws.services.kinesis.clientlibrary.lib.worker.ShutdownReason | ||
import com.amazonaws.services.kinesis.clientlibrary.types.ExtendedSequenceNumber | ||
import com.amazonaws.services.kinesis.model.Record | ||
|
||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
class CommittableRecord( | ||
val shardId: String, | ||
val extendedSequenceNumber: ExtendedSequenceNumber, | ||
val millisBehindLatest: Long, | ||
val record: Record, | ||
recordProcessor: IRecordProcessor, | ||
checkpointer: IRecordProcessorCheckpointer | ||
)(implicit executor: ExecutionContext) { | ||
|
||
val sequenceNumber = record.getSequenceNumber | ||
|
||
def shutdown: Option[ShutdownReason] = | ||
recordProcessor.shutdown | ||
def checkpoint(): Future[Unit] = | ||
Future(checkpointer.checkpoint(record)) | ||
|
||
} | ||
|
||
object CommittableRecord { | ||
|
||
implicit val order: Ordering[CommittableRecord] = Ordering.by(_.sequenceNumber) | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
kinesis/src/main/scala/akka/stream/alpakka/kinesis/worker/IRecordProcessor.scala
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,47 @@ | ||
/* | ||
* Copyright (C) 2016-2017 Lightbend Inc. <http://www.lightbend.com> | ||
*/ | ||
package akka.stream.alpakka.kinesis.worker | ||
|
||
import com.amazonaws.services.kinesis.clientlibrary.lib.worker.ShutdownReason | ||
import com.amazonaws.services.kinesis.clientlibrary.types.{ | ||
ExtendedSequenceNumber, | ||
InitializationInput, | ||
ProcessRecordsInput, | ||
ShutdownInput | ||
} | ||
|
||
import scala.concurrent.ExecutionContext | ||
|
||
private[kinesis] class IRecordProcessor( | ||
callback: CommittableRecord => Unit | ||
)(implicit executionContext: ExecutionContext) | ||
extends com.amazonaws.services.kinesis.clientlibrary.interfaces.v2.IRecordProcessor { self: IRecordProcessor => | ||
private var shardId: String = _ | ||
private var extendedSequenceNumber: ExtendedSequenceNumber = _ | ||
|
||
var shutdown: Option[ShutdownReason] = None | ||
|
||
override def initialize(initializationInput: InitializationInput): Unit = { | ||
this.shardId = initializationInput.getShardId | ||
this.extendedSequenceNumber = initializationInput.getExtendedSequenceNumber | ||
} | ||
|
||
override def processRecords(processRecordsInput: ProcessRecordsInput): Unit = | ||
processRecordsInput.getRecords.forEach { record => | ||
callback( | ||
new CommittableRecord( | ||
shardId, | ||
extendedSequenceNumber, | ||
processRecordsInput.getMillisBehindLatest, | ||
record, | ||
recordProcessor = this, | ||
processRecordsInput.getCheckpointer | ||
) | ||
) | ||
} | ||
|
||
override def shutdown(shutdownInput: ShutdownInput): Unit = | ||
shutdown = Some(shutdownInput.getShutdownReason) | ||
|
||
} |