-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: run fmt and add manual workflow test
- Loading branch information
1 parent
59472d6
commit eb3dd11
Showing
18 changed files
with
113 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: Manual Trigger Workflow | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Run a one-line script | ||
run: echo "This workflow was manually triggered." |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
mod queries; | ||
mod connect; | ||
mod queries; | ||
|
||
pub use queries::*; | ||
pub use connect::*; | ||
pub use queries::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
use crate::models::Wisdom; | ||
use super::connect::Database; | ||
use crate::models::Wisdom; | ||
|
||
pub async fn _get_wisdoms(db: &Database) -> Result<Vec<Wisdom>, sqlx::Error> { | ||
tracing_fast_dev::tfd().info("GET_WISDOMS_INTERNAL", "QUERY"); | ||
let wisdoms: Vec<Wisdom> = sqlx::query_as("SELECT * from wisdoms") | ||
.fetch_all(db) | ||
.await?; | ||
Ok(wisdoms) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
mod response_mapper_mw; | ||
mod rate_limiter; | ||
|
||
mod response_mapper_mw; | ||
|
||
pub use rate_limiter::*; | ||
pub use response_mapper_mw::*; | ||
pub use response_mapper_mw::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,10 @@ | ||
mod error; | ||
mod rate_limit_info; | ||
mod rate_limit_mw; | ||
mod rate_limiter_config; | ||
mod rate_limit_info; | ||
mod redis_interactor; | ||
mod error; | ||
|
||
|
||
pub use error::*; | ||
pub use rate_limit_info::*; | ||
pub use rate_limit_mw::*; | ||
pub use rate_limiter_config::*; | ||
pub use rate_limit_info::*; | ||
pub use error::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
use redis_macros::{FromRedisValue, ToRedisArgs}; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Serialize, Deserialize,FromRedisValue,ToRedisArgs,PartialEq,Eq,Debug)] | ||
#[derive(Serialize, Deserialize, FromRedisValue, ToRedisArgs, PartialEq, Eq, Debug)] | ||
pub struct RateLimitInfo { | ||
pub limit: i32, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
use std::net::SocketAddr; | ||
|
||
use axum::{extract::{ConnectInfo, Request}, middleware::Next, response::Response}; | ||
|
||
use axum::{ | ||
extract::{ConnectInfo, Request}, | ||
middleware::Next, | ||
response::Response, | ||
}; | ||
|
||
pub async fn rate_limit( | ||
ConnectInfo(ip_addr): ConnectInfo<SocketAddr>, | ||
mut req: Request, | ||
next: Next, | ||
)-> Response { | ||
println!("Rate limiter hit with ip: {}",ip_addr); | ||
) -> Response { | ||
println!("Rate limiter hit with ip: {}", ip_addr); | ||
next.run(req).await | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,29 @@ | ||
use std::time::Duration; | ||
|
||
|
||
pub trait RateLimiter { | ||
fn new(requests_amount:u32,limit:Duration)->Self; | ||
fn set_requests_amount(&mut self,requests_amount:u32); | ||
fn set_limit(&mut self, limit:Duration); | ||
fn new(requests_amount: u32, limit: Duration) -> Self; | ||
fn set_requests_amount(&mut self, requests_amount: u32); | ||
fn set_limit(&mut self, limit: Duration); | ||
} | ||
|
||
pub struct RateLimiterConfig { | ||
pub requests_amount:u32, | ||
pub limit:Duration, | ||
pub requests_amount: u32, | ||
pub limit: Duration, | ||
} | ||
|
||
impl RateLimiter for RateLimiterConfig { | ||
fn new(requests_amount:u32,limit:Duration) -> Self { | ||
fn new(requests_amount: u32, limit: Duration) -> Self { | ||
Self { | ||
requests_amount, | ||
limit | ||
limit, | ||
} | ||
} | ||
|
||
fn set_requests_amount(&mut self,requests_amount:u32) { | ||
self.requests_amount=requests_amount; | ||
} | ||
|
||
fn set_limit(&mut self, limit:Duration) { | ||
self.limit=limit; | ||
|
||
fn set_requests_amount(&mut self, requests_amount: u32) { | ||
self.requests_amount = requests_amount; | ||
} | ||
|
||
} | ||
fn set_limit(&mut self, limit: Duration) { | ||
self.limit = limit; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ use sqlx::prelude::FromRow; | |
pub struct Wisdom { | ||
pub id: i32, | ||
pub description: String, | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.