< Back
 

# Packages

-  package root
  Definition Classes
    root
-  package uk
  Definition Classes
    root
-  package gov
  Definition Classes
    uk
-  package hmrc
  Definition Classes
    gov
-  package mongo
  Definition Classes
    hmrc
-  package workitem
  Definition Classes
    mongo
- Operations
- ProcessingStatus
- ResultStatus
- StatusUpdateResult
- WorkItem
- WorkItemFields
- WorkItemModuleRepository
- WorkItemRepository

c

uk.gov.hmrc.mongo.workitem

# WorkItemRepository 

###

#### 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.

Linear Supertypes
MetricSource, FindById[T], Cancel, PlayMongoRepository[WorkItem[T]], MongoDatabaseCollection, AnyRef, Any
Known Subclasses
WorkItemModuleRepository
 
Ordering

1. Alphabetic
2. By Inheritance

Inherited

1. WorkItemRepository
2. MetricSource
3. FindById
4. Cancel
5. PlayMongoRepository
6. MongoDatabaseCollection
7. AnyRef
8. Any

1. Hide All
2. Show All

Visibility

1. Public
2. All

### Instance Constructors

1.  new WorkItemRepository(collectionName: String, mongoComponent: MongoComponent, itemFormat: Format[T], workItemFields: WorkItemFields, replaceIndexes: Boolean = true)(implicit ec: ExecutionContext)

### Abstract Value Members

1.  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.

2.  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

1.  final def !=(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
2.  final def ##(): Int
   Definition Classes
     AnyRef → Any
3.  final def ==(arg0: Any): Boolean
   Definition Classes
     AnyRef → Any
4.  final def asInstanceOf[T0]: T0
   Definition Classes
     Any
5.  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
6.  def clone(): AnyRef
   Attributes
     protected[lang]
   Definition Classes
     AnyRef
   Annotations
     @throws( ... ) @native()
7.  val collection: MongoCollection[WorkItem[T]]
   Definition Classes
     PlayMongoRepository
8.  val collectionName: String
   Definition Classes
     PlayMongoRepository → MongoDatabaseCollection
9.  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.

10.  def completeAndDelete(id: ObjectId): Future[Boolean]

    Deletes the WorkItem.

    Deletes the WorkItem. It will return false if the WorkItem is not InProgress.

11.  def count(state: ProcessingStatus): Future[Long]

    Returns the number of WorkItems in the specified ProcessingStatus

12.  val domainFormat: Format[WorkItem[T]]
    Definition Classes
      PlayMongoRepository
13.  def ensureIndexes: Future[Seq[String]]
    Definition Classes
      PlayMongoRepository
14.  def ensureSchema: Future[Unit]
    Definition Classes
      PlayMongoRepository
15.  final def eq(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
16.  def equals(arg0: Any): Boolean
    Definition Classes
      AnyRef → Any
17.  def finalize(): Unit
    Attributes
      protected[lang]
    Definition Classes
      AnyRef
    Annotations
      @throws( classOf[java.lang.Throwable] )
18.  def findById(id: ObjectId): Future[Option[WorkItem[T]]]
    Definition Classes
      WorkItemRepository → FindById
19.  final def getClass(): Class[_]
    Definition Classes
      AnyRef → Any
    Annotations
      @native()
20.  def hashCode(): Int
    Definition Classes
      AnyRef → Any
    Annotations
      @native()
21.  val indexes: Seq[IndexModel]
    Definition Classes
      PlayMongoRepository → MongoDatabaseCollection
22.  final def isInstanceOf[T0]: Boolean
    Definition Classes
      Any
23.  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.

24.  def metricPrefix: String
25.  def metrics(implicit ec: ExecutionContext): Future[Map[String, Int]]
    Definition Classes
      WorkItemRepository → MetricSource
26.  final def ne(arg0: AnyRef): Boolean
    Definition Classes
      AnyRef
27.  final def notify(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
28.  final def notifyAll(): Unit
    Definition Classes
      AnyRef
    Annotations
      @native()
29.  val optSchema: Option[BsonDocument]
    Definition Classes
      PlayMongoRepository
30.  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

31.  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

32.  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

33.  final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
      AnyRef
34.  def toString(): String
    Definition Classes
      AnyRef → Any
35.  final def wait(): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )
36.  final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws( ... )
37.  final def wait(arg0: Long): Unit
    Definition Classes
      AnyRef
    Annotations
      @throws( ... ) @native()
38.  val workItemFields: WorkItemFields

### Inherited from MetricSource

### Inherited from FindById[T]

### Inherited from Cancel

### Inherited from PlayMongoRepository[WorkItem[T]]

### Inherited from MongoDatabaseCollection

### Inherited from AnyRef

### Inherited from Any

### Ungrouped