Online video game back-end using AWS Gamelift with rusoto_gamelift crate #1922
Replies: 2 comments 4 replies
-
Use https://crates.io/crates/rusoto_gamelift/0.45.0 for actix-web v3. (or use actix-web v4 beta with 0.46) For client like the compiler tells. actix-web client is not thread safe. It's meant to be used on single thread. So it's not possible to send it between threads. It's not an issue or bug as it's designed to do exactly single thread work. |
Beta Was this translation helpful? Give feedback.
1 reply
-
use actix_web::{get, App, HttpServer, web::Data};
use rusoto_gamelift::GameLiftClient;
use rusoto_core::credential::{EnvironmentProvider};
use rusoto_core::request::HttpClient;
use rusoto_core::region::Region;
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let cred = EnvironmentProvider::default();
let client = HttpClient::new().unwrap();
let client = GameLiftClient::new_with(client, cred, Region::EuWest1);
HttpServer::new(move || App::new().data(client.clone()).service(index))
.bind("127.0.0.1:8000")?
.run()
.await
}
#[get("/")]
async fn index(data: Data<GameLiftClient>) -> &'static str {
"working!"
}
[dependencies]
actix-web = "3"
rusoto_core = "0.43.0"
rusoto_gamelift = "0.43.0" |
Beta Was this translation helpful? Give feedback.
3 replies
Answer selected by
Tipnos
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello everyone,
I'm currently working on a back-end service of an online multiplayer game which use Amazon Web Service Gamelift for matchmaking and server fleet scaling.
I'm facing some difficulty with integrating rusoto_gamelift crate which provide some tools to format and send request to AWS, the problem comes from the HttpClient.
Firstly I tried to use their default http client :
But I faced this error at runtime: thread 'actix-web' panicked at 'not currently running on the Tokio runtime.', /home/tristan/.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.0.2/src/runtime/blocking/pool.rs:84:33
I implemented the solution mentioned here to start actix web in a tokio runtime. But sadly, I faced exactly the same error at runtime.
Then I tried to implement their DispatchSignedRequest trait with actix web client. I had then the following compiler error:
Rc<awc::ClientConfig>
cannot be sent between threads safelywithin
GameliftClient
, the traitstd::marker::Send
is not implemented forRc<awc::ClientConfig>
I found already an issue here on this but at the moment ClientConfig is still Rc and not Arc.
I guess people have already implemented AWS services with this crate so I may miss something big here...
Any help is really appreciated! Thanks.
Beta Was this translation helpful? Give feedback.
All reactions