Skip to content

Commit

Permalink
Merge pull request #103 from TeamBulbbot/workflow_problems
Browse files Browse the repository at this point in the history
  • Loading branch information
y3ll0wlife authored Jul 1, 2024
2 parents bb5a95c + 08d0b4c commit 648ddde
Show file tree
Hide file tree
Showing 17 changed files with 27 additions and 38 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/gateway.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
pull_request:
paths:
- "bulbbot.Gateway/**"
types: [opened, edited, reopened]
types: [opened, edited, reopened, synchronize]

jobs:
test:
Expand All @@ -28,7 +28,7 @@ jobs:
fmt:
defaults:
run:
working-directory: ./Bulbbot.Gateway
working-directory: ./bulbbot.Gateway
name: Rustfmt
runs-on: ubuntu-latest
steps:
Expand All @@ -42,7 +42,7 @@ jobs:
clippy:
defaults:
run:
working-directory: ./Bulbbot.Gateway
working-directory: ./bulbbot.Gateway
name: Clippy
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/gateway_handler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
pull_request:
paths:
- "bulbbot.GatewayHandler/**"
types: [opened, edited, reopened]
types: [opened, edited, reopened, synchronize]

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/guild_service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
pull_request:
paths:
- "bulbbot.GuildService/**"
types: [opened, edited, reopened]
types: [opened, edited, reopened, synchronize]

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/message_service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
pull_request:
paths:
- "bulbbot.MessageService/**"
types: [opened, edited, reopened]
types: [opened, edited, reopened, synchronize]

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion bulbbot.Gateway/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ async fn main() {
info!("Running http server on localhost:{}", server_port);
HttpServer::new(|| App::new().service(hello))
.bind(("127.0.0.1", server_port))
.expect("Failed to bind to localhost:8080")
.unwrap_or_else(|_| panic!("Failed to bind to localhost:8080"))
.run()
.await
.expect("Failed to start server");
Expand Down
2 changes: 1 addition & 1 deletion bulbbot.GatewayHandler/src/events/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Handler {
let mut request = self.client.post(&url).json(&message).build().unwrap();
global::get_text_map_propagator(|propagator| {
propagator.inject_context(
&cx,
cx,
&mut ReqwestInjector {
headers: request.headers_mut(),
},
Expand Down
2 changes: 1 addition & 1 deletion bulbbot.GatewayHandler/src/events/message_delete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Handler {
let mut request = self.client.post(&url).json(&message).build().unwrap();
global::get_text_map_propagator(|propagator| {
propagator.inject_context(
&cx,
cx,
&mut ReqwestInjector {
headers: request.headers_mut(),
},
Expand Down
2 changes: 1 addition & 1 deletion bulbbot.GuildService/src/handlers/create_guild_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ pub async fn create_guild_command_handler(

match response {
Some(resp) => Ok(HttpResponse::Created().json(resp)),
None => Ok(HttpResponse::BadRequest().body(format!("Guild already exists"))),
None => Ok(HttpResponse::BadRequest().body("Guild already exists")),
}
}
2 changes: 1 addition & 1 deletion bulbbot.GuildService/src/handlers/get_guild_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@ pub async fn get_guild_command_handler(

match response {
Some(resp) => Ok(HttpResponse::Ok().json(resp)),
None => Ok(HttpResponse::NotFound().body(format!("Guild does not exist"))),
None => Ok(HttpResponse::NotFound().body("Guild does not exist")),
}
}
2 changes: 1 addition & 1 deletion bulbbot.GuildService/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async fn main() {
.service(health)
})
.bind(("127.0.0.1", server_port))
.expect(&format!("Failed to bind to localhost:{}", server_port))
.unwrap_or_else(|_| panic!("Failed to bind to localhost:{}", server_port))
.run()
.await
.expect("Failed to start server");
Expand Down
4 changes: 2 additions & 2 deletions bulbbot.GuildService/src/middleware/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ where
fn call(&self, req: ServiceRequest) -> Self::Future {
let request = req.request();
let cx = global::get_text_map_propagator(|propagator| {
propagator.extract(&mut ActixWebExtractor {
headers: &mut request.headers(),
propagator.extract(&ActixWebExtractor {
headers: request.headers(),
})
});

Expand Down
5 changes: 1 addition & 4 deletions bulbbot.GuildService/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,4 @@ diesel::table! {

diesel::joinable!(logging -> guilds (guilds_id));

diesel::allow_tables_to_appear_in_same_query!(
guilds,
logging,
);
diesel::allow_tables_to_appear_in_same_query!(guilds, logging,);
2 changes: 1 addition & 1 deletion bulbbot.MessageService/src/handlers/create_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub async fn create_message(
content: web::Json<MessageCommand>,
) -> Result<HttpResponse, Error> {
let response = http_client
.get_guild(content.content.guild_id.unwrap(), &request.headers())
.get_guild(content.content.guild_id.unwrap(), request.headers())
.await;

if response.logging.message.is_none() {
Expand Down
12 changes: 4 additions & 8 deletions bulbbot.MessageService/src/handlers/delete_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ use crate::extractor::ActixWebExtractor;
use crate::injector::RabbitMqInjector;
use crate::models::messages::Messages;
use crate::schema::messages::dsl::messages;
use crate::{
database::DbPool,
http_client::HttpClient,
models::{event_type::EventType, messages::NewMessage},
};
use crate::{database::DbPool, http_client::HttpClient, models::event_type::EventType};
use actix_web::HttpRequest;
use actix_web::{http::Error, web, HttpResponse};
use diesel::{QueryDsl, RunQueryDsl};
Expand Down Expand Up @@ -51,7 +47,7 @@ pub async fn delete_message(
content: web::Json<MessageDeleteCommand>,
) -> Result<HttpResponse, Error> {
let response = http_client
.get_guild(content.content.guild_id.unwrap(), &request.headers())
.get_guild(content.content.guild_id.unwrap(), request.headers())
.await;

if response.logging.message.is_none() {
Expand Down Expand Up @@ -79,8 +75,8 @@ pub async fn delete_message(
None => Ok(HttpResponse::NotFound().finish()),
Some(msg) => {
let cx = global::get_text_map_propagator(|propagator| {
propagator.extract(&mut ActixWebExtractor {
headers: &mut request.headers(),
propagator.extract(&ActixWebExtractor {
headers: request.headers(),
})
});

Expand Down
12 changes: 4 additions & 8 deletions bulbbot.MessageService/src/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ impl HttpClient {
}
}

fn add_telelementry(&self, mut headers: &HeaderMap, request: &mut Request) {
fn add_telelementry(&self, headers: &HeaderMap, request: &mut Request) {
let cx = global::get_text_map_propagator(|propagator| {
propagator.extract(&mut ActixWebExtractor {
headers: &mut headers,
})
propagator.extract(&ActixWebExtractor { headers })
});

global::get_text_map_propagator(|propagator| {
Expand All @@ -56,7 +54,7 @@ impl HttpClient {

let response = self.client.execute(request).await.expect("Invalid reponse");

let guild = match response.json::<GuildDto>().await {
match response.json::<GuildDto>().await {
Ok(g) => g,
Err(_) => {
let mut request = self
Expand All @@ -78,9 +76,7 @@ impl HttpClient {

response.json::<GuildDto>().await.unwrap()
}
};

guild
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion bulbbot.MessageService/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async fn main() {
.service(health)
})
.bind(("127.0.0.1", server_port))
.expect(&format!("Failed to bind to localhost:{}", server_port))
.unwrap_or_else(|_| panic!("Failed to bind to localhost:{}", server_port))
.run()
.await
.expect("Failed to start server");
Expand Down
4 changes: 2 additions & 2 deletions bulbbot.MessageService/src/middleware/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ where
fn call(&self, req: ServiceRequest) -> Self::Future {
let request = req.request();
let cx = global::get_text_map_propagator(|propagator| {
propagator.extract(&mut ActixWebExtractor {
headers: &mut request.headers(),
propagator.extract(&ActixWebExtractor {
headers: request.headers(),
})
});

Expand Down

0 comments on commit 648ddde

Please sign in to comment.