diff --git a/ServiceClient.java b/ServiceClient.java new file mode 100644 index 0000000..29145fc --- /dev/null +++ b/ServiceClient.java @@ -0,0 +1,34 @@ +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); + } +} \ No newline at end of file