A previously implemented anti-pattern for all redis operations, where calls to redis return a result of [T | null, Error | null] made control flow extremely hard. This PR is mainly focused around correcting this logic.
Changes also focus on implementing the Redis' locking mechanism in the code, as well as allowing multiple connections to the Redis DB when concurrent requests are handled.
Finally, a new orca_key property is added to ensure uniqueness across a job's key and response_url components.
Solution (Changes Made)
Removal of old [T | null, Error | null] anti-pattern to clean up code.
Creation of GradingQueueService to handle CRUD operations to the Redis DB (and thus the grading queue)
Creation of a pseudo-transaction builder to help prevent state corruption if queue operations fail.
Locking of operations to ensure state is only changed by one Redis connection at a time.
Custom exceptions to provide more feedback to developers and users of the API.
Moving request body validations of grading queue controller endpoints to utilize ajv for type checking that allows linters more information.
Nonce generation is now unique, as arrival_time + priority may incur collisions.
Feature/Problem Description
A previously implemented anti-pattern for all redis operations, where calls to redis return a result of
[T | null, Error | null]
made control flow extremely hard. This PR is mainly focused around correcting this logic.Changes also focus on implementing the Redis' locking mechanism in the code, as well as allowing multiple connections to the Redis DB when concurrent requests are handled.
Finally, a new
orca_key
property is added to ensure uniqueness across a job'skey
andresponse_url
components.Solution (Changes Made)
[T | null, Error | null]
anti-pattern to clean up code.GradingQueueService
to handle CRUD operations to the Redis DB (and thus the grading queue)ajv
for type checking that allows linters more information.arrival_time + priority
may incur collisions.arrival_time_0 = 10, priority_0 = 2; arrival_time_1 = 12, priority_1 = 0
key
combinations.