Dependent Jobs #
Dependent jobs are a Pragma Engine structure that enable concurrent processing across services at moments when there are dependencies between processed data.
Dependent jobs can be used to manage the following conditions:
- processing that can occur concurrently
- processing that has a dependency on other processing
- the need to collate data from multiple systems to be sent to the game client
Using dependent jobs #
There are three primary cases for dependent jobs:
- Match End Plugin
- Login Data Plugin
- Custom service plugins
Match End Plugin #
On match end, the Match End Plugin allows the authorship of dependent jobs that will be run after each match. The DefaultPragmaMatchEndPlugin
employs the InventoryMatchEndDependentJob
to process player inventory updates based on match end data and sends this information to the game client.
Login Data Plugin #
Another place where data must be collected from multiple sources and sent to the client is on player login. The Login Data Plugin defines jobs that should be executed whenever a player logs in, and by default collects a player’s inventory data. Authoring additional dependent jobs can handle new capabilities, such as granting players rewards on login.
Custom Service Plugins #
Dependent jobs can be authored to pull custom data from a custom service. For more information, visit the custom services page.
Authoring dependent jobs #
A dependent job is composed of two main pieces:
dependenciesMet
: a definition of dependencies that gate the execution of the jobmakeRequest
the job’s work
These are reflected in the method signature of the abstract class DependentJob
:
protected abstract fun dependenciesMet(context: DependentJobContext): Boolean
protected abstract suspend fun makeRequest(context: DependentJobContext, mutable: ThreadsafeMutable<T>)
Dependencies #
When the method dependenciesMet
returns true
, then the dependent job is no longer gated and makeRequest
will be called on the DependentJob
.
To ascertain if dependencies are met, the dependent job uses DependentJobContext
, which is passed into both methods. This is a cache of data types that have been processed.
Request #
Once a dependent job has determined that its dependencies are met, it can execute its work. The intent is to enable service requests to gather and collate data.
For example, during match end, the default behavior is to send match rewards to be processed by the Inventory service. Results from this processing are subsequently sent to the game client.
To capture results and add them to the notification sent to the player, updates are added to the ThreadsafeMutable
. The ThreadsafeMutable
class is a container for the context object collating the player response data, ensuring thread-safe access.