options aren't a thing anymore
This commit is contained in:
parent
bcae9f3bc4
commit
b504f7722c
|
@ -69,9 +69,16 @@ struct BuildWorker {
|
||||||
system: String,
|
system: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl BuildWorker {
|
||||||
|
fn actions(&self) -> buildjob::Actions {
|
||||||
|
return buildjob::Actions{
|
||||||
|
system: self.system.clone(),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl worker::SimpleWorker for BuildWorker {
|
impl worker::SimpleWorker for BuildWorker {
|
||||||
type J = buildjob::BuildJob;
|
type J = buildjob::BuildJob;
|
||||||
type R = buildjob::Actions;
|
|
||||||
|
|
||||||
fn msg_to_job(&self, method: &Deliver, headers: &BasicProperties,
|
fn msg_to_job(&self, method: &Deliver, headers: &BasicProperties,
|
||||||
body: &Vec<u8>) -> Result<Self::J, String> {
|
body: &Vec<u8>) -> Result<Self::J, String> {
|
||||||
|
@ -85,14 +92,7 @@ impl worker::SimpleWorker for BuildWorker {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn job_to_actions(&self) -> buildjob::Actions {
|
fn consumer(&self, job: &buildjob::BuildJob) -> Result<(), Error> {
|
||||||
return buildjob::Actions{
|
|
||||||
system: self.system.clone(),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fn consumer(&self, job: &buildjob::BuildJob, resp: buildjob::Actions) -> Result<(), Error> {
|
|
||||||
let project = self.cloner.project(job.repo.full_name.clone(), job.repo.clone_url.clone());
|
let project = self.cloner.project(job.repo.full_name.clone(), job.repo.clone_url.clone());
|
||||||
let co = project.clone_for("builder".to_string(),
|
let co = project.clone_for("builder".to_string(),
|
||||||
job.pr.number.to_string())?;
|
job.pr.number.to_string())?;
|
||||||
|
|
|
@ -17,13 +17,11 @@ enum Action {
|
||||||
|
|
||||||
pub trait SimpleWorker {
|
pub trait SimpleWorker {
|
||||||
type J;
|
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,
|
fn msg_to_job(&self, method: &Deliver, headers: &BasicProperties,
|
||||||
body: &Vec<u8>) -> Result<Self::J, String>;
|
body: &Vec<u8>) -> Result<Self::J, String>;
|
||||||
|
|
||||||
fn job_to_actions(&self) -> Self::R;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new<T: SimpleWorker>(worker: T) -> Worker<T> {
|
pub fn new<T: SimpleWorker>(worker: T) -> Worker<T> {
|
||||||
|
@ -42,7 +40,6 @@ impl <T: SimpleWorker + Send> Consumer for Worker<T> {
|
||||||
body: Vec<u8>) {
|
body: Vec<u8>) {
|
||||||
|
|
||||||
let job = self.internal.msg_to_job(&method, &headers, &body).unwrap();
|
let job = self.internal.msg_to_job(&method, &headers, &body).unwrap();
|
||||||
let actions = self.internal.job_to_actions();
|
self.internal.consumer(&job).unwrap();
|
||||||
self.internal.consumer(&job, actions).unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue