You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by "nogeek-cn (via GitHub)" <gi...@apache.org> on 2024/10/24 02:21:18 UTC
[I] 如何在某次调用中指定服务提供者的 Instence [servicecomb-java-chassis]
nogeek-cn opened a new issue, #4567:
URL: https://github.com/apache/servicecomb-java-chassis/issues/4567
我想请教一个问题
服务提供者 地址有一个 List<Instance>,这个我有办法拿到
我希望,我本次调用,我自己指定调用其中的一个 Instence
问,如何指定???
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] 如何在某次调用中指定服务提供者的 Instence [servicecomb-java-chassis]
Posted by "liubao68 (via GitHub)" <gi...@apache.org>.
liubao68 commented on issue #4567:
URL: https://github.com/apache/servicecomb-java-chassis/issues/4567#issuecomment-2434102215
可以看看 [Endpoint参数](https://servicecomb.apache.org/references/java-chassis/zh_CN/build-provider/context-param.html)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] 如何在某次调用中指定服务提供者的 Instence [servicecomb-java-chassis]
Posted by "nogeek-cn (via GitHub)" <gi...@apache.org>.
nogeek-cn commented on issue #4567:
URL: https://github.com/apache/servicecomb-java-chassis/issues/4567#issuecomment-2434236191
文档地址不对
https://servicecomb.apache.org/references/java-chassis/zh_CN/general-development/context.html#context-discoverytree
应该是这个:
案例: 使用 Context 和 DiscoveryTree 实现轮询调用一个微服务的所有实例
```java
interface DateTimeSchemaWithContextInf {
Date getDate(InvocationContext context, Date date);
}
@RpcReference(microserviceName = "springmvc", schemaId = "DateTimeSchema")
private DateTimeSchemaWithContextInf dateTimeSchemaWithContextInf;
// code slip
for (String endpoint : enpoints) {
InvocationContext invocationContext = new InvocationContext();
invocationContext.addLocalContext(LoadbalanceHandler.SERVICECOMB_SERVER_ENDPOINT, parseEndpoint(endpoint));
Date date = new Date();
TestMgr.check(date.getTime(), dateTimeSchemaWithContextInf.getDate(invocationContext, date).getTime());
}
// code slip
private Endpoint parseEndpoint(String endpointUri) throws Exception {
URI formatUri = new URI(endpointUri);
Transport transport = SCBEngine.getInstance().getTransportManager().findTransport(formatUri.getScheme());
return new Endpoint(transport, endpointUri);
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@servicecomb.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org