Skip to content

Commit

Permalink
update crates
Browse files Browse the repository at this point in the history
  • Loading branch information
wildonion committed May 27, 2024
1 parent d50ff1b commit 31f13ab
Show file tree
Hide file tree
Showing 12 changed files with 324 additions and 307 deletions.
554 changes: 281 additions & 273 deletions Cargo.lock

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@ reqwest = { version = "0.12", features = ["json", "blocking", "stream", "multipa
tokio-stream = { version = "0.1" }
serde = {version = "1", features = ["derive"] }
redis = { version = "0.25", features = ["tokio-comp", "cluster-async", "json"] }
redis-async = "0.17.1"
hyper = { version = "0.14", features = ["full"] }
redis-async = "0.17"
actix-cors = "0.7.0"
sha2 = "0.10"
actix-multipart = "0.6"
actix-redis = "0.13.0"
actix = "0.13"
is_type = "0.2.1"
actix-web = { version = "4", features = ["openssl"] }
actix-web-actors = "4.3"
sha2 = "0.10"
is_type = "0.2.1"
rayon = "1.10.0"
rand = "0.8"
actix-web = { version = "4", features = ["openssl"] }
rslock = "0.3.0"
tonic = "0.11.0"
futures = "0.3"
Expand Down
2 changes: 1 addition & 1 deletion hooper/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ use redis::RedisResult;
use redis::Commands;
use redis_async::client::{self, PubsubConnection, ConnectionBuilder};
use redis::RedisError;
use hyper::StatusCode;
use uuid::Uuid;
use log::{info, error};
use actix_redis::{Command, RedisActor, resp_array, RespValue};
Expand Down Expand Up @@ -196,6 +195,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync + 'static>
Migrator::refresh(&connection).await.unwrap();
} else{
Migrator::up(&connection, None).await.unwrap(); // executing database tasks like creating tables on startup
Migrator::status(&connection).await.unwrap();
}

/* ******************************* IMPORTANT *******************************
Expand Down
5 changes: 5 additions & 0 deletions migration/src/m20240508_213126_notifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ pub struct Migration;
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {

let db = manager.get_connection();
db.execute_unprepared("
SELECT CURRENT_DATE;
").await.unwrap();

let fired_at_index = Index::create()
.if_not_exists()
.index_type(sea_query::IndexType::BTree)
Expand Down
4 changes: 2 additions & 2 deletions src/apis/http/v1/events/hoop.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@



use crate::{models::event::{EventQuery, NewHoopRequest, NotifData, UpdateHoopRequest}, workers::cqrs::accessors::notif::NotifDataResponse};
use crate::{models::event::{EventQuery, NewHoopRequest, NotifData, UpdateHoopRequest},
workers::cqrs::accessors::notif::NotifDataResponse};
use actix_web::{delete, put};
use redis::AsyncCommands;
use sea_orm::ConnectionTrait;
use self::models::event::HoopQuery;

pub use super::*;


Expand Down
2 changes: 1 addition & 1 deletion src/apis/http/v1/health/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use wallexerr::misc::{SecureCellConfig, Wallet};
use crate::consts::CRYPTER_THEMIS_ERROR_CODE;
use base58::{ToBase58, FromBase58};
use self::models::event::GenerateTokenTimeQuery;

use actix_web::http::StatusCode;
pub use super::*;


Expand Down
1 change: 0 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ use redis::RedisResult;
use redis::Commands;
use redis_async::client::{self, PubsubConnection, ConnectionBuilder};
use redis::RedisError;
use hyper::StatusCode;
use uuid::Uuid;
use log::{info, error};
use actix_redis::{Command, RedisActor, resp_array, RespValue};
Expand Down
2 changes: 1 addition & 1 deletion src/error/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ use crate::models::http::Response;
*/

use actix::Addr;
use actix_web::http::StatusCode;
use crate::models::event::*;
use serde::{Serialize, Deserialize};
use std::error::Error;
use std::io::{Write, Read};
use actix_web::cookie::Cookie;
use actix_web::HttpResponse;
use actix_web_actors::ws;
use hyper::StatusCode;
use thiserror::Error;
use tokio::fs::OpenOptions;
use tokio::io::AsyncWriteExt;
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/passport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use config::EnvExt;
use consts::STORAGE_IO_ERROR_CODE;
use models::user::UserData;
use types::*;

use actix_web::http::StatusCode;
use self::appstate::AppState;


Expand Down
6 changes: 3 additions & 3 deletions src/requests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ use serde::{Serialize, Deserialize};
#[derive(Serialize, Deserialize, Clone, Debug, Default)]
pub struct Request{
path: String,
jwt: String,
auth_token: String,
base_url: String,
}

impl Request{

pub fn builder(path: &str, jwt: &str, base_url: &str) -> Self{
pub fn builder(path: &str, auth_token: &str, base_url: &str) -> Self{
Self{
path: path.to_string(),
jwt: jwt.to_string(),
auth_token: auth_token.to_string(),
base_url: base_url.to_string()
}
}
Expand Down
42 changes: 24 additions & 18 deletions src/workers/consumers/notif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,31 +44,38 @@ pub struct ConsumeNotif{
pub queue: String,
pub exchange_name: String,
/* -ˋˏ✄┈┈┈┈
routing_key in ConsumeNotif can be the same as in ProduceNotif struct
but also it can be different than that cause:
pattern for the exchange to route the messages to the bounded queue,
any queue that is bounded to this exchange routing key will receive
routing_key is pattern for the exchange to route the messages to the
bounded queue.
multiple producers can send their messages to a single exchange but
each of with different routing keys.
any queue that is bounded to the exchange routing key will receive
all the messages that follows the pattern inside the routing_key.
a message can be sent from producer to an exchange in a topic way with
an sepecific routing key which tells the exchange this is the way of
receiving messages that a bounded queue can does since we might have
receiving messages that a bounded queue does since we might have
sent messages to the same exchange with multiple different routing
keys per each message and for a queue that is bounded to the exchange
with the passed in routing key can only receives the messages that
follow the pattern in the selected routing key. so the routing key in
consumer is patterns for this queue to tell exchange to what messages
this queue is interested in:
------> routing_key1 --------
| | queue1 | ----
-----------------> routing_key2 <------------------- | ---------
messages ------> | exchange| | <----- |consumer1|
-----------------> routing_key3 -------- | ---------
| | queue2 | ---
------> routing_key4 <-------------------
consumer is the patterns for this queue to tell exchange to what
messages this queue is interested in:
1) producer produces messages and send them to the exchange with an specific routing key
2) a consumer create its own queue and bind it to the exchange with the bind key that
is interested to receive the message from the exchange based on that key.
-------- ---------
| queue1 | <----- |consumer1|
------> routing_key1 <--------------------------- ---------
|
producer1 ---------- -----------------> routing_key0
|____ messages > routing_key1 ------> | exchange|
____ messages > routing_key4 ------> -----------------> routing_key2
| | -------- -----------
producer2 ----------- | | queue2 | <----| consumer2 |
------> routing_key4 <------------------ -----------
*/
pub routing_key: String, // patterns for this queue to tell exchange to what messages this queue is interested in
pub routing_key: String, // patterns for this queue to tell exchange what messages this queue is interested in
pub tag: String,
pub redis_cache_exp: u64,
pub local_spawn: bool // either spawn in actor context or tokio threadpool
Expand Down Expand Up @@ -304,8 +311,7 @@ impl NotifConsumerActor{
let is_key_there: bool = redis_conn.exists(&redis_notif_key.clone()).await.unwrap();
if is_key_there{ // update only the value
let _: () = redis_conn.set(&redis_notif_key.clone(), &events_string).await.unwrap();
} else{
// initializing value for the expirable key
} else{ // initializing a new expirable key containing the new notif data
/*
make sure you won't get the following error:
called `Result::unwrap()` on an `Err` value: MISCONF: Redis is configured to
Expand Down
2 changes: 1 addition & 1 deletion src/workers/producers/notif.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl NotifProducerActor{

};

// publish in the background in a free thread
// async task: publish messages to exchange in the background in a free thread
tokio::spawn(async move{

// -ˋˏ✄┈┈┈┈ publishing to exchange from this channel,
Expand Down

0 comments on commit 31f13ab

Please sign in to comment.