From a0446637ef15cd726e3a7d53f28cb4e0ed921bb8 Mon Sep 17 00:00:00 2001 From: pf5ub3a78 <1162620239@qq.com> Date: Sun, 2 Nov 2025 21:24:47 +0800 Subject: [PATCH] SOA --- ServiceClient.java | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 ServiceClient.java 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