Add Task Prerequest "Middleware" #361
Labels
area:task-runner
Related to Nebula's Task Runner package
focus:monitor
things involving site monitoring
priority:low
Issues that are low priority don't need to be solved right away
type:enhancement
New feature or request
Is your feature request related to a problem? Please describe.
Both #321 and #360 share a similar structure for the notion of a pre-request shortciruit. The only difference is the aspect of the request they are looking at. Instead of having two issues come up with potentially different solutions, we should have a general structure that can be used by both.
Describe the solution you'd like
Both of these issues (and potentially other related) track very similarly to the idea of a request "middleware" chain. This is very similar to how
redux
offers a middleware chain for handling issues, orexpress
offers a middleware chain for handling incoming web requests.A similar middleware chain logic should be implemented for us to use when making a request from the monitor. This would be broken down in 3 parts
Step 1: Implementing middleware chaining logic and registration
We need to implement the logic for registering middleware onto a chain, as well as passing the request through the chain. This must be done before any changes to the monitor can be made to use it. At a high-level, we would need a
register
method to add middleware to the chain. When arequest
is made, we use the chain to either shortcircuit with a predefined response, or reach the end of the chain that makes the actual request.Step 2: Using the middleware chain API
At a high level, this step would involve changing any monitor-related request methods to using the middleware chain api implemented in Step 1.
Step 3: Implementing middleware
This step would not be included in addressing this issue, but would addressed in the individual issues that call for this backbone structure (issues #321 and #360 at the time of making this issue)
Describe alternatives you've considered
I haven't considered any at this time, but I'm open to any suggestions!
Additional context
Before addressing this issues, we should have a plan for the proposed middleware chain API functions and their parameters. This would help us greatly in step 2 since we would know what each function does and what it requires.
The text was updated successfully, but these errors were encountered: