Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
|
a02d58d50b | 1 year ago |
|
6579f0a331 | 1 year ago |
|
338033b11a | 1 year ago |
9 changed files with 204 additions and 38 deletions
@ -1,25 +1,54 @@
|
||||
use actix::{Actor, Addr, Context, Handler, Response}; |
||||
|
||||
use crate::messages::UploadNar; |
||||
use crate::{messages::{BeginWritePath, FinalizeWritePath}, types::{NarInfo, Path, StorePath}}; |
||||
|
||||
pub struct UploadConsumer {} |
||||
pub struct PartialNarInfo { |
||||
store_path: StorePath, |
||||
nar_hash: String, |
||||
nar_size: u32, |
||||
references: Vec<Path>, |
||||
deriver: Path, |
||||
sig: Vec<String>, |
||||
} |
||||
|
||||
// TODO add checks perhaps?
|
||||
impl From<BeginWritePath> for PartialNarInfo { |
||||
fn from(b: BeginWritePath) -> Self { |
||||
Self { |
||||
store_path: b.store_path, |
||||
nar_hash: b.nar_hash, |
||||
nar_size: b.nar_size, |
||||
references: b.references, |
||||
deriver: b.deriver, |
||||
sig: b.sig, |
||||
} |
||||
} |
||||
} |
||||
|
||||
pub struct UploadConsumer { |
||||
partial_narinfo: PartialNarInfo, |
||||
} |
||||
|
||||
impl Actor for UploadConsumer { |
||||
type Context = Context<Self>; |
||||
} |
||||
|
||||
impl UploadConsumer { |
||||
pub fn new() -> Addr<Self> { |
||||
pub fn new(begin_write_path: BeginWritePath) -> Addr<Self> { |
||||
Self::create(|ctx| { |
||||
Self {} |
||||
Self { |
||||
partial_narinfo: begin_write_path.into() |
||||
} |
||||
}) |
||||
} |
||||
} |
||||
|
||||
impl Handler<UploadNar> for UploadConsumer { |
||||
type Result = (); |
||||
impl Handler<FinalizeWritePath> for UploadConsumer { |
||||
type Result = Response<NarInfo>; |
||||
|
||||
fn handle(&mut self, msg: UploadNar, ctx: &mut Self::Context) -> Self::Result { |
||||
() |
||||
fn handle(&mut self, msg: FinalizeWritePath, ctx: &mut Self::Context) -> Self::Result { |
||||
println!("{}", msg.id); |
||||
|
||||
todo!() |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue