options aren't a thing anymore

This commit is contained in:
Graham Christensen 2017-11-09 12:38:52 -05:00
parent bcae9f3bc4
commit b504f7722c
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C
2 changed files with 12 additions and 15 deletions

View file

@ -69,9 +69,16 @@ struct BuildWorker {
system: String,
}
impl BuildWorker {
fn actions(&self) -> buildjob::Actions {
return buildjob::Actions{
system: self.system.clone(),
};
}
}
impl worker::SimpleWorker for BuildWorker {
type J = buildjob::BuildJob;
type R = buildjob::Actions;
fn msg_to_job(&self, method: &Deliver, headers: &BasicProperties,
body: &Vec<u8>) -> Result<Self::J, String> {
@ -85,14 +92,7 @@ impl worker::SimpleWorker for BuildWorker {
}
}
fn job_to_actions(&self) -> buildjob::Actions {
return buildjob::Actions{
system: self.system.clone(),
};
}
fn consumer(&self, job: &buildjob::BuildJob, resp: buildjob::Actions) -> Result<(), Error> {
fn consumer(&self, job: &buildjob::BuildJob) -> Result<(), Error> {
let project = self.cloner.project(job.repo.full_name.clone(), job.repo.clone_url.clone());
let co = project.clone_for("builder".to_string(),
job.pr.number.to_string())?;

View file

@ -17,13 +17,11 @@ enum Action {
pub trait SimpleWorker {
type J;
type R;
fn consumer(&self, job: &Self::J, resp: Self::R) -> Result<(), Error>;
fn consumer(&self, job: &Self::J) -> Result<(), Error>;
fn msg_to_job(&self, method: &Deliver, headers: &BasicProperties,
body: &Vec<u8>) -> Result<Self::J, String>;
fn job_to_actions(&self) -> Self::R;
}
pub fn new<T: SimpleWorker>(worker: T) -> Worker<T> {
@ -42,7 +40,6 @@ impl <T: SimpleWorker + Send> Consumer for Worker<T> {
body: Vec<u8>) {
let job = self.internal.msg_to_job(&method, &headers, &body).unwrap();
let actions = self.internal.job_to_actions();
self.internal.consumer(&job, actions).unwrap();
self.internal.consumer(&job).unwrap();
}
}