Introduction
I don't really know the correct workflow for receive feedback on this potential feature. I hope opening this issue is the right way to do it.
If this isn't the correct workflow, I apologize.
What is the feature.
The "maxTimeMS" configuration can be applied at the query level using the "timeout()" method, like this:
NiceModel::timeout(2)->find()
It cannot be applied at the cluster or project level. You need to apply it to each query individually.
Why this is importante?
Let's say your company defines a policy such as: "All queries should take a maximum of 2 seconds to run. Keep them performant."
This also helps prevent extremely long-running queries. For example, a query should not take more than 5 minutes to complete.
How to use is?
We can configure this at connection options array like this:
'mongodb' => [
'driver' => 'mongodb',
'dsn' => env('MONGODB_DSN'),
'database' => env('MONGODB_CONVENIA', 'convenia'),
'options' => [
'database' => env('DB_AUTHENTICATION_DATABASE', 'admin'),
'maxTimeMS' => env('DB_MAX_TIME_MS', 2000),
],
],
If the user calls the ->timeout() method than it takes precedence. The project level configuration acts like a default configuration that can be overrided.
Do i have a MR?
Yeah!
I already have the code tested with a very small change to achieve this.
All tests are passing, and I believe the implementation is safe. I haven't noticed any side effects.
I'm just trying to figure out which branch I should target for the merge request and where this feature should be documented.