Forward the cancellation to the right partition

谁说胖子不能爱 提交于 2019-12-24 11:27:16

问题


This question is continuation from previous thread. store cancellation tokens in service fabric services

Opened a new thread because answering this question would not be trivial.

To summarize what has been discussed regarding cancel a job / task running in particular service in some partition of service fabric:

Cancellation Token limitation:

Cancellation token works within the service partition and that is the limitation in partition-wise storing the instances, probably the reason why cancellation token is not provided with serializable attributes (Attempt made using ISerializationSurrogate to serialize into byte array and saved into class with DataContract attribute attached and it loses all nested struct data when deserialized back.), therefore reliable dictionary can't be used.

Two distinct use of cancellation tokens in service fabric application:

  1. Service Fabric provided which innately injected onto methods such as RunAsync(CancellationToken) { forever loop } or used by Web API cancel request handle, which also can be forwarded to custom methods in actor / service per web API calls.
  2. User generated cancellation tokens need to be managed differently than ones being created by #1 (More explanation on how to manage these tokens belong to the previous thread linked at the top of this thread).

Question belong to this thread:

How do you forward from API request received via multiple partitions end points to the right partition? I guess once request has been forwarded from a Web API end point to the right partition then it seems all make sense because at that point then you should be simply able to call cancellationtokensource.cancel() with stored cancellationtoken in that specific partition, with assumption that cancellationtoken.Cancel() works partition-wise.

来源:https://stackoverflow.com/questions/53050219/forward-the-cancellation-to-the-right-partition

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!