在运行时查找有状态服务的分区键

Find partition key of stateful service at runtime

我需要在 运行 时间找到 Service Fabric 有状态服务的当前分区键。

我查看了 ICodePackageActivationContextStatefulServiceContext,但似乎在任何地方都看不到此信息。

编辑:

正如 LoekD 在他的回答中指出的那样,此信息可从 StatefulService class 中获得。明确地说,这是我访问的方式:

var info = (Int64RangePartitionInformation) this.Partition.PartitionInfo;

var highKey = info.HighKey;
var lowKey = info.LowKey;

在服务本身中,您可以使用 Partition.PartitionInfo property