-
Notifications
You must be signed in to change notification settings - Fork 227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IAsyncBatchEventHandler with CancellationToken #72
Comments
I think it is a good idea even though it is probably a niche requirement. I suspect that most async handlers are relatively short running and thus do not require cancellation support. I will try to find the proper design for this. Your suggestion is clean and simple but it would be a breaking change, so I might decide to add a dedicated interface. |
In my view, most event handlers are supposed to be short running and they should process all published events. On shutdown, the Disruptor will wait until published events are processed by all event handlers before halting the handlers. I do not clearly understand what an event handler could do with the halting @jinghua395 Could you describe your use case so I can better understand the value of exposing the Right now, I consider adding a dedicated interface like the following one to expose the public interface IEventProcessorCancellationTokenAware
{
void SetCancellationToken(CancellationToken cancellationToken);
} It is clearly less discoverable than exposing then token in |
In general, I would use the cancellation token to cancel the async operation, e.g., network or I/O, (they might not fast operation as CPU workload), then we are not waiting when the disruptor shuts down, or not start expensive async operation when the disruptor is shut down. I am also thinking we could have a disruptor ShutdownAsync(int timeout), thus we could wait the handler to finish in a graceful manner or brutally shut it down if timeout. |
Hi,
I wonder if there is a plan to add CancellationToken intioi IAsyncBatchEventHandler interface, it could get cancelled when shutdown process? If is it technically possible?
IAsyncBatchEventHandler
ValueTask OnBatch(EventBatch batch, long sequence, CancellationToken cancellationtoken);
The text was updated successfully, but these errors were encountered: