Skip to content

Commit

Permalink
feat: implemented find by namespace grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
paulobressan committed Oct 2, 2024
1 parent be4ae4e commit 49b4eb8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/domain/project/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,14 @@ pub struct FetchByNamespaceCmd {
pub credential: Credential,
pub namespace: String,
}
impl FetchByNamespaceCmd {
pub fn new(credential: Credential, namespace: String) -> Self {
Self {
credential,
namespace,
}
}
}

#[derive(Debug, Clone)]
pub struct CreateCmd {
Expand Down
21 changes: 21 additions & 0 deletions src/drivers/grpc/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,27 @@ impl proto::project_service_server::ProjectService for ProjectServiceImpl {

Ok(tonic::Response::new(message))
}
async fn fetch_project_by_namespace(
&self,
request: tonic::Request<proto::FetchProjectByNamespaceRequest>,
) -> Result<tonic::Response<proto::FetchProjectByNamespaceResponse>, tonic::Status> {
let credential = match request.extensions().get::<Credential>() {
Some(credential) => credential.clone(),
None => return Err(Status::unauthenticated("invalid credential")),
};

let req = request.into_inner();

let cmd = project::command::FetchByNamespaceCmd::new(credential, req.namespace);

let project = project::command::fetch_by_namespace(self.cache.clone(), cmd.clone()).await?;

let message = proto::FetchProjectByNamespaceResponse {
records: vec![project.into()],
};

Ok(tonic::Response::new(message))
}

async fn create_project(
&self,
Expand Down

0 comments on commit 49b4eb8

Please sign in to comment.