Skip to content

Commit

Permalink
grpc client
Browse files Browse the repository at this point in the history
  • Loading branch information
Larkooo committed Oct 18, 2024
1 parent ba0510a commit 1d5064c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
4 changes: 2 additions & 2 deletions crates/torii/client/src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use tokio::sync::RwLock as AsyncRwLock;
use torii_grpc::client::{EntityUpdateStreaming, EventUpdateStreaming, IndexerUpdateStreaming};
use torii_grpc::proto::world::{RetrieveEntitiesResponse, RetrieveEventsResponse};
use torii_grpc::types::schema::Entity;
use torii_grpc::types::{EntityKeysClause, Event, EventQuery, KeysClause, Query};
use torii_grpc::types::{EntityKeysClause, Event, EventQuery, Query};
use torii_relay::client::EventLoop;
use torii_relay::types::Message;

Expand Down Expand Up @@ -159,7 +159,7 @@ impl Client {
/// A direct stream to grpc subscribe starknet events
pub async fn on_starknet_event(
&self,
keys: Option<KeysClause>,
keys: Vec<EntityKeysClause>,

Check warning on line 162 in crates/torii/client/src/client/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/client/src/client/mod.rs#L162

Added line #L162 was not covered by tests
) -> Result<EventUpdateStreaming, Error> {
let mut grpc_client = self.inner.write().await;
let stream = grpc_client.subscribe_events(keys).await?;
Expand Down
8 changes: 3 additions & 5 deletions crates/torii/grpc/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ use crate::proto::world::{
UpdateEntitiesSubscriptionRequest, WorldMetadataRequest,
};
use crate::types::schema::{Entity, SchemaError};
use crate::types::{
EntityKeysClause, Event, EventQuery, IndexerUpdate, KeysClause, ModelKeysClause, Query,
};
use crate::types::{EntityKeysClause, Event, EventQuery, IndexerUpdate, ModelKeysClause, Query};

#[derive(Debug, thiserror::Error)]
pub enum Error {
Expand Down Expand Up @@ -206,9 +204,9 @@ impl WorldClient {
/// Subscribe to the events of a World.
pub async fn subscribe_events(
&mut self,
keys: Option<KeysClause>,
keys: Vec<EntityKeysClause>,

Check warning on line 207 in crates/torii/grpc/src/client.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/grpc/src/client.rs#L207

Added line #L207 was not covered by tests
) -> Result<EventUpdateStreaming, Error> {
let keys = keys.map(|c| c.into());
let keys = keys.into_iter().map(|c| c.into()).collect();

Check warning on line 209 in crates/torii/grpc/src/client.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/grpc/src/client.rs#L209

Added line #L209 was not covered by tests

let stream = self
.inner
Expand Down
3 changes: 1 addition & 2 deletions crates/torii/grpc/src/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1190,8 +1190,7 @@ impl proto::world::world_server::World for DojoWorld {
&self,
request: Request<proto::world::SubscribeEventsRequest>,
) -> ServiceResult<Self::SubscribeEventsStream> {
let keys = request.into_inner().keys.unwrap_or_default();

let keys = request.into_inner().keys;

Check warning on line 1193 in crates/torii/grpc/src/server/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/torii/grpc/src/server/mod.rs#L1193

Added line #L1193 was not covered by tests
let rx = self.subscribe_events(keys).await.map_err(|e| Status::internal(e.to_string()))?;

Ok(Response::new(Box::pin(ReceiverStream::new(rx)) as Self::SubscribeEventsStream))
Expand Down

0 comments on commit 1d5064c

Please sign in to comment.