在Curator中将选择策略与缓存一起使用

在Curator中将选择策略与缓存一起使用

本文介绍了在Curator中将选择策略与缓存一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用Apache策展人( https://github.com/Netflix/curator/wiki/Service-Discovery )引入了以下概念:

The page on Service Discovery using apache curator (https://github.com/Netflix/curator/wiki/Service-Discovery) introduces the following concepts:

  • 我可以看到如何在ServiceProviderBuilder上使用提供者策略,但是ServiceCacheBuilder上没有等效方法,并且ServiceCache类本身唯一可用的相关方法是getInstances(),该方法得到所有实例.

    I can see how to use the Provider strategies with a ServiceProviderBuilder, but there's no equivalent method on the ServiceCacheBuilder, and the only relevant method available on the ServiceCache class itself is getInstances(), which gets all instances.

    如何在ServiceCache中使用提供者策略?

    How can I use a provider strategy with a ServiceCache?

    推荐答案

    @ simonalexander2005我只是在看代码,结果发现ServiceProvider内部已经使用了serviceCacheBuilder. TBH-我已经忘了这个,或者它已经被另一个提交者提交了-我不确定.无论如何,对于此处的解决方法,我感到非常抱歉.另外,必须更新文档以反映这一点-我今天将为此发布一个问题.我敢肯定这会让你发疯,对此再次感到抱歉.好消息是,使用ServiceProvider您会自动获得缓存.

    @simonalexander2005 I was just looking in the code and it turns out that ServiceProvider internally already uses a serviceCacheBuilder. TBH - I've either forgotten about this or it got put in by another committer - I'm not sure. Anyway, I'm very sorry about the runaround here. Also, the documentation must be updated to reflect this - I'll open an issue for this today. I'm sure this be maddening to you, again sorry for this. The good news, though, is that with ServiceProvider you automatically get caching.

    这篇关于在Curator中将选择策略与缓存一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

    08-15 15:32