Skip to content

Commit

Permalink
Merge pull request #50 from igh9410/dev
Browse files Browse the repository at this point in the history
Revert to previous version
  • Loading branch information
igh9410 authored May 7, 2024
2 parents cd59820 + b451988 commit 3b32dcc
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 21 deletions.
30 changes: 9 additions & 21 deletions backend/cmd/blabber-hive/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,29 +45,18 @@ func main() {
log.Printf("Error closing the Redis connection: %s", err)
}
}()
/*
kafkaClient, err := kafka.NewKafkaClient()
if err != nil {
log.Printf("Failed to initialize Kafka cluster connection")
}
defer kafkaClient.Close()
kafkaProducer, err := kafka.KafkaProducer()
if err != nil {
log.Printf("Failed to initialize Kafka producer")
}
defer kafkaProducer.Close() */

// Start the Kafka reconnection loop
stopReconnect := make(chan struct{})
kafkaConnected, kafkaProducer := kafka.ReconnectLoop(stopReconnect)

// Wait for successful Kafka connection
<-kafkaConnected
kafkaClient, err := kafka.NewKafkaClient()
if err != nil {
log.Printf("Failed to initialize Kafka cluster connection")
}
defer kafkaClient.Close()

// Use the kafkaProducer instance
kafkaProducer, err := kafka.KafkaProducer()
if err != nil {
log.Printf("Failed to initialize Kafka producer")
}
defer kafkaProducer.Close()
// ... (rest of the code that uses kafkaProducer)

userRep := user.NewRepository(dbConn.GetDB())
userSvc := user.NewService(userRep)
Expand Down Expand Up @@ -123,7 +112,6 @@ func main() {
MatchHandler: matchHandler,
// Future handlers can be added here without changing the InitRouter signature
}
close(stopReconnect)

router.InitRouter(routerConfig)
cancel()
Expand Down
68 changes: 68 additions & 0 deletions docker-compose-k8s.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
services:
zookeeper: # ZooKepper for Kafka
image: confluentinc/cp-zookeeper:7.4.3
container_name: blabber-hive-zookeeper
environment:
ZOOKEEPER_CLIENT_PORT: 2181
ZOOKEEPER_TICK_TIME: 2000
networks:
- blabber-hive

broker: # Kafka Broker
image: confluentinc/cp-kafka:7.4.3
container_name: blabber-hive-broker
ports:
- "9092:9092"
depends_on:
- zookeeper
environment:
KAFKA_BROKER_ID: 1
KAFKA_ZOOKEEPER_CONNECT: "zookeeper:2181"
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: PLAINTEXT:PLAINTEXT,PLAINTEXT_INTERNAL:PLAINTEXT
KAFKA_LISTENERS: PLAINTEXT://0.0.0.0:9092,PLAINTEXT_INTERNAL://0.0.0.0:29092
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://broker:9092,PLAINTEXT_INTERNAL://broker:29092
KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1
KAFKA_TRANSACTION_STATE_LOG_MIN_ISR: 1
KAFKA_TRANSACTION_STATE_LOG_REPLICATION_FACTOR: 1
networks:
- blabber-hive
labels:
app: broker

postgres: # Postgres Container
image: postgres:15.5-alpine
container_name: blabber-hive-postgres
ports:
- "5432:5432"
networks:
- blabber-hive
env_file:
- backend/.env.docker
volumes:
- ./database:/var/lib/postgresql/data
labels:
app: postgres

redis: # Redis Container
image: redis:7.2.3-alpine3.18
container_name: blabber-hive-redis
ports:
- "6379:6379"
networks:
- blabber-hive
kafka-setup:
image: confluentinc/cp-kafka:latest
container_name: blabber-hive-kafka-setup
depends_on:
- broker
volumes:
- ./backend/create-kafka-topics.sh:/tmp/create-kafka-topics.sh
command: "/tmp/create-kafka-topics.sh"
networks:
- blabber-hive
labels:
app: redis

networks:
blabber-hive:
driver: bridge

0 comments on commit 3b32dcc

Please sign in to comment.