gsaslis / radicle-ci-broker

A placeholder project to use for issue tracking
0 stars 0 forks source link

Implement API endpoint polling with Future trait #20

Open Archimidis opened 1 year ago

Archimidis commented 1 year ago

The current implementation is based on a loop that breaks as soon as a job status is reached. Instead this should be implemented using the Future trait.

A possible interface would be something like the following:

async fn async_fn() {
  // hit endpoint
  // check status
  // return true if ready, else false
}

const fut = EndpointPoll {
  op: async_fn
}

let result = fut.await?;

Major blocking issue is how to type the op field of EndpointPoll struct. That's a function pointer to an async function. It requires the use of the Pin trait but I'm unsure how this can be done.