You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
903 B
34 lines
903 B
package com.soa.microservice.core;
|
|
|
|
/**
|
|
* 服务调用客户端接口
|
|
* 封装服务发现、负载均衡和熔断功能
|
|
*/
|
|
public interface ServiceClient {
|
|
/**
|
|
* 调用远程服务
|
|
* @param serviceName 服务名称
|
|
* @param method 方法名称
|
|
* @param params 参数
|
|
* @return 调用结果
|
|
* @throws Exception 调用异常
|
|
*/
|
|
Object invoke(String serviceName, String method, Object... params) throws Exception;
|
|
|
|
/**
|
|
* 异步调用远程服务
|
|
* @param serviceName 服务名称
|
|
* @param method 方法名称
|
|
* @param callback 回调函数
|
|
* @param params 参数
|
|
*/
|
|
void invokeAsync(String serviceName, String method, ServiceCallback callback, Object... params);
|
|
|
|
/**
|
|
* 服务回调接口
|
|
*/
|
|
interface ServiceCallback {
|
|
void onSuccess(Object result);
|
|
void onFailure(Exception e);
|
|
}
|
|
} |