我有一些服务。我需要从弹性搜索返回数据(如果可用)或从数据库返回:
@Service
class DefaulUserService implements UserService {
private final DbDao dbDao;
private final ElasticsearchDao elasticsearchDao;
DefaultDoctorService(DbDao dbDao, ElasticsearchDao elasticsearchDao) {
this.dbDao= dbDao;
this.elasticsearchDao= elasticsearchDao;
}
@Override
public List<User> findAll() {
if(elasticsearch is down){
return dbDao.findAll();
} else {
return elasticsearchDao.findAll();
}
}
}
如何检查elasticsearch is down
我的服务中的条件?