Skip to content

Commit

Permalink
chore: updated server IP paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jaineil committed Nov 14, 2021
1 parent 70d7e34 commit d702157
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 29 deletions.
17 changes: 3 additions & 14 deletions kafka-server/kafka/connection.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import kafka from "kafka-node";

import { kafkaIP } from "../kafkaServerConfig.js";
export class ConnectionProvider {
constructor() {
this.getConsumer = (topicName) => {
this.client = new kafka.KafkaClient("localhost:9092");
this.client = new kafka.KafkaClient(`${kafkaIP}:9092`);

this.kafkaConsumerConnection = new kafka.Consumer(this.client, [
{ topic: topicName, partition: 0 },
Expand All @@ -17,23 +17,12 @@ export class ConnectionProvider {
};

this.getProducer = () => {
// if (!this.kafkaProducerConnection) {
// this.client = new kafka.KafkaClient('localhost:2181');

// // const HighLevelProducer = kafka.HighLevelProducer;
// this.kafkaProducerConnection = new kafka.HighLevelProducer(this.client);
// //this.kafkaConnection = new kafka.Producer(this.client);
// console.log('Producer ready!');
// }

this.client = new kafka.KafkaClient("localhost:9092");
this.client = new kafka.KafkaClient(`${kafkaIP}:9092`);

// const HighLevelProducer = kafka.HighLevelProducer;
this.kafkaProducerConnection = new kafka.HighLevelProducer(
this.client
);

//this.kafkaConnection = new kafka.Producer(this.client);
this.client.on("ready", () => {
console.log("Producer ready!");
});
Expand Down
3 changes: 2 additions & 1 deletion server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,10 @@ import { make_request } from "./kafka/client.js";
import customerRoutes from "./routes/customer.routes.js";
import orderRoutes from "./routes/order.routes.js";
import restaurantRoutes from "./routes/restaurant.routes.js";
import { serverIP } from "./serverConfig.js";

const app = express();
app.use(cors({ origin: "http://localhost:3000", credentials: true }));
app.use(cors({ origin: `http://${serverIP}:3000`, credentials: true }));
app.use(cookieParser());

app.use(
Expand Down
17 changes: 3 additions & 14 deletions server/kafka/connection.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import kafka from "kafka-node";

import { kafkaIP } from "../../kafka-server/kafkaServerConfig.js";
export class ConnectionProvider {
constructor() {
this.getConsumer = (topicName) => {
this.client = new kafka.KafkaClient("localhost:9092");
this.client = new kafka.KafkaClient(`${kafkaIP}:9092`);

this.kafkaConsumerConnection = new kafka.Consumer(this.client, [
{ topic: topicName, partition: 0 },
Expand All @@ -17,21 +17,10 @@ export class ConnectionProvider {
};

this.getProducer = () => {
// if (!this.kafkaProducerConnection) {
// this.client = new kafka.KafkaClient('localhost:2181');

// // const HighLevelProducer = kafka.HighLevelProducer;
// this.kafkaProducerConnection = new kafka.HighLevelProducer(this.client);
// //this.kafkaConnection = new kafka.Producer(this.client);
// console.log('Producer ready!');
// }

this.client = new kafka.KafkaClient("localhost:9092");
// const HighLevelProducer = kafka.HighLevelProducer;
this.client = new kafka.KafkaClient(`${kafkaIP}:9092`);
this.kafkaProducerConnection = new kafka.HighLevelProducer(
this.client
);
//this.kafkaConnection = new kafka.Producer(this.client);
this.client.on("ready", () => {
console.log("Producer ready!");
});
Expand Down

0 comments on commit d702157

Please sign in to comment.