-
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 #21 from brunograssano/separar_ex4
[EDIT] Refactor Ex4 - 4 services
- Loading branch information
Showing
42 changed files
with
1,331 additions
and
246 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
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,19 @@ | ||
FROM golang:1.21 AS builder | ||
# Client uses docker multistage builds feature https://docs.docker.com/develop/develop-images/multistage-build/ | ||
# First stage is used to compile golang binary and second stage is used to only copy the | ||
# binary generated to the deploy image. | ||
# Docker multi stage does not delete intermediate stages used to build our image, so we need | ||
# to delete it by ourselves. Since docker does not give a good alternative to delete the intermediate images | ||
# we are adding a very specific label to the image to then find these kind of images and delete them | ||
LABEL intermediateStageToBeDeleted=true | ||
|
||
RUN mkdir -p /build | ||
WORKDIR /build/ | ||
COPY .. . | ||
# CGO_ENABLED must be disabled to run go binary in Alpine | ||
RUN CGO_ENABLED=0 GOOS=linux go build -o bin/avg_calculator_ex4 avg_calculator_ex4 | ||
|
||
|
||
FROM busybox:latest | ||
COPY --from=builder /build/bin/avg_calculator_ex4 /avg_calculator_ex4 | ||
ENTRYPOINT ["/avg_calculator_ex4"] |
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 |
---|---|---|
@@ -1,8 +1,5 @@ | ||
|
||
log: | ||
level: "info" | ||
internal: | ||
savers: | ||
count: 6 | ||
rabbitmq: | ||
address: "amqp://guest:guest@rabbitmq:5672/" |
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,3 @@ | ||
module avg_calculator_ex4 | ||
|
||
go 1.21 |
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,34 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/brunograssano/Distribuidos-TP1/common/middleware" | ||
queueProtocol "github.com/brunograssano/Distribuidos-TP1/common/protocol/queues" | ||
"github.com/brunograssano/Distribuidos-TP1/common/utils" | ||
log "github.com/sirupsen/logrus" | ||
) | ||
|
||
func main() { | ||
sigs := utils.CreateSignalListener() | ||
env, err := InitEnv() | ||
if err != nil { | ||
log.Fatalf("Main - Ex4 Avg Calculator | Error initializing env | %s", err) | ||
} | ||
config, err := GetConfig(env) | ||
if err != nil { | ||
log.Fatalf("Main - Ex4 Avg Calculator | Error initializing Config | %s", err) | ||
} | ||
|
||
qMiddleware := middleware.NewQueueMiddleware(config.RabbitAddress) | ||
inputQueue := queueProtocol.NewConsumerQueueProtocolHandler(qMiddleware.CreateConsumer(config.InputQueueName, true)) | ||
var toJourneySavers []queueProtocol.ProducerProtocolInterface | ||
for i := uint(0); i < config.SaversCount; i++ { | ||
producer := qMiddleware.CreateExchangeProducer(config.OutputQueueName, fmt.Sprintf("%v", i), "direct", true) | ||
toJourneySavers = append(toJourneySavers, queueProtocol.NewProducerQueueProtocolHandler(producer)) | ||
} | ||
|
||
avgCalculator := NewAvgCalculator(toJourneySavers, inputQueue, config) | ||
go avgCalculator.CalculateAvgLoop() | ||
<-sigs | ||
qMiddleware.Close() | ||
} |
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
Oops, something went wrong.