Creating a worker
You can create your workers from scratch using the Graphql schema. Or you can use the few utilities functions available to quickly setup a worker.
checkForJobs()
typeList (Array<String>) is the type of jobs the worker will wait to execute.
client (ApolloClient) is a client with the URL of your GraphQL endpoint.
processingFunction (Function(job, facilities) => Promise<JsonObject>) is the function that executes the job.
workerId = undefined
looping = true
loopTime = 1000
When processingFunction return something, the job is considered as done. The returned Object is serialized and stored as the "output" of the job.
Easy debug without looping
With the looping option to false the worker will only check for a job once. Made for end-to-end tests or manual debugging.
Facilities
updateProcessingInfo()
Avoiding spamming your API
Some jobs runs very rarely, so you may want that your worker only check the queue from time to time.
Identifying workers
GNJ automatically generated uuid for your new workers to easily track what went wrong. But if you need to link a run to an id your want you can just specify it under the workerId property.
They all use the GraphQL api provided by the server. So even if it's really convenient to use those functions you can create your own.
Last updated
Was this helpful?