try to do a type thing
This commit is contained in:
parent
f7377c1584
commit
d559383737
|
@ -11,13 +11,19 @@ use std::io::Error;
|
||||||
|
|
||||||
use ofborg::checkout;
|
use ofborg::checkout;
|
||||||
use ofborg::worker;
|
use ofborg::worker;
|
||||||
use ofborg::worker::{Actions,StdPr,StdRepo,BuildJob};
|
use ofborg::worker::{Actions,StdPr,StdRepo};
|
||||||
|
|
||||||
|
|
||||||
|
pub struct BuildJob {
|
||||||
|
pub repo: StdRepo,
|
||||||
|
pub pr: StdPr,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("Hello, world!");
|
println!("Hello, world!");
|
||||||
|
|
||||||
|
|
||||||
if false {
|
|
||||||
let mut session = Session::open_url("amqps://grahamc:cCbKQmwnRcd8kvPW9cjmMSkp@events.nix.gsc.io//").unwrap();
|
let mut session = Session::open_url("amqps://grahamc:cCbKQmwnRcd8kvPW9cjmMSkp@events.nix.gsc.io//").unwrap();
|
||||||
let mut channel = session.open_channel(1).unwrap();
|
let mut channel = session.open_channel(1).unwrap();
|
||||||
|
|
||||||
|
@ -48,14 +54,13 @@ fn main() {
|
||||||
process::exit(1);
|
process::exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
struct BuildWorker {
|
struct BuildWorker {
|
||||||
cloner: checkout::CachedCloner,
|
cloner: checkout::CachedCloner,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl worker::SimpleWorker for BuildWorker {
|
impl worker::SimpleWorker for BuildWorker {
|
||||||
fn consumer(&self, job: BuildJob, resp: Actions) -> Result<(), Error> {
|
fn consumer<BuildJob>(&self, job: BuildJob, resp: Actions) -> Result<(), Error> {
|
||||||
let project = self.cloner.project(job.repo.full_name, job.repo.clone_url);
|
let project = self.cloner.project(job.repo.full_name, job.repo.clone_url);
|
||||||
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())?;
|
||||||
|
|
|
@ -19,18 +19,11 @@ pub struct StdPr {
|
||||||
pub head_sha: String,
|
pub head_sha: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub struct BuildJob {
|
|
||||||
pub repo: StdRepo,
|
|
||||||
pub pr: StdPr,
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
pub struct Actions {
|
pub struct Actions {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait SimpleWorker {
|
pub trait SimpleWorker {
|
||||||
fn consumer(&self, job: BuildJob, resp: Actions) -> Result<(), Error>;
|
fn consumer<J>(&self, job: J, resp: Actions) -> Result<(), Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new<T: SimpleWorker>(worker: T) -> Worker<T> {
|
pub fn new<T: SimpleWorker>(worker: T) -> Worker<T> {
|
||||||
|
|
Loading…
Reference in a new issue