Dart Client for Bigquery是异步的,需要根据下面的Java代码轮询作业状态。 我如何在Dart中实现相同的目标?
//Java Equivalent
Job job = bigquery.jobs().insert(PROJECT_ID, runJob).execute();
String status = job.getStatus().getState();
while(!status.equalsIgnoreCase("DONE")) {
status = bigquery.jobs().get(PROJECT_ID, job.getId()).execute().getStatus().getState();
System.out.println("Status: " + status);
Thread.wait(1000);
}
答案 0 :(得分:1)
像
这样的东西Future poll() {
return new Future.delayed(new Duration(seconds: 1), () => job.getStatus().getState()).then((e) {
if(e.done) {
somethingToDoAfterGotState());
} else {
return poll();
}
});
}
(未经测试)