Skip to content

Commit

Permalink
chore: add kafka
Browse files Browse the repository at this point in the history
  • Loading branch information
ToxicToast committed Nov 7, 2024
1 parent af598ef commit 54dcc41
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 39 deletions.
20 changes: 20 additions & 0 deletions apps/azkaban-gateway/src/app/health/health.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,18 @@ export class HealthController {
@Inject('MEMORY_RSS_TRESHOLD') private readonly rssTreshold: number,
@Inject('BROKER_CONNECTION_STRING')
private readonly brokerConnectionString: string,
@Inject('KAFKA_CONNECTION_STRING')
private readonly kafkaConnectionString: string,
@Inject('REDIS_HOST_STRING')
private readonly redisHostString: string,
@Inject('REDIS_PORT_NUMBER')
private readonly redisPortNumber: number,
@Inject('REDIS_PASSWORD_STRING')
private readonly redisPasswordString: string,
@Inject('KAFKA_USER_STRING')
private readonly kafkaUserString: string,
@Inject('KAFKA_PASSWORD_STRING')
private readonly kafkaPasswordString: string,
private readonly service: HealthCheckService,
private readonly memory: MemoryHealthIndicator,
private readonly microservices: MicroserviceHealthIndicator,
Expand All @@ -44,6 +50,20 @@ export class HealthController {
consumerTag: 'gateway-health',
},
}),
() =>
this.microservices.pingCheck('kafka', {
transport: Transport.KAFKA,
options: {
client: {
brokers: [this.kafkaConnectionString],
sasl: {
mechanism: 'scram-sha-256',
username: this.kafkaUserString,
password: this.kafkaPasswordString,
},
},
},
}),
() =>
this.microservices.pingCheck<RedisOptions>('redis', {
transport: Transport.REDIS,
Expand Down
24 changes: 24 additions & 0 deletions apps/azkaban-gateway/src/app/health/health.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,16 @@ import { azkaban_vhost } from '@toxictoast/azkaban-broker-rabbitmq';
},
inject: [ConfigService],
},
{
provide: 'KAFKA_CONNECTION_STRING',
useFactory: (config: ConfigService) => {
const hostname = config.get('KAFKA_HOST', 'localhost');
const port = config.get('KAFKA_PORT', 9092);
//
return `${hostname}:${port}`;
},
inject: [ConfigService],
},
{
provide: 'REDIS_HOST_STRING',
useFactory: (config: ConfigService) => {
Expand All @@ -59,6 +69,20 @@ import { azkaban_vhost } from '@toxictoast/azkaban-broker-rabbitmq';
},
inject: [ConfigService],
},
{
provide: 'KAFKA_USER_STRING',
useFactory: (config: ConfigService) => {
return config.get('KAFKA_USERNAME', 'guest');
},
inject: [ConfigService],
},
{
provide: 'KAFKA_PASSWORD_STRING',
useFactory: (config: ConfigService) => {
return config.get('KAFKA_PASSWORD', 'supersecret');
},
inject: [ConfigService],
},
],
})
export class HealthModule {}
113 changes: 75 additions & 38 deletions package-lock.json

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
"jest-environment-jsdom": "29.7.0",
"jest-environment-node": "^29.7.0",
"jsdom": "~25.0.0",
"kafkajs": "^2.2.4",
"nx": "20.0.6",
"postcss": "8.4.44",
"prettier": "^3.3.3",
Expand Down Expand Up @@ -104,8 +105,9 @@
"@reduxjs/toolkit": "^2.2.7",
"@tailwindcss/forms": "^0.5.8",
"@toxictoast/azkaban-base-domain": "^0.0.2",
"@toxictoast/azkaban-base-helpers": "^0.0.15",
"@toxictoast/azkaban-base-helpers": "^0.0.21",
"@toxictoast/azkaban-base-types": "^0.0.1",
"@toxictoast/azkaban-broker-kafka": "^0.0.8",
"@toxictoast/azkaban-broker-rabbitmq": "^0.0.45",
"@toxictoast/azkaban-sdk": "^0.0.16",
"@toxictoast/azkaban-twitch-bot": "^0.0.1",
Expand Down

0 comments on commit 54dcc41

Please sign in to comment.