简体   繁体   English

奥尔良无国籍工人

[英]Orleans StatelessWorkers

I am finding it hard to find any detailed documentation on the use of StatelessWorkers. 我发现很难找到有关StatelessWorkers使用的任何详细文档。

I want to achieve something similar to this . 我想实现与此类似的东西。 As suggested in the document I need to use Stateless Workers in order to process some messages and activate the grains that will eventually hold the state. 正如文件中所建议的那样,我需要使用无状态工作者来处理一些消息并激活最终将持有该状态的谷物。

I would like to have multiple instances of a dispatcher grain processing the "initialization" since this grain by no means handles any state and the messages do not need to be queued in order. 我希望有一个调度程序粒度的多个实例处理“初始化”,因为这个粒子决不会处理任何状态,并且消息不需要按顺序排队。

Do I need to mark this grain as Reentrant? 我是否需要将此颗粒标记为可重入? or Will the StatelessWorker (attribute) be enough? 或StatelessWorker(属性)是否足够?

With regards to activation, it seems like I need to inherit from IGrainWithIntegerKey (or a similar interface). 关于激活,似乎我需要从IGrainWithIntegerKey (或类似的接口)继承。 this means that I need to activate the grain as follows: 这意味着我需要激活谷物如下:

GrainClient.GrainFactory.GetGrain<IDispatcherActor>(0)

Since I am always using 0 as ID will multiple instances of the grain still be activated? 由于我总是使用0作为ID,谷物的多个实例仍然会被激活? or do I need to create different IDs. 或者我是否需要创建不同的ID。 It seems like I cannot call the grain as follows: 好像我不能称之为如下:

GrainClient.GrainFactory.GetGrain<IDispatcherActor>()

even if I inherit from IGrain 即使我继承了IGrain

Short Answer 简答

You can create a stateless worker by inheriting IGrainWithIntegerKey and using a key 0 . 您可以通过继承IGrainWithIntegerKey并使用键0来创建无状态工作程序。

Long Answer 答案很长

Stateless workers are the same as normal grains with a couple of differences: 无国籍工人与普通农民一样,但存在一些差异:

  1. They are always activated locally (in the same silo as the caller). 它们总是在本地激活(与呼叫者在同一个孤岛中)。
  2. Multiple activations can be created if the calls to a stateless worker activation build up. 如果对无状态工作程序激活的调用建立,则可以创建多个激活。

They are subject to the same deactivation semantics. 它们受制于相同的停用语义。

It might be surprising that stateless workers have keys, but there are couple of reasons why keys might be useful: 无国籍工人有钥匙可能会令人惊讶,但有几个原因可能是钥匙有用:

  1. Stateless worker activations may have different 'flavours', which could be related to their key. 无国籍工人激活可能有不同的“口味”,这可能与他们的关键有关。
  2. A larger pool of stateless workers could be activated by addressing them with a range of keys. 可以通过使用一系列密钥对其进行处理来激活更大的无状态工作者池。

But if these features aren't useful to you, the convention is to use a key of 0 . 但是如果这些功能对你没用,那么约定是使用0的键。

  1. They can only be called from inside a silo. 它们只能从筒仓内部调用。

StatelessWorker grains can be called from clients. 可以从客户端调用StatelessWorker grain。 That's actually one of the popular scenarios when calls from clients should be preprocessed before they can be routed to other grains for actual processing. 这实际上是客户来电之前应该进行预处理的流行方案之一,然后才能将其路由到其他谷物进行实际处理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM