-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add public API prototype, add grpc-web
- Loading branch information
Showing
38 changed files
with
348 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "summa-proto" | ||
version = "0.34.0" | ||
version = "0.35.0" | ||
authors = ["Pasha Podolsky <[email protected]>"] | ||
edition = "2021" | ||
license-file = "LICENSE" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
syntax = "proto3"; | ||
package summa.proto; | ||
|
||
import "search_service.proto"; | ||
import "query.proto"; | ||
|
||
|
||
// Searches documents in the stored indices | ||
service PublicApi { | ||
// Make search in Summa | ||
rpc search (SearchRequest) returns (SearchResponse) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ | |
pub mod consumer; | ||
pub mod index; | ||
pub mod public; | ||
pub mod reflection; | ||
pub mod search; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//! Public GRPC API | ||
//! | ||
//! Public GRPC API is using for querying indices but queries are restricted for making it safe to open endpoint in public | ||
use std::time::Instant; | ||
|
||
use summa_proto::proto; | ||
use tonic::{Request, Response, Status}; | ||
use tracing::{info_span, Instrument}; | ||
|
||
use crate::errors::SummaServerResult; | ||
use crate::services::Index; | ||
|
||
pub struct PublicApiImpl { | ||
index_service: Index, | ||
} | ||
|
||
impl PublicApiImpl { | ||
pub fn new(index_service: &Index) -> SummaServerResult<PublicApiImpl> { | ||
Ok(PublicApiImpl { | ||
index_service: index_service.clone(), | ||
}) | ||
} | ||
} | ||
|
||
#[tonic::async_trait] | ||
impl proto::public_api_server::PublicApi for PublicApiImpl { | ||
async fn search(&self, proto_request: Request<proto::SearchRequest>) -> Result<Response<proto::SearchResponse>, Status> { | ||
let proto_request = proto_request.into_inner(); | ||
let now = Instant::now(); | ||
let collector_outputs = self | ||
.index_service | ||
.constrained_search(proto_request) | ||
.instrument(info_span!("search")) | ||
.await | ||
.map_err(crate::errors::Error::from)?; | ||
let elapsed_secs = now.elapsed().as_secs_f64(); | ||
Ok(Response::new(proto::SearchResponse { | ||
collector_outputs, | ||
elapsed_secs, | ||
})) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "summa-wasm" | ||
version = "0.132.2" | ||
version = "0.133.0" | ||
authors = ["Pasha Podolsky <[email protected]>"] | ||
edition = "2021" | ||
license-file = "LICENSE" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export * as index_service from "./index_service" | ||
export * as query from "./query" | ||
export * as search_service from "./search_service" | ||
export * as search_service_client from "./search_service.client" |
Oops, something went wrong.