-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from igh9410/dev
Dev
- Loading branch information
Showing
14 changed files
with
142 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
./database/* | ||
.env | ||
.env.* | ||
k8s | ||
./k8s/configmaps/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Makefile` | ||
|
||
# Run the application | ||
run: | ||
@echo "Running the Kubernetes cluster..." | ||
@kubectl apply -f ./k8s/services/ | ||
@kubectl apply -f ./k8s/deployments/ | ||
@kubectl apply -f ./k8s/configmaps/ | ||
|
||
shutdown: | ||
@echo "Shutting down the Kubernetes cluster..." | ||
|
||
@kubectl scale --replicas=0 deployment blabber-hive | ||
@kubectl scale --replicas=0 deployment broker | ||
@kubectl scale --replicas=0 deployment fastapi | ||
@kubectl scale --replicas=0 deployment grafana | ||
@kubectl scale --replicas=0 deployment kafka-setup | ||
@kubectl scale --replicas=0 deployment nginx | ||
@kubectl scale --replicas=0 deployment postgres | ||
@kubectl scale --replicas=0 deployment prometheus | ||
@kubectl scale --replicas=0 deployment redis | ||
@kubectl scale --replicas=0 deployment zookeeper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package kafka | ||
|
||
import ( | ||
"log" | ||
"time" | ||
|
||
confluentKafka "github.com/confluentinc/confluent-kafka-go/v2/kafka" | ||
) | ||
|
||
// ReconnectLoop continuously attempts to establish a Kafka connection | ||
// and sends a signal on the returned channel when a connection is made. | ||
// The loop will continue to run until the provided stop channel is closed. | ||
// It also returns the Kafka producer instance. | ||
func ReconnectLoop(stop chan struct{}) (chan struct{}, *confluentKafka.Producer) { | ||
connected := make(chan struct{}) | ||
var producer *confluentKafka.Producer | ||
|
||
go func() { | ||
for { | ||
select { | ||
case <-stop: | ||
log.Println("Stopping Kafka reconnection loop") | ||
close(connected) | ||
if producer != nil { | ||
producer.Close() | ||
} | ||
return | ||
default: | ||
kafkaClient, err := NewKafkaClient() | ||
if err != nil { | ||
log.Printf("Failed to initialize Kafka cluster connection: %s", err) | ||
time.Sleep(30 * time.Second) // Wait for 30 seconds before retrying | ||
continue | ||
} | ||
defer kafkaClient.Close() | ||
|
||
producer, err = KafkaProducer() | ||
if err != nil { | ||
log.Printf("Failed to initialize Kafka producer: %s", err) | ||
time.Sleep(30 * time.Second) // Wait for 30 seconds before retrying | ||
continue | ||
} | ||
|
||
log.Println("Kafka connection established") | ||
connected <- struct{}{} | ||
|
||
// Wait for the connection to be closed (e.g., due to an error) | ||
<-connected | ||
} | ||
} | ||
}() | ||
|
||
return connected, producer | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.