每天早上七点三十,准时推送干货
Hello、早上好~
最近阿粉的朋友出去面试了一下蚂蚁金服,一面的时候收到一道系统设计题,今天跟大家分享一下。
ps:偷偷告诉你,这道题星球球友之前面试的时候也碰到了,这次相当于刚好押题了。
题目
用户有多种支付方式(余额、红包、优惠券,代金券等),假如每种支付方式需要通过实时调用远程服务获取可用性。在外部资源环境不变情况下,请设计程序以最短响应时间获得尽可能多的可用支付方式列表。
假定支付方式可用性咨询服务接口定义:PaymentRemoteSerivce
接口方法:ConsultResult isEnabled(String paymentType)
;
public class ConsultResult {
public ConsultResult (boolean isEnable,String errorCode){
this.isEnable = isEnable;
this.errorCode= errorCode;
}
/** 咨询结果是否可用*/
private boolean isEnable;
/** 错误码 */
private String errorCode;
public boolean getIsEnable(){
return isEnable;
}
public String getErrorCode(){
return errorCode;
}
}
题目要求:
「尽可能展