Skip to content

Commit

Permalink
refactor: remove retry kafka
Browse files Browse the repository at this point in the history
  • Loading branch information
iam-abin committed Oct 31, 2024
1 parent 0ffe10f commit a84bbfa
Show file tree
Hide file tree
Showing 9 changed files with 10 additions and 32 deletions.
5 changes: 0 additions & 5 deletions auth/src/config/kafka.connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ import { Kafka } from 'kafkajs';
const kafkaClient = new Kafka({
clientId: 'auth-client',
brokers: ['devhive-kafka:9092'],
retry: {
retries: 5, // Number of retries
initialRetryTime: 300, // Initial time to wait before the first retry (in ms)
maxRetryTime: 10000, // Maximum time to wait before giving up (in ms)
}
});

export { kafkaClient };
2 changes: 1 addition & 1 deletion auth/src/frameworks/database/mongo/models/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ userSchema.pre('save', async function (next) {
userSchema.pre('findOneAndUpdate', async function (next) {
const update = this.getUpdate() as Partial<ISignup>;
if (!update.password) return next();

try {
const hashedPassword: string = await generateHashedPassword(update.password);
this.setUpdate({ ...update, password: hashedPassword });
Expand Down
1 change: 0 additions & 1 deletion auth/src/frameworks/repositories/mongo/users.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export = {
},

updateVerification: async (email: string): Promise<IUserDocument | null> => {

const user = await UserModel.findOneAndUpdate({ email }, { isVerified: true }, { new: true });
return user;
},
Expand Down
2 changes: 1 addition & 1 deletion auth/src/useCases/otp/authEmailVerificationOtp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export = (dependencies: IDependency) => {
await usersRepository.deleteOtp(email);
// to update user verification status in users collection
const result = await usersRepository.updateVerification(email);

// to produce a message to kafka topic
const userCreatedEvent = new UserCreatedEventPublisher(kafkaClient);
await userCreatedEvent.publish({
Expand Down
6 changes: 1 addition & 5 deletions chat/src/config/kafka.connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { Kafka } from 'kafkajs';
const kafkaClient = new Kafka({
clientId: 'chat-client',
brokers: ['devhive-kafka:9092'],
retry: {
retries: 5, // Number of retries
initialRetryTime: 300, // Initial time to wait before the first retry (in ms)
maxRetryTime: 10000, // Maximum time to wait before giving up (in ms)
}

});

export { kafkaClient };
6 changes: 1 addition & 5 deletions job/src/config/kafka.connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { Kafka } from 'kafkajs';
const kafkaClient = new Kafka({
clientId: 'job-client',
brokers: ['devhive-kafka:9092'],
retry: {
retries: 5, // Number of retries
initialRetryTime: 300, // Initial time to wait before the first retry (in ms)
maxRetryTime: 10000, // Maximum time to wait before giving up (in ms)
}

});

export { kafkaClient };
8 changes: 4 additions & 4 deletions job/src/frameworks/repositories/mongo/job.repository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { IFilter, IJob } from '../../types/job';

const { JobModel } = Models;

const JOB_LIST_SELECT_FIELDS: string[] = [
const JOBS_SELECT_FIELDS: string[] = [
'title',
'companyLocation',
'employmentType',
Expand Down Expand Up @@ -47,7 +47,7 @@ export = {
const filteredJobs = await JobModel.find({...jobFilterData, isDeleted: false})
.skip(skip)
.limit(limit)
.select(JOB_LIST_SELECT_FIELDS);
.select(JOBS_SELECT_FIELDS);
return filteredJobs;
},

Expand All @@ -63,13 +63,13 @@ export = {
let jobs: Partial<IJobDocument>[] | [];
if (applicationJobIds) {
jobs = await JobModel.find({ _id: { $nin: applicationJobIds }, isDeleted: false })
.select(JOB_LIST_SELECT_FIELDS)
.select(JOBS_SELECT_FIELDS)
.sort({ createdAt: -1 })
.skip(skip)
.limit(limit);
} else {
jobs = await JobModel.find({ isActive: true })
.select(JOB_LIST_SELECT_FIELDS)
.select(JOBS_SELECT_FIELDS)
.sort({ createdAt: -1 })
.skip(skip)
.limit(limit);
Expand Down
6 changes: 1 addition & 5 deletions payment/src/config/kafka.connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { Kafka } from 'kafkajs';
const kafkaClient: Kafka = new Kafka({
clientId: 'payment-client',
brokers: ['devhive-kafka:9092'],
retry: {
retries: 5, // Number of retries
initialRetryTime: 300, // Initial time to wait before the first retry (in ms)
maxRetryTime: 10000, // Maximum time to wait before giving up (in ms)
}

});

export { kafkaClient };
6 changes: 1 addition & 5 deletions profile/src/config/kafka.connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import { Kafka } from 'kafkajs';
const kafkaClient = new Kafka({
clientId: 'profile-client',
brokers: ['devhive-kafka:9092'],
retry: {
retries: 5, // Number of retries
initialRetryTime: 300, // Initial time to wait before the first retry (in ms)
maxRetryTime: 10000, // Maximum time to wait before giving up (in ms)
}

});

export { kafkaClient };

0 comments on commit a84bbfa

Please sign in to comment.