Skip to content

Commit

Permalink
Added some temporary timer logging (to be removed.)
Browse files Browse the repository at this point in the history
  • Loading branch information
lmath committed Dec 6, 2018
1 parent 8041f13 commit d574d69
Showing 1 changed file with 19 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@ object SqsSendBatch extends Logging {

def sendBatchSync(sqsSend: Payload => Try[Unit])(emailBatchItems: List[EmailBatchItem]): List[EmailBatchItemId] = {
def sendAndRetainItemIdOnFailure(payload: Payload, emailBatchItemId: EmailBatchItemId): Option[EmailBatchItemId] = {
Try(sqsSend(payload)) match {
val stopWatch = new StopWatch
val result: Option[EmailBatchItemId] = Try(sqsSend(payload)) match {
case Success(_) => None
case Failure(_) =>
Some(emailBatchItemId)
}

logger.info(s"We added emailbatchId ${emailBatchItemId} to the queue and it took ${stopWatch.elapsed} ms" )

result
}

emailBatchItems flatMap { emailBatchItem: EmailBatchItem =>
Expand All @@ -28,3 +33,16 @@ object SqsSendBatch extends Logging {

}
}

//TODO: remove!
object StopWatch {
def apply() = new StopWatch
}

class StopWatch {
private val startTime = System.currentTimeMillis

def elapsed: Long = System.currentTimeMillis - startTime

override def toString() = s"${elapsed}ms"
}

0 comments on commit d574d69

Please sign in to comment.