Skip to content

Commit

Permalink
update docker compose docker file
Browse files Browse the repository at this point in the history
  • Loading branch information
code-ga committed Dec 15, 2023
1 parent 5871078 commit 38bcbdf
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
1 change: 0 additions & 1 deletion server/like-service/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion server/like-service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ serde_json = "1.0.93"
url = "2.3.1"
uuid = { version = "1.3.0", features = ["v4", "v8"] }
tokio = { version = "1.25.0", features = ["full"] }
futures-util = "0.3.26"
juniper = "0.15.11"
juniper_actix = "0.4.0"
mongodb = { version = "2.6.0", features = ["tokio-runtime", "tokio-sync"] }
Expand Down
5 changes: 3 additions & 2 deletions server/like-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
FROM rust:alpine as rust-build
WORKDIR /home/app

# gcc musl-dev rustup
RUN apk add git curl &&\
apk add pkgconfig openssl-dev gcc musl-dev rustup &&\
apk add pkgconfig openssl-dev musl-dev &&\
rm -rf /var/cache/apk/*

COPY Cargo.toml Cargo.lock ./
Expand All @@ -14,7 +15,7 @@ RUN rm -rf src

COPY ./src ./src

RUN rm -rf ./target/release/deps/like_service*
# RUN rm -rf ./target/release/deps/like_service*
RUN --mount=type=cache,target=/usr/local/cargo/registry cargo build --release

FROM alpine
Expand Down
6 changes: 3 additions & 3 deletions server/like-service/src/util/service.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use futures_util::StreamExt;
use crate::juniper::futures::StreamExt;
use redis::AsyncCommands;

use crate::types::{RedisClient, SenderData};
Expand All @@ -12,12 +12,12 @@ pub async fn send_service_message<T: for<'a> serde::Deserialize<'a>>(
let channel = message.url.to_string();
let message_str = serde_json::to_string(&message)?;
let _ = redis
.get_async_connection()
.get_tokio_connection()
.await
.unwrap()
.publish(channel.to_string(), message_str)
.await?;
let mut pubsub = redis.get_async_connection().await.unwrap().into_pubsub();
let mut pubsub = redis.get_tokio_connection().await.unwrap().into_pubsub();
if listen_response {
pubsub.subscribe(channel).await?;
loop {
Expand Down
5 changes: 1 addition & 4 deletions server/user/src/ws/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,23 @@ export class RedisListen<RedisModule extends RedisModules, RedisFunction extends
onmessage: (this: typeof this.redisClient, message: string, channel: string, subscriber: typeof this.redisClient) => any
eventHandle: string[];
subscriber: typeof this.redisClient;
publisher: typeof this.redisClient;
constructor(public redisClient: RedisClientType<RedisDefaultModules & RedisModule, RedisFunction, RedisScript>) {
this.eventHandle = ["user/decodeToken", "user/updateUserComic", "user/DeleteComic", "user/UpdateUserShortComic", "user/UpdateUserStatus", "user/UpdateUserTeam"]
this.subscriber = this.redisClient.duplicate();
this.publisher = this.redisClient.duplicate();
this.subscriber.on('error', err => console.error(err));

this.connect()
this.handlers()
}
async connect() {
await this.subscriber.connect();
await this.publisher.connect();
}
async handlers() {

this.onmessage = async (message, channel) => {
const data: SenderData = JSON.parse(message.toString())
const send = (result: SenderData) =>
this.publisher.publish(channel, JSON.stringify(result))
this.redisClient.publish(channel, JSON.stringify(result))

let result: SenderData | null = null
if (data.url == 'user/decodeToken') {
Expand Down

1 comment on commit 38bcbdf

@code-ga
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#41

Please sign in to comment.