TEMP BROKEN - need to upgrade storyteller-web, I think

The situation with selectively enabling different versions off actix
in a workspace using library features is crazy. It doesn't work,
anyway.
This commit is contained in:
Brandon Thomas committed 2021-11-11 22:13:53 -05:00
1 parent aa38f0a71f
commit c55cc81022
10 files changed
+82 -29

No files matched your search

Generated
+1 -1
View File
@@ -2059,6 +2059,7 @@ dependencies = [
name = "http_server_common"
version = "0.0.1"
dependencies = [
"actix-cors 0.5.4",
"actix-cors 0.6.0-beta.3",
"actix-http 2.2.0",
"actix-http 3.0.0-beta.11",
@@ -4048,7 +4049,6 @@ dependencies = [
"hex",
"hmac 0.10.1",
"hostname",
"http_server_common",
"hyper 0.13.10",
"infer",
"jwt",
+6 -3
View File
@@ -22,11 +22,13 @@ dotenv = "0.15.0"
log = "0.4.14"
# Web
actix-cors = "0.6.0-beta.3"
# NB: One microservice requires old Tokio (thus old actix), and another new Tokio (new actix).
# Thus I'm being extremely extra here and supporting both.
actix-cors-old = { package = "actix-cors", version = "0.5.4", optional = true }
actix-http-old = { package = "actix-http", version = "2.2.0", optional = true }
actix-web-old = { package = "actix-web", version = "3.3.2", optional = true }
actix-cors-new = { package = "actix-cors", version = "0.6.0-beta.3", optional = true }
actix-http-new = { package = "actix-http", version = "3.0.0-beta.11", optional = true }
actix-web-new = { package = "actix-web", version = "4.0.0-beta.10", optional = true }
@@ -37,5 +39,6 @@ serde_json = "1.0.64"
toml = "0.5.8"
[features]
actix-new = ["actix-http-new", "actix-web-new"]
actix-old = ["actix-http-old", "actix-web-old"]
# default = ["actix-cors-new", "actix-web-new", "actix-http-new"]
actix-new = ["actix-cors-new", "actix-http-new", "actix-web-new"]
actix-old = ["actix-cors-old", "actix-http-old", "actix-web-old"]
@@ -1,18 +1,11 @@
use actix_http::http::StatusCode;
use actix_web::{HttpResponse, HttpRequest, Responder, get};
use actix_web::{HttpResponse, HttpRequest, get};
use actix_web::Responder;
use actix_web::Result;
use actix_web::Error;
use log::debug;
/*
error[E0277]: the trait bound `fn() -> impl futures::Future {get_root_index}: HttpServiceFactory` is not satisfied
--> app/storyteller_web/src/main.rs:627:16
|
627 | .service(get_root_index)
| ^^^^^^^^^^^^^^ the trait `HttpServiceFactory` is not implemented for `fn() -> impl futures::Future {get_root_index}`
*/
pub async fn get_root_index() -> impl Responder {
pub async fn get_root_index() -> HttpResponse {
debug!("GET /"); // NB: Google load balancer hits this a lot, and it spams.
HttpResponse::build(StatusCode::OK)
.content_type("text/html; charset=utf-8")
+32 -4
View File
@@ -10,16 +10,44 @@
// I don't think this will be too hard to maintain. AFAICT, the only major differences are which
// package "HttpResponseBuilder" is located in.
#[cfg(feature = "actix-new")]
#[cfg(all(feature = "actix-new", not(feature = "actix-old")))]
//#[cfg(feature = "actix-cors-new")]
extern crate actix_cors_new as actix_cors;
#[cfg(all(feature = "actix-new", not(feature = "actix-old")))]
//#[cfg(feature = "actix-http-new")]
extern crate actix_http_new as actix_http;
#[cfg(feature = "actix-new")]
#[cfg(all(feature = "actix-new", not(feature = "actix-old")))]
//#[cfg(feature = "actix-web-new")]
extern crate actix_web_new as actix_web;
#[cfg(not(feature = "actix-new"))]
#[cfg(all(feature = "actix-old", not(feature = "actix-new")))]
//#[cfg(feature = "actix-cors-old")]
extern crate actix_cors_old as actix_cors;
#[cfg(all(feature = "actix-old", not(feature = "actix-new")))]
//#[cfg(feature = "actix-http-old")]
extern crate actix_http_old as actix_http;
#[cfg(not(feature = "actix-new"))]
#[cfg(all(feature = "actix-old", not(feature = "actix-new")))]
//#[cfg(feature = "actix-web-old")]
extern crate actix_web_old as actix_web;
//#[cfg(any(
// all(feature = "actix-cors-new", not(feature = "actix-cors-old")),
// all(feature = "actix-cors-old", not(feature = "actix-cors-new")),
//))]
#[cfg(any(
feature = "actix-new",
feature = "actix-old",
))]
pub mod cors;
#[cfg(any(
feature = "actix-new",
feature = "actix-old",
))]
pub mod endpoints;
#[cfg(any(
feature = "actix-new",
feature = "actix-old",
))]
pub mod response;
+3
View File
@@ -315,6 +315,9 @@ pub async fn serve(server_state: ObsGatewayServerState) -> AnyhowResult<()>
.wrap(DefaultHeaders::new()
.header("X-Backend-Hostname", &hostname)
.header("X-Build-Sha", ""))
.service(web::resource("/")
.route(web::get().to(get_root_index))
)
// Twitch
.service(
web::resource("/twitch")
+2 -4
View File
@@ -39,7 +39,7 @@ path = "src/w2l_inference_job.rs"
# Internal
config = { path = "../config" }
http_server_common = { path = "../http_server_common", features = ["actix-old"] }
#http_server_common = { path = "../http_server_common", features = ["actix-old"] }
# External
anyhow = "1.0.40"
@@ -101,9 +101,6 @@ tempdir = "0.3.7"
# Web
actix = "0.10"
#actix-web = "3"
actix-web-actors = "3"
actix-cors = "0.5.4"
actix-files= "0.5"
actix-http = "2.2.0"
@@ -112,6 +109,7 @@ actix-rt = "2.2.0"
actix-service = "1.0.6"
actix-utils = "3.0.0"
actix-web = "3.3.2"
actix-web-actors = "3"
jwt = "0.13.0"
# NB: Hyper is just for HTTP client use in jobs. I'd use Actix client, but I need tokio runtime
@@ -0,0 +1,10 @@
use actix_http::http::StatusCode;
use actix_web::{HttpResponse, HttpRequest, Responder, get};
use log::warn;
pub async fn default_route_404() -> impl Responder {
warn!("404 not found");
HttpResponse::NotFound()
.content_type("text/html; charset=utf-8")
.body("<h1>not found</h1>")
}
@@ -1,3 +1,5 @@
pub mod alpha_cookie;
pub mod default_route_404;
pub mod enable_alpha_easy_handler;
pub mod enable_alpha_handler;
pub mod enable_alpha_easy_handler;
pub mod root_index;
@@ -0,0 +1,13 @@
use actix_http::http::StatusCode;
use actix_web::{HttpResponse, HttpRequest, get};
use actix_web::Responder;
use actix_web::Result;
use actix_web::Error;
use log::debug;
pub async fn get_root_index() -> HttpResponse {
debug!("GET /"); // NB: Google load balancer hits this a lot, and it spams.
HttpResponse::build(StatusCode::OK)
.content_type("text/html; charset=utf-8")
.body("<h1>hello!</h1><p>Are you looking for an API? Join our Discord!</p><p>Maybe you want to work with us? We can pay! Get in touch!</p>")
}
+7 -4
View File
@@ -103,8 +103,6 @@ use crate::util::encrypted_sort_id::SortKeyCrypto;
use futures::Future;
use futures::executor::ThreadPool;
//use http_server_common::cors::build_common_cors_config;
use http_server_common::endpoints::default_route_404::default_route_404;
use http_server_common::endpoints::root_index::get_root_index;
use limitation::Limiter;
use log::{info};
use r2d2_redis::RedisConnectionManager;
@@ -114,6 +112,8 @@ use sqlx::MySqlPool;
use sqlx::mysql::MySqlPoolOptions;
use std::sync::Arc;
use std::time::Duration;
use crate::http_server::endpoints::misc::root_index::get_root_index;
use crate::http_server::endpoints::misc::default_route_404::default_route_404;
// TODO TODO TODO TODO
// TODO TODO TODO TODO
@@ -624,10 +624,13 @@ pub async fn serve(server_state: ServerState) -> AnyhowResult<()>
.route(web::get().to(leaderboard_handler))
.route(web::head().to(|| HttpResponse::Ok()))
)
//.service(get_root_index)
.service(web::resource("/")
.route(web::get().to(get_root_index))
.route(web::head().to(|| HttpResponse::Ok()))
)
.service(enable_alpha_handler)
.service(enable_alpha_easy_handler)
//.default_service( web::route().to(default_route_404))
.default_service( web::route().to(default_route_404))
})
.bind(bind_address)?
.workers(num_workers)