Some factories take really long time to run. Like fetching all users from a tenant from AzureAD. That's why they need to be cached. GraphAPI provides paginated fetch possibility only - that makes sense. Hence the data is produced in chunks. Each chunk can time out on its own, but the complete batch can take much-much longer. Setting a long timeout for the whole factory is not resilient enough.
Solution
If there is a way to signal from the producer that the factory is still working properly, it could reset the timeout timer.
Proposal
An overload for each core method that takes a factory, where the factory is
Fun<IHeartbeatSignal, T> and Fun<IHeartbeatSignal, CancellationToken, Task<T>> respectively
public interface IHeartbeatSignal
{
void Signal();
}
The factory should call this method to reset the timeout counter. If the signal does not arrive within the timeout period, the factory is considered to be in timeout and handled accordingly based on failsafe setup and async version.
Hi @zorgoz , this is in fact an interesting idea!
Not straightforward to implement, but still: let me think about it (including potential ramifications, edge cases and whatnot), will get back to you.
Thanks!
Problem
Some factories take really long time to run. Like fetching all users from a tenant from AzureAD. That's why they need to be cached. GraphAPI provides paginated fetch possibility only - that makes sense. Hence the data is produced in chunks. Each chunk can time out on its own, but the complete batch can take much-much longer. Setting a long timeout for the whole factory is not resilient enough.
Solution
If there is a way to signal from the producer that the factory is still working properly, it could reset the timeout timer.
Proposal
An overload for each core method that takes a factory, where the factory is
Fun<IHeartbeatSignal, T>
andFun<IHeartbeatSignal, CancellationToken, Task<T>>
respectivelyThe factory should call this method to reset the timeout counter. If the signal does not arrive within the timeout period, the factory is considered to be in timeout and handled accordingly based on failsafe setup and async version.