package jnpf.audit.fallback;
|
|
import jnpf.audit.AuditDeliveryException;
|
import jnpf.audit.AuditEventApi;
|
import jnpf.audit.model.AuditEventDTO;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.cloud.openfeign.FallbackFactory;
|
import org.springframework.stereotype.Component;
|
|
@Component
|
@Slf4j
|
public class AuditEventApiFallbackFactory implements FallbackFactory<AuditEventApi> {
|
@Override
|
public AuditEventApi create(Throwable cause) {
|
return dto -> {
|
// 关键:把异常重新抛出,让 SDK 降级链感知失败(L009 教训:静态 fallback 静默吞会误判成功)
|
throw new AuditDeliveryException("Feign 投递审计事件失败", cause);
|
};
|
}
|
}
|