abstract class WorkItemRepository[T] extends PlayMongoRepository[WorkItem[T]] with Cancel with FindById[T] with MetricSource
The repository to set and get the work item's for processing. See pushNew for creating work items, and pullOutstanding for retrieving them.
- Alphabetic
- By Inheritance
- WorkItemRepository
- MetricSource
- FindById
- Cancel
- PlayMongoRepository
- MongoDatabaseCollection
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
- new WorkItemRepository(collectionName: String, mongoComponent: MongoComponent, itemFormat: Format[T], workItemFields: WorkItemFields, replaceIndexes: Boolean = true, extraIndexes: Seq[IndexModel] = Seq.empty, extraCodecs: Seq[Codec[_]] = Seq.empty)(implicit ec: ExecutionContext)
- collectionName
the name of the mongo collection.
- itemFormat
a play Json format to map the item to mongo entities
- workItemFields
the internal fields for WorkItem, allowing customisation
- replaceIndexes
optional - default is true If true, existing indices should be removed/updated to match the provided indices. If false, any old indices are left behind, and indices with changed definitions will throw IndexConflict exceptions.
- extraIndexes
optional - to add additional indexes
- extraCodecs
optional - to support more types
Abstract Value Members
- abstract def inProgressRetryAfter: Duration
Returns the timeout of any WorkItems marked as InProgress.
Returns the timeout of any WorkItems marked as InProgress. WorkItems marked as InProgress will be hidden from pullOutstanding until this window expires.
- abstract def now(): Instant
Returns the current date time for setting the updatedAt field.
Returns the current date time for setting the updatedAt field. abstract to allow for test friendly implementations.
Concrete Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def cancel(id: ObjectId): Future[StatusUpdateResult]
Sets the ProcessingStatus of a WorkItem to Cancelled.
Sets the ProcessingStatus of a WorkItem to Cancelled.
- returns
StatusUpdateResult.Updated if the WorkItem is cancelled, StatusUpdateResult.NotFound if it's not found, and StatusUpdateResult.NotUpdated if it's not in a cancellable ProcessingStatus.
- Definition Classes
- WorkItemRepository → Cancel
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @native()
- lazy val collection: MongoCollection[WorkItem[T]]
- Definition Classes
- PlayMongoRepository
- final val collectionName: String
- Definition Classes
- PlayMongoRepository → MongoDatabaseCollection
- def complete(id: ObjectId, newStatus: ResultStatus): Future[Boolean]
Sets the ProcessingStatus of a WorkItem to a ResultStatus.
Sets the ProcessingStatus of a WorkItem to a ResultStatus. It will also update the updatedAt timestamp. It will return false if the WorkItem is not InProgress.
- def completeAndDelete(id: ObjectId): Future[Boolean]
Deletes the WorkItem.
Deletes the WorkItem. It will return false if the WorkItem is not InProgress.
- def count(state: ProcessingStatus): Future[Long]
Returns the number of WorkItems in the specified ProcessingStatus
- final val domainFormat: Format[WorkItem[T]]
- Definition Classes
- PlayMongoRepository
- def ensureIndexes(): Future[Seq[String]]
- Definition Classes
- PlayMongoRepository
- def ensureSchema(): Future[Unit]
- Definition Classes
- PlayMongoRepository
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable])
- def findById(id: ObjectId): Future[Option[WorkItem[T]]]
- Definition Classes
- WorkItemRepository → FindById
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
- final val indexes: Seq[IndexModel]
- Definition Classes
- PlayMongoRepository → MongoDatabaseCollection
- lazy val initialised: Future[Unit]
- Definition Classes
- PlayMongoRepository
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def markAs(id: ObjectId, status: ProcessingStatus, availableAt: Option[Instant] = None): Future[Boolean]
Sets the ProcessingStatus of a WorkItem.
Sets the ProcessingStatus of a WorkItem. It will also update the updatedAt timestamp.
- def metricPrefix: String
- def metrics(implicit ec: ExecutionContext): Future[Map[String, Int]]
- Definition Classes
- WorkItemRepository → MetricSource
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
- final val optSchema: Option[BsonDocument]
- Definition Classes
- PlayMongoRepository
- def pullOutstanding(failedBefore: Instant, availableBefore: Instant): Future[Option[WorkItem[T]]]
Returns a WorkItem to be processed, if available.
Returns a WorkItem to be processed, if available. The item will be atomically set to ProcessingStatus.InProgress, so it will not be picked up by other calls to pullOutstanding until it's status has been explicitly marked as Failed or ToDo, or it's progress status has timed out (set by inProgressRetryAfter).
A WorkItem will be considered for processing in the following order: 1) Has ToDo status, and the availableAt field is before the availableBefore param. 2) Has Failed status, and it was marked as Failed before the failedBefore param. 3) Has InProgress status, and was marked as InProgress before the inProgressRetryAfter configuration. Basically a timeout to ensure WorkItems that don't advance from InProgress do not get stuck.
- failedBefore
it will only consider WorkItems in FailedState if they were marked as Failed before the failedBefore. This can avoid retrying a failure immediately.
- availableBefore
it will only consider WorkItems where the availableAt field is before the availableBefore
- def pushNew(item: T, availableAt: Instant = now(), initialState: (T) => ProcessingStatus = toDo): Future[WorkItem[T]]
Creates a new WorkItem.
Creates a new WorkItem.
- item
the item to store in the WorkItem
- availableAt
when to defer processing until
- initialState
defines the initial state of the WorkItem for the item
- def pushNewBatch(items: Seq[T], availableAt: Instant = now(), initialState: (T) => ProcessingStatus = toDo): Future[Seq[WorkItem[T]]]
Creates a batch of new WorkItems.
Creates a batch of new WorkItems.
- items
the items to store as WorkItems
- availableAt
when to defer processing until
- initialState
defines the initial state of the WorkItems for the item
- lazy val requiresTtlIndex: Boolean
- Attributes
- protected[mongo]
- Definition Classes
- PlayMongoRepository
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- val workItemFields: WorkItemFields