AJLMC7UMTMBYBXLOSMGT5PDNX4D7O7LV4GDV7AN25CPOBPRUFYVAC
LIUJQXB752UIHJFF32LKJ7ECUZ2VDIFDDHBLAUVNBRTPDYNCAUYQC
BQ4E3XLAVS2AQAUYRGN6SZ4J35KQ2KIH7BBT2JNZXSPKKCGX7DYAC
ODUDDQRY373JMDR6W2BHUWSKEU6TEICQMNZIAIFKJPNUA5UN3C4QC
UWQB743KR36X6A6JVNK3VH6KMEFUHOUT6ZS2Y2SWIJR55JSF5WQAC
SI454P2VFO6Y6RO2NIOH6ZROURP3OTB2BBXH2F36KJT6YML6YBIAC
BDEVQIAUBDZLH5NNXJ3HD3WK2ART4V6K2FLHMAQVAQYNXGL4TOIQC
R7J4254ZZREVMWXXDUM772GPLZSCZSIJKOLEAI33WUF2CPS3X6WQC
let p = download_extract_deps(&index, &self.deb_client, &r.name, &link_extra)
.await
.unwrap();
info!("path {:?} {:#?}", r.name, p);
Ok(tonic::Response::new(proto::DerivationReply {
result: Some(proto::derivation_reply::Result::Ok(
proto::DerivationResult {
destdir: p
.result
.iter()
.rev()
.map(|x| x.to_str().unwrap().to_string())
.collect(),
paths: p.paths.into_iter().filter_map(Arc::into_inner).collect(),
path_patterns: Vec::new(),
let (tx, rx) = tokio::sync::mpsc::channel(200);
use crate::extract::Msg;
let output_stream = ReceiverStream::new(rx).map(|x| {
Ok(match x {
Msg::Downloading(p) => proto::DerivationReply {
result: Some(proto::derivation_reply::Result::Loading(p)),
)),
}))
Msg::Ok(p) => proto::DerivationReply {
result: Some(proto::derivation_reply::Result::Ok(
proto::DerivationResult {
destdir: p
.result
.iter()
.rev()
.map(|x| x.to_str().unwrap().to_string())
.collect(),
paths: p.paths.into_iter().filter_map(Arc::into_inner).collect(),
path_patterns: Vec::new(),
},
)),
},
Msg::Error(e) => proto::DerivationReply {
result: Some(proto::derivation_reply::Result::Error(e.to_string())),
},
})
});
match download_extract_deps(
&index,
&self.deb_client,
&r.name,
&link_extra,
PollSender::new(tx.clone()),
)
.await
{
Ok(p) => {
info!("path {:?} {:#?}", r.name, p);
tx.send(Msg::Ok(p)).await.unwrap();
}
Err(e) => tx.send(Msg::Error(e)).await.unwrap(),
}
Ok(tonic::Response::new(Box::pin(output_stream)))
async fn download_url<'a>(&self, url: &str, sha256: &str) -> Result<(Downloaded, bool), Error> {
async fn download_url<'a, S: futures::Sink<extract::Msg> + Unpin>(
&self,
url: &str,
sha256: &str,
mut tx: S,
) -> Result<(Downloaded, bool), Error>
where
S::Error: std::fmt::Debug,
{
) -> Result<Packages, Error> {
let pkg = multi_lookup(index, &package).await.unwrap();
tx: F,
) -> Result<Packages, Error>
where
F::Error: std::fmt::Debug,
{
let Some(pkg) = multi_lookup(index, &package).await else {
return Err(Error::PackageNotFound {
pkg: package.to_string(),
});
};
use std::convert::Infallible;
use std::pin::Pin;
#[derive(Clone, Copy)]
pub struct DummySink {}
impl<T> futures::Sink<T> for DummySink {
type Error = Infallible;
fn poll_ready(
self: Pin<&mut Self>,
_cx: &mut futures::task::Context<'_>,
) -> futures::task::Poll<Result<(), Infallible>> {
futures::task::Poll::Ready(Ok(()))
}
fn start_send(self: Pin<&mut Self>, _item: T) -> Result<(), Infallible> {
Ok(())
}
fn poll_flush(
self: Pin<&mut Self>,
_cx: &mut futures::task::Context<'_>,
) -> futures::task::Poll<Result<(), Infallible>> {
futures::task::Poll::Ready(Ok(()))
}
fn poll_close(
self: Pin<&mut Self>,
_cx: &mut futures::task::Context<'_>,
) -> futures::task::Poll<Result<(), Infallible>> {
futures::task::Poll::Ready(Ok(()))
}
}
Client.call ~service:"elpe.Elpe" ~rpc:"UbuntuPackage"
~do_request:
(H2_lwt_unix.Client.request connection ~error_handler:(fun _ ->
failwith "Error"))
~handler:
(Client.Rpc.unary enc ~f:(fun decoder ->
let+ decoder = decoder in
match decoder with
| Some decoder -> (
Reader.create decoder |> decode |> function
| Ok v -> v
| Error e ->
failwith
(Printf.sprintf "Could not decode request: %s"
(Result.show_error e)))
| None -> Elpegrpc.Elpe.Elpe.Derivation.Response.make ()))
()
let result = ref None in
let* x =
Client.call ~service:"elpe.Elpe" ~rpc:"UbuntuPackage"
~do_request:
(H2_lwt_unix.Client.request connection ~error_handler:(fun _ ->
failwith "Error"))
~handler:
(Client.Rpc.server_streaming enc ~f:(fun responses ->
Lwt_stream.iter_s
(fun str ->
Reader.create str |> decode |> function
| Ok (`Ok v) ->
result := Some v;
Lwt.return ()
| Ok (`Loading v) ->
Printf.eprintf "Downloading %s\n" v;
Stdlib.flush Stdlib.stderr;
Lwt.return ()
| Error e ->
failwith
(Printf.sprintf "Could not decode request: %s"
(Result.show_error e))
| _ -> Lwt.return ())
responses))
()
in
match x with
| Ok _ -> Lwt.return (Ok (Option.get !result))
| Error e -> Lwt.return (Error e)
type arch = Amd64 | Aarch64