-
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.
feat: Added monorepos + Docker support
- Loading branch information
1 parent
7ce831a
commit 6134aff
Showing
26 changed files
with
202 additions
and
29 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,3 @@ | ||
[package] | ||
name = "distributed-id-indexer" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
dotenv = "0.15.0" | ||
redis = { version = "0.26.1", features = ["tokio-comp","cluster-async"] } | ||
tokio = { version = "1.40.0", features = ["full"] } | ||
actix-web = "4.3.1" | ||
actix-http = "3.4.0" | ||
serde = { version = "1.0.167", features = ["derive"] } | ||
serde_json = "1.0.100" | ||
actix = "0.13.0" | ||
env_logger = "0.11.0" | ||
lazy_static = "1.4" | ||
listenfd = "1.0.1" | ||
tracing-actix-web = "0.7" | ||
tracing = "0.1" | ||
[workspace] | ||
resolver = "2" | ||
members = ["crates/http", "crates/pubsub"] |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
REDIS_URL= | ||
WEB_SERVER_PORT= | ||
NUM_WORKERS= | ||
LOG_LEVEL= |
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,19 @@ | ||
[package] | ||
name = "distributed-id-indexer-http" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
dotenv = "0.15.0" | ||
redis = { version = "0.26.1", features = ["tokio-comp","cluster-async"] } | ||
tokio = { version = "1.40.0", features = ["full"] } | ||
actix-web = "4.3.1" | ||
actix-http = "3.4.0" | ||
serde = { version = "1.0.167", features = ["derive"] } | ||
serde_json = "1.0.100" | ||
actix = "0.13.0" | ||
env_logger = "0.11.0" | ||
lazy_static = "1.4" | ||
listenfd = "1.0.1" | ||
tracing-actix-web = "0.7" | ||
tracing = "0.1" |
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,14 @@ | ||
FROM rust:1.80.1-slim-bullseye | ||
|
||
# View app name in Cargo.toml | ||
ARG APP_NAME=distributed-id-indexer-http | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
RUN cargo build --release | ||
RUN cp ./target/release/$APP_NAME /distributed-id-indexer-http | ||
|
||
EXPOSE 8000 | ||
|
||
CMD ["/distributed-id-indexer-http"] |
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,3 @@ | ||
### http - crate | ||
|
||
REST API Server for Retriving IDs from Redis |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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,17 @@ | ||
use redis::AsyncCommands; | ||
|
||
pub async fn connection_to_redis( | ||
redis_url: &str, | ||
) -> redis::Client { | ||
let client: redis::Client = redis::Client::open(redis_url).unwrap(); | ||
client | ||
} | ||
|
||
pub async fn get_value(connection: &mut redis::aio::MultiplexedConnection, key: &str) -> String { | ||
let value = connection.get(key).await; | ||
|
||
match value { | ||
Ok(value) => value, | ||
Err(_) => "".to_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
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 @@ | ||
REDIS_URL= |
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,19 @@ | ||
[package] | ||
name = "distributed-id-indexer-pubsub" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
dotenv = "0.15.0" | ||
redis = { version = "0.26.1", features = ["tokio-comp","cluster-async"] } | ||
tokio = { version = "1.40.0", features = ["full"] } | ||
actix-web = "4.3.1" | ||
actix-http = "3.4.0" | ||
serde = { version = "1.0.167", features = ["derive"] } | ||
serde_json = "1.0.100" | ||
actix = "0.13.0" | ||
env_logger = "0.11.0" | ||
lazy_static = "1.4" | ||
listenfd = "1.0.1" | ||
tracing-actix-web = "0.7" | ||
tracing = "0.1" |
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,12 @@ | ||
FROM rust:1.80.1-slim-bullseye | ||
|
||
# View app name in Cargo.toml | ||
ARG APP_NAME=distributed-id-indexer-pubsub | ||
|
||
WORKDIR /app | ||
|
||
COPY . . | ||
RUN cargo build --release | ||
RUN cp ./target/release/$APP_NAME /distributed-id-indexer-pubsub | ||
|
||
CMD ["/distributed-id-indexer-pubsub"] |
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,3 @@ | ||
### pubsub - crate | ||
|
||
Redis Pub/Sub Server which saves IDs to Redis |
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,20 @@ | ||
use std::env; | ||
use dotenv::dotenv; | ||
|
||
pub struct Env { | ||
pub redis_url: String, | ||
} | ||
|
||
impl Env { | ||
pub fn new() -> Self { | ||
dotenv().ok(); | ||
|
||
Self { | ||
redis_url: env::var("REDIS_URL").expect("REDIS_URL must be set"), | ||
} | ||
} | ||
} | ||
|
||
pub fn get_env() -> Env { | ||
Env::new() | ||
} |
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 @@ | ||
pub mod env; |
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 @@ | ||
pub mod redis; |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
mod config; | ||
mod libs; | ||
|
||
#[tokio::main] | ||
async fn main() { | ||
let _ = libs::redis::start_pub_sub().await; | ||
|
||
println!("PubSub started"); | ||
} |
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,41 @@ | ||
version: '3.7' | ||
|
||
services: | ||
http: | ||
build: | ||
context: ./crates/http | ||
dockerfile: Dockerfile | ||
ports: | ||
- "8181:4000" | ||
depends_on: | ||
- redis | ||
environment: | ||
- REDIS_URL=redis://redis:6379 | ||
- WEB_SERVER_PORT=4000 | ||
- NUM_WORKERS=1 | ||
- LOG_LEVEL="info" | ||
networks: | ||
- dii | ||
|
||
pubsub: | ||
build: | ||
context: ./crates/pubsub | ||
dockerfile: Dockerfile | ||
depends_on: | ||
- redis | ||
environment: | ||
- REDIS_URL=redis://redis:6379 | ||
networks: | ||
- dii | ||
|
||
redis: | ||
image: "redis:alpine" | ||
networks: | ||
- dii | ||
ports: | ||
- "6380:6379" | ||
|
||
networks: | ||
dii: | ||
|
||
|