🔧 Changes to support BullMQ on the service layer

1. Removed socket connection from context
2. Added Redux middleware to persist socket connection
3. Removed amqplib and RabbitMQ support
4. Removed RabbitMQ from docker-compose configuration
5. Removed a proxy route to IMS from the facade
6. Refactored file actions to support the new way of socket event emitting and listening
This commit is contained in:
2021-10-27 07:46:21 -07:00
parent 8fbea27fb2
commit 56d22a28a0
16 changed files with 151 additions and 270 deletions

View File

@@ -1,48 +0,0 @@
import React, { createContext, ReactElement } from "react";
import io, { Socket } from "socket.io-client";
import { SOCKET_BASE_URI } from "../../constants/endpoints";
import { useDispatch } from "react-redux";
import { RMQ_SOCKET_CONNECTED } from "../../constants/action-types";
import { success } from "react-notification-system-redux";
const WebSocketContext = createContext(null);
export const WebSocketProvider = ({ children }): ReactElement => {
const dispatch = useDispatch();
const socket: Socket = io(SOCKET_BASE_URI);
socket.on("connect", () => {
console.log("connected");
dispatch({
type: RMQ_SOCKET_CONNECTED,
isSocketConnected: true,
socketId: socket.id,
});
});
// on cover extraction
socket.on("coverExtracted", (data) => {
console.log("shaket", data);
dispatch(
success({
// uid: 'once-please', // you can specify your own uid if required
title: "Cover Extracted",
message: `<span class="icon-text has-text-success"><i class="fas fa-plug"></i></span> Socket <span class="has-text-info">${socket.id}</span> connected. <strong>${data}</strong>`,
dismissible: "click",
position: "tr",
autoDismiss: 0,
}),
);
});
socket.on("disconnect", () => {
console.log(`disconnect`);
});
socket.emit("bastard", { name: "puk" });
const ws: any = {
socket,
};
return (
<WebSocketContext.Provider value={ws}>{children}</WebSocketContext.Provider>
);
};
export { WebSocketContext };
export default WebSocketProvider;