refactor(tvix/store): rename C to DS, client to directory_service
This matches the semantics in other gRPC wrappers. Change-Id: I505c901aa77a58deab216316d08542877b0b2c14 Reviewed-on: https://cl.tvl.fyi/c/depot/+/8247 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI Autosubmit: flokli <flokli@flokli.de> Reviewed-by: raitobezarius <tvl@lahfa.xyz>
This commit is contained in:
parent
3506d3bd0e
commit
ceb9d670bf
1 changed files with 11 additions and 9 deletions
|
@ -8,18 +8,20 @@ use tonic::{async_trait, Request, Response, Status, Streaming};
|
||||||
use tracing::{debug, info_span, instrument, warn};
|
use tracing::{debug, info_span, instrument, warn};
|
||||||
|
|
||||||
pub struct GRPCDirectoryServiceWrapper<C: DirectoryService> {
|
pub struct GRPCDirectoryServiceWrapper<C: DirectoryService> {
|
||||||
client: C,
|
directory_service: C,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<C: DirectoryService> From<C> for GRPCDirectoryServiceWrapper<C> {
|
impl<DS: DirectoryService> From<DS> for GRPCDirectoryServiceWrapper<DS> {
|
||||||
fn from(value: C) -> Self {
|
fn from(value: DS) -> Self {
|
||||||
Self { client: value }
|
Self {
|
||||||
|
directory_service: value,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<C: DirectoryService + Send + Sync + Clone + 'static>
|
impl<DS: DirectoryService + Send + Sync + Clone + 'static>
|
||||||
proto::directory_service_server::DirectoryService for GRPCDirectoryServiceWrapper<C>
|
proto::directory_service_server::DirectoryService for GRPCDirectoryServiceWrapper<DS>
|
||||||
{
|
{
|
||||||
type GetStream = ReceiverStream<tonic::Result<proto::Directory, Status>>;
|
type GetStream = ReceiverStream<tonic::Result<proto::Directory, Status>>;
|
||||||
|
|
||||||
|
@ -32,7 +34,7 @@ impl<C: DirectoryService + Send + Sync + Clone + 'static>
|
||||||
|
|
||||||
let req_inner = request.into_inner();
|
let req_inner = request.into_inner();
|
||||||
|
|
||||||
let client = self.client.clone();
|
let client = self.directory_service.clone();
|
||||||
|
|
||||||
// kick off an async thread
|
// kick off an async thread
|
||||||
task::spawn(async move {
|
task::spawn(async move {
|
||||||
|
@ -201,7 +203,7 @@ impl<C: DirectoryService + Send + Sync + Clone + 'static>
|
||||||
// check if the directory already exists in the database. We can skip
|
// check if the directory already exists in the database. We can skip
|
||||||
// inserting if it's already there, as that'd be a no-op.
|
// inserting if it's already there, as that'd be a no-op.
|
||||||
match self
|
match self
|
||||||
.client
|
.directory_service
|
||||||
.get(&proto::get_directory_request::ByWhat::Digest(dgst.to_vec()))
|
.get(&proto::get_directory_request::ByWhat::Digest(dgst.to_vec()))
|
||||||
{
|
{
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -212,7 +214,7 @@ impl<C: DirectoryService + Send + Sync + Clone + 'static>
|
||||||
Ok(Some(_)) => {}
|
Ok(Some(_)) => {}
|
||||||
// insert if it doesn't already exist
|
// insert if it doesn't already exist
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
self.client.put(directory)?;
|
self.directory_service.put(directory)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue