linera_rpc/
mass_client.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) Zefchain Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

use async_trait::async_trait;
use thiserror::Error;

use crate::RpcMessage;

#[derive(Error, Debug)]
pub enum MassClientError {
    #[error("io error: {0}")]
    Io(#[from] std::io::Error),
    #[error("tonic transport: {0}")]
    TonicTransport(#[from] crate::grpc::transport::Error),
    #[error("conversion error: {0}")]
    Conversion(#[from] crate::grpc::GrpcProtoConversionError),
    #[error("error while making a remote call: {0}")]
    Rpc(#[from] tonic::Status),
}

#[async_trait]
pub trait MassClient {
    async fn send(
        &self,
        requests: Vec<RpcMessage>,
        max_in_flight: usize,
    ) -> Result<Vec<RpcMessage>, MassClientError>;
}