From 2861c5db43297e8715fe4f72aa927ae9ab3e247a Mon Sep 17 00:00:00 2001 From: Pau Peinado Date: Wed, 28 Aug 2024 09:59:06 +0200 Subject: [PATCH] use same ackChannel for r/w and fix startup in development --- docker-compose.yaml | 8 ++++++++ pkg/main.go | 8 ++++---- pkg/readers/adapters/amqp.go | 9 +++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/docker-compose.yaml b/docker-compose.yaml index e038d1a..338c87e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -28,6 +28,9 @@ services: MIDDLEWARES_SOCKET: "passthrough:///unix:///tmp/hp" READ_ADAPTER: "AMQP" WRITE_ADAPTER: "ELASTIC" + depends_on: + rabbit-mq: + condition: service_healthy hp-middleware-pass: volumes: - ./sockets:/tmp @@ -40,6 +43,11 @@ services: ports: - 15672:15672 - 5672:5672 + healthcheck: + test: [ "CMD", "rabbitmqctl", "status"] + interval: 5s + timeout: 20s + retries: 5 elasticsearch: image: docker.elastic.co/elasticsearch/elasticsearch-oss:7.4.2 ports: diff --git a/pkg/main.go b/pkg/main.go index 1336165..c7c9a60 100644 --- a/pkg/main.go +++ b/pkg/main.go @@ -1,13 +1,14 @@ package main import ( + "os" + "strconv" + "github.com/softonic/homing-pigeon/pkg/messages" "github.com/softonic/homing-pigeon/pkg/middleware" "github.com/softonic/homing-pigeon/pkg/readers" "github.com/softonic/homing-pigeon/pkg/writers" "k8s.io/klog" - "os" - "strconv" ) func main() { @@ -19,9 +20,8 @@ func main() { bufLen = GetBufferLength("ACK_BUFFER_LENGTH") ackCh1 := make(chan messages.Ack, bufLen) - ackCh2 := make(chan messages.Ack, bufLen) - reader, err := readers.NewReader(msgCh1, ackCh2) + reader, err := readers.NewReader(msgCh1, ackCh1) if err != nil { panic(err) } diff --git a/pkg/readers/adapters/amqp.go b/pkg/readers/adapters/amqp.go index cde1c40..945709f 100644 --- a/pkg/readers/adapters/amqp.go +++ b/pkg/readers/adapters/amqp.go @@ -4,15 +4,16 @@ import ( "bytes" "crypto/tls" "crypto/x509" + "html/template" + "os" + "strconv" + "strings" + "github.com/softonic/homing-pigeon/pkg/helpers" "github.com/softonic/homing-pigeon/pkg/messages" amqpAdapter "github.com/softonic/homing-pigeon/pkg/readers/adapters/amqp" "github.com/streadway/amqp" - "html/template" "k8s.io/klog" - "os" - "strconv" - "strings" ) type Amqp struct {