aboutsummaryrefslogtreecommitdiff
path: root/src/main/scala/xyz/driver/common/concurrent/BridgeUploadQueue.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/xyz/driver/common/concurrent/BridgeUploadQueue.scala')
-rw-r--r--src/main/scala/xyz/driver/common/concurrent/BridgeUploadQueue.scala88
1 files changed, 0 insertions, 88 deletions
diff --git a/src/main/scala/xyz/driver/common/concurrent/BridgeUploadQueue.scala b/src/main/scala/xyz/driver/common/concurrent/BridgeUploadQueue.scala
deleted file mode 100644
index 6ecb299..0000000
--- a/src/main/scala/xyz/driver/common/concurrent/BridgeUploadQueue.scala
+++ /dev/null
@@ -1,88 +0,0 @@
-package xyz.driver.common.concurrent
-
-import java.time.LocalDateTime
-
-import xyz.driver.common.concurrent.BridgeUploadQueue.Item
-import xyz.driver.common.domain.LongId
-import xyz.driver.common.logging._
-
-import scala.concurrent.Future
-
-object BridgeUploadQueue {
-
- /**
- * @param kind For example documents
- * @param tag For example, a patient's id: 1
- * @param attempts Which attempt
- * @param created When the task was created
- * @param nextAttempt Time of the next attempt
- */
- final case class Item(id: LongId[Item],
- kind: String,
- tag: String,
- created: LocalDateTime,
- attempts: Int,
- nextAttempt: LocalDateTime,
- completed: Boolean,
- dependencyKind: Option[String],
- dependencyTag: Option[String]) {
-
- def dependency: Option[Dependency] = {
- dependencyKind.zip(dependencyTag)
- .headOption
- .map(Function.tupled(Dependency.apply))
- }
-
- }
-
- object Item {
-
- implicit def toPhiString(x: Item): PhiString = {
- import x._
- phi"BridgeUploadQueue.Item(id=$id, kind=${Unsafe(kind)}, tag=${Unsafe(tag)}, " +
- phi"attempts=${Unsafe(attempts)}, start=$created, nextAttempt=$nextAttempt, completed=$completed, " +
- phi"dependency=$dependency)"
- }
-
- def apply(kind: String, tag: String, dependency: Option[Dependency] = None): Item = {
- val now = LocalDateTime.now()
-
- Item(
- id = LongId(0),
- kind = kind,
- tag = tag,
- created = now,
- attempts = 0,
- nextAttempt = now,
- completed = false,
- dependencyKind = dependency.map(_.kind),
- dependencyTag = dependency.map(_.tag)
- )
- }
-
- }
-
- final case class Dependency(kind: String, tag: String)
-
- object Dependency {
-
- implicit def toPhiString(x: Dependency): PhiString = {
- import x._
- phi"Dependency(kind=${Unsafe(kind)}, tag=${Unsafe(tag)})"
- }
-
- }
-
-}
-
-trait BridgeUploadQueue {
-
- def add(item: Item): Future[Unit]
-
- def get(kind: String): Future[Option[Item]]
-
- def remove(item: LongId[Item]): Future[Unit]
-
- def tryRetry(item: Item): Future[Option[Item]]
-
-}