WorkItemModuleRepository

uk.gov.hmrc.mongo.workitem.WorkItemModuleRepository
See theWorkItemModuleRepository companion object
abstract class WorkItemModuleRepository[T](collectionName: String, moduleName: String, mongoComponent: MongoComponent, replaceIndexes: Boolean, extraIndexes: Seq[IndexModel], extraCodecs: Seq[Codec[_]])(implicit trd: Reads[T], ec: ExecutionContext) extends WorkItemRepository[T]

If you have multiple lifecycles on a WorkItem, you can use the WorkItemModuleRepository to interact with those lifecycles. It will namespace the lifecycle fields with the provided moduleName. It assumes creation of WorkItems are made through another view (e.g. a standard WorkItemRepository), it will only allow interacting with the WorkItem lifecycle, and will throw runtime exceptions if pushNew or pushNewBatch are called.

Attributes

Companion
object
Graph
Supertypes
trait MetricSource
trait FindById[T]
trait Cancel
class PlayMongoRepository[WorkItem[T]]
trait MongoDatabaseCollection
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def pushNew(item: T, availableAt: Instant, initialState: T => ProcessingStatus): Future[WorkItem[T]]

Creates a new WorkItem.

Creates a new WorkItem.

Value parameters

availableAt

when to defer processing until

initialState

defines the initial state of the WorkItem for the item

item

the item to store in the WorkItem

Attributes

Definition Classes
override def pushNewBatch(items: Seq[T], availableAt: Instant, initialState: T => ProcessingStatus): Future[Seq[WorkItem[T]]]

Creates a batch of new WorkItems.

Creates a batch of new WorkItems.

Value parameters

availableAt

when to defer processing until

initialState

defines the initial state of the WorkItems for the item

items

the items to store as WorkItems

Attributes

Definition Classes

Inherited methods

def cancel(id: ObjectId): Future[StatusUpdateResult]

Sets the ProcessingStatus of a WorkItem to Cancelled.

Sets the ProcessingStatus of a WorkItem to Cancelled.

Attributes

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.

Inherited from:
WorkItemRepository
def complete(id: ObjectId, newStatus: ResultStatus): Future[Boolean]

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.

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.

Attributes

Inherited from:
WorkItemRepository
def completeAndDelete(id: ObjectId): Future[Boolean]

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

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

Attributes

Inherited from:
WorkItemRepository
def count(state: ProcessingStatus): Future[Long]

Returns the number of WorkItems in the specified ProcessingStatus

Returns the number of WorkItems in the specified ProcessingStatus

Attributes

Inherited from:
WorkItemRepository
def ensureIndexes(): Future[Seq[String]]

Attributes

Inherited from:
PlayMongoRepository
def ensureSchema(): Future[Unit]

Attributes

Inherited from:
PlayMongoRepository
def findById(id: ObjectId): Future[Option[WorkItem[T]]]

Attributes

Inherited from:
WorkItemRepository
def inProgressRetryAfter: Duration

Returns the timeout of any WorkItems marked as InProgress. WorkItems marked as InProgress will be hidden from pullOutstanding until this window expires.

Returns the timeout of any WorkItems marked as InProgress. WorkItems marked as InProgress will be hidden from pullOutstanding until this window expires.

Attributes

Inherited from:
WorkItemRepository
def markAs(id: ObjectId, status: ProcessingStatus, availableAt: Option[Instant]): Future[Boolean]

Sets the ProcessingStatus of a WorkItem. It will also update the updatedAt timestamp.

Sets the ProcessingStatus of a WorkItem. It will also update the updatedAt timestamp.

Attributes

Inherited from:
WorkItemRepository
override def metrics(implicit ec: ExecutionContext): Future[Map[String, Int]]

Attributes

Definition Classes
WorkItemRepository -> MetricSource
Inherited from:
WorkItemRepository
def now(): Instant

Returns the current date time for setting the updatedAt field. abstract to allow for test friendly implementations.

Returns the current date time for setting the updatedAt field. abstract to allow for test friendly implementations.

Attributes

Inherited from:
WorkItemRepository
def pullOutstanding(failedBefore: Instant, availableBefore: Instant): Future[Option[WorkItem[T]]]

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

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.

Value parameters

availableBefore

it will only consider WorkItems where the availableAt field is before the availableBefore

failedBefore

it will only consider WorkItems in FailedState if they were marked as Failed before the failedBefore. This can avoid retrying a failure immediately.

Attributes

Inherited from:
WorkItemRepository

Concrete fields

lazy override val metricPrefix: String

Inherited fields

lazy val collection: MongoCollection[WorkItem[T]]

Attributes

Inherited from:
PlayMongoRepository
final val domainFormat: Format[WorkItem[T]]

Attributes

Inherited from:
PlayMongoRepository
final val indexes: Seq[IndexModel]

Attributes

Inherited from:
PlayMongoRepository
lazy val initialised: Future[Unit]

Attributes

Inherited from:
PlayMongoRepository
final val optSchema: Option[BsonDocument]

Attributes

Inherited from:
PlayMongoRepository

Attributes

Inherited from:
WorkItemRepository