Struct iroh_rpc_client::store::StoreClient
source · pub struct StoreClient { /* private fields */ }
Implementations§
source§impl StoreClient
impl StoreClient
sourcepub async fn new(addr: StoreAddr) -> Result<Self>
pub async fn new(addr: StoreAddr) -> Result<Self>
Examples found in repository?
src/client.rs (line 119)
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131
pub async fn new(cfg: Config) -> Result<Self> {
let Config {
gateway_addr,
p2p_addr,
store_addr,
channels,
} = cfg;
let gateway = if let Some(addr) = gateway_addr {
Some(
GatewayClient::new(addr)
.await
.context("Could not create gateway rpc client")?,
)
} else {
None
};
let n_channels = channels.unwrap_or(1);
let mut p2p = P2pLBClient::new();
if let Some(addr) = p2p_addr {
for _i in 0..n_channels {
let sc = P2pClient::new(addr.clone())
.await
.context("Could not create store rpc client")?;
p2p.clients.push(sc);
}
}
let mut store = StoreLBClient::new();
if let Some(addr) = store_addr {
for _i in 0..n_channels {
let sc = StoreClient::new(addr.clone())
.await
.context("Could not create store rpc client")?;
store.clients.push(sc);
}
}
Ok(Client {
gateway,
p2p,
store,
})
}
pub async fn version(&self) -> Result<String>
pub async fn put(&self, cid: Cid, blob: Bytes, links: Vec<Cid>) -> Result<()>
pub async fn put_many(&self, blocks: Vec<(Cid, Bytes, Vec<Cid>)>) -> Result<()>
pub async fn get(&self, cid: Cid) -> Result<Option<Bytes>>
pub async fn has(&self, cid: Cid) -> Result<bool>
pub async fn get_links(&self, cid: Cid) -> Result<Option<Vec<Cid>>>
pub async fn get_size(&self, cid: Cid) -> Result<Option<u64>>
sourcepub async fn check(&self) -> (StatusType, String)
pub async fn check(&self) -> (StatusType, String)
Examples found in repository?
src/client.rs (line 161)
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
pub async fn check(&self) -> crate::status::ClientStatus {
let g = if let Some(ref g) = self.gateway {
let (s, v) = g.check().await;
Some(ServiceStatus::new(ServiceType::Gateway, s, v))
} else {
None
};
let p = if let Some(ref p) = self.p2p.get() {
let (s, v) = p.check().await;
Some(ServiceStatus::new(ServiceType::P2p, s, v))
} else {
None
};
let s = if let Some(ref s) = self.store.get() {
let (s, v) = s.check().await;
Some(ServiceStatus::new(ServiceType::Store, s, v))
} else {
None
};
ClientStatus::new(g, p, s)
}
pub async fn watch(&self) -> impl Stream<Item = (StatusType, String)>
Trait Implementations§
source§impl Clone for StoreClient
impl Clone for StoreClient
source§fn clone(&self) -> StoreClient
fn clone(&self) -> StoreClient
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for StoreClient
impl Send for StoreClient
impl Sync for StoreClient
impl Unpin for StoreClient
impl !UnwindSafe for StoreClient
Blanket Implementations§
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T
in a tonic::Request