[英]Who should own the logic for service resolution in Service Fabric Stateful Services?
I am using Service Fabric stateful services to store state about users in the system. 我正在使用Service Fabric状态服务在系统中存储有关用户的状态。 My partitioning strategy is to use the normalized international string format phone number to address a named service instance, and the hash of the phone number to resolve a partition of that service.
我的分区策略是使用规范化的国际字符串格式电话号码来寻址已命名的服务实例,并使用电话号码的哈希值来解析该服务的分区。 EX: fabric:/myapp/users/1/718 (where the international phone number is +1718xxxxxxx) This allows me to geo-locate services based on their country (and further in the US/Canada markets by area code).
例如:fabric:/ myapp / users / 1/718(国际电话号码为+ 1718xxxxxxx),这使我可以根据服务所在的国家/地区(以及地区号在美国/加拿大市场)对服务进行地理位置定位。
My question is sort of theoretical, but also practical in nature. 我的问题是理论上的,但实际上也是实用的。 Who owns the logic for service resolution?
谁拥有服务解析逻辑? A simple approach is to just require anyone taking a dependency on this service to know how its partitioned, but that feels like a leaky abstraction to me.
一种简单的方法是仅要求依赖此服务的任何人都知道该服务的分区方式,但这对我来说就像是一个抽象的泄漏。 Furthermore, I would like to assign an Id to the user which is divorced from the concept of a phone number.
此外,我想为用户分配一个ID,该ID与电话号码的概念不同。
I also, am open to entertaining the idea that partitioning users this way is a bad idea. 我也乐于接受这样的想法:以这种方式对用户进行分区是个坏主意。 However, using the phone is advisable for a number of reasons.
但是,出于多种原因,建议使用电话。
I'd recommend keeping any knowledge about partitioning away from your service consumers, if possible. 如果可能的话,我建议远离您的服务使用者,保持对分区的任何了解。 This way you can change the service internals without changing anything at the consumer-side.
这样,您可以更改服务内部,而无需在用户端进行任何更改。
That leads to option 3, combined with the built-in reverse proxy service. 这导致选项3与内置的反向代理服务结合在一起。 In that extra service, you can look up the authenticated user and use its location to determine the service partition.
在该额外服务中,您可以查找经过身份验证的用户,并使用其位置来确定服务分区。
If you make it a new application, it can become the entrypoint (/proxy) for multiple bounded contexts 如果将其设为新应用程序,则它可以成为多个有界上下文的入口点(/ proxy)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.