-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use troupe crate #202
base: development
Are you sure you want to change the base?
Use troupe crate #202
Changes from all commits
b50b228
058bc05
33c2c4d
94664ea
1ef180e
17d2231
f2f291e
68534b5
edb11fa
78f4b0c
b0b55f4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ use async_trait::async_trait; | |
use axum::extract::ws::WebSocket; | ||
use mongodb::{options::ClientOptions, Client as DbClient, Database}; | ||
use squire_sdk::{ | ||
actor::{ActorBuilder, ActorClient}, | ||
api::*, | ||
model::{ | ||
accounts::SquireAccount, | ||
|
@@ -17,6 +16,7 @@ use squire_sdk::{ | |
}, | ||
sync::TournamentManager, | ||
}; | ||
use troupe::prelude::{ActorBuilder, Permanent, SinkClient}; | ||
|
||
mod accounts; | ||
mod boilerplate; | ||
|
@@ -100,7 +100,7 @@ impl AppStateBuilder<Uri, DbName> { | |
.database(self.get_db_name()); | ||
let tourn_coll = Arc::from(self.get_tournament_collection_name()); | ||
let tourn_db = TournDb::new(db_conn.clone(), tourn_coll); | ||
let tournaments = ActorClient::builder(TournPersister::new(tourn_db.clone())).launch(); | ||
let tournaments = ActorBuilder::new(TournPersister::new(tourn_db.clone())).launch(); | ||
let gatherings = ActorBuilder::new(GatheringHall::new(tournaments.clone())).launch(); | ||
AppState { | ||
sessions: SessionStoreHandle::new(db_conn.clone()), | ||
|
@@ -125,7 +125,7 @@ impl AppStateBuilder<Database, ()> { | |
pub fn build(self) -> AppState { | ||
let tourn_coll: Arc<str> = Arc::from(self.get_tournament_collection_name()); | ||
let tourn_db = TournDb::new(self.db_conn.clone(), tourn_coll); | ||
let tourns = ActorClient::builder(TournPersister::new(tourn_db.clone())).launch(); | ||
let tourns = ActorBuilder::new(TournPersister::new(tourn_db.clone())).launch(); | ||
let gatherings = ActorBuilder::new(GatheringHall::new(tourns.clone())).launch(); | ||
AppState { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So just to be sure of my reasoning here: it looks like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct. All of those should be permanent. The only actors that should be transient are the |
||
sessions: SessionStoreHandle::new(self.db_conn.clone()), | ||
|
@@ -154,7 +154,7 @@ pub struct AppState { | |
tourn_db: TournDb, | ||
sessions: SessionStoreHandle, | ||
accounts: AccountStoreHandle, | ||
gatherings: ActorClient<GatheringHall<TournPersister>>, | ||
gatherings: SinkClient<Permanent, GatheringHallMessage>, | ||
} | ||
|
||
impl AppState { | ||
|
@@ -215,7 +215,7 @@ impl ServerState for AppState { | |
self.tourn_db.persist_tourn(tourn).await | ||
} | ||
|
||
async fn handle_new_onlooker(&self, id: TournamentId, user: SessionWatcher, ws: WebSocket) { | ||
async fn handle_new_onlooker(&self, id: TournamentId, user: SessionWatcher, ws: WebSocket) -> bool { | ||
println!("Passing connection request off to gathering hall..."); | ||
self.gatherings | ||
.send(GatheringHallMessage::NewConnection(id, user, ws)) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,6 +63,8 @@ headers = { version = "0.4", optional = true } | |
# To be moved | ||
hashbag = { version = "0.1.11", features = ["serde"] } | ||
derive_more = "0.99.17" | ||
hyper = "1.0" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The history of this one is a bit weird. Within the history of Should this line be here in this PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ya, the history is a bit weird, but this line is fine. This change is needed regardless. |
||
troupe = "0.1.0" | ||
|
||
[target.'cfg(target_arch = "wasm32")'.dependencies] | ||
wasm-bindgen-futures = { version = "0.4.37" } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not necessary for this PR, but I wonder if we could use the
derive_more
crates macros to generate this.